From f27a1749fe8f4b98a8edc62f05dbbc99a730a643 Mon Sep 17 00:00:00 2001 From: kub Date: Fri, 26 May 2023 20:45:13 +0000 Subject: [PATCH] mcd, preparations for msu support (arm version) --- pico/cd/memory.c | 23 +++++++++++++---------- pico/cd/memory_arm.S | 27 ++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pico/cd/memory.c b/pico/cd/memory.c index ba3ee398..87bbc252 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -95,6 +95,14 @@ void m68k_comm_check(u32 a) } } +u32 pcd_stopwatch_read(int sub) +{ + // ugh.. + u32 d = sub ? SekCyclesDoneS68k() : pcd_cycles_m68k_to_s68k(SekCyclesDone()); + d = (d - Pico_mcd->m.stopwatch_base_c) / 384; + return d & 0x0fff; +} + #ifndef _ASM_CD_MEMORY_C static u32 m68k_reg_read16(u32 a) { @@ -121,14 +129,11 @@ static u32 m68k_reg_read16(u32 a) case 8: d = cdc_host_r(); goto end; - case 0xA: + case 0xa: elprintf(EL_UIO, "m68k FIXME: reserved read"); goto end; - case 0xC: // 384 cycle stopwatch timer - // ugh.. - d = pcd_cycles_m68k_to_s68k(SekCyclesDone()); - d = (d - Pico_mcd->m.stopwatch_base_c) / 384; - d &= 0x0fff; + case 0xc: // 384 cycle stopwatch timer + d = pcd_stopwatch_read(0); elprintf(EL_CDREGS, "m68k stopwatch timer read (%04x)", d); goto end; } @@ -331,10 +336,8 @@ u32 s68k_reg_read16(u32 a) case 8: d = cdc_host_r(); goto end; - case 0xC: - d = SekCyclesDoneS68k() - Pico_mcd->m.stopwatch_base_c; - d /= 384; - d &= 0x0fff; + case 0xc: + d = pcd_stopwatch_read(1); elprintf(EL_CDREGS, "s68k stopwatch timer read (%04x)", d); goto end; case 0x30: diff --git a/pico/cd/memory_arm.S b/pico/cd/memory_arm.S index f601d47c..68bd48b8 100644 --- a/pico/cd/memory_arm.S +++ b/pico/cd/memory_arm.S @@ -195,6 +195,8 @@ m_m68k_read8_r06: ldrb r0, [r1, #0x73] @ IRQ vector bx lr m_m68k_read8_r07: + PIC_LDR(r1, r2, Pico) + ldr r1, [r1, #OFS_Pico_rom] ldrb r0, [r1, #0x72] bx lr m_m68k_read8_r08: @@ -206,17 +208,13 @@ m_m68k_read8_r09: mov r0, #0 b cdc_host_r m_m68k_read8_r0c: - add r1, r1, #0x110000 - add r1, r1, #0x002200 - ldr r0, [r1, #0x14] @ Pico_mcd->m.timer_stopwatch - mov r0, r0, lsr #24 + mov r1, #0 + bl pcd_stopwatch_read + mov r0, r0, lsr #8 bx lr m_m68k_read8_r0d: - add r1, r1, #0x110000 - add r1, r1, #0x002200 - ldr r0, [r1, #0x14] - mov r0, r0, lsr #16 - bx lr + mov r1, #0 + b pcd_stopwatch_read m_m68k_read8_hi: cmp r0, #0x30 add r1, r1, #0x110000 @@ -258,7 +256,7 @@ PicoRead16_mcd_io: m_m68k_read16_m68k_regs: PIC_LDR(r1, r2, Pico_mcd) and r0, r0, #0x3e - ldr r1, [r1, @ Pico.mcd + ldr r1, [r1] @ Pico.mcd cmp r0, #0x0e PIC_XB(lt ,r0, lsl #1) b m_m68k_read16_hi @@ -293,17 +291,16 @@ m_m68k_read16_r04: mov r0, r0, lsl #8 bx lr m_m68k_read16_r06: + PIC_LDR(r1, r2, Pico) + ldr r1, [r1, #OFS_Pico_rom] ldrh r0, [r1, #0x72] @ IRQ vector bx lr m_m68k_read16_r08: mov r0, #0 b cdc_host_r m_m68k_read16_r0c: - add r1, r1, #0x110000 - add r1, r1, #0x002200 - ldr r0, [r1, #0x14] - mov r0, r0, lsr #16 - bx lr + mov r1, #0 + b pcd_stopwatch_read m_m68k_read16_hi: cmp r0, #0x30 add r1, r1, #0x110000 -- 2.39.5