51f3a685 |
1 | # Assemble with gas |
2 | # --register-prefix-optional --bitwise-or |
3 | |
4 | .macro ldarg arg, stacksz, reg |
5 | move.l (4 + \arg * 4 + \stacksz)(%sp), \reg |
6 | .endm |
7 | |
8 | |
df43aeea |
9 | .global read_joy_responses /* u8 *rbuf */ |
51f3a685 |
10 | read_joy_responses: |
11 | ldarg 0, 0, a1 |
12 | movem.l d2-d7, -(sp) |
13 | movea.l #0xa10003, a0 |
14 | move.b #0x40, (6,a0) |
15 | move.b #0x40, (a0) |
16 | |
17 | .macro one_test val |
18 | move.l #100/12-1, d0 |
19 | 0: |
20 | dbra d0, 0b |
21 | move.b \val, d0 |
22 | move.b d0, (a0) |
23 | move.b (a0), d0 |
24 | move.b (a0), d1 |
25 | move.b (a0), d2 |
26 | move.b (a0), d3 |
27 | move.b (a0), d4 |
28 | move.b (a0), d5 |
29 | move.b (a0), d6 |
30 | move.b (a0), d7 |
31 | move.b d0, (a1)+ |
32 | move.b d1, (a1)+ |
33 | move.b d2, (a1)+ |
34 | move.b d3, (a1)+ |
35 | move.b d4, (a1)+ |
36 | move.b d5, (a1)+ |
37 | move.b d6, (a1)+ |
38 | move.b d7, (a1)+ |
39 | .endm |
40 | |
41 | move.w #0x2700, sr |
42 | one_test #0x00 |
43 | one_test #0x40 |
44 | one_test #0x00 |
45 | one_test #0x40 |
46 | one_test #0x00 |
47 | move.w #0x2000, sr |
48 | movem.l (sp)+, d2-d7 |
49 | rts |
50 | |
51 | |
65d9165c |
52 | .global run_game /* u16 mapper, int tas_sync */ |
df43aeea |
53 | run_game: |
54 | move.w #0x2700, sr |
55 | ldarg 0, 0, d7 |
65d9165c |
56 | ldarg 1, 0, d6 |
57 | move.l #0xa10000, a6 |
58 | move.l #0xc00000, a5 |
59 | move.l #0xc00005, a4 |
60 | move.l #0xc00004, a3 |
61 | moveq.l #0x00, d2 |
62 | move.b #0xff, d3 |
63 | move.b #0x40, d4 |
64 | move.b d4, (0x09,a6) /* CtrlA */ |
65 | move.b d2, (0x0b,a6) /* CtrlB */ |
66 | move.b d2, (0x0d,a6) /* CtrlC */ |
67 | move.b d2, (0x13,a6) /* S-CtrlA */ |
68 | move.b d3, (0x0f,a6) /* TxDataA */ |
69 | move.b d2, (0x19,a6) /* S-CtrlB */ |
70 | move.b d3, (0x15,a6) /* TxDataB */ |
71 | move.b d2, (0x1f,a6) /* S-CtrlC */ |
72 | move.b d3, (0x1b,a6) /* TxDataC */ |
73 | |
74 | /* set up for vram write */ |
75 | move.l #0x40000000, (a3) |
df43aeea |
76 | |
77 | move.l #0xff0000, a1 |
65d9165c |
78 | move.l #0x10000/4/4-1, d0 |
df43aeea |
79 | 0: |
65d9165c |
80 | move.l d2, (a1)+ |
81 | move.l d2, (a1)+ |
82 | move.l d2, (a1)+ |
83 | move.l d2, (a1)+ |
df43aeea |
84 | dbra d0, 0b |
85 | |
65d9165c |
86 | move.l #0xfffe00, a1 |
87 | tst.l d6 |
88 | bne use_tas_code |
89 | |
90 | lea (run_game_r,pc), a0 |
91 | move.l #(run_game_r_end - run_game_r)/2-1, d0 |
92 | bra 0f |
93 | use_tas_code: |
94 | lea (run_game_r_tas,pc), a0 |
95 | move.l #(run_game_r_tas_end - run_game_r_tas)/2-1, d0 |
96 | |
df43aeea |
97 | 0: |
65d9165c |
98 | move.w (a0)+, (a1)+ |
df43aeea |
99 | dbra d0, 0b |
65d9165c |
100 | jmp 0xfffe00 |
df43aeea |
101 | |
65d9165c |
102 | run_game_r: |
df43aeea |
103 | move.w #0x3210, (0xA13006) |
104 | |
105 | move.w d7, (0xA13010) |
106 | move.w #0, (0xA13000) |
107 | |
108 | move.l (0x00), a7 |
109 | move.l (0x04), a0 |
110 | jmp (a0) |
65d9165c |
111 | run_game_r_end: |
112 | |
113 | run_game_r_tas: |
114 | move.w #0x3210, (0xA13006) |
115 | move.w d7, (0xA13010) |
116 | move.w #0, (0xA13000) |
117 | |
118 | move.l (0x00), a7 |
119 | move.l (0x04), a0 |
120 | |
121 | 0: /* wait for special code */ |
122 | move.b d4, (0x03,a6) |
123 | move.b (0x03,a6), d0 |
124 | move.b d2, (0x03,a6) |
125 | move.b (0x03,a6), d1 |
126 | and.b #0x3f, d0 |
127 | cmp.b d0, d1 |
128 | bne 0b |
129 | cmp.b #0x25, d0 |
130 | bne 0b |
131 | |
132 | 0: /* wait for special code to end */ |
133 | cmp.b (0x03,a6), d0 |
134 | beq 0b |
df43aeea |
135 | |
65d9165c |
136 | /* wait for active display */ |
137 | moveq.l #3, d0 |
138 | 0: |
139 | btst d0, (a4) /* 8 */ |
140 | beq.s 0b /* 10 */ |
141 | 0: |
142 | btst d0, (a4) |
143 | bne.s 0b |
144 | |
145 | /* flood the VDP FIFO */ |
146 | .rept 5 |
147 | move.w d2, (a5) |
148 | .endr |
149 | |
150 | /* doesn't help.. */ |
151 | .if 0 |
152 | .rept 94 |
153 | nop |
154 | .endr |
155 | move.l #0x93049400, (a3) /* DMALEN LO/HI = 0x0008 */ |
156 | move.l #0x95009601, (a3) /* DMA SRC LO/MID */ |
157 | move.l #0x977f8114, (a3) /* DMA SRC HI/MODE, Turn off Display */ |
158 | move.l #0xc0000080, (a3) /* start DMA */ |
159 | .endif |
160 | |
161 | move.b d2, (0x09,a6) /* CtrlA */ |
162 | move.b d4, (0x03,a6) |
163 | jmp (a0) |
164 | run_game_r_tas_end: |
df43aeea |
165 | |
51f3a685 |
166 | # vim:filetype=asmM68k:ts=4:sw=4:expandtab |