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