-
Notifications
You must be signed in to change notification settings - Fork 3
/
smiley.60p
188 lines (165 loc) · 3.62 KB
/
smiley.60p
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// smiley.60p - SixtyPical translation of smiley.oph (2018),
// which is itself a stripped-down version of atari-2600-example.oph
// SPDX-FileCopyrightText: Chris Pressey, the author of this work, has dedicated it to the public domain.
// For more information, please refer to <https://unlicense.org/>
// SPDX-License-Identifier: Unlicense
byte VSYNC @ $00
byte VBLANK @ $01
byte WSYNC @ $02
byte NUSIZ0 @ $04
byte NUSIZ1 @ $05
byte COLUPF @ $08
byte COLUBK @ $09
byte PF0 @ $0D
byte PF1 @ $0E
byte PF2 @ $0F
byte SWCHA @ $280
byte INTIM @ $284
byte TIM64T @ $296
byte CTRLPF @ $0A
byte COLUP0 @ $06
byte COLUP1 @ $07
byte GP0 @ $1B
byte GP1 @ $1C
byte HMOVE @ $2a
byte RESP0 @ $10
byte RESP1 @ $11
byte colour @ $80
byte luminosity @ $81
byte joystick_delay @ $82
byte table[8] image_data : 126, 129, 153, 165, 129, 165, 129, 126
// %01111110
// %10000001
// %10011001
// %10100101
// %10000001
// %10100101
// %10000001
// %01111110
define vertical_blank routine
outputs VSYNC, WSYNC, TIM64T
trashes a, x, z, n
{
ld x, $00
ld a, $02
st a, WSYNC
st a, WSYNC
st a, WSYNC
st a, VSYNC
st a, WSYNC
st a, WSYNC
ld a, $2C
st a, TIM64T
ld a, $00
st a, WSYNC
st a, VSYNC
}
define display_frame routine
inputs INTIM, image_data
outputs WSYNC, HMOVE, VBLANK, RESP0, GP0, PF0, PF1, PF2, COLUPF, COLUBK
trashes a, x, y, z, n
{
repeat {
ld a, INTIM
} until z
//; (After that loop finishes, we know the accumulator must contain 0.)
st a, WSYNC
st a, HMOVE
st a, VBLANK
//;
//; Wait for $3f (plus one?) scan lines to pass, by waiting for
//; WSYNC that many times.
//;
ld x, $3F
repeat {
st a, WSYNC
dec x
} until n
st a, WSYNC
//;
//; Delay while the raster scans across the screen. The more
//; we delay here, the more to the right the player will be when
//; we draw it.
//;
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
//;
//; OK, *now* display the player.
//;
st a, RESP0
//;
//; Loop over the rows of the sprite data, drawing each to the screen
//; over four scan lines.
//;
//; TODO understand this better and describe it!
//;
ld y, $07
for y down to 0 {
ld a, image_data + y
st a, GP0
st a, WSYNC
st a, WSYNC
st a, WSYNC
st a, WSYNC
} // FIXME original was "dec y; bpl _image_loop"
ld a, $00
st a, GP0
//;
//; Turn off screen display and clear display registers.
//;
ld a, $02
st a, WSYNC
st a, VBLANK
ld a, $00
st a, PF0
st a, PF1
st a, PF2
st a, COLUPF
st a, COLUBK
}
define colourize_player routine
inputs colour, luminosity
outputs COLUP0
trashes a, z, c, n
{
ld a, colour
st off, c
shl a
shl a
shl a
shl a
or a, luminosity
st a, COLUP0
}
define main routine
inputs image_data, INTIM
outputs CTRLPF, colour, luminosity, NUSIZ0, VSYNC, WSYNC, TIM64T, HMOVE, VBLANK, RESP0, GP0, PF0, PF1, PF2, COLUPF, COLUBK, COLUP0
trashes a, x, y, z, c, n
{
ld a, $00
st a, CTRLPF
ld a, $0c
st a, colour
ld a, $0a
st a, luminosity
ld a, $00
st a, NUSIZ0
repeat {
call vertical_blank
call display_frame
call colourize_player
} forever
}