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: |
219 | cmp r0, #0x30 |
220 | movge r0, #0 |
221 | bxeq lr |
222 | add r1, r1, #0x110000 |
223 | ldrb r0, [r1, r0] |
224 | bx lr |
225 | |
4ff2d527 |
226 | |
227 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
228 | |
229 | |
0ace9b9a |
230 | PicoReadM68k16_cell0: @ 0x220000 - 0x23ffff, cell arranged |
231 | mov r3, #0x0c0000 |
232 | b 0f |
4ff2d527 |
233 | |
0ace9b9a |
234 | PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged |
235 | mov r3, #0x0e0000 |
236 | 0: |
4ff2d527 |
237 | cell_map |
238 | ldr r1, =(Pico+0x22200) |
0ace9b9a |
239 | add r0, r0, r3 |
4ff2d527 |
240 | ldr r1, [r1] |
241 | bic r0, r0, #1 |
242 | ldrh r0, [r1, r0] |
243 | bx lr |
244 | |
245 | |
0ace9b9a |
246 | PicoReadM68k16_io: |
247 | and r1, r0, #0xff00 |
248 | cmp r1, #0x2000 @ a120xx |
249 | bne PicoRead16_io |
4ff2d527 |
250 | |
251 | m_m68k_read16_m68k_regs: |
252 | ldr r1, =(Pico+0x22200) |
253 | and r0, r0, #0x3e |
254 | ldr r1, [r1] @ Pico.mcd (used everywhere) |
255 | cmp r0, #0x0e |
256 | ldrlt pc, [pc, r0, lsl #1] |
257 | b m_m68k_read16_hi |
258 | .long m_m68k_read16_r00 |
259 | .long m_m68k_read16_r02 |
260 | .long m_m68k_read16_r04 |
261 | .long m_m68k_read16_r06 |
262 | .long m_m68k_read16_r08 |
263 | .long m_read_null @ reserved |
264 | .long m_m68k_read16_r0c |
265 | m_m68k_read16_r00: |
266 | add r1, r1, #0x110000 |
7a1f6e45 |
267 | ldr r0, [r1, #0x30] |
4ff2d527 |
268 | add r1, r1, #0x002200 |
269 | ldrb r1, [r1, #2] @ Pico_mcd->m.busreq |
270 | and r0, r0, #0x04000000 @ we need irq2 mask state |
271 | orr r0, r1, r0, lsr #11 |
272 | bx lr |
273 | m_m68k_read16_r02: |
274 | add r1, r1, #0x110000 |
275 | ldrb r0, [r1, #2] |
c008977e |
276 | ldrb r2, [r1, #3] |
277 | add r1, r1, #0x002200 |
278 | ldr r1, [r1, #4] |
279 | and r2, r2, #0xc7 |
280 | orr r0, r2, r0, lsl #8 |
281 | tst r1, #2 @ DMNA pending? |
282 | bxeq lr |
283 | bic r0, r0, #1 |
284 | orr r0, r0, #2 |
4ff2d527 |
285 | bx lr |
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 |
296 | b Read_CDC_Host |
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 |
305 | addlt r1, r1, #0x110000 |
306 | ldrlth r1, [r1, r0] |
307 | movge r0, #0 |
308 | bxge lr |
309 | mov r0, r1, lsr #8 |
310 | and r1, r1, #0xff |
311 | orr r0, r0, r1, lsl #8 |
312 | bx lr |
313 | |
314 | |
0ace9b9a |
315 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
4ff2d527 |
316 | |
4ff2d527 |
317 | |
0ace9b9a |
318 | PicoWriteM68k8_cell0: @ 0x220000 - 0x23ffff, cell arranged |
319 | mov r12,#0x0c0000 |
320 | b 0f |
4ff2d527 |
321 | |
0ace9b9a |
322 | PicoWriteM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged |
323 | mov r12,#0x0e0000 |
324 | 0: |
325 | mov r3, r1 |
326 | cell_map |
327 | ldr r2, =(Pico+0x22200) |
328 | add r0, r0, r12 |
329 | ldr r2, [r2] |
330 | eor r0, r0, #1 |
331 | strb r3, [r2, r0] |
4ff2d527 |
332 | bx lr |
333 | |
334 | |
0ace9b9a |
335 | PicoWriteM68k8_io: |
336 | and r2, r0, #0xff00 |
337 | cmp r2, #0x2000 @ a120xx? |
338 | beq m68k_reg_write8 |
339 | b PicoWrite8_io |
340 | |
341 | |
4ff2d527 |
342 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
343 | |
344 | |
0ace9b9a |
345 | PicoWriteM68k16_cell0: @ 0x220000 - 0x23ffff, cell arranged |
346 | mov r12, #0x0c0000 |
347 | b 0f |
348 | |
349 | PicoWriteM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged |
350 | mov r12, #0x0e0000 |
351 | 0: |
352 | mov r3, r1 |
353 | cell_map |
4ff2d527 |
354 | ldr r1, =(Pico+0x22200) |
0ace9b9a |
355 | add r0, r0, r12 |
4ff2d527 |
356 | ldr r1, [r1] |
357 | bic r0, r0, #1 |
0ace9b9a |
358 | strh r3, [r1, r0] |
4ff2d527 |
359 | bx lr |
360 | |
361 | |
0ace9b9a |
362 | PicoWriteM68k16_io: |
363 | and r2, r0, #0xff00 |
364 | cmp r2, #0x2000 @ a120xx? |
365 | bne PicoWrite16_io |
4ff2d527 |
366 | |
0ace9b9a |
367 | m_m68k_write16_regs: |
368 | and r0, r0, #0x3e |
369 | cmp r0, #0x0e |
370 | beq m_m68k_write16_regs_spec |
371 | and r3, r1, #0xff |
372 | add r2, r0, #1 |
373 | stmfd sp!,{r2,r3,lr} |
374 | mov r1, r1, lsr #8 |
375 | bl m68k_reg_write8 |
376 | ldmfd sp!,{r0,r1,lr} |
377 | b m68k_reg_write8 |
4ff2d527 |
378 | |
0ace9b9a |
379 | m_m68k_write16_regs_spec: @ special case |
380 | ldr r2, =(Pico+0x22200) |
381 | ldr r3, =s68k_poll_adclk |
382 | mov r0, #0x110000 |
383 | ldr r2, [r2] |
384 | add r0, r0, #0x00000e |
385 | mov r1, r1, lsr #8 |
386 | strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0x0e] = d >> 8; |
387 | ldr r2, [r3] |
388 | mov r1, #0 |
389 | and r2, r2, #0xfe |
390 | cmp r2, #0x0e |
391 | bxne lr |
392 | ldr r0, =PicoCpuCS68k |
393 | str r1, [r0, #0x58] @ push s68k out of stopped state |
394 | str r1, [r3] |
4ff2d527 |
395 | bx lr |
396 | |
397 | |
0ace9b9a |
398 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
399 | @ Sub 68k |
400 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
4ff2d527 |
401 | |
4ff2d527 |
402 | |
0ace9b9a |
403 | PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff |
404 | mov r3, #0x080000 @ + ^ / 2 |
405 | b 0f |
4ff2d527 |
406 | |
0ace9b9a |
407 | PicoReadS68k8_dec1: |
408 | mov r3, #0x0a0000 @ + ^ / 2 |
409 | 0: |
5c69a605 |
410 | ldr r2, =(Pico+0x22200) |
411 | eor r0, r0, #2 |
412 | ldr r2, [r2] |
413 | movs r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
414 | add r2, r2, r3 @ map to our address |
5c69a605 |
415 | ldrb r0, [r2, r0] |
416 | movcc r0, r0, lsr #4 |
417 | andcs r0, r0, #0xf |
418 | bx lr |
5c69a605 |
419 | |
4ff2d527 |
420 | |
0ace9b9a |
421 | PicoReadS68k8_pr: |
422 | and r2, r0, #0xfe00 |
423 | cmp r2, #0x8000 |
424 | bne m_s68k_read8_pcm |
4ff2d527 |
425 | |
426 | m_s68k_read8_regs: |
427 | bic r0, r0, #0xff0000 |
428 | bic r0, r0, #0x008000 |
2433f409 |
429 | sub r2, r0, #0x0e |
430 | cmp r2, #(0x30-0x0e) |
431 | blo m_s68k_read8_comm |
4ff2d527 |
432 | sub r2, r0, #0x58 |
433 | cmp r2, #0x10 |
434 | ldrlo r2, =gfx_cd_read |
435 | ldrhs r2, =s68k_reg_read16 |
436 | stmfd sp!,{r0,lr} |
437 | bic r0, r0, #1 |
438 | mov lr, pc |
439 | bx r2 |
440 | ldmfd sp!,{r1,lr} |
441 | tst r1, #1 |
442 | moveq r0, r0, lsr #8 |
443 | and r0, r0, #0xff |
444 | bx lr |
445 | |
2433f409 |
446 | m_s68k_read8_comm: |
447 | ldr r1, =(Pico+0x22200) |
448 | ldr r1, [r1] |
449 | add r1, r1, #0x110000 |
450 | ldrb r1, [r1, r0] |
451 | b s68k_poll_detect |
452 | |
4ff2d527 |
453 | |
0ace9b9a |
454 | m_s68k_read8_pcm: |
455 | tst r0, #0x8000 |
456 | bne m_read_null |
4ff2d527 |
457 | |
0ace9b9a |
458 | @ must not trash r3 and r12 |
4ff2d527 |
459 | ldr r1, =(Pico+0x22200) |
0ace9b9a |
460 | bic r0, r0, #0xff0000 |
461 | @ bic r0, r0, #0x008000 |
4ff2d527 |
462 | ldr r1, [r1] |
0ace9b9a |
463 | mov r2, #0x110000 |
464 | orr r2, r2, #0x002200 |
465 | cmp r0, #0x2000 |
466 | bge m_s68k_read8_pcm_ram |
467 | cmp r0, #0x20 |
468 | movlt r0, #0 |
469 | bxlt lr |
470 | orr r2, r2, #(0x48+8) @ pcm.ch + addr_offset |
471 | add r1, r1, r2 |
472 | and r2, r0, #0x1c |
473 | ldr r1, [r1, r2, lsl #2] |
474 | tst r0, #2 |
475 | moveq r0, r1, lsr #PCM_STEP_SHIFT |
476 | movne r0, r1, lsr #(PCM_STEP_SHIFT+8) |
477 | and r0, r0, #0xff |
5c69a605 |
478 | bx lr |
4ff2d527 |
479 | |
0ace9b9a |
480 | m_s68k_read8_pcm_ram: |
481 | orr r2, r2, #0x40 |
482 | ldr r2, [r1, r2] |
483 | add r1, r1, #0x100000 @ pcm_ram |
484 | and r2, r2, #0x0f000000 @ bank |
485 | add r1, r1, r2, lsr #12 |
486 | bic r0, r0, #0x00e000 |
487 | mov r0, r0, lsr #1 |
488 | ldrb r0, [r1, r0] |
489 | bx lr |
4ff2d527 |
490 | |
491 | |
492 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
493 | |
494 | |
0ace9b9a |
495 | PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff |
496 | mov r3, #0x080000 @ + ^ / 2 |
497 | b 0f |
5c69a605 |
498 | |
0ace9b9a |
499 | PicoReadS68k16_dec1: |
500 | mov r3, #0x0a0000 @ + ^ / 2 |
501 | 0: |
5c69a605 |
502 | ldr r2, =(Pico+0x22200) |
503 | eor r0, r0, #2 |
504 | ldr r2, [r2] |
505 | mov r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
506 | add r2, r2, r3 @ map to our address |
507 | ldrb r0, [r2, r0] |
5c69a605 |
508 | orr r0, r0, r0, lsl #4 |
509 | bic r0, r0, #0xf0 |
5c69a605 |
510 | bx lr |
4ff2d527 |
511 | |
512 | |
0ace9b9a |
513 | PicoReadS68k16_pr: |
514 | and r2, r0, #0xfe00 |
515 | cmp r2, #0x8000 |
516 | @ pcm is on 8-bit bus, would this be same as byte access? |
517 | bne m_s68k_read8_pcm |
4ff2d527 |
518 | |
0ace9b9a |
519 | m_s68k_read16_regs: |
4ff2d527 |
520 | bic r0, r0, #0xff0000 |
521 | bic r0, r0, #0x008000 |
522 | bic r0, r0, #0x000001 |
4ff2d527 |
523 | sub r2, r0, #0x58 |
524 | cmp r2, #0x10 |
0ace9b9a |
525 | blo gfx_cd_read |
526 | cmp r0, #8 |
527 | bne s68k_reg_read16 |
528 | mov r0, #1 |
529 | b Read_CDC_Host |
4ff2d527 |
530 | |
4ff2d527 |
531 | |
532 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
533 | |
534 | |
0ace9b9a |
535 | .macro m_s68k_write8_2M_decode |
48e8482f |
536 | ldr r2, =(Pico+0x22200) |
537 | eor r0, r0, #2 |
0ace9b9a |
538 | ldr r2, [r2] @ Pico.rom |
48e8482f |
539 | movs r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
540 | add r2, r2, r3 @ map to our address |
48e8482f |
541 | .endm |
542 | |
0ace9b9a |
543 | PicoWriteS68k8_dec_m2b0: @ overwrite |
544 | ands r1, r1, #0x0f |
545 | bxeq lr |
546 | |
547 | PicoWriteS68k8_dec_m0b0: |
548 | mov r3, #0x080000 |
549 | b 0f |
550 | |
551 | PicoWriteS68k8_dec_m2b1: @ overwrite |
552 | ands r1, r1, #0x0f |
553 | bxeq lr |
554 | |
555 | PicoWriteS68k8_dec_m0b1: |
556 | mov r3, #0x0a0000 |
557 | 0: |
558 | m_s68k_write8_2M_decode |
48e8482f |
559 | ldrb r0, [r2, r0]! |
560 | and r1, r1, #0x0f |
561 | movcc r1, r1, lsl #4 |
562 | andcc r3, r0, #0x0f |
563 | andcs r3, r0, #0xf0 |
564 | orr r3, r3, r1 |
48e8482f |
565 | strneb r3, [r2] |
566 | bx lr |
48e8482f |
567 | |
0ace9b9a |
568 | PicoWriteS68k8_dec_m1b0: @ underwrite |
569 | mov r3, #0x080000 |
570 | b 0f |
571 | |
572 | PicoWriteS68k8_dec_m1b1: |
573 | mov r3, #0x0a0000 |
574 | 0: |
48e8482f |
575 | ands r1, r1, #0x0f |
576 | bxeq lr |
0ace9b9a |
577 | m_s68k_write8_2M_decode |
48e8482f |
578 | ldrb r0, [r2, r0]! |
579 | movcc r1, r1, lsl #4 |
580 | andcc r3, r0, #0x0f |
581 | andcs r3, r0, #0xf0 |
0ace9b9a |
582 | teq r3, r0 |
583 | bxne lr |
48e8482f |
584 | orr r3, r3, r1 |
48e8482f |
585 | strneb r3, [r2] |
586 | bx lr |
48e8482f |
587 | |
48e8482f |
588 | |
0ace9b9a |
589 | PicoWriteS68k8_pr: |
590 | and r2, r0, #0xfe00 |
591 | cmp r2, #0x8000 |
592 | bne m_s68k_write8_pcm |
48e8482f |
593 | |
0ace9b9a |
594 | m_s68k_write8_regs: |
4ff2d527 |
595 | bic r0, r0, #0xff0000 |
0ace9b9a |
596 | bic r0, r0, #0x008000 |
597 | tst r0, #0x7e00 |
598 | movne r0, #0 |
599 | bxne lr |
600 | sub r2, r0, #0x58 |
601 | cmp r2, #0x10 |
602 | bhs s68k_reg_write8 |
603 | bic r0, r0, #1 |
604 | orr r1, r1, r1, lsl #8 |
605 | b gfx_cd_write16 |
4ff2d527 |
606 | |
607 | |
608 | m_s68k_write8_pcm: |
0ace9b9a |
609 | tst r0, #0x8000 |
610 | bxne lr |
4ff2d527 |
611 | bic r0, r0, #0xff0000 |
612 | cmp r0, #0x12 |
613 | movlt r0, r0, lsr #1 |
614 | blt pcm_write |
615 | |
616 | cmp r0, #0x2000 |
617 | bxlt lr |
618 | |
619 | m_s68k_write8_pcm_ram: |
620 | ldr r3, =(Pico+0x22200) |
621 | bic r0, r0, #0x00e000 |
622 | ldr r3, [r3] |
623 | mov r0, r0, lsr #1 |
624 | add r2, r3, #0x110000 |
625 | add r2, r2, #0x002200 |
626 | add r2, r2, #0x000040 |
627 | ldr r2, [r2] |
628 | add r3, r3, #0x100000 @ pcm_ram |
629 | and r2, r2, #0x0f000000 @ bank |
630 | add r3, r3, r2, lsr #12 |
631 | strb r1, [r3, r0] |
632 | bx lr |
633 | |
634 | |
4ff2d527 |
635 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
636 | |
637 | |
0ace9b9a |
638 | .macro m_s68k_write16_2M_decode |
48e8482f |
639 | ldr r2, =(Pico+0x22200) |
640 | eor r0, r0, #2 |
641 | ldr r2, [r2] |
642 | mov r0, r0, lsr #1 @ +4-6 <<16 |
0ace9b9a |
643 | add r2, r2, r3 @ map to our address |
48e8482f |
644 | .endm |
645 | |
0ace9b9a |
646 | PicoWriteS68k16_dec_m0b0: |
647 | mov r3, #0x080000 |
648 | b 0f |
649 | |
650 | PicoWriteS68k16_dec_m0b1: |
651 | mov r3, #0x0a0000 |
652 | 0: |
653 | m_s68k_write16_2M_decode |
48e8482f |
654 | bic r1, r1, #0xf0 |
655 | orr r1, r1, r1, lsr #4 |
656 | strb r1, [r2, r0] |
657 | bx lr |
48e8482f |
658 | |
0ace9b9a |
659 | PicoWriteS68k16_dec_m1b0: @ underwrite |
660 | mov r3, #0x080000 |
661 | b 0f |
662 | |
663 | PicoWriteS68k16_dec_m1b1: |
664 | mov r3, #0x0a0000 |
665 | 0: |
48e8482f |
666 | bics r1, r1, #0xf000 |
667 | bicnes r1, r1, #0x00f0 |
668 | bxeq lr |
669 | orr r1, r1, r1, lsr #4 |
0ace9b9a |
670 | m_s68k_write16_2M_decode |
48e8482f |
671 | ldrb r0, [r2, r0]! |
672 | and r3, r1, #0x0f |
673 | and r1, r1, #0xf0 |
674 | tst r0, #0x0f |
675 | orreq r0, r0, r3 |
676 | tst r0, #0xf0 |
677 | orreq r0, r0, r1 |
678 | strb r0, [r2] |
679 | bx lr |
48e8482f |
680 | |
0ace9b9a |
681 | PicoWriteS68k16_dec_m2b0: @ overwrite |
682 | mov r3, #0x080000 |
683 | b 0f |
684 | |
685 | PicoWriteS68k16_dec_m2b1: |
686 | mov r3, #0x0a0000 |
687 | 0: |
48e8482f |
688 | bics r1, r1, #0xf000 |
689 | bicnes r1, r1, #0x00f0 |
690 | bxeq lr |
691 | orr r1, r1, r1, lsr #4 |
0ace9b9a |
692 | m_s68k_write16_2M_decode |
48e8482f |
693 | ldrb r0, [r2, r0]! |
694 | ands r3, r1, #0x0f |
695 | andne r0, r0, #0xf0 |
696 | orrne r0, r0, r3 |
697 | ands r1, r1, #0xf0 |
698 | andne r0, r0, #0x0f |
699 | orrne r0, r0, r1 |
700 | strb r0, [r2] |
701 | bx lr |
48e8482f |
702 | |
4ff2d527 |
703 | |
0ace9b9a |
704 | PicoWriteS68k16_pr: |
705 | and r2, r0, #0xfe00 |
706 | cmp r2, #0x8000 |
707 | bne m_s68k_write8_pcm |
4ff2d527 |
708 | |
709 | m_s68k_write16_regs: |
710 | bic r0, r0, #0xff0000 |
711 | bic r0, r0, #0x008000 |
5c69a605 |
712 | bic r0, r0, #1 |
4ff2d527 |
713 | tst r0, #0x7e00 |
714 | movne r0, #0 |
715 | bxne lr |
5c69a605 |
716 | cmp r0, #0x0e |
717 | beq m_s68k_write16_regs_spec |
4ff2d527 |
718 | sub r2, r0, #0x58 |
719 | cmp r2, #0x10 |
5c69a605 |
720 | blo gfx_cd_write16 |
4ff2d527 |
721 | and r3, r1, #0xff |
722 | add r2, r0, #1 |
4ff2d527 |
723 | stmfd sp!,{r2,r3,lr} |
724 | mov r1, r1, lsr #8 |
725 | bl s68k_reg_write8 |
726 | ldmfd sp!,{r0,r1,lr} |
727 | b s68k_reg_write8 |
728 | |
5c69a605 |
729 | m_s68k_write16_regs_spec: @ special case |
730 | ldr r2, =(Pico+0x22200) |
731 | mov r0, #0x110000 |
732 | ldr r2, [r2] |
733 | add r0, r0, #0x00000f |
734 | strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d; |
48e8482f |
735 | bx lr |
4ff2d527 |
736 | |
0ace9b9a |
737 | .pool |
6cadc2da |
738 | |
cff531af |
739 | @ vim:filetype=armasm |