| 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 | @* |
| 8 | |
| 9 | .equiv PCM_STEP_SHIFT, 11 |
| 10 | |
| 11 | .text |
| 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 |
| 49 | |
| 50 | @ externs, just for reference |
| 51 | .extern Pico |
| 52 | .extern Read_CDC_Host |
| 53 | .extern m68k_reg_write8 |
| 54 | .extern s68k_reg_read16 |
| 55 | .extern s68k_reg_write8 |
| 56 | .extern s68k_poll_adclk |
| 57 | .extern s68k_poll_detect |
| 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 |
| 65 | |
| 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 | |
| 113 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 114 | |
| 115 | |
| 116 | m_read_null: |
| 117 | mov r0, #0 |
| 118 | bx lr |
| 119 | |
| 120 | |
| 121 | PicoReadM68k8_cell0: @ 0x220000 - 0x23ffff, cell arranged |
| 122 | mov r3, #0x0c0000 |
| 123 | b 0f |
| 124 | |
| 125 | PicoReadM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged |
| 126 | mov r3, #0x0e0000 |
| 127 | 0: |
| 128 | cell_map |
| 129 | ldr r1, =(Pico+0x22200) |
| 130 | add r0, r0, r3 |
| 131 | ldr r1, [r1] |
| 132 | eor r0, r0, #1 |
| 133 | ldrb r0, [r1, r0] |
| 134 | bx lr |
| 135 | |
| 136 | |
| 137 | PicoReadM68k8_io: |
| 138 | and r1, r0, #0xff00 |
| 139 | cmp r1, #0x2000 @ a120xx? |
| 140 | bne PicoRead8_io |
| 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 |
| 164 | ldr r0, [r1, #0x30] |
| 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] |
| 180 | add r1, r1, #0x002200 |
| 181 | ldr r1, [r1, #4] |
| 182 | and r0, r0, #0xc7 |
| 183 | tst r1, #2 @ DMNA pending? |
| 184 | bxeq lr |
| 185 | bic r0, r0, #1 |
| 186 | orr r0, r0, #2 |
| 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 | push {r0,r1,lr} |
| 220 | bl m68k_comm_check |
| 221 | pop {r0,r1,lr} |
| 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 | |
| 229 | |
| 230 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 231 | |
| 232 | |
| 233 | PicoReadM68k16_cell0: @ 0x220000 - 0x23ffff, cell arranged |
| 234 | mov r3, #0x0c0000 |
| 235 | b 0f |
| 236 | |
| 237 | PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged |
| 238 | mov r3, #0x0e0000 |
| 239 | 0: |
| 240 | cell_map |
| 241 | ldr r1, =(Pico+0x22200) |
| 242 | add r0, r0, r3 |
| 243 | ldr r1, [r1] |
| 244 | bic r0, r0, #1 |
| 245 | ldrh r0, [r1, r0] |
| 246 | bx lr |
| 247 | |
| 248 | |
| 249 | PicoReadM68k16_io: |
| 250 | and r1, r0, #0xff00 |
| 251 | cmp r1, #0x2000 @ a120xx |
| 252 | bne PicoRead16_io |
| 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 |
| 270 | ldr r0, [r1, #0x30] |
| 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] |
| 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 |
| 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 | |
| 318 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 319 | |
| 320 | |
| 321 | PicoWriteM68k8_cell0: @ 0x220000 - 0x23ffff, cell arranged |
| 322 | mov r12,#0x0c0000 |
| 323 | b 0f |
| 324 | |
| 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] |
| 335 | bx lr |
| 336 | |
| 337 | |
| 338 | PicoWriteM68k8_io: |
| 339 | and r2, r0, #0xff00 |
| 340 | cmp r2, #0x2000 @ a120xx? |
| 341 | beq m68k_reg_write8 |
| 342 | b PicoWrite8_io |
| 343 | |
| 344 | |
| 345 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 346 | |
| 347 | |
| 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 |
| 357 | ldr r1, =(Pico+0x22200) |
| 358 | add r0, r0, r12 |
| 359 | ldr r1, [r1] |
| 360 | bic r0, r0, #1 |
| 361 | strh r3, [r1, r0] |
| 362 | bx lr |
| 363 | |
| 364 | |
| 365 | PicoWriteM68k16_io: |
| 366 | and r2, r0, #0xff00 |
| 367 | cmp r2, #0x2000 @ a120xx? |
| 368 | bne PicoWrite16_io |
| 369 | |
| 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 |
| 381 | |
| 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] |
| 398 | bx lr |
| 399 | |
| 400 | |
| 401 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 402 | @ Sub 68k |
| 403 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 404 | |
| 405 | |
| 406 | PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff |
| 407 | mov r3, #0x080000 @ + ^ / 2 |
| 408 | b 0f |
| 409 | |
| 410 | PicoReadS68k8_dec1: |
| 411 | mov r3, #0x0a0000 @ + ^ / 2 |
| 412 | 0: |
| 413 | ldr r2, =(Pico+0x22200) |
| 414 | eor r0, r0, #2 |
| 415 | ldr r2, [r2] |
| 416 | movs r0, r0, lsr #1 @ +4-6 <<16 |
| 417 | add r2, r2, r3 @ map to our address |
| 418 | ldrb r0, [r2, r0] |
| 419 | movcc r0, r0, lsr #4 |
| 420 | andcs r0, r0, #0xf |
| 421 | bx lr |
| 422 | |
| 423 | |
| 424 | PicoReadS68k8_pr: |
| 425 | and r2, r0, #0xfe00 |
| 426 | cmp r2, #0x8000 |
| 427 | bne m_s68k_read8_pcm |
| 428 | |
| 429 | m_s68k_read8_regs: |
| 430 | bic r0, r0, #0xff0000 |
| 431 | bic r0, r0, #0x008000 |
| 432 | sub r2, r0, #0x0e |
| 433 | cmp r2, #(0x30-0x0e) |
| 434 | blo m_s68k_read8_comm |
| 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 | |
| 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 | |
| 456 | |
| 457 | m_s68k_read8_pcm: |
| 458 | tst r0, #0x8000 |
| 459 | bne m_read_null |
| 460 | |
| 461 | @ must not trash r3 and r12 |
| 462 | ldr r1, =(Pico+0x22200) |
| 463 | bic r0, r0, #0xff0000 |
| 464 | @ bic r0, r0, #0x008000 |
| 465 | ldr r1, [r1] |
| 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 |
| 481 | bx lr |
| 482 | |
| 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 |
| 493 | |
| 494 | |
| 495 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 496 | |
| 497 | |
| 498 | PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff |
| 499 | mov r3, #0x080000 @ + ^ / 2 |
| 500 | b 0f |
| 501 | |
| 502 | PicoReadS68k16_dec1: |
| 503 | mov r3, #0x0a0000 @ + ^ / 2 |
| 504 | 0: |
| 505 | ldr r2, =(Pico+0x22200) |
| 506 | eor r0, r0, #2 |
| 507 | ldr r2, [r2] |
| 508 | mov r0, r0, lsr #1 @ +4-6 <<16 |
| 509 | add r2, r2, r3 @ map to our address |
| 510 | ldrb r0, [r2, r0] |
| 511 | orr r0, r0, r0, lsl #4 |
| 512 | bic r0, r0, #0xf0 |
| 513 | bx lr |
| 514 | |
| 515 | |
| 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 |
| 521 | |
| 522 | m_s68k_read16_regs: |
| 523 | bic r0, r0, #0xff0000 |
| 524 | bic r0, r0, #0x008000 |
| 525 | bic r0, r0, #0x000001 |
| 526 | sub r2, r0, #0x58 |
| 527 | cmp r2, #0x10 |
| 528 | blo gfx_cd_read |
| 529 | cmp r0, #8 |
| 530 | bne s68k_reg_read16 |
| 531 | mov r0, #1 |
| 532 | b Read_CDC_Host |
| 533 | |
| 534 | |
| 535 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 536 | |
| 537 | |
| 538 | .macro m_s68k_write8_2M_decode |
| 539 | ldr r2, =(Pico+0x22200) |
| 540 | eor r0, r0, #2 |
| 541 | ldr r2, [r2] @ Pico.rom |
| 542 | movs r0, r0, lsr #1 @ +4-6 <<16 |
| 543 | add r2, r2, r3 @ map to our address |
| 544 | .endm |
| 545 | |
| 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 |
| 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 |
| 568 | strneb r3, [r2] |
| 569 | bx lr |
| 570 | |
| 571 | PicoWriteS68k8_dec_m1b0: @ underwrite |
| 572 | mov r3, #0x080000 |
| 573 | b 0f |
| 574 | |
| 575 | PicoWriteS68k8_dec_m1b1: |
| 576 | mov r3, #0x0a0000 |
| 577 | 0: |
| 578 | ands r1, r1, #0x0f |
| 579 | bxeq lr |
| 580 | m_s68k_write8_2M_decode |
| 581 | ldrb r0, [r2, r0]! |
| 582 | movcc r1, r1, lsl #4 |
| 583 | andcc r3, r0, #0x0f |
| 584 | andcs r3, r0, #0xf0 |
| 585 | teq r3, r0 |
| 586 | bxne lr |
| 587 | orr r3, r3, r1 |
| 588 | strneb r3, [r2] |
| 589 | bx lr |
| 590 | |
| 591 | |
| 592 | PicoWriteS68k8_pr: |
| 593 | and r2, r0, #0xfe00 |
| 594 | cmp r2, #0x8000 |
| 595 | bne m_s68k_write8_pcm |
| 596 | |
| 597 | m_s68k_write8_regs: |
| 598 | bic r0, r0, #0xff0000 |
| 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 |
| 609 | |
| 610 | |
| 611 | m_s68k_write8_pcm: |
| 612 | tst r0, #0x8000 |
| 613 | bxne lr |
| 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 | |
| 638 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 639 | |
| 640 | |
| 641 | .macro m_s68k_write16_2M_decode |
| 642 | ldr r2, =(Pico+0x22200) |
| 643 | eor r0, r0, #2 |
| 644 | ldr r2, [r2] |
| 645 | mov r0, r0, lsr #1 @ +4-6 <<16 |
| 646 | add r2, r2, r3 @ map to our address |
| 647 | .endm |
| 648 | |
| 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 |
| 657 | bic r1, r1, #0xf0 |
| 658 | orr r1, r1, r1, lsr #4 |
| 659 | strb r1, [r2, r0] |
| 660 | bx lr |
| 661 | |
| 662 | PicoWriteS68k16_dec_m1b0: @ underwrite |
| 663 | mov r3, #0x080000 |
| 664 | b 0f |
| 665 | |
| 666 | PicoWriteS68k16_dec_m1b1: |
| 667 | mov r3, #0x0a0000 |
| 668 | 0: |
| 669 | bics r1, r1, #0xf000 |
| 670 | bicnes r1, r1, #0x00f0 |
| 671 | bxeq lr |
| 672 | orr r1, r1, r1, lsr #4 |
| 673 | m_s68k_write16_2M_decode |
| 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 |
| 683 | |
| 684 | PicoWriteS68k16_dec_m2b0: @ overwrite |
| 685 | mov r3, #0x080000 |
| 686 | b 0f |
| 687 | |
| 688 | PicoWriteS68k16_dec_m2b1: |
| 689 | mov r3, #0x0a0000 |
| 690 | 0: |
| 691 | bics r1, r1, #0xf000 |
| 692 | bicnes r1, r1, #0x00f0 |
| 693 | bxeq lr |
| 694 | orr r1, r1, r1, lsr #4 |
| 695 | m_s68k_write16_2M_decode |
| 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 |
| 705 | |
| 706 | |
| 707 | PicoWriteS68k16_pr: |
| 708 | and r2, r0, #0xfe00 |
| 709 | cmp r2, #0x8000 |
| 710 | bne m_s68k_write8_pcm |
| 711 | |
| 712 | m_s68k_write16_regs: |
| 713 | bic r0, r0, #0xff0000 |
| 714 | bic r0, r0, #0x008000 |
| 715 | bic r0, r0, #1 |
| 716 | tst r0, #0x7e00 |
| 717 | movne r0, #0 |
| 718 | bxne lr |
| 719 | cmp r0, #0x0e |
| 720 | beq m_s68k_write16_regs_spec |
| 721 | sub r2, r0, #0x58 |
| 722 | cmp r2, #0x10 |
| 723 | blo gfx_cd_write16 |
| 724 | and r3, r1, #0xff |
| 725 | add r2, r0, #1 |
| 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 | |
| 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; |
| 738 | bx lr |
| 739 | |
| 740 | .pool |
| 741 | |
| 742 | @ vim:filetype=armasm |