Source |
# This program shows how to draw sprites.
# Sprites are 4x4, encoded in two bytes.
# First byte encodes the top 2 lines (8 values).
# Second byte encodes the bottom 2 lines (8 values).
# High nibble encodes the top 4 pixels.
# Low nibble encodess the bottom 4 pixels.
0 0
LIT 52
DUP LIT @t LIT @draw JMR
DUP LIT 4 ADD LIT @n LIT @draw JMR
DUP LIT 8 ADD LIT @y LIT @draw JMR
POP
BRK
draw: # pos adr
OVR OVR
LDA LIT @sprite JMR
SWP LIT 20 ADD SWP
INC LDA LIT @sprite JMR
RET
sprite: # pos n --
LIT 0 LIT 8 PSH PSH do:
OVR
RSI LIT 4 DIV LIT 10 MUL
RSI LIT 4 MOD ADD ADD
OVR LIT 80 RSI SFT AND
SET
PUL INC PSH
RSI RSJ LTH LIT @do JCN
PUL PUL POP POP POP POP
RET
t: 46 42
n: 6a aa
y: aa 48
|