random cleanups

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@789 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-09-22 10:51:49 +00:00
parent 94d2199eb1
commit 5e128c6d27
8 changed files with 41 additions and 38 deletions

View file

@ -16,7 +16,6 @@
// sn76496 // sn76496
extern int *sn76496_regs; extern int *sn76496_regs;
struct PicoArea { void *data; int len; char *name; }; struct PicoArea { void *data; int len; char *name; };
// strange observation on Symbian OS 9.1, m600 organizer fw r3a06: // 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: // Save or load the state from PmovFile:
static int PmovState(int is_write, void *PmovFile) static int PmovState(int is_write, void *PmovFile)
{ {
int minimum=0;
unsigned char head[32]; unsigned char head[32];
if ((PicoAHW & PAHW_MCD) || carthw_chunks != NULL) if ((PicoAHW & PAHW_MCD) || carthw_chunks != NULL)
@ -191,12 +189,10 @@ static int PmovState(int is_write, void *PmovFile)
memset(head,0,sizeof(head)); memset(head,0,sizeof(head));
// Find out minimal compatible version: // not really used..
minimum = 0x0021;
memcpy(head,"Pico",4); memcpy(head,"Pico",4);
*(unsigned int *)(head+0x8)=PicoVer; *(unsigned int *)(head+0x8)=0x0133;
*(unsigned int *)(head+0xc)=minimum; *(unsigned int *)(head+0xc)=0x0021;
// Scan header: // Scan header:
if (is_write) if (is_write)

View file

@ -100,9 +100,10 @@ PICO_INTERNAL int PicoCdSaveState(void *file)
{ {
unsigned char buff[0x60]; unsigned char buff[0x60];
void *ym2612_regs = YM2612GetRegs(); void *ym2612_regs = YM2612GetRegs();
int ver = 0x0133; // not really used..
areaWrite("PicoSEXT", 1, 8, file); areaWrite("PicoSEXT", 1, 8, file);
areaWrite(&PicoVer, 1, 4, file); areaWrite(&ver, 1, 4, file);
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));
PicoAreaPackCpu(buff, 0); PicoAreaPackCpu(buff, 0);
@ -114,17 +115,13 @@ PICO_INTERNAL int PicoCdSaveState(void *file)
CHECKED_WRITE_BUFF(CHUNK_VSRAM, Pico.vsram); CHECKED_WRITE_BUFF(CHUNK_VSRAM, Pico.vsram);
CHECKED_WRITE_BUFF(CHUNK_MISC, Pico.m); CHECKED_WRITE_BUFF(CHUNK_MISC, Pico.m);
CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video); CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video);
if (PicoOpt&7) {
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));
z80_pack(buff); z80_pack(buff);
CHECKED_WRITE_BUFF(CHUNK_Z80, buff); CHECKED_WRITE_BUFF(CHUNK_Z80, buff);
}
if (PicoOpt&3)
CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs); CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs);
if (PicoOpt&1) {
ym2612_pack_state(); ym2612_pack_state();
CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs); CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);
}
if (PicoAHW & PAHW_MCD) if (PicoAHW & PAHW_MCD)
{ {

View file

@ -10,17 +10,18 @@
#include "pico_int.h" #include "pico_int.h"
#include "sound/ym2612.h" #include "sound/ym2612.h"
int PicoVer=0x0133;
struct Pico Pico; struct Pico Pico;
int PicoOpt = 0; int PicoOpt;
int PicoSkipFrame = 0; // skip rendering frame? int PicoSkipFrame; // skip rendering frame?
int emustatus = 0; // rapid_ym2612, multi_ym_updates
int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
int PicoPadInt[2]; // internal copy int PicoPadInt[2]; // internal copy
int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active, pico_active int PicoAHW; // active addon hardware: PAHW_*
int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
int PicoAutoRgnOrder = 0; int PicoAutoRgnOrder;
struct PicoSRAM SRam = {0,};
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 (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware
void (*PicoResetHook)(void) = NULL; void (*PicoResetHook)(void) = NULL;
@ -208,6 +209,17 @@ int PicoReset(void)
return 0; 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) // 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) // same for Outrunners (92-121, when active is set to 24)

View file

@ -59,6 +59,7 @@ extern void emu_32x_startup(void);
#define POPT_DIS_SPRITE_LIM (1<<18) #define POPT_DIS_SPRITE_LIM (1<<18)
#define POPT_DIS_IDLE_DET (1<<19) #define POPT_DIS_IDLE_DET (1<<19)
#define POPT_DIS_32X (1<<20) #define POPT_DIS_32X (1<<20)
#define POPT_DIS_PWM (1<<21)
extern int PicoOpt; // bitfield extern int PicoOpt; // bitfield
#define PAHW_MCD (1<<0) #define PAHW_MCD (1<<0)
@ -67,7 +68,6 @@ extern int PicoOpt; // bitfield
#define PAHW_PICO (1<<3) #define PAHW_PICO (1<<3)
#define PAHW_SMS (1<<4) #define PAHW_SMS (1<<4)
extern int PicoAHW; // Pico active hw 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 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 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 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 PicoExit(void);
void PicoPower(void); void PicoPower(void);
int PicoReset(void); int PicoReset(void);
void PicoLoopPrepare(void);
void PicoFrame(void); void PicoFrame(void);
void PicoFrameDrawOnly(void); void PicoFrameDrawOnly(void);
extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU

View file

@ -221,9 +221,8 @@ static int PicoFrameHints(void)
if (PicoLineHook) PicoLineHook(); if (PicoLineHook) PicoLineHook();
#endif #endif
// PAL line count might actually be 313 according to Steve Snake, but that would complicate things. lines = scanlines_total;
lines = Pico.m.pal ? 312 : 262; vcnt_wrap = Pico.m.pal ? 0x103 : 0xEB; // based on Gens, TODO: verify
vcnt_wrap = Pico.m.pal ? 0x103 : 0xEB; // based on Gens
for (y++; y < lines; y++) for (y++; y < lines; y++)
{ {

View file

@ -404,11 +404,11 @@ typedef struct
// 32X // 32X
#define P32XS_FM (1<<15) #define P32XS_FM (1<<15)
#define P32XS2_ADEN (1<< 9) #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_68S (1<< 2)
#define P32XS_RV (1<< 0) #define P32XS_RV (1<< 0)
#define P32XV_nPAL (1<<15) #define P32XV_nPAL (1<<15) // VDP
#define P32XV_PRI (1<< 7) #define P32XV_PRI (1<< 7)
#define P32XV_Mx (3<< 0) // display mode mask #define P32XV_Mx (3<< 0) // display mode mask
@ -534,6 +534,7 @@ extern struct Pico Pico;
extern struct PicoSRAM SRam; extern struct PicoSRAM SRam;
extern int PicoPadInt[2]; extern int PicoPadInt[2];
extern int emustatus; extern int emustatus;
extern int scanlines_total;
extern void (*PicoResetHook)(void); extern void (*PicoResetHook)(void);
extern void (*PicoLineHook)(void); extern void (*PicoLineHook)(void);
PICO_INTERNAL int CheckDMA(void); PICO_INTERNAL int CheckDMA(void);

View file

@ -1373,6 +1373,7 @@ void emu_loop(void)
// prepare CD buffer // prepare CD buffer
if (PicoAHW & PAHW_MCD) if (PicoAHW & PAHW_MCD)
PicoCDBufferInit(); PicoCDBufferInit();
PicoLoopPrepare();
pemu_loop_prep(); pemu_loop_prep();

View file

@ -1689,10 +1689,6 @@ static int menu_loop_options(menu_id id, int keys)
me_loop(e_menu_options, &sel, NULL); me_loop(e_menu_options, &sel, NULL);
if (PicoRegionOverride)
// force setting possibly changed..
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;
return 0; return 0;
} }