From 5e128c6d279ac90f7b6078740ab1d0ba516969b9 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 22 Sep 2009 10:51:49 +0000 Subject: [PATCH] random cleanups git-svn-id: file:///home/notaz/opt/svn/PicoDrive@789 be3aeb3a-fb24-0410-a615-afba39da0efa --- pico/area.c | 10 +++------- pico/cd/area.c | 21 +++++++++------------ pico/pico.c | 28 ++++++++++++++++++++-------- pico/pico.h | 3 ++- pico/pico_cmn.c | 5 ++--- pico/pico_int.h | 7 ++++--- platform/common/emu.c | 1 + platform/common/menu.c | 4 ---- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/pico/area.c b/pico/area.c index e12b949..23e00da 100644 --- a/pico/area.c +++ b/pico/area.c @@ -16,7 +16,6 @@ // sn76496 extern int *sn76496_regs; - struct PicoArea { void *data; int len; char *name; }; // strange observation on Symbian OS 9.1, m600 organizer fw r3a06: @@ -175,7 +174,6 @@ static int PicoAreaScan(int is_write, unsigned int ver, void *PmovFile) // Save or load the state from PmovFile: static int PmovState(int is_write, void *PmovFile) { - int minimum=0; unsigned char head[32]; if ((PicoAHW & PAHW_MCD) || carthw_chunks != NULL) @@ -191,12 +189,10 @@ static int PmovState(int is_write, void *PmovFile) memset(head,0,sizeof(head)); - // Find out minimal compatible version: - minimum = 0x0021; - + // not really used.. memcpy(head,"Pico",4); - *(unsigned int *)(head+0x8)=PicoVer; - *(unsigned int *)(head+0xc)=minimum; + *(unsigned int *)(head+0x8)=0x0133; + *(unsigned int *)(head+0xc)=0x0021; // Scan header: if (is_write) diff --git a/pico/cd/area.c b/pico/cd/area.c index b43a4d9..645993b 100644 --- a/pico/cd/area.c +++ b/pico/cd/area.c @@ -100,9 +100,10 @@ PICO_INTERNAL int PicoCdSaveState(void *file) { unsigned char buff[0x60]; void *ym2612_regs = YM2612GetRegs(); + int ver = 0x0133; // not really used.. areaWrite("PicoSEXT", 1, 8, file); - areaWrite(&PicoVer, 1, 4, file); + areaWrite(&ver, 1, 4, file); memset(buff, 0, sizeof(buff)); PicoAreaPackCpu(buff, 0); @@ -114,17 +115,13 @@ PICO_INTERNAL int PicoCdSaveState(void *file) CHECKED_WRITE_BUFF(CHUNK_VSRAM, Pico.vsram); CHECKED_WRITE_BUFF(CHUNK_MISC, Pico.m); CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video); - if (PicoOpt&7) { - memset(buff, 0, sizeof(buff)); - z80_pack(buff); - CHECKED_WRITE_BUFF(CHUNK_Z80, buff); - } - if (PicoOpt&3) - CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs); - if (PicoOpt&1) { - ym2612_pack_state(); - CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs); - } + + memset(buff, 0, sizeof(buff)); + z80_pack(buff); + CHECKED_WRITE_BUFF(CHUNK_Z80, buff); + CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs); + ym2612_pack_state(); + CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs); if (PicoAHW & PAHW_MCD) { diff --git a/pico/pico.c b/pico/pico.c index 302cc69..c4b9031 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -10,17 +10,18 @@ #include "pico_int.h" #include "sound/ym2612.h" -int PicoVer=0x0133; struct Pico Pico; -int PicoOpt = 0; -int PicoSkipFrame = 0; // skip rendering frame? -int emustatus = 0; // rapid_ym2612, multi_ym_updates +int PicoOpt; +int PicoSkipFrame; // skip rendering frame? int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU int PicoPadInt[2]; // internal copy -int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active, pico_active -int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe -int PicoAutoRgnOrder = 0; -struct PicoSRAM SRam = {0,}; +int PicoAHW; // active addon hardware: PAHW_* +int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoAutoRgnOrder; + +struct PicoSRAM SRam; +int emustatus; // rapid_ym2612, multi_ym_updates +int scanlines_total; void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware void (*PicoResetHook)(void) = NULL; @@ -208,6 +209,17 @@ int PicoReset(void) return 0; } +// flush cinfig changes before emu loop starts +void PicoLoopPrepare(void) +{ + if (PicoRegionOverride) + // force setting possibly changed.. + Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; + + // FIXME: PAL has 313 scanlines.. + scanlines_total = Pico.m.pal ? 312 : 262; +} + // dma2vram settings are just hacks to unglitch Legend of Galahad (needs <= 104 to work) // same for Outrunners (92-121, when active is set to 24) diff --git a/pico/pico.h b/pico/pico.h index 2398ad1..f15915d 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -59,6 +59,7 @@ extern void emu_32x_startup(void); #define POPT_DIS_SPRITE_LIM (1<<18) #define POPT_DIS_IDLE_DET (1<<19) #define POPT_DIS_32X (1<<20) +#define POPT_DIS_PWM (1<<21) extern int PicoOpt; // bitfield #define PAHW_MCD (1<<0) @@ -67,7 +68,6 @@ extern int PicoOpt; // bitfield #define PAHW_PICO (1<<3) #define PAHW_SMS (1<<4) extern int PicoAHW; // Pico active hw -extern int PicoVer; extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP @@ -76,6 +76,7 @@ void PicoInit(void); void PicoExit(void); void PicoPower(void); int PicoReset(void); +void PicoLoopPrepare(void); void PicoFrame(void); void PicoFrameDrawOnly(void); extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index 212ed8d..d2801ed 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -221,9 +221,8 @@ static int PicoFrameHints(void) if (PicoLineHook) PicoLineHook(); #endif - // PAL line count might actually be 313 according to Steve Snake, but that would complicate things. - lines = Pico.m.pal ? 312 : 262; - vcnt_wrap = Pico.m.pal ? 0x103 : 0xEB; // based on Gens + lines = scanlines_total; + vcnt_wrap = Pico.m.pal ? 0x103 : 0xEB; // based on Gens, TODO: verify for (y++; y < lines; y++) { diff --git a/pico/pico_int.h b/pico/pico_int.h index 5b7f2f4..d28067b 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -404,11 +404,11 @@ typedef struct // 32X #define P32XS_FM (1<<15) #define P32XS2_ADEN (1<< 9) -#define P32XS_FULL (1<< 7) +#define P32XS_FULL (1<< 7) // DREQ FIFO full #define P32XS_68S (1<< 2) #define P32XS_RV (1<< 0) -#define P32XV_nPAL (1<<15) +#define P32XV_nPAL (1<<15) // VDP #define P32XV_PRI (1<< 7) #define P32XV_Mx (3<< 0) // display mode mask @@ -458,7 +458,7 @@ struct Pico32xMem unsigned char sh2_rom_m[0x800]; unsigned char sh2_rom_s[0x400]; unsigned short pal[0x100]; - unsigned short pal_native[0x100]; // converted to native (for renderer) + unsigned short pal_native[0x100]; // converted to native (for renderer) unsigned int sh2_peri_regs[2][0x200/4]; // periphereal regs of SH2s }; @@ -534,6 +534,7 @@ extern struct Pico Pico; extern struct PicoSRAM SRam; extern int PicoPadInt[2]; extern int emustatus; +extern int scanlines_total; extern void (*PicoResetHook)(void); extern void (*PicoLineHook)(void); PICO_INTERNAL int CheckDMA(void); diff --git a/platform/common/emu.c b/platform/common/emu.c index cc450d8..507437a 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1373,6 +1373,7 @@ void emu_loop(void) // prepare CD buffer if (PicoAHW & PAHW_MCD) PicoCDBufferInit(); + PicoLoopPrepare(); pemu_loop_prep(); diff --git a/platform/common/menu.c b/platform/common/menu.c index 8673784..4393ed5 100644 --- a/platform/common/menu.c +++ b/platform/common/menu.c @@ -1689,10 +1689,6 @@ static int menu_loop_options(menu_id id, int keys) me_loop(e_menu_options, &sel, NULL); - if (PicoRegionOverride) - // force setting possibly changed.. - Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; - return 0; } -- 2.39.2