-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathheader.s
315 lines (277 loc) · 5.41 KB
/
header.s
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/*
* Copyright (c) 2011 Emmanuel Vadot <[email protected]>
* Copyright (c) 2011 Furrtek <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: header.s,v 1.34 2011/11/12 10:02:40 elbarto Exp $ */
.global START
.global HBLANK
.global VBLANK
.text
.include "defines.inc"
.org 0
Vectors:
dc.l 0x10F300
dc.l 0xC00402
dc.l err_bus
dc.l err_addr
dc.l err_illegal
dc.l err_divzero
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
dc.l VBLANK
dc.l HBLANK
dc.l START
dc.l START
dc.l START
dc.l START
dc.l START
.org 0x100
.string "ENPONEB OI S.0c1" | NEOPEN BIOS 0.1c
.org 0x402
jmp START
.org 0x408
jmp START
.org 0x40E
jmp START
.org 0x414
jmp START
.org 0x41A
jmp START
.org 0x420
jmp START
.org 0x426
jmp START
.org 0x42C
jmp START
.org 0x432
jmp START
.org 0x438
jmp VBLANK
.org 0x43E
jmp HBLANK
.org 0x444
jmp system_return
.org 0x44A
jmp system_io
.org 0x450
jmp credit_check
.org 0x456
jmp credit_down
.org 0x45C
jmp read_calendar
.org 0x462
jmp setup_calendar
.org 0x468
jmp card
.org 0x46E
jmp card_error
.org 0x474
jmp how_to_play
.org 0x47A
jmp START
.org 0x480
jmp null
.org 0x486
jmp null
.org 0x48C
jmp null
.org 0x492
jmp null
.org 0x498
jmp null
.org 0x49E
jmp null
.org 0x4A4
jmp null
.org 0x4AA
jmp null
.org 0x4B0
jmp null
.org 0x4B6
jmp null
.org 0x4BC
jmp null
.org 0x4C2
jmp fix_clear
.org 0x4C8
jmp sprite_clear
.org 0x4CE
jmp mess_out
.org 0x4D4
jmp check_mahjong_controller
null:
rts
waitnop:
bsr 2f
bsr 1f
2:
bsr 1f
bsr 1f
1:
nop
nop
nop
nop
nop
nop
rts
START:
move #0x2700, sr
move.b d0,(REG_WATCHDOG)
move.w #7,(REG_IRQACK)
move.w #0x4000,REG_LSPCMODE
lea 0x10F300,a5
|Testing on real HW
move.b #0xFF,(0x380031)
bsr waitnop
move.b #0xFF,(0x380041)
move.b #0xF7,(0x380031)
bsr waitnop
move.b #0xFF,(0x380031)
bsr waitnop
move.b #0xEF,(0x380031)
bsr waitnop
move.b #0xFF,(0x380031)
bsr waitnop
move.b #0xDF,(0x380031)
bsr waitnop
move.b #0xFF,(0x380031)
move.b d0,(0x3A0003)
move.b d0,(0x3A000B)
move.b d0,(0x380065)
move.b d0,(0x380067)
|Testing on real HW
move.l #0xFFFFFFF,d7
.wait:
move.b d0,(REG_WATCHDOG)
nop
nop
nop
nop
nop
nop
dbra d7,.wait
|Testing on real HW
move.w #0x7FFF,d7
move.w #1,(REG_VRAMMOD)
move.w #0,(REG_VRAMADDR)
.clvram:
move.b d0,(REG_WATCHDOG)
move.w #0,(REG_VRAMRW)
nop
dbra d7,.clvram
move #0x2000, sr | Enable interrupts
move.b #3,(REG_SOUND) | Reset Z80
bsr wait_vsync
move #0x2700, sr | Disable interrupts
move.b d0,(REG_SWPBIOS)
move.b d0,(REG_BRDFIX)
move.b d0,(REG_NOSHADOW)
move.b #0x0,(BIOS_SYSTEM_MODE) | Set to SYSTEM_MODE
jsr fix_clear
jsr palette_clear
/* Clear the whole RAM */
move.l #(0xFFFF/4)-1,d7
lea RAMSTART,a0
1:
clr.l (a0)+
move.b d0,REG_DIPSW
dbra d7,1b
/* Copy .data section into the ram */
lea _text_end, a0
lea 0x10F300, a1
move.l #_data_size, d0
beq skip_data
1:
move.w (a0)+, (a1)+
move.b d0,REG_DIPSW
dbra d0, 1b
skip_data:
/* Zeroing the .bss section */
move.l #_bss_size, d0
beq skip_bss
1:
move.w #0x0, (a1)+
move.b d0,REG_DIPSW
dbra d0, 1b
skip_bss:
|Skip for debug purposes, must leave this later !
|jsr selfcheck | Checksum check
move.w #0x2000,sr | Enable interrupts
jsr wait_vsync
/* Shortcuts */
move.b REG_P1CNT,d0
and.b #0x30,d0 | A+B buttons: quickboot
bne 1f
jmp init_game
1:
move.b REG_DIPSW,d0
btst.b #0,d0 | DIPSW1: HW test
bne 1f
jmp hardware_test
1:
jsr test_sram
jsr setup_bootmenu
Loop:
bra Loop
HBLANK:
movem.l d0-a6, -(sp)
jsr hblank_palette
move.w #0x2, (REG_IRQACK)
movem.l (sp)+,d0-a6
rte
VBLANK:
move.w #0x4, (REG_IRQACK)
move.b d0, (REG_WATCHDOG)
clr.b (VSYNC_FLAG)
tst.b (0x10FEE3) | ?
bne 3f
movem.l d0-a6, -(sp)
jsr system_io | Do player input stuff
tst.b (BIOS_SYSTEM_MODE)
bne 1f | System mode
tst.l VBL_HANDLER
beq 1f
movea.l VBL_HANDLER,a0
jsr (a0)
1:
movem.l (sp)+, d0-a6
3:
addq.b #1, (BIOS_FRAME_COUNTER)
rte
.global VBL_HANDLER
.global MENU_MODE
.global CALLBACK
.section .bss
VBL_HANDLER: .long 0
CALLBACK: .long 0
MENU_MODE: .byte 0