So, Am I doing this wrong then?
;=== Global Variables ===
.ENUM $00
TX db
TY db
TA db
.ENDE
.MACRO LoadLevel
; BASIC
; For y = 0 to 15
; For x = 0 to 15
; A = LevelMaps + 16 * y + x
; DrawBlock A,x,y
; Next x
; Next y
LDY #15 ; Reverse the loop order to simplify the loop
LDX #255 ; Start with the last byte (16*16 - 1)
Next_Y:
STY TY
LDA #15
STA TX ; Use TX as a loop counter instead of the X-register
Next_X:
LDA.L LevelMaps,X
DrawBlock 1,TX,TY ; 1 to draw tile #1 all over the screen
DEX
DEC TX
BPL Next_X ; Loop while TX >= 0
DEY
BPL Next_Y
.ENDM
.MACRO DrawBlock
; This macro works fine
; e.g. DrawBlock 1,2,3 will draw block#1 at 4,6 on the screen (blocks are 16x16)
LDA #\1 ; A = tile
ASL A ; A << 1 (A = A * 2) (Tiles are 16x16px)
LDX #64*\3 + \2*2 ; X = 32*y+x (tile location)
STA MapBuffer,X ; Map(X) = A
INC A ; A = A + 1
STA MapBuffer+1,X ; Map(X) = A
LDY #$1F ; Y = 32
jump: ; A Lable
INC A ; A = A + 1
DEY ; Y = Y - 1
CPY #$00 ; N 0 - Y
BNE jump ; If N != 0 goto loop
STA MapBuffer+32,X ; Map(X) = A
INC A ; A = A + 1
STA MapBuffer+33,X ; Map(X+1) = A
.ENDM