Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .feature leading_dot_in_identifiers
- .macpack generic
- .macpack longbranch
- ; Meant to be an easy replacement for .repeat and .endrepeat
- ; when you're trying to save space. Uses a zeropage memory location
- ; instead of a register as a loop counter so as not to disturb any
- ; registers.
- ; Times - Number of times to loop ( may be a memory location )
- ; Free - Free zeropage memory location to use
- .macro .dj_loop Times, Free
- .scope
- DJ_Counter = Free
- lda Times
- sta Free
- DJ_Label:
- .endmacro
- .macro .end_djl
- NextIndex:
- dec DJ_Counter
- jne DJ_Label
- .endscope
- .endmacro
- ; Imitation of z80's djnz opcode.
- ; Can be on A, X, Y, or a zeropage memory location
- ; Label - Label to jump to
- ; Reg - Counter register to use: A,X,Y or memory location
- .macro djnz Label, Reg
- .if (.match({Reg}, a))
- sub #1
- .elseif (.match({Reg}, x))
- dex
- .elseif (.match({Reg}, y))
- dey
- .else
- dec var
- .endif
- bne Label
- .endmacro
- ; Working with X,Y is much more fun than working with PPU addresses
- ; give it an X and Y position, as well as a nametable number (0-3),
- ; and if you want to save the address to a 16-bit zeropage address
- ; ( big endian ) you can give an additional argument.
- ; NT - Nametable number (0-3)
- ; PX - X position in tiles
- ; PY - Y position in tiles
- ; Var - Variable to store address in (optional)
- .macro PositionXY NT, PX, PY, Var
- .scope
- t0 = $2000 + (NT * 1024) ; Nametable data starts at $2000
- t1 = PX ; and each nametable is 1024 bytes in size
- t2 = PY * 32 ; Nametable rows are 32 bytes large
- t3 = t0 + t1 + t2
- .ifblank Var
- lda #>t3
- sta $2006
- lda #<t3
- sta $2006
- .else
- lda #>t3
- sta Var+0
- lda #<t3
- sta Var+1
- .endif
- .endscope
- .endmacro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement