aboutsummaryrefslogtreecommitdiff
path: root/samples/move.orgaasm
blob: 7ca109f09dc898a7d782b933caedb88f29b3a041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
JMP ,main
include(std.orgaasm)

@main
	#0000 #4007 /draw/hline
	#0001 #4007 /draw/hline
	#007e #4007 /draw/hline
	#007f #4007 /draw/hline
	#0000 #4007 /draw/vline
	#0001 #4007 /draw/vline
	#007e #4007 /draw/vline
	#007f #4007 /draw/vline
@main/loop
	SLP
	/input/update
	/player/erase
	/player/update
	/player/draw
	JMP ,main/loop

@input.kleft  0000
@input.kright 0000
@input.kup    0000
@input.kdown  0000
@input/update ( -- )
	-Input LDA
	DUP #0010 AND #0000 NEQ -input.kup    STA
	DUP #0020 AND #0000 NEQ -input.kdown  STA
	DUP #0040 AND #0000 NEQ -input.kleft  STA
	    #0080 AND #0000 NEQ -input.kright STA
	RET

@player.x 003b
@player.y 003b

@player/update ( -- )
@player/update/movex
	#0003 #0075
	-player.x LDA
	-input.kleft LDA SUB
	-input.kright LDA ADD
	/clamp -player.x STA
@player/update/movey
	#0002 #0074
	-player.y LDA
	-input.kup LDA SUB
	-input.kdown LDA ADD
	/clamp -player.y STA
	RET

@player/erase ( -- )
	-player.x LDA
	-player.y LDA
	-blacksquare
	/draw/sprite
	RET

@player/draw ( -- )
	-player.x LDA
	-player.y LDA
	-player.spr
	/draw/sprite
	RET

@draw/pixel ( x y col -- )
	ROT #007f AND
	ROT #007f AND
	#0007 LSF ADD -Screen ADD
	STA
	RET

@draw.col 0000
@draw/hline ( y col -- )
	-draw.col STA       ( y )
	#0080               ( y x )
@draw/hline/loop
	DEC
	OVR OVR SWP         ( y x x y )
	-draw.col LDA       ( y x x y col )
	/draw/pixel         ( y x )
	DUP JNZ ,draw/hline/loop
	POP POP RET

@draw/vline ( x col -- )
	-draw.col STA       ( x )
	#0080               ( x y )
@draw/vline/loop
	DEC
	OVR OVR             ( x y x y )
	-draw.col LDA       ( x y x y col )
	/draw/pixel         ( x y )
	DUP JNZ ,draw/vline/loop
	POP POP RET

@draw/sprite.oscr 0000
@draw/sprite ( x y addr -- )
	ROT ROT #0007 LSF ADD -Screen ADD ( spr scr )
	#0008                             ( spr scr n )
@draw/sprite/loop
	DEC
	OVR OVR #0007 LSF ADD             ( spr scr n oscr )
	#0080 ADD                         ( spr scr n oscr )
	-draw/sprite.oscr STA             ( spr scr n )
	ROT SWP OVR OVR #0003 LSF ADD     ( scr spr n ospr )
	-draw/sprite.oscr LDA             ( scr spr n ospr oscr )
	#0008 /memcpy                     ( scr spr n )
	SWP ROT ROT                       ( spr scr n )
	DUP JNZ ,draw/sprite/loop
	POP POP POP RET

@blacksquare
	0000 0000 000f 000f 000f 000f 0000 0000
	0000 0000 0000 0000 0000 0000 0000 0000
	000f 0000 000f 000f 000f 000f 0000 000f
	000f 0000 000f 000f 000f 000f 0000 000f
	000f 0000 000f 000f 000f 000f 0000 000f
	000f 0000 000f 000f 000f 000f 0000 000f
	0000 0000 0000 0000 0000 0000 0000 0000
	0000 0000 000f 000f 000f 000f 0000 0000

@player.spr
	0000 ffff ffff ffff ffff ffff ffff 0000
	ffff 0000 ffff ffff ffff ffff 0000 ffff
	ffff ffff ffff ffff ffff ffff ffff ffff
	ffff ffff ffff ffff ffff ffff ffff ffff
	ffff ffff ffff ffff ffff ffff ffff ffff
	ffff ffff ffff ffff ffff ffff 0000 ffff
	ffff ffff 0000 0000 0000 0000 ffff ffff
	0000 ffff ffff ffff ffff ffff ffff 0000