-
Notifications
You must be signed in to change notification settings - Fork 1
/
my_plus4.inc
265 lines (242 loc) · 3.65 KB
/
my_plus4.inc
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
MAX_HEIGHT=12
MAX_WIDTH=20
SPACE_COL = 0
BLOCK_COL = 8 | $60
BLOCK_HI_COL = 8 | $F0
BLOCK_LO_COL = 8 | $C0
STATIC_HUD_COL = $F1
WONMSG_COL = $FF
BACKDROP_COL = $61
LOSTMSG_COL = $F2
MENU_BODY_COL = $61
MENU_HL_COL = $FF
BSIZE_ON_COL = $FF
BSIZE_OFF_COL = $21
BYLINE_COL = $F2
SIDE_FLAGS_COL = $61
PRESSRET_COL = $61
CLOCK_COL = $61
MINE_COL = $62
FLAG_COL = $01
TITLE_COL = $FF
TITLE_BOX_COL = $6F
MENU_BOX_COL = $FF
SPACE_COL_BG = 0
BLOCK_COL_BG = %01000000
BLOCK_LO_COL_BG = %10000000
BLOCK_HI_COL_BG = %11000000
PTR2 = $D8
PTR = $DA
RNDL = $DC
RNDH = $DD
CURSOR_ENABLED = $DE
CURSOR_ON = $DF
CURSOR_TMP = $E8
TEMP2 = $5C
BoardScreen = VRAM
KEY_RIGHT = $1d
KEY_RIGHT2 = $44 ;D
KEY_LEFT = $9d
KEY_LEFT2 = $41 ; A
KEY_UP = $91
KEY_UP2 = $57 ; W
KEY_DOWN = $11
KEY_DOWN2 = $53 ; S
KEY_FLAG = $0d
KEY_DIG = $20
KEY_FW = $1d
KEY_HW = $9d
KEY_EASIER = $11
KEY_HARDER = $91
KEY_START = $0d
.MACRO start_irq
.ENDMACRO
.MACRO ack_irq
jmp handle_interrupt
.ENDMACRO
.MACRO CLEAR_CURSOR
jsr clear_cursor
.ENDMACRO
.macro GETIN
inc RNDL
jsr $FFE4 ; GETIN kernal function
.endmacro
.PROC init
lda #0
sta TED_BORDERCOLOR
lda #0
lda $FF06 ; mode register
ora #%01000000 ; extended color mode
sta $FF06
lda $FF12
and #$FB
sta $FF12
lda #$30 ; set chars location to $2200 for displaying the custom font
sta $FF13
lda #SPACE_COL
sta TED_BGCOLOR
lda #BLOCK_COL
sta TED_COLOR1
lda #BLOCK_LO_COL
sta TED_COLOR2
lda #BLOCK_HI_COL
sta TED_COLOR3
rts
.ENDPROC
VRAM = $0C00
CRAM = $0800
.proc clear_cursor
lda CURSOR_ON
cmp #0
bne :+
rts
: jmp flash_cursor
.endproc
.MACRO show_cursor
.ENDMACRO
.MACRO hide_cursor
.ENDMACRO
.proc flash_cursor
lda CURSOR_ENABLED
cmp #0
beq :+
lda CURSOR_ON
eor #$FF
sta CURSOR_ON
lda #>VRAM
sta PTR+1
lda cursor_col
asl
clc
adc #<VRAM
bcc :+
inc PTR+1
:
sta PTR
ldx cursor_row
loop:
cpx #0
beq done
lda PTR
clc
adc #80
bcc :+
inc PTR+1
: sta PTR
dex
jmp loop
done:
ldx #0
lda (PTR,X)
cmp #91
beq put_back
sta CURSOR_TMP
lda #91
sta (PTR,X)
jmp :+
put_back:
lda CURSOR_TMP
sta (PTR,X)
: rts
.endproc
.MACRO SILENCE
.ENDMACRO
.PROC handle_interrupt
.byte $4C
address: .byte $00, $00
.ENDPROC
.PROC setup_timer
lda #$FF
sei
lda $0314
sta handle_interrupt::address
lda $0315
sta handle_interrupt::address+1
lda #<clock
sta $0314
lda #>clock
sta $0315
cli
rts
.ENDPROC
SOUND_TICKS: .byte 0
MUSIC_TICKS: .byte 0
.PROC fade_sfx
lda SOUND_TICKS
cmp #0
bne :+
lda $FF11
and #%10011111
sta $FF11
jmp :++
:
dec SOUND_TICKS
:
lda MUSIC_TICKS
cmp #0
bne :+
lda $FF11
and #%11101111
sta $FF11
jmp :++
:
dec MUSIC_TICKS
:
rts
.endproc
.PROC setup_sound
lda #%00001111
sta $FF11
lda #$2A
sta $FF0F
lda #$3
sta $FF10
rts
.ENDPROC
.PROC dig_sound
lda #20
sta SOUND_TICKS
lda $FF11
ora #%01000000
and #%11011111
sta $FF11
rts
.ENDPROC
.PROC bass_note
rts
.ENDPROC
.PROC treble_note
lda #5
sta MUSIC_TICKS
txa
asl
tax
inx
lda @treble_table,x
sta $FF0E ; frequency
dex
lda @treble_table,x
ora $FF12
sta $FF12
lda #$8
lda $FF11
ora #%00010000
sta $FF11
rts
@treble_table:
.byte $3, $2A ; C
.byte $3, $42 ; D
.byte $3, $46 ; Eflat
.byte $3, $69 ; fsharp
.byte $3, $71 ; G
.byte $3, $81 ; A
.ENDPROC
.PROC position_cursor_sprite
lda #$0
sta CURSOR_ON
lda #1
sta CURSOR_ENABLED
jmp flash_cursor
.ENDPROC
.segment "CHARS"
.incbin "chars_hires-charset.bin",0,512