cff531af |
1 | @* |
2 | @* Memory I/O handlers for Sega/Mega CD emulation |
3 | @* (C) notaz, 2007-2009 |
4 | @* |
5 | @* This work is licensed under the terms of MAME license. |
6 | @* See COPYING file in the top-level directory. |
7 | @* |
4ff2d527 |
8 | |
88fd63ad |
9 | #include "../pico_int_o32.h" |
10 | |
4ff2d527 |
11 | .equiv PCM_STEP_SHIFT, 11 |
4ff2d527 |
12 | |
13 | .text |
0ace9b9a |
14 | .align 2 |
15 | |
fa8fb754 |
16 | .global PicoRead8_mcd_io |
17 | .global PicoRead16_mcd_io |
18 | .global PicoWrite8_mcd_io |
19 | .global PicoWrite16_mcd_io |
0ace9b9a |
20 | |
21 | .global PicoReadS68k8_pr |
22 | .global PicoReadS68k16_pr |
23 | .global PicoWriteS68k8_pr |
24 | .global PicoWriteS68k16_pr |
25 | |
26 | .global PicoReadM68k8_cell0 |
27 | .global PicoReadM68k8_cell1 |
28 | .global PicoReadM68k16_cell0 |
29 | .global PicoReadM68k16_cell1 |
30 | .global PicoWriteM68k8_cell0 |
31 | .global PicoWriteM68k8_cell1 |
32 | .global PicoWriteM68k16_cell0 |
33 | .global PicoWriteM68k16_cell1 |
34 | |
35 | .global PicoReadS68k8_dec0 |
36 | .global PicoReadS68k8_dec1 |
37 | .global PicoReadS68k16_dec0 |
38 | .global PicoReadS68k16_dec1 |
39 | .global PicoWriteS68k8_dec_m0b0 |
40 | .global PicoWriteS68k8_dec_m1b0 |
41 | .global PicoWriteS68k8_dec_m2b0 |
42 | .global PicoWriteS68k8_dec_m0b1 |
43 | .global PicoWriteS68k8_dec_m1b1 |
44 | .global PicoWriteS68k8_dec_m2b1 |
45 | .global PicoWriteS68k16_dec_m0b0 |
46 | .global PicoWriteS68k16_dec_m1b0 |
47 | .global PicoWriteS68k16_dec_m2b0 |
48 | .global PicoWriteS68k16_dec_m0b1 |
49 | .global PicoWriteS68k16_dec_m1b1 |
50 | .global PicoWriteS68k16_dec_m2b1 |
4ff2d527 |
51 | |
52 | @ externs, just for reference |
53 | .extern Pico |
3f23709e |
54 | .extern cdc_host_r |
4ff2d527 |
55 | .extern m68k_reg_write8 |
4ff2d527 |
56 | .extern s68k_reg_read16 |
4ff2d527 |
57 | .extern s68k_reg_write8 |
a93a80de |
58 | .extern s68k_reg_write16 |
2433f409 |
59 | .extern s68k_poll_detect |
33be04ca |
60 | .extern pcd_pcm_write |
61 | .extern pcd_pcm_read |
0ace9b9a |
62 | .extern PicoRead8_io |
63 | .extern PicoRead16_io |
64 | .extern PicoWrite8_io |
65 | .extern PicoWrite16_io |
08769494 |
66 | .extern m68k_comm_check |
4ff2d527 |
67 | |
4ff2d527 |
68 | |
69 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
70 | |
71 | @ utilities |
72 | |
73 | @ r0=addr[in,out], r1,r2=tmp |
74 | .macro cell_map |
75 | ands r1, r0, #0x01c000 |
76 | ldrne pc, [pc, r1, lsr #12] |
77 | beq 0f @ most common? |
78 | .long 0f |
79 | .long 0f |
80 | .long 0f |
81 | .long 0f |
82 | .long 1f |
83 | .long 1f |
84 | .long 2f |
85 | .long 3f |
86 | 1: @ x16 cells |
87 | and r1, r0, #0x7e00 @ col |
88 | and r2, r0, #0x01fc @ row |
89 | orr r2, r2, #0x0400 |
90 | orr r1, r2, r1, ror #13 |
91 | b 9f |
92 | 2: @ x8 cells |
93 | and r1, r0, #0x3f00 @ col |
94 | and r2, r0, #0x00fc @ row |
95 | orr r2, r2, #0x0600 |
96 | orr r1, r2, r1, ror #12 |
97 | b 9f |
98 | 3: @ x4 cells |
99 | and r1, r0, #0x1f80 @ col |
100 | and r2, r0, #0x007c @ row |
101 | orr r1, r2, r1, ror #11 |
102 | and r2, r0,#0x1e000 |
103 | orr r1, r1, r2, lsr #6 |
104 | b 9f |
105 | 0: @ x32 cells |
106 | and r1, r0, #0xfc00 @ col |
107 | and r2, r0, #0x03fc @ row |
108 | orr r1, r2, r1, ror #14 |
109 | 9: |
110 | and r0, r0, #3 |
111 | orr r0, r0, r1, ror #26 @ rol 4+2 |
112 | .endm |
113 | |
114 | |
4ff2d527 |
115 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
116 | |
117 | |
118 | m_read_null: |
119 | mov r0, #0 |
120 | bx lr |
121 | |
122 | |
0ace9b9a |
123 | PicoReadM68k8_cell0: @ 0x220000 - 0x23ffff, cell arranged |
124 | mov r3, #0x0c0000 |
125 | b 0f |
4ff2d527 |
126 | |
0ace9b9a |
127 | PicoReadM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged |
128 | mov r3, #0x0e0000 |
129 | 0: |
4ff2d527 |
130 | cell_map |
88fd63ad |
131 | ldr r1, =Pico |
0ace9b9a |
132 | add r0, r0, r3 |
88fd63ad |
133 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd (used everywhere) |
4ff2d527 |
134 | eor r0, r0, #1 |
135 | ldrb r0, [r1, r0] |
136 | bx lr |
137 | |
138 | |
fa8fb754 |
139 | PicoRead8_mcd_io: |
0ace9b9a |
140 | and r1, r0, #0xff00 |
141 | cmp r1, #0x2000 @ a120xx? |
142 | bne PicoRead8_io |
4ff2d527 |
143 | |
88fd63ad |
144 | ldr r1, =Pico |
4ff2d527 |
145 | and r0, r0, #0x3f |
88fd63ad |
146 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd |
4ff2d527 |
147 | cmp r0, #0x0e |
148 | ldrlt pc, [pc, r0, lsl #2] |
149 | b m_m68k_read8_hi |
150 | .long m_m68k_read8_r00 |
151 | .long m_m68k_read8_r01 |
152 | .long m_m68k_read8_r02 |
153 | .long m_m68k_read8_r03 |
154 | .long m_m68k_read8_r04 |
155 | .long m_read_null @ unused bits |
156 | .long m_m68k_read8_r06 |
157 | .long m_m68k_read8_r07 |
158 | .long m_m68k_read8_r08 |
159 | .long m_m68k_read8_r09 |
160 | .long m_read_null @ reserved |
161 | .long m_read_null |
162 | .long m_m68k_read8_r0c |
163 | .long m_m68k_read8_r0d |
164 | m_m68k_read8_r00: |
165 | add r1, r1, #0x110000 |
00bd648e |
166 | ldr r0, [r1, #0x30] |
4ff2d527 |
167 | and r0, r0, #0x04000000 @ we need irq2 mask state |
168 | mov r0, r0, lsr #19 |
169 | bx lr |
170 | m_m68k_read8_r01: |
171 | add r1, r1, #0x110000 |
172 | add r1, r1, #0x002200 |
173 | ldrb r0, [r1, #2] @ Pico_mcd->m.busreq |
174 | bx lr |
175 | m_m68k_read8_r02: |
176 | add r1, r1, #0x110000 |
177 | ldrb r0, [r1, #2] |
178 | bx lr |
cc5ffc3c |
179 | m_m68k_read8_r03: |
180 | add r1, r1, #0x110000 |
181 | push {r1, lr} |
182 | bl m68k_comm_check |
183 | pop {r1, lr} |
184 | ldrb r0, [r1, #3] |
185 | and r0, r0, #0xc7 |
186 | bx lr |
4ff2d527 |
187 | m_m68k_read8_r04: |
188 | add r1, r1, #0x110000 |
189 | ldrb r0, [r1, #4] |
190 | bx lr |
191 | m_m68k_read8_r06: |
192 | ldrb r0, [r1, #0x73] @ IRQ vector |
193 | bx lr |
194 | m_m68k_read8_r07: |
195 | ldrb r0, [r1, #0x72] |
196 | bx lr |
197 | m_m68k_read8_r08: |
198 | mov r0, #0 |
3f23709e |
199 | bl cdc_host_r |
4ff2d527 |
200 | mov r0, r0, lsr #8 |
201 | bx lr |
202 | m_m68k_read8_r09: |
203 | mov r0, #0 |
3f23709e |
204 | b cdc_host_r |
4ff2d527 |
205 | m_m68k_read8_r0c: |
206 | add r1, r1, #0x110000 |
207 | add r1, r1, #0x002200 |
208 | ldr r0, [r1, #0x14] @ Pico_mcd->m.timer_stopwatch |
209 | mov r0, r0, lsr #24 |
210 | bx lr |
211 | m_m68k_read8_r0d: |
212 | add r1, r1, #0x110000 |
213 | add r1, r1, #0x002200 |
214 | ldr r0, [r1, #0x14] |
215 | mov r0, r0, lsr #16 |
216 | bx lr |
217 | m_m68k_read8_hi: |
218 | cmp r0, #0x30 |
4ff2d527 |
219 | add r1, r1, #0x110000 |
cc5ffc3c |
220 | movge r0, #0 |
221 | bxge lr |
222 | add r1, r0 |
223 | push {r1, lr} |
224 | bl m68k_comm_check |
225 | pop {r1, lr} |
226 | ldrb r0, [r1] |
227 | bx lr |
4ff2d527 |
228 | |
4ff2d527 |
229 | |
230 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
231 | |
232 | |
0ace9b9a |
233 | PicoReadM68k16_cell0: @ 0x220000 - 0x23ffff, cell arranged |
234 | mov r3, #0x0c0000 |
235 | b 0f |
4ff2d527 |
236 | |
0ace9b9a |
237 | PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged |
238 | mov r3, #0x0e0000 |
239 | 0: |
4ff2d527 |
240 | cell_map |
88fd63ad |
241 | ldr r1, =Pico |
0ace9b9a |
242 | add r0, r0, r3 |
88fd63ad |
243 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd |
4ff2d527 |
244 | bic r0, r0, #1 |
245 | ldrh r0, [r1, r0] |
246 | bx lr |
247 | |
248 | |
fa8fb754 |
249 | PicoRead16_mcd_io: |
0ace9b9a |
250 | and r1, r0, #0xff00 |
251 | cmp r1, #0x2000 @ a120xx |
252 | bne PicoRead16_io |
4ff2d527 |
253 | |
254 | m_m68k_read16_m68k_regs: |
88fd63ad |
255 | ldr r1, =Pico |
4ff2d527 |
256 | and r0, r0, #0x3e |
88fd63ad |
257 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd |
4ff2d527 |
258 | cmp r0, #0x0e |
259 | ldrlt pc, [pc, r0, lsl #1] |
260 | b m_m68k_read16_hi |
261 | .long m_m68k_read16_r00 |
262 | .long m_m68k_read16_r02 |
263 | .long m_m68k_read16_r04 |
264 | .long m_m68k_read16_r06 |
265 | .long m_m68k_read16_r08 |
266 | .long m_read_null @ reserved |
267 | .long m_m68k_read16_r0c |
268 | m_m68k_read16_r00: |
269 | add r1, r1, #0x110000 |
7a1f6e45 |
270 | ldr r0, [r1, #0x30] |
4ff2d527 |
271 | add r1, r1, #0x002200 |
272 | ldrb r1, [r1, #2] @ Pico_mcd->m.busreq |
273 | and r0, r0, #0x04000000 @ we need irq2 mask state |
274 | orr r0, r1, r0, lsr #11 |
275 | bx lr |
cc5ffc3c |
276 | m_m68k_read16_r02: |
277 | add r1, r1, #0x110000 |
278 | push {r1, lr} |
279 | bl m68k_comm_check |
280 | pop {r1, lr} |
281 | ldrb r2, [r1, #3] |
282 | ldrb r0, [r1, #2] |
c008977e |
283 | and r2, r2, #0xc7 |
cc5ffc3c |
284 | orr r0, r2, r0, lsl #8 |
285 | bx lr |
4ff2d527 |
286 | m_m68k_read16_r04: |
287 | add r1, r1, #0x110000 |
288 | ldrb r0, [r1, #4] |
289 | mov r0, r0, lsl #8 |
290 | bx lr |
291 | m_m68k_read16_r06: |
292 | ldrh r0, [r1, #0x72] @ IRQ vector |
293 | bx lr |
294 | m_m68k_read16_r08: |
295 | mov r0, #0 |
3f23709e |
296 | b cdc_host_r |
4ff2d527 |
297 | m_m68k_read16_r0c: |
298 | add r1, r1, #0x110000 |
299 | add r1, r1, #0x002200 |
300 | ldr r0, [r1, #0x14] |
301 | mov r0, r0, lsr #16 |
302 | bx lr |
303 | m_m68k_read16_hi: |
304 | cmp r0, #0x30 |
cc5ffc3c |
305 | add r1, r1, #0x110000 |
4ff2d527 |
306 | movge r0, #0 |
307 | bxge lr |
cc5ffc3c |
308 | |
309 | add r1, r0, r1 |
310 | push {r1, lr} |
311 | bl m68k_comm_check |
312 | pop {r0, lr} |
313 | ldrh r0, [r0] |
314 | mov r1, r0, lsr #8 |
315 | and r0, r0, #0xff |
316 | orr r0, r1, r0, lsl #8 |
317 | bx lr |
4ff2d527 |
318 | |
319 | |
0ace9b9a |
320 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
4ff2d527 |
321 | |
4ff2d527 |
322 | |
0ace9b9a |
323 | PicoWriteM68k8_cell0: @ 0x220000 - 0x23ffff, cell arranged |
324 | mov r12,#0x0c0000 |
325 | b 0f |
4ff2d527 |
326 | |
0ace9b9a |
327 | PicoWriteM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged |
328 | mov r12,#0x0e0000 |
329 | 0: |
330 | mov r3, r1 |
331 | cell_map |
88fd63ad |
332 | ldr r2, =Pico |
0ace9b9a |
333 | add r0, r0, r12 |
88fd63ad |
334 | ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd |
0ace9b9a |
335 | ldr r2, [r2] |
336 | eor r0, r0, #1 |
337 | strb r3, [r2, r0] |
4ff2d527 |
338 | bx lr |
339 | |
340 | |
fa8fb754 |
341 | PicoWrite8_mcd_io: |
0ace9b9a |
342 | and r2, r0, #0xff00 |
343 | cmp r2, #0x2000 @ a120xx? |
344 | beq m68k_reg_write8 |
345 | b PicoWrite8_io |
346 | |
347 | |
4ff2d527 |
348 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
349 | |
350 | |
0ace9b9a |
351 | PicoWriteM68k16_cell0: @ 0x220000 - 0x23ffff, cell arranged |
352 | mov r12, #0x0c0000 |
353 | b 0f |
354 | |
355 | PicoWriteM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged |
356 | mov r12, #0x0e0000 |
357 | 0: |
358 | mov r3, r1 |
359 | cell_map |
88fd63ad |
360 | ldr r1, =Pico |
0ace9b9a |
361 | add r0, r0, r12 |
88fd63ad |
362 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd |
4ff2d527 |
363 | bic r0, r0, #1 |
0ace9b9a |
364 | strh r3, [r1, r0] |
4ff2d527 |
365 | bx lr |
366 | |
367 | |
fa8fb754 |
368 | PicoWrite16_mcd_io: |
0ace9b9a |
369 | and r2, r0, #0xff00 |
370 | cmp r2, #0x2000 @ a120xx? |
371 | bne PicoWrite16_io |
4ff2d527 |
372 | |
0ace9b9a |
373 | m_m68k_write16_regs: |
374 | and r0, r0, #0x3e |
375 | cmp r0, #0x0e |
376 | beq m_m68k_write16_regs_spec |
377 | and r3, r1, #0xff |
378 | add r2, r0, #1 |
379 | stmfd sp!,{r2,r3,lr} |
380 | mov r1, r1, lsr #8 |
381 | bl m68k_reg_write8 |
382 | ldmfd sp!,{r0,r1,lr} |
383 | b m68k_reg_write8 |
4ff2d527 |
384 | |
0ace9b9a |
385 | m_m68k_write16_regs_spec: @ special case |
0ace9b9a |
386 | mov r1, r1, lsr #8 |
08769494 |
387 | b m68k_reg_write8 |
4ff2d527 |
388 | |
389 | |
0ace9b9a |
390 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
391 | @ Sub 68k |
392 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
4ff2d527 |
393 | |
4ff2d527 |
394 | |
0ace9b9a |
395 | PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff |
396 | mov r3, #0x080000 @ + ^ / 2 |
397 | b 0f |
4ff2d527 |
398 | |
0ace9b9a |
399 | PicoReadS68k8_dec1: |
400 | mov r3, #0x0a0000 @ + ^ / 2 |
401 | 0: |
88fd63ad |
402 | ldr r2, =Pico |
5c69a605 |
403 | eor r0, r0, #2 |
88fd63ad |
404 | ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd |
5c69a605 |
405 | movs r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
406 | add r2, r2, r3 @ map to our address |
5c69a605 |
407 | ldrb r0, [r2, r0] |
408 | movcc r0, r0, lsr #4 |
409 | andcs r0, r0, #0xf |
410 | bx lr |
5c69a605 |
411 | |
4ff2d527 |
412 | |
0ace9b9a |
413 | PicoReadS68k8_pr: |
414 | and r2, r0, #0xfe00 |
415 | cmp r2, #0x8000 |
416 | bne m_s68k_read8_pcm |
4ff2d527 |
417 | |
418 | m_s68k_read8_regs: |
419 | bic r0, r0, #0xff0000 |
420 | bic r0, r0, #0x008000 |
2433f409 |
421 | sub r2, r0, #0x0e |
422 | cmp r2, #(0x30-0x0e) |
423 | blo m_s68k_read8_comm |
4ff2d527 |
424 | stmfd sp!,{r0,lr} |
425 | bic r0, r0, #1 |
a93a80de |
426 | bl s68k_reg_read16 |
4ff2d527 |
427 | ldmfd sp!,{r1,lr} |
428 | tst r1, #1 |
429 | moveq r0, r0, lsr #8 |
430 | and r0, r0, #0xff |
431 | bx lr |
432 | |
2433f409 |
433 | m_s68k_read8_comm: |
88fd63ad |
434 | ldr r1, =Pico |
435 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd |
2433f409 |
436 | add r1, r1, #0x110000 |
437 | ldrb r1, [r1, r0] |
334d9fb6 |
438 | bic r0, r0, #1 |
2433f409 |
439 | b s68k_poll_detect |
440 | |
4ff2d527 |
441 | |
0ace9b9a |
442 | m_s68k_read8_pcm: |
443 | tst r0, #0x8000 |
444 | bne m_read_null |
4ff2d527 |
445 | |
0ace9b9a |
446 | @ must not trash r3 and r12 |
88fd63ad |
447 | ldr r1, =Pico |
0ace9b9a |
448 | bic r0, r0, #0xff0000 |
88fd63ad |
449 | ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd |
0ace9b9a |
450 | mov r2, #0x110000 |
451 | orr r2, r2, #0x002200 |
452 | cmp r0, #0x2000 |
453 | bge m_s68k_read8_pcm_ram |
454 | cmp r0, #0x20 |
33be04ca |
455 | movge r0, r0, lsr #1 |
456 | bge pcd_pcm_read |
457 | mov r0, #0 |
5c69a605 |
458 | bx lr |
4ff2d527 |
459 | |
0ace9b9a |
460 | m_s68k_read8_pcm_ram: |
461 | orr r2, r2, #0x40 |
462 | ldr r2, [r1, r2] |
463 | add r1, r1, #0x100000 @ pcm_ram |
464 | and r2, r2, #0x0f000000 @ bank |
465 | add r1, r1, r2, lsr #12 |
466 | bic r0, r0, #0x00e000 |
467 | mov r0, r0, lsr #1 |
468 | ldrb r0, [r1, r0] |
469 | bx lr |
4ff2d527 |
470 | |
471 | |
472 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
473 | |
474 | |
0ace9b9a |
475 | PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff |
476 | mov r3, #0x080000 @ + ^ / 2 |
477 | b 0f |
5c69a605 |
478 | |
0ace9b9a |
479 | PicoReadS68k16_dec1: |
480 | mov r3, #0x0a0000 @ + ^ / 2 |
481 | 0: |
88fd63ad |
482 | ldr r2, =Pico |
5c69a605 |
483 | eor r0, r0, #2 |
88fd63ad |
484 | ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd |
5c69a605 |
485 | mov r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
486 | add r2, r2, r3 @ map to our address |
487 | ldrb r0, [r2, r0] |
5c69a605 |
488 | orr r0, r0, r0, lsl #4 |
489 | bic r0, r0, #0xf0 |
5c69a605 |
490 | bx lr |
4ff2d527 |
491 | |
492 | |
0ace9b9a |
493 | PicoReadS68k16_pr: |
494 | and r2, r0, #0xfe00 |
495 | cmp r2, #0x8000 |
496 | @ pcm is on 8-bit bus, would this be same as byte access? |
497 | bne m_s68k_read8_pcm |
4ff2d527 |
498 | |
0ace9b9a |
499 | m_s68k_read16_regs: |
4ff2d527 |
500 | bic r0, r0, #0xff0000 |
501 | bic r0, r0, #0x008000 |
502 | bic r0, r0, #0x000001 |
0ace9b9a |
503 | cmp r0, #8 |
504 | bne s68k_reg_read16 |
505 | mov r0, #1 |
3f23709e |
506 | b cdc_host_r |
4ff2d527 |
507 | |
4ff2d527 |
508 | |
509 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
510 | |
511 | |
0ace9b9a |
512 | .macro m_s68k_write8_2M_decode |
88fd63ad |
513 | ldr r2, =Pico |
48e8482f |
514 | eor r0, r0, #2 |
88fd63ad |
515 | ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd |
48e8482f |
516 | movs r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
517 | add r2, r2, r3 @ map to our address |
48e8482f |
518 | .endm |
519 | |
0ace9b9a |
520 | PicoWriteS68k8_dec_m2b0: @ overwrite |
521 | ands r1, r1, #0x0f |
522 | bxeq lr |
523 | |
524 | PicoWriteS68k8_dec_m0b0: |
525 | mov r3, #0x080000 |
526 | b 0f |
527 | |
528 | PicoWriteS68k8_dec_m2b1: @ overwrite |
529 | ands r1, r1, #0x0f |
530 | bxeq lr |
531 | |
532 | PicoWriteS68k8_dec_m0b1: |
533 | mov r3, #0x0a0000 |
534 | 0: |
535 | m_s68k_write8_2M_decode |
48e8482f |
536 | ldrb r0, [r2, r0]! |
537 | and r1, r1, #0x0f |
538 | movcc r1, r1, lsl #4 |
539 | andcc r3, r0, #0x0f |
540 | andcs r3, r0, #0xf0 |
541 | orr r3, r3, r1 |
48e8482f |
542 | strneb r3, [r2] |
543 | bx lr |
48e8482f |
544 | |
0ace9b9a |
545 | PicoWriteS68k8_dec_m1b0: @ underwrite |
546 | mov r3, #0x080000 |
547 | b 0f |
548 | |
549 | PicoWriteS68k8_dec_m1b1: |
550 | mov r3, #0x0a0000 |
551 | 0: |
48e8482f |
552 | ands r1, r1, #0x0f |
553 | bxeq lr |
0ace9b9a |
554 | m_s68k_write8_2M_decode |
48e8482f |
555 | ldrb r0, [r2, r0]! |
556 | movcc r1, r1, lsl #4 |
557 | andcc r3, r0, #0x0f |
558 | andcs r3, r0, #0xf0 |
0ace9b9a |
559 | teq r3, r0 |
560 | bxne lr |
48e8482f |
561 | orr r3, r3, r1 |
48e8482f |
562 | strneb r3, [r2] |
563 | bx lr |
48e8482f |
564 | |
48e8482f |
565 | |
0ace9b9a |
566 | PicoWriteS68k8_pr: |
567 | and r2, r0, #0xfe00 |
568 | cmp r2, #0x8000 |
569 | bne m_s68k_write8_pcm |
48e8482f |
570 | |
0ace9b9a |
571 | m_s68k_write8_regs: |
4ff2d527 |
572 | bic r0, r0, #0xff0000 |
0ace9b9a |
573 | bic r0, r0, #0x008000 |
574 | tst r0, #0x7e00 |
575 | movne r0, #0 |
576 | bxne lr |
a93a80de |
577 | sub r2, r0, #0x59 |
578 | cmp r2, #0x0f |
0ace9b9a |
579 | bhs s68k_reg_write8 |
580 | bic r0, r0, #1 |
581 | orr r1, r1, r1, lsl #8 |
a93a80de |
582 | b s68k_reg_write16 |
4ff2d527 |
583 | |
584 | |
585 | m_s68k_write8_pcm: |
0ace9b9a |
586 | tst r0, #0x8000 |
587 | bxne lr |
4ff2d527 |
588 | bic r0, r0, #0xff0000 |
589 | cmp r0, #0x12 |
590 | movlt r0, r0, lsr #1 |
33be04ca |
591 | blt pcd_pcm_write |
4ff2d527 |
592 | |
593 | cmp r0, #0x2000 |
594 | bxlt lr |
595 | |
596 | m_s68k_write8_pcm_ram: |
88fd63ad |
597 | ldr r3, =Pico |
4ff2d527 |
598 | bic r0, r0, #0x00e000 |
88fd63ad |
599 | ldr r3, [r3, #OFS_Pico_rom] @ Pico.mcd |
4ff2d527 |
600 | mov r0, r0, lsr #1 |
601 | add r2, r3, #0x110000 |
602 | add r2, r2, #0x002200 |
603 | add r2, r2, #0x000040 |
604 | ldr r2, [r2] |
605 | add r3, r3, #0x100000 @ pcm_ram |
606 | and r2, r2, #0x0f000000 @ bank |
607 | add r3, r3, r2, lsr #12 |
608 | strb r1, [r3, r0] |
609 | bx lr |
610 | |
611 | |
4ff2d527 |
612 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
613 | |
614 | |
0ace9b9a |
615 | .macro m_s68k_write16_2M_decode |
88fd63ad |
616 | ldr r2, =Pico |
48e8482f |
617 | eor r0, r0, #2 |
88fd63ad |
618 | ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd |
48e8482f |
619 | mov r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
620 | add r2, r2, r3 @ map to our address |
48e8482f |
621 | .endm |
622 | |
0ace9b9a |
623 | PicoWriteS68k16_dec_m0b0: |
624 | mov r3, #0x080000 |
625 | b 0f |
626 | |
627 | PicoWriteS68k16_dec_m0b1: |
628 | mov r3, #0x0a0000 |
629 | 0: |
630 | m_s68k_write16_2M_decode |
48e8482f |
631 | bic r1, r1, #0xf0 |
632 | orr r1, r1, r1, lsr #4 |
633 | strb r1, [r2, r0] |
634 | bx lr |
48e8482f |
635 | |
0ace9b9a |
636 | PicoWriteS68k16_dec_m1b0: @ underwrite |
637 | mov r3, #0x080000 |
638 | b 0f |
639 | |
640 | PicoWriteS68k16_dec_m1b1: |
641 | mov r3, #0x0a0000 |
642 | 0: |
48e8482f |
643 | bics r1, r1, #0xf000 |
644 | bicnes r1, r1, #0x00f0 |
645 | bxeq lr |
646 | orr r1, r1, r1, lsr #4 |
0ace9b9a |
647 | m_s68k_write16_2M_decode |
48e8482f |
648 | ldrb r0, [r2, r0]! |
649 | and r3, r1, #0x0f |
650 | and r1, r1, #0xf0 |
651 | tst r0, #0x0f |
652 | orreq r0, r0, r3 |
653 | tst r0, #0xf0 |
654 | orreq r0, r0, r1 |
655 | strb r0, [r2] |
656 | bx lr |
48e8482f |
657 | |
0ace9b9a |
658 | PicoWriteS68k16_dec_m2b0: @ overwrite |
659 | mov r3, #0x080000 |
660 | b 0f |
661 | |
662 | PicoWriteS68k16_dec_m2b1: |
663 | mov r3, #0x0a0000 |
664 | 0: |
48e8482f |
665 | bics r1, r1, #0xf000 |
666 | bicnes r1, r1, #0x00f0 |
667 | bxeq lr |
668 | orr r1, r1, r1, lsr #4 |
0ace9b9a |
669 | m_s68k_write16_2M_decode |
48e8482f |
670 | ldrb r0, [r2, r0]! |
671 | ands r3, r1, #0x0f |
672 | andne r0, r0, #0xf0 |
673 | orrne r0, r0, r3 |
674 | ands r1, r1, #0xf0 |
675 | andne r0, r0, #0x0f |
676 | orrne r0, r0, r1 |
677 | strb r0, [r2] |
678 | bx lr |
48e8482f |
679 | |
4ff2d527 |
680 | |
0ace9b9a |
681 | PicoWriteS68k16_pr: |
682 | and r2, r0, #0xfe00 |
683 | cmp r2, #0x8000 |
684 | bne m_s68k_write8_pcm |
4ff2d527 |
685 | |
686 | m_s68k_write16_regs: |
687 | bic r0, r0, #0xff0000 |
688 | bic r0, r0, #0x008000 |
5c69a605 |
689 | bic r0, r0, #1 |
4ff2d527 |
690 | tst r0, #0x7e00 |
691 | movne r0, #0 |
692 | bxne lr |
5c69a605 |
693 | cmp r0, #0x0e |
a93a80de |
694 | bne s68k_reg_write16 |
4ff2d527 |
695 | |
5c69a605 |
696 | m_s68k_write16_regs_spec: @ special case |
88fd63ad |
697 | ldr r2, =Pico |
5c69a605 |
698 | mov r0, #0x110000 |
88fd63ad |
699 | ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd |
5c69a605 |
700 | add r0, r0, #0x00000f |
701 | strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d; |
48e8482f |
702 | bx lr |
4ff2d527 |
703 | |
0ace9b9a |
704 | .pool |
6cadc2da |
705 | |
cff531af |
706 | @ vim:filetype=armasm |