From 00bd648e6308fbcfe759a56dc24c11435d358ec4 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 22 Mar 2007 23:14:43 +0000 Subject: [PATCH] gfx_cd finished, bugfixes git-svn-id: file:///home/notaz/opt/svn/PicoDrive@76 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/cd/Area.c | 3 +- Pico/cd/Memory.s | 15 ++++++---- Pico/cd/Pico.c | 2 +- Pico/cd/gfx_cd.c | 67 ++++++++++++++++++++++++------------------ platform/gp2x/940ctl.c | 2 ++ platform/gp2x/emu.c | 5 ++-- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/Pico/cd/Area.c b/Pico/cd/Area.c index baf501f..5040748 100644 --- a/Pico/cd/Area.c +++ b/Pico/cd/Area.c @@ -245,7 +245,8 @@ int PicoCdLoadState(void *file) wram_2M_to_1M(Pico_mcd->word_ram2M); #ifdef _ASM_CD_MEMORY_C PicoMemResetCD(Pico_mcd->s68k_regs[3]); - PicoMemResetCDdecode(Pico_mcd->s68k_regs[3]); + if (Pico_mcd->s68k_regs[3]&4) + PicoMemResetCDdecode(Pico_mcd->s68k_regs[3]); #endif if (Pico_mcd->m.audio_track > 0 && Pico_mcd->m.audio_track < Pico_mcd->TOC.Last_Track) mp3_start_play(Pico_mcd->TOC.Tracks[Pico_mcd->m.audio_track].F, Pico_mcd->m.audio_offset); diff --git a/Pico/cd/Memory.s b/Pico/cd/Memory.s index 80f628a..6bdf3e5 100644 --- a/Pico/cd/Memory.s +++ b/Pico/cd/Memory.s @@ -199,6 +199,8 @@ PicoMemResetCD: @ r3 PicoMemResetCDdecode: @r3 + tst r3, #4 + bxeq lr @ we should not be called in 2M mode ldr r1, =m_s68k_write8_table ldr r3, =m_s68k_decode_write_table and r2, r0, #0x18 @@ -336,7 +338,7 @@ PicoWriteS68k32: @ u32 a, u32 d .endm -@ r0=prt1, r1=ptr2 +@ r0=prt1, r1=ptr2; unaligned ptr MUST be r0 .macro m_read32_gen tst r0, #2 ldrneh r0, [r1, r0]! @@ -347,7 +349,7 @@ PicoWriteS68k32: @ u32 a, u32 d .endm -@ r0=prt1, r1=data, r2=ptr2 +@ r0=prt1, r1=data, r2=ptr2; unaligned ptr MUST be r0 .macro m_write32_gen tst r0, #2 mov r1, r1, ror #16 @@ -468,7 +470,7 @@ m_m68k_read8_system_io: .long m_m68k_read8_r0d m_m68k_read8_r00: add r1, r1, #0x110000 - ldr r0, [r1, #30] + ldr r0, [r1, #0x30] and r0, r0, #0x04000000 @ we need irq2 mask state mov r0, r0, lsr #19 bx lr @@ -842,11 +844,12 @@ m_m68k_read32_system_io: movge r0, #0 bxge lr @ I have seen the range 0x0e-0x2f accessed quite frequently with long i/o, so here is some code for that - ldr r0, =(Pico+0x22200) + mov r0, r1 + ldr r1, =(Pico+0x22200) mov r2, #0xff - ldr r0, [r0] + ldr r1, [r1] orr r2, r2, r2, lsl #16 - add r0, r0, #0x110000 + add r1, r1, #0x110000 m_read32_gen and r1, r2, r0 @ data is big-endian read as little, have to byteswap and r0, r2, r0, lsr #8 diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index a7c3b95..acfe5e8 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -51,7 +51,7 @@ int PicoResetMCD(int hard) gfx_cd_reset(); #ifdef _ASM_CD_MEMORY_C PicoMemResetCD(1); - PicoMemResetCDdecode(1); + //PicoMemResetCDdecode(1); // don't have to call this in 2M mode #endif return 0; diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c index 23deb4e..db2a406 100644 --- a/Pico/cd/gfx_cd.c +++ b/Pico/cd/gfx_cd.c @@ -79,18 +79,14 @@ static void gfx_completed(void) } -static void gfx_do(void) +static void gfx_do(unsigned int func, unsigned short *stamp_base, unsigned int H_Dot) { unsigned int eax, ebx, ecx, edx, esi, edi, pixel; - unsigned int XD, Buffer_Adr, H_Dot; - unsigned int func = rot_comp.Function; - unsigned short *stamp_base; + unsigned int XD, Buffer_Adr; int DYXS; XD = rot_comp.Reg_60 & 7; Buffer_Adr = ((rot_comp.Reg_5E & 0xfff8) + rot_comp.YD) << 2; - stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + rot_comp.Stamp_Map_Adr); - H_Dot = rot_comp.Reg_62 & 0x1ff; ecx = *(unsigned int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr); edx = ecx >> 16; ecx = (ecx & 0xffff) << 8; @@ -105,29 +101,28 @@ static void gfx_do(void) { if (func & 4) // 16x16 screen { - eax = (ecx >> (11+5)) & 0x007f; - ebx = (edx >> (11-2)) & 0x3f80; + ebx = ((ecx >> (11+5)) & 0x007f) | + ((edx >> (11-2)) & 0x3f80); } else // 1x1 screen { - eax = (ecx >> (11+5)) & 0x07; - ebx = (edx >> (11+2)) & 0x38; + ebx = ((ecx >> (11+5)) & 0x07) | + ((edx >> (11+2)) & 0x38); } } else // mode 16x16 dot { if (func & 4) // 16x16 screen { - eax = (ecx >> (11+4)) & 0x00ff; - ebx = (edx >> (11-4)) & 0xff00; + ebx = ((ecx >> (11+4)) & 0x00ff) | + ((edx >> (11-4)) & 0xff00); } else // 1x1 screen { - eax = (ecx >> (11+4)) & 0x0f; - ebx = (edx >> (11+0)) & 0xf0; + ebx = ((ecx >> (11+4)) & 0x0f) | + ((edx >> (11+0)) & 0xf0); } } - ebx += eax; // MAKE_IMAGE_PIXEL if (!(func & 1)) // NOT TILED @@ -141,12 +136,10 @@ static void gfx_do(void) } } - // esi = rot_comp.Stamp_Map_Adr; - edi = stamp_base[ebx] | (stamp_base[ebx+1] << 16); - esi = edi; - edi >>= (11+1); - esi = (esi & 0x7ff) << 7; + edi = stamp_base[ebx];// | (stamp_base[ebx+1] << 16); + esi = (edi & 0x7ff) << 7; if (!esi) { pixel = 0; goto Pixel_Out; } + edi >>= (11+1); edi &= (0x1c>>1); eax = ecx; ebx = edx; @@ -285,7 +278,7 @@ Next_Pixel: // end while -//nothing_to_draw: +// nothing_to_draw: rot_comp.YD++; // rot_comp.V_Dot--; // will be done by caller } @@ -293,12 +286,12 @@ Next_Pixel: void gfx_cd_update(void) { - unsigned char *V_Dot = (unsigned char *) &rot_comp.Reg_64; + int V_Dot = rot_comp.Reg_64 & 0xff; int jobs; dprintf("gfx_cd_update, Reg_64 = %04x", rot_comp.Reg_64); - if (!*V_Dot) + if (!V_Dot) { gfx_completed(); return; @@ -315,20 +308,36 @@ void gfx_cd_update(void) rot_comp.Float_Part &= 0xffff; rot_comp.Float_Part += rot_comp.Draw_Speed; - while (jobs--) + if (PicoOpt & 0x1000) // scale/rot enabled { - if (PicoOpt & 0x1000) - gfx_do(); // jmp [Jmp_Adr]: + unsigned int func = rot_comp.Function; + unsigned int H_Dot = rot_comp.Reg_62 & 0x1ff; + unsigned short *stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + rot_comp.Stamp_Map_Adr); - (*V_Dot)--; // dec byte [V_Dot] + while (jobs--) + { + gfx_do(func, stamp_base, H_Dot); // jmp [Jmp_Adr]: - if (!*V_Dot) + V_Dot--; // dec byte [V_Dot] + if (V_Dot == 0) + { + // GFX_Completed: + gfx_completed(); + return; + } + } + } + else + { + if (jobs >= V_Dot) { - // GFX_Completed: gfx_completed(); return; } + V_Dot -= jobs; } + + rot_comp.Reg_64 = V_Dot; } diff --git a/platform/gp2x/940ctl.c b/platform/gp2x/940ctl.c index b035591..bcbb09b 100644 --- a/platform/gp2x/940ctl.c +++ b/platform/gp2x/940ctl.c @@ -20,6 +20,7 @@ extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */ extern volatile unsigned long *gp2x_memregl; +extern int reset_timing; static unsigned char *shared_mem = 0; static _940_data_t *shared_data = 0; _940_ctl_t *shared_ctl = 0; @@ -589,6 +590,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 if (CHECK_BUSY(JOB940_MP3DECODE)) wait_busy_940(JOB940_MP3DECODE); add_job_940(JOB940_INVALIDATE_DCACHE); } + reset_timing = 1; } // seek.. diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 7c63cdb..60907ff 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -54,13 +54,14 @@ extern int crashed_940; static short sndBuffer[2*44100/50]; static char noticeMsg[64]; // notice msg to draw static struct timeval noticeMsgTime = { 0, 0 }; // when started showing -static int reset_timing, osd_fps_x; +static int osd_fps_x; static int combo_keys = 0, combo_acts = 0; // keys and actions which need button combos static int gp2x_old_gamma = 100; static unsigned char *movie_data = NULL; static int movie_size = 0; unsigned char *framebuff = 0; // temporary buffer for alt renderer int state_slot = 0; +int reset_timing = 0; /* // tmp @@ -1191,7 +1192,7 @@ void emu_Loop(void) continue; } updateKeys(); - SkipFrame(tval.tv_usec < lim_time+target_frametime); frames_done++; + SkipFrame(tval.tv_usec < lim_time+target_frametime*2); frames_done++; continue; } -- 2.39.2