rearrange globals

scripted find/replace
gives slightly better code on ARM, less unnecessary asm,
~400 bytes saved
This commit is contained in:
notaz 2017-10-19 02:38:20 +03:00
parent 759c9d3846
commit 93f9619ed8
47 changed files with 532 additions and 573 deletions

View file

@ -99,7 +99,7 @@ void Pico32xStartup(void)
elprintf(EL_STATUS|EL_32X, "32X startup");
// TODO: OOM handling
PicoAHW |= PAHW_32X;
PicoIn.AHW |= PAHW_32X;
sh2_init(&msh2, 0, &ssh2);
msh2.irq_callback = sh2_irq_cb;
sh2_init(&ssh2, 1, &msh2);
@ -136,7 +136,7 @@ void p32x_reset_sh2s(void)
if (p32x_bios_m == NULL) {
sh2_set_gbr(0, 0x20004000);
if (!(PicoAHW & PAHW_MCD)) {
if (!(PicoIn.AHW & PAHW_MCD)) {
unsigned int idl_src, idl_dst, idl_size; // initial data load
unsigned int vbr;
@ -200,12 +200,12 @@ void PicoUnload32x(void)
sh2_finish(&msh2);
sh2_finish(&ssh2);
PicoAHW &= ~PAHW_32X;
PicoIn.AHW &= ~PAHW_32X;
}
void PicoReset32x(void)
{
if (PicoAHW & PAHW_32X) {
if (PicoIn.AHW & PAHW_32X) {
p32x_trigger_irq(NULL, SekCyclesDone(), P32XI_VRES);
p32x_sh2_poll_event(&msh2, SH2_IDLE_STATES, 0);
p32x_sh2_poll_event(&ssh2, SH2_IDLE_STATES, 0);
@ -216,13 +216,13 @@ void PicoReset32x(void)
static void p32x_start_blank(void)
{
if (Pico32xDrawMode != PDM32X_OFF && !PicoSkipFrame) {
if (Pico32xDrawMode != PDM32X_OFF && !PicoIn.skipFrame) {
int offs, lines;
pprof_start(draw);
offs = 8; lines = 224;
if ((Pico.video.reg[1] & 8) && !(PicoOpt & POPT_ALT_RENDERER)) {
if ((Pico.video.reg[1] & 8) && !(PicoIn.opt & POPT_ALT_RENDERER)) {
offs = 0;
lines = 240;
}
@ -376,7 +376,7 @@ static void run_sh2(SH2 *sh2, int m68k_cycles)
elprintf_sh2(sh2, EL_32X, "+run %u %d @%08x",
sh2->m68krcycles_done, cycles, sh2->pc);
done = sh2_execute(sh2, cycles, PicoOpt & POPT_EN_DRC);
done = sh2_execute(sh2, cycles, PicoIn.opt & POPT_EN_DRC);
sh2->m68krcycles_done += C_SH2_TO_M68K(*sh2, done);
sh2->state &= ~SH2_STATE_RUN;
@ -521,13 +521,13 @@ void sync_sh2s_lockstep(unsigned int m68k_target)
}
#define CPUS_RUN(m68k_cycles) do { \
if (PicoAHW & PAHW_MCD) \
if (PicoIn.AHW & PAHW_MCD) \
pcd_run_cpus(m68k_cycles); \
else \
SekRunM68k(m68k_cycles); \
\
if ((Pico32x.emu_flags & P32XF_Z80_32X_IO) && Pico.m.z80Run \
&& !Pico.m.z80_reset && (PicoOpt & POPT_EN_Z80)) \
&& !Pico.m.z80_reset && (PicoIn.opt & POPT_EN_Z80)) \
PicoSyncZ80(SekCyclesDone()); \
if (Pico32x.emu_flags & (P32XF_68KCPOLL|P32XF_68KVPOLL)) \
p32x_sync_sh2s(SekCyclesDone()); \
@ -550,7 +550,7 @@ void PicoFrame32x(void)
p32x_sh2_poll_event(&msh2, SH2_STATE_VPOLL, 0);
p32x_sh2_poll_event(&ssh2, SH2_STATE_VPOLL, 0);
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
pcd_prepare_frame();
PicoFrameStart();

View file

@ -787,7 +787,7 @@ static u32 PicoRead8_32x_on(u32 a)
}
if ((a & 0xfc00) != 0x5000) {
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
return PicoRead8_mcd_io(a);
else
return PicoRead8_io(a);
@ -831,7 +831,7 @@ static u32 PicoRead16_32x_on(u32 a)
}
if ((a & 0xfc00) != 0x5000) {
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
return PicoRead16_mcd_io(a);
else
return PicoRead16_io(a);
@ -871,7 +871,7 @@ static void PicoWrite8_32x_on(u32 a, u32 d)
}
if ((a & 0xfc00) != 0x5000) {
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
PicoWrite8_mcd_io(a, d);
else
PicoWrite8_io(a, d);
@ -909,7 +909,7 @@ static void PicoWrite16_32x_on(u32 a, u32 d)
}
if ((a & 0xfc00) != 0x5000) {
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
PicoWrite16_mcd_io(a, d);
else
PicoWrite16_io(a, d);
@ -938,15 +938,18 @@ static void PicoWrite16_32x_on(u32 a, u32 d)
u32 PicoRead8_32x(u32 a)
{
u32 d = 0;
if ((a & 0xffc0) == 0x5100) { // a15100
// regs are always readable
d = ((u8 *)Pico32x.regs)[(a & 0x3f) ^ 1];
goto out;
}
if ((a & 0xfffc) == 0x30ec) { // a130ec
d = str_mars[a & 3];
goto out;
if (PicoIn.opt & POPT_EN_32X) {
if ((a & 0xffc0) == 0x5100) { // a15100
// regs are always readable
d = ((u8 *)Pico32x.regs)[(a & 0x3f) ^ 1];
goto out;
}
if ((a & 0xfffc) == 0x30ec) { // a130ec
d = str_mars[a & 3];
goto out;
}
}
elprintf(EL_UIO, "m68k unmapped r8 [%06x] @%06x", a, SekPc);
@ -960,14 +963,17 @@ out:
u32 PicoRead16_32x(u32 a)
{
u32 d = 0;
if ((a & 0xffc0) == 0x5100) { // a15100
d = Pico32x.regs[(a & 0x3f) / 2];
goto out;
}
if ((a & 0xfffc) == 0x30ec) { // a130ec
d = !(a & 2) ? ('M'<<8)|'A' : ('R'<<8)|'S';
goto out;
if (PicoIn.opt & POPT_EN_32X) {
if ((a & 0xffc0) == 0x5100) { // a15100
d = Pico32x.regs[(a & 0x3f) / 2];
goto out;
}
if ((a & 0xfffc) == 0x30ec) { // a130ec
d = !(a & 2) ? ('M'<<8)|'A' : ('R'<<8)|'S';
goto out;
}
}
elprintf(EL_UIO, "m68k unmapped r16 [%06x] @%06x", a, SekPc);
@ -980,7 +986,8 @@ out:
void PicoWrite8_32x(u32 a, u32 d)
{
if ((a & 0xffc0) == 0x5100) { // a15100
if ((PicoIn.opt & POPT_EN_32X) && (a & 0xffc0) == 0x5100) // a15100
{
u16 *r = Pico32x.regs;
elprintf(EL_32X, "m68k 32x w8 [%06x] %02x @%06x", a, d & 0xff, SekPc);
@ -1008,7 +1015,8 @@ void PicoWrite8_32x(u32 a, u32 d)
void PicoWrite16_32x(u32 a, u32 d)
{
if ((a & 0xffc0) == 0x5100) { // a15100
if ((PicoIn.opt & POPT_EN_32X) && (a & 0xffc0) == 0x5100) // a15100
{
u16 *r = Pico32x.regs;
elprintf(EL_UIO, "m68k 32x w16 [%06x] %04x @%06x", a, d & 0xffff, SekPc);

View file

@ -576,9 +576,9 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
if (!is_sms)
{
// maybe we are loading MegaCD BIOS?
if (!(PicoAHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) ||
if (!(PicoIn.AHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) ||
!strncmp((char *)rom+0x128, "BOOT", 4))) {
PicoAHW |= PAHW_MCD;
PicoIn.AHW |= PAHW_MCD;
}
// Check for SMD:
@ -628,7 +628,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
}
pdb_cleanup();
PicoAHW &= PAHW_MCD|PAHW_SMS;
PicoIn.AHW &= PAHW_MCD|PAHW_SMS;
PicoCartMemSetup = NULL;
PicoDmaHook = NULL;
@ -637,13 +637,13 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
PicoLoadStateHook = NULL;
carthw_chunks = NULL;
if (!(PicoAHW & (PAHW_MCD|PAHW_SMS)))
if (!(PicoIn.AHW & (PAHW_MCD|PAHW_SMS)))
PicoCartDetect(carthw_cfg);
// setup correct memory map for loaded ROM
switch (PicoAHW) {
switch (PicoIn.AHW) {
default:
elprintf(EL_STATUS|EL_ANOMALY, "starting in unknown hw configuration: %x", PicoAHW);
elprintf(EL_STATUS|EL_ANOMALY, "starting in unknown hw configuration: %x", PicoIn.AHW);
case 0:
case PAHW_SVP: PicoMemSetup(); break;
case PAHW_MCD: PicoMemSetupCD(); break;
@ -654,7 +654,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
if (PicoCartMemSetup != NULL)
PicoCartMemSetup();
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
PicoPowerMS();
else
PicoPower();
@ -681,7 +681,7 @@ void PicoCartUnload(void)
PicoCartUnloadHook = NULL;
}
if (PicoAHW & PAHW_32X)
if (PicoIn.AHW & PAHW_32X)
PicoUnload32x();
if (Pico.rom != NULL) {
@ -965,7 +965,7 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
else if (strcmp(p, "filled_sram") == 0)
*fill_sram = 1;
else if (strcmp(p, "force_6btn") == 0)
PicoQuirks |= PQUIRK_FORCE_6BTN;
PicoIn.quirks |= PQUIRK_FORCE_6BTN;
else {
elprintf(EL_STATUS, "carthw:%d: unsupported prop: %s", line, p);
goto bad_nomsg;

View file

@ -30,8 +30,9 @@
#include <cpu/drc/cmn.h>
#include "compiler.h"
#define SVP_CYCLES_LINE 850
svp_t *svp = NULL;
int PicoSVPCycles = 850; // cycles/line, just a guess
static int svp_dyn_ready = 0;
/* save state stuff */
@ -57,7 +58,7 @@ static void PicoSVPReset(void)
memcpy(svp->iram_rom + 0x800, Pico.rom + 0x800, 0x20000 - 0x800);
ssp1601_reset(&svp->ssp1601);
#ifdef _SVP_DRC
if ((PicoOpt & POPT_EN_DRC) && svp_dyn_ready)
if ((PicoIn.opt & POPT_EN_DRC) && svp_dyn_ready)
ssp1601_dyn_reset(&svp->ssp1601);
#endif
}
@ -77,17 +78,17 @@ static void PicoSVPLine(void)
#endif
#ifdef _SVP_DRC
if ((PicoOpt & POPT_EN_DRC) && svp_dyn_ready)
ssp1601_dyn_run(PicoSVPCycles * count);
if ((PicoIn.opt & POPT_EN_DRC) && svp_dyn_ready)
ssp1601_dyn_run(SVP_CYCLES_LINE * count);
else
#endif
{
ssp1601_run(PicoSVPCycles * count);
ssp1601_run(SVP_CYCLES_LINE * count);
svp_dyn_ready = 0; // just in case
}
// test mode
//if (Pico.m.frame_count == 13) PicoPad[0] |= 0xff;
//if (Pico.m.frame_count == 13) PicoIn.pad[0] |= 0xff;
}
@ -148,7 +149,7 @@ void PicoSVPStartup(void)
// init SVP compiler
svp_dyn_ready = 0;
#ifdef _SVP_DRC
if (PicoOpt & POPT_EN_DRC) {
if (PicoIn.opt & POPT_EN_DRC) {
if (ssp1601_dyn_startup())
return;
svp_dyn_ready = 1;
@ -167,6 +168,6 @@ void PicoSVPStartup(void)
svp_states[1].ptr = svp->dram;
svp_states[2].ptr = &svp->ssp1601;
carthw_chunks = svp_states;
PicoAHW |= PAHW_SVP;
PicoIn.AHW |= PAHW_SVP;
}

View file

@ -434,7 +434,7 @@ void gfx_update(unsigned int cycles)
pcd_event_schedule(cycles, PCD_EVENT_GFX, 5 * w * lines);
}
if (PicoOpt & POPT_EN_MCD_GFX)
if (PicoIn.opt & POPT_EN_MCD_GFX)
{
/* render lines */
while (lines--)

View file

@ -79,7 +79,7 @@ PICO_INTERNAL int PicoResetMCD(void)
// reset button doesn't affect MCD hardware
// use Pico.sv.data for RAM cart
if (PicoOpt & POPT_EN_MCD_RAMCART) {
if (PicoIn.opt & POPT_EN_MCD_RAMCART) {
if (Pico.sv.data == NULL)
Pico.sv.data = calloc(1, 0x12000);
}

View file

@ -1099,7 +1099,7 @@ PICO_INTERNAL void PicoMemSetupCD(void)
// main68k map (BIOS mapped by PicoMemSetup()):
// RAM cart
if (PicoOpt & POPT_EN_MCD_RAMCART) {
if (PicoIn.opt & POPT_EN_MCD_RAMCART) {
cpu68k_map_set(m68k_read8_map, 0x400000, 0x7fffff, PicoReadM68k8_ramc, 1);
cpu68k_map_set(m68k_read16_map, 0x400000, 0x7fffff, PicoReadM68k16_ramc, 1);
cpu68k_map_set(m68k_write8_map, 0x400000, 0x7fffff, PicoWriteM68k8_ramc, 1);

View file

@ -127,7 +127,7 @@ void pcd_pcm_update(int *buf32, int length, int stereo)
pcd_pcm_sync(SekCyclesDoneS68k());
if (!Pico_mcd->pcm_mixbuf_dirty || !(PicoOpt & POPT_EN_MCD_PCM))
if (!Pico_mcd->pcm_mixbuf_dirty || !(PicoIn.opt & POPT_EN_MCD_PCM))
goto out;
step = (Pico_mcd->pcm_mixpos << 16) / length;

View file

@ -201,7 +201,7 @@ void PDebugShowPalette(unsigned short *screen, int stride)
int x, y;
Pico.m.dirtyPal = 1;
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
PicoDoHighPal555M4();
else
PicoDoHighPal555(1, 0, est);
@ -328,7 +328,7 @@ void PDebugDumpMem(void)
dump_ram_noswab(PicoMem.zram, "dumps/zram.bin");
dump_ram(PicoMem.cram, "dumps/cram.bin");
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
{
dump_ram_noswab(PicoMem.vramb, "dumps/vram.bin");
}
@ -339,7 +339,7 @@ void PDebugDumpMem(void)
dump_ram(PicoMem.vsram,"dumps/vsram.bin");
}
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
{
dump_ram(Pico_mcd->prg_ram, "dumps/prg_ram.bin");
if (Pico_mcd->s68k_regs[3]&4) // 1M mode?
@ -355,7 +355,7 @@ void PDebugDumpMem(void)
}
#ifndef NO_32X
if (PicoAHW & PAHW_32X)
if (PicoIn.AHW & PAHW_32X)
{
dump_ram(Pico32xMem->sdram, "dumps/sdram.bin");
dump_ram(Pico32xMem->dram[0], "dumps/dram0.bin");
@ -371,7 +371,7 @@ void PDebugZ80Frame(void)
{
int lines, line_sample;
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
return;
if (Pico.m.pal) {
@ -385,12 +385,12 @@ void PDebugZ80Frame(void)
z80_resetCycles();
PsndStartFrame();
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
PicoSyncZ80(Pico.t.m68c_cnt + line_sample * 488);
if (PsndOut)
PsndGetSamples(line_sample);
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
PicoSyncZ80(Pico.t.m68c_cnt + 224 * 488);
z80_int();
}
@ -398,7 +398,7 @@ void PDebugZ80Frame(void)
PsndGetSamples(224);
// sync z80
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
Pico.t.m68c_cnt += Pico.m.pal ? 151809 : 127671; // cycles adjusted for converter
PicoSyncZ80(Pico.t.m68c_cnt);
}
@ -412,7 +412,7 @@ void PDebugZ80Frame(void)
void PDebugCPUStep(void)
{
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
z80_run_nr(1);
else
SekStepM68k();

View file

@ -1027,7 +1027,7 @@ static NOINLINE void PrepareSprites(int full)
if (!(Pico.video.reg[12]&1))
max_sprites = 64, max_line_sprites = 16, max_width = 264;
if (PicoOpt & POPT_DIS_SPRITE_LIM)
if (PicoIn.opt & POPT_DIS_SPRITE_LIM)
max_line_sprites = MAX_LINE_SPRITES;
if (pvid->reg[1]&8) max_lines = 240;
@ -1267,7 +1267,7 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est)
if (Pico.video.reg[12]&1) {
len = 320;
} else {
if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;
if (!(PicoIn.opt&POPT_DIS_32C_BORDER)) pd+=32;
len = 256;
}
@ -1314,7 +1314,7 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
if (Pico.video.reg[12]&1) {
len = 320;
} else {
if (!(PicoOpt & POPT_DIS_32C_BORDER))
if (!(PicoIn.opt & POPT_DIS_32C_BORDER))
pd += 32;
len = 256;
}
@ -1427,7 +1427,7 @@ static int DrawDisplay(int sh)
else if (est->rendstatus & PDRAW_INTERLACE)
DrawAllSpritesInterlace(1, sh);
// have sprites without layer pri bit ontop of sprites with that bit
else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES))
else if ((sprited[1] & 0xd0) == 0xd0 && (PicoIn.opt & POPT_ACC_SPRITES))
DrawSpritesHiAS(sprited, sh);
else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP))
DrawSpritesSHi(sprited, est);
@ -1481,7 +1481,7 @@ PICO_INTERNAL void PicoFrameStart(void)
Pico.est.DrawScanline = 0;
skip_next_line = 0;
if (PicoOpt & POPT_ALT_RENDERER)
if (PicoIn.opt & POPT_ALT_RENDERER)
return;
if (Pico.m.dirtyPal)
@ -1577,7 +1577,7 @@ void PicoDrawUpdateHighPal(void)
{
struct PicoEState *est = &Pico.est;
int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?
if (PicoOpt & POPT_ALT_RENDERER)
if (PicoIn.opt & POPT_ALT_RENDERER)
sh = 0; // no s/h support
PicoDoHighPal555(sh, 0, &Pico.est);
@ -1597,7 +1597,7 @@ void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)
break;
case PDF_RGB555:
if ((PicoAHW & PAHW_32X) && use_32x_line_mode)
if ((PicoIn.AHW & PAHW_32X) && use_32x_line_mode)
FinalizeLine = FinalizeLine32xRGB555;
else
FinalizeLine = FinalizeLine555;
@ -1640,7 +1640,7 @@ void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned in
PicoScan32xBegin = NULL;
PicoScan32xEnd = NULL;
if ((PicoAHW & PAHW_32X) && FinalizeLine != FinalizeLine32xRGB555) {
if ((PicoIn.AHW & PAHW_32X) && FinalizeLine != FinalizeLine32xRGB555) {
PicoScan32xBegin = begin;
PicoScan32xEnd = end;
}

View file

@ -209,11 +209,11 @@ enum media_type_e PicoLoadMedia(const char *filename,
if (media_type == PM_BAD_DETECT)
goto out;
if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)
if ((PicoIn.AHW & PAHW_MCD) && Pico_mcd != NULL)
cdd_unload();
PicoCartUnload();
PicoAHW = 0;
PicoQuirks = 0;
PicoIn.AHW = 0;
PicoIn.quirks = 0;
if (media_type == PM_CD)
{
@ -230,7 +230,7 @@ enum media_type_e PicoLoadMedia(const char *filename,
goto out;
}
PicoAHW |= PAHW_MCD;
PicoIn.AHW |= PAHW_MCD;
}
else {
media_type = PM_BAD_CD;
@ -239,7 +239,7 @@ enum media_type_e PicoLoadMedia(const char *filename,
}
else if (media_type == PM_MARK3) {
lprintf("detected SMS ROM\n");
PicoAHW = PAHW_SMS;
PicoIn.AHW = PAHW_SMS;
}
rom = pm_open(rom_fname);
@ -249,7 +249,7 @@ enum media_type_e PicoLoadMedia(const char *filename,
goto out;
}
ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0);
ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoIn.AHW & PAHW_SMS) ? 1 : 0);
pm_close(rom);
if (ret != 0) {
if (ret == 2) lprintf("Out of memory\n");
@ -266,7 +266,7 @@ enum media_type_e PicoLoadMedia(const char *filename,
goto out;
}
if (!(PicoAHW & PAHW_SMS)) {
if (!(PicoIn.AHW & PAHW_SMS)) {
unsigned short *d = (unsigned short *)(rom_data + 4);
if ((((d[0] << 16) | d[1]) & 0xffffff) >= (int)rom_size) {
lprintf("bad reset vector\n");
@ -276,7 +276,7 @@ enum media_type_e PicoLoadMedia(const char *filename,
}
// load config for this ROM (do this before insert to get correct region)
if (!(PicoAHW & PAHW_MCD)) {
if (!(PicoIn.AHW & PAHW_MCD)) {
memcpy(media_id_header, rom_data + 0x100, sizeof(media_id_header));
if (do_region_override != NULL)
do_region_override(filename);
@ -300,7 +300,7 @@ enum media_type_e PicoLoadMedia(const char *filename,
Pico.m.ncart_in = 1;
}
if (PicoQuirks & PQUIRK_FORCE_6BTN)
if (PicoIn.quirks & PQUIRK_FORCE_6BTN)
PicoSetInputDevice(0, PICO_INPUT_PAD_6BTN);
out:

View file

@ -210,7 +210,7 @@ void cyclone_crashed(u32 pc, struct Cyclone *context)
static u32 read_pad_3btn(int i, u32 out_bits)
{
u32 pad = ~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU
u32 pad = ~PicoIn.padInt[i]; // Get inverse of pad MXYZ SACB RLDU
u32 value;
if (out_bits & 0x40) // TH
@ -224,7 +224,7 @@ static u32 read_pad_3btn(int i, u32 out_bits)
static u32 read_pad_6btn(int i, u32 out_bits)
{
u32 pad = ~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU
u32 pad = ~PicoIn.padInt[i]; // Get inverse of pad MXYZ SACB RLDU
int phase = Pico.m.padTHPhase[i];
u32 value;
@ -349,7 +349,7 @@ void NOINLINE ctl_write_z80busreq(u32 d)
}
else
{
if ((PicoOpt&POPT_EN_Z80) && !Pico.m.z80_reset) {
if ((PicoIn.opt & POPT_EN_Z80) && !Pico.m.z80_reset) {
pprof_start(m68k);
PicoSyncZ80(SekCyclesDone());
pprof_end_sub(m68k);
@ -367,7 +367,7 @@ void NOINLINE ctl_write_z80reset(u32 d)
{
if (d)
{
if ((PicoOpt&POPT_EN_Z80) && Pico.m.z80Run) {
if ((PicoIn.opt & POPT_EN_Z80) && Pico.m.z80Run) {
pprof_start(m68k);
PicoSyncZ80(SekCyclesDone());
pprof_end_sub(m68k);
@ -542,8 +542,8 @@ static void PicoWrite8_z80(u32 a, u32 d)
return;
}
if ((a & 0x6000) == 0x4000) { // FM Sound
if (PicoOpt & POPT_EN_FM)
emustatus |= ym2612_write_local(a&3, d&0xff, 0)&1;
if (PicoIn.opt & POPT_EN_FM)
Pico.m.status |= ym2612_write_local(a & 3, d & 0xff, 0) & 1;
return;
}
// TODO: probably other VDP access too? Maybe more mirrors?
@ -597,12 +597,8 @@ u32 PicoRead8_io(u32 a)
goto end;
}
if (PicoOpt & POPT_EN_32X) {
d = PicoRead8_32x(a);
goto end;
}
d = PicoRead8_32x(a);
d = m68k_unmapped_read8(a);
end:
return d;
}
@ -632,12 +628,8 @@ u32 PicoRead16_io(u32 a)
goto end;
}
if (PicoOpt & POPT_EN_32X) {
d = PicoRead16_32x(a);
goto end;
}
d = PicoRead16_32x(a);
d = m68k_unmapped_read16(a);
end:
return d;
}
@ -662,12 +654,7 @@ void PicoWrite8_io(u32 a, u32 d)
Pico.m.sram_reg |= (u8)(d & 3);
return;
}
if (PicoOpt & POPT_EN_32X) {
PicoWrite8_32x(a, d);
return;
}
m68k_unmapped_write8(a, d);
PicoWrite8_32x(a, d);
}
void PicoWrite16_io(u32 a, u32 d)
@ -690,11 +677,7 @@ void PicoWrite16_io(u32 a, u32 d)
Pico.m.sram_reg |= (u8)(d & 3);
return;
}
if (PicoOpt & POPT_EN_32X) {
PicoWrite16_32x(a, d);
return;
}
m68k_unmapped_write16(a, d);
PicoWrite16_32x(a, d);
}
#endif // _ASM_MEMORY_C
@ -971,7 +954,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
ym2612.OPN.ST.address = d;
ym2612.addr_A1 = 0;
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM) YM2612Write_940(a, d, -1);
if (PicoIn.opt & POPT_EXT_FM) YM2612Write_940(a, d, -1);
#endif
return 0;
@ -1036,7 +1019,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
if ((d ^ old_mode) & 0xc0) {
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM) return YM2612Write_940(a, d, get_scanline(is_from_z80));
if (PicoIn.opt & POPT_EXT_FM) return YM2612Write_940(a, d, get_scanline(is_from_z80));
#endif
return 1;
}
@ -1049,7 +1032,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
PsndDacLine = scanline;
}
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM) YM2612Write_940(a, d, scanline);
if (PicoIn.opt & POPT_EXT_FM) YM2612Write_940(a, d, scanline);
#endif
return 0;
}
@ -1060,7 +1043,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
ym2612.OPN.ST.address = d;
ym2612.addr_A1 = 1;
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM) YM2612Write_940(a, d, -1);
if (PicoIn.opt & POPT_EXT_FM) YM2612Write_940(a, d, -1);
#endif
return 0;
@ -1074,7 +1057,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
}
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM)
if (PicoIn.opt & POPT_EXT_FM)
return YM2612Write_940(a, d, get_scanline(is_from_z80));
#endif
return YM2612Write_(a, d);
@ -1123,7 +1106,7 @@ void ym2612_pack_state(void)
elprintf(EL_YMTIMER, "save: timer b %i/%i", tbt >> 16, tbc);
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM)
if (PicoIn.opt & POPT_EXT_FM)
YM2612PicoStateSave2_940(tat, tbt);
else
#endif
@ -1158,7 +1141,7 @@ void ym2612_unpack_state(void)
}
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM)
if (PicoIn.opt & POPT_EXT_FM)
ret = YM2612PicoStateLoad2_940(&tat, &tbt);
else
#endif
@ -1233,8 +1216,8 @@ static unsigned char z80_md_bank_read(unsigned short a)
static void z80_md_ym2612_write(unsigned int a, unsigned char data)
{
if (PicoOpt & POPT_EN_FM)
emustatus |= ym2612_write_local(a, data, 1) & 1;
if (PicoIn.opt & POPT_EN_FM)
Pico.m.status |= ym2612_write_local(a, data, 1) & 1;
}
static void z80_md_vdp_br_write(unsigned int a, unsigned char data)

View file

@ -70,7 +70,7 @@ PicoRead8_io: @ u32 a
m_read8_not_io:
and r2, r0, #0xfc00
cmp r2, #0x1000
bne m_read8_not_brq
bne PicoRead8_32x
ldr r3, =Pico
mov r1, r0
@ -92,14 +92,6 @@ m_read8_not_io:
orr r0, r0, r2
bx lr
m_read8_not_brq:
ldr r2, =PicoOpt
ldr r2, [r2]
tst r2, #POPT_EN_32X
bne PicoRead8_32x
mov r0, #0
bx lr
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
PicoRead16_sram: @ u32 a, u32 d
@ -146,7 +138,7 @@ PicoRead16_io: @ u32 a, u32 d
m_read16_not_io:
and r2, r0, #0xfc00
cmp r2, #0x1000
bne m_read16_not_brq
bne PicoRead16_32x
ldr r3, =Pico
and r2, r0, #0xff00
@ -165,14 +157,6 @@ m_read16_not_io:
orr r0, r0, r2, lsl #8
bx lr
m_read16_not_brq:
ldr r2, =PicoOpt
ldr r2, [r2]
tst r2, #POPT_EN_32X
bne PicoRead16_32x
mov r0, #0
bx lr
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
PicoWrite8_io: @ u32 a, u32 d
@ -197,7 +181,7 @@ m_write8_not_z80ctl:
eor r2, r0, #0xa10000
eor r2, r2, #0x003000
eors r2, r2, #0x0000f1
bne m_write8_not_sreg
bne PicoWrite8_32x
ldr r3, =Pico
ldrb r2, [r3, #OFS_Pico_m_sram_reg]
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
@ -206,13 +190,6 @@ m_write8_not_z80ctl:
strb r2, [r3, #OFS_Pico_m_sram_reg]
bx lr
m_write8_not_sreg:
ldr r2, =PicoOpt
ldr r2, [r2]
tst r2, #POPT_EN_32X
bne PicoWrite8_32x
bx lr
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
PicoWrite16_io: @ u32 a, u32 d
@ -234,7 +211,7 @@ m_write16_not_z80ctl:
eor r2, r0, #0xa10000
eor r2, r2, #0x003000
eors r2, r2, #0x0000f0
bne m_write16_not_sreg
bne PicoWrite16_32x
ldr r3, =Pico
ldrb r2, [r3, #OFS_Pico_m_sram_reg]
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
@ -243,13 +220,6 @@ m_write16_not_z80ctl:
strb r2, [r3, #OFS_Pico_m_sram_reg]
bx lr
m_write16_not_sreg:
ldr r2, =PicoOpt
ldr r2, [r2]
tst r2, #POPT_EN_32X
bne PicoWrite16_32x
bx lr
.pool
@ vim:filetype=armasm

View file

@ -284,7 +284,7 @@ static void FinalizeLine8bitM4(int line)
{
unsigned char *pd = Pico.est.DrawLineDest;
if (!(PicoOpt & POPT_DIS_32C_BORDER))
if (!(PicoIn.opt & POPT_DIS_32C_BORDER))
pd += 32;
memcpy(pd, Pico.est.HighCol + 8, 256);

View file

@ -290,7 +290,7 @@ void decode(const char* code, struct patch* result)
/* Initialize the result */
result->addr = result->data = result->comp = 0;
if(!(PicoAHW & PAHW_SMS))
if(!(PicoIn.AHW & PAHW_SMS))
{
//If Genesis
@ -445,7 +445,7 @@ void PicoPatchPrepare(void)
PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + addr);
else
{
if(!(PicoAHW & PAHW_SMS))
if(!(PicoIn.AHW & PAHW_SMS))
PicoPatches[i].data_old = (unsigned short) m68k_read16(addr);
else
;// wrong: PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr);
@ -468,7 +468,7 @@ void PicoPatchApply(void)
{
if (PicoPatches[i].active)
{
if (!(PicoAHW & PAHW_SMS))
if (!(PicoIn.AHW & PAHW_SMS))
*(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data;
else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr))
*(char *)(Pico.rom + addr) = (char) PicoPatches[i].data;
@ -480,7 +480,7 @@ void PicoPatchApply(void)
if (PicoPatches[u].addr == addr) break;
if (u == i)
{
if (!(PicoAHW & PAHW_SMS))
if (!(PicoIn.AHW & PAHW_SMS))
*(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old;
else
*(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old;
@ -493,7 +493,7 @@ void PicoPatchApply(void)
{
if (PicoPatches[i].active)
{
if (!(PicoAHW & PAHW_SMS))
if (!(PicoIn.AHW & PAHW_SMS))
m68k_write16(addr,PicoPatches[i].data);
else
;// wrong: PicoWrite8_z80(addr,PicoPatches[i].data);
@ -505,7 +505,7 @@ void PicoPatchApply(void)
if (PicoPatches[u].addr == addr) break;
if (u == i)
{
if (!(PicoAHW & PAHW_SMS))
if (!(PicoIn.AHW & PAHW_SMS))
m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
else
;// wrong: PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old);

View file

@ -12,16 +12,7 @@
struct Pico Pico;
struct PicoMem PicoMem;
int PicoOpt;
int PicoSkipFrame; // skip rendering frame?
int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
int PicoPadInt[2]; // internal copy
int PicoAHW; // active addon hardware: PAHW_*
int PicoQuirks; // game-specific quirks
int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
int PicoAutoRgnOrder;
int emustatus; // rapid_ym2612, multi_ym_updates
PicoInterface PicoIn;
void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware
void (*PicoResetHook)(void) = NULL;
@ -33,13 +24,13 @@ void PicoInit(void)
// Blank space for state:
memset(&Pico,0,sizeof(Pico));
memset(&PicoMem,0,sizeof(PicoMem));
memset(&PicoPad,0,sizeof(PicoPad));
memset(&PicoPadInt,0,sizeof(PicoPadInt));
memset(&PicoIn.pad,0,sizeof(PicoIn.pad));
memset(&PicoIn.padInt,0,sizeof(PicoIn.padInt));
Pico.est.Pico = &Pico;
Pico.est.PicoMem_vram = PicoMem.vram;
Pico.est.PicoMem_cram = PicoMem.cram;
Pico.est.PicoOpt = &PicoOpt;
Pico.est.PicoOpt = &PicoIn.opt;
// Init CPUs:
SekInit();
@ -56,7 +47,7 @@ void PicoInit(void)
// to be called once on emu exit
void PicoExit(void)
{
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
PicoExitMCD();
PicoCartUnload();
z80_exit();
@ -89,10 +80,10 @@ void PicoPower(void)
Pico.video.reg[0xc] = 0x81;
Pico.video.reg[0xf] = 0x02;
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
PicoPowerMCD();
if (PicoOpt & POPT_EN_32X)
if (PicoIn.opt & POPT_EN_32X)
PicoPower32x();
PicoReset();
@ -103,9 +94,9 @@ PICO_INTERNAL void PicoDetectRegion(void)
int support=0, hw=0, i;
unsigned char pal=0;
if (PicoRegionOverride)
if (PicoIn.regionOverride)
{
support = PicoRegionOverride;
support = PicoIn.regionOverride;
}
else
{
@ -138,10 +129,10 @@ PICO_INTERNAL void PicoDetectRegion(void)
}
// auto detection order override
if (PicoAutoRgnOrder) {
if (((PicoAutoRgnOrder>>0)&0xf) & support) support = (PicoAutoRgnOrder>>0)&0xf;
else if (((PicoAutoRgnOrder>>4)&0xf) & support) support = (PicoAutoRgnOrder>>4)&0xf;
else if (((PicoAutoRgnOrder>>8)&0xf) & support) support = (PicoAutoRgnOrder>>8)&0xf;
if (PicoIn.autoRgnOrder) {
if (((PicoIn.autoRgnOrder>>0)&0xf) & support) support = (PicoIn.autoRgnOrder>>0)&0xf;
else if (((PicoIn.autoRgnOrder>>4)&0xf) & support) support = (PicoIn.autoRgnOrder>>4)&0xf;
else if (((PicoIn.autoRgnOrder>>8)&0xf) & support) support = (PicoIn.autoRgnOrder>>8)&0xf;
}
// Try to pick the best hardware value for English/50hz:
@ -161,17 +152,16 @@ int PicoReset(void)
return 1;
#if defined(CPU_CMP_R) || defined(CPU_CMP_W) || defined(DRC_CMP)
PicoOpt |= POPT_DIS_VDP_FIFO|POPT_DIS_IDLE_DET;
PicoIn.opt |= POPT_DIS_VDP_FIFO|POPT_DIS_IDLE_DET;
#endif
/* must call now, so that banking is reset, and correct vectors get fetched */
if (PicoResetHook)
PicoResetHook();
memset(&PicoPadInt,0,sizeof(PicoPadInt));
emustatus = 0;
memset(&PicoIn.padInt, 0, sizeof(PicoIn.padInt));
if (PicoAHW & PAHW_SMS) {
if (PicoIn.AHW & PAHW_SMS) {
PicoResetMS();
return 0;
}
@ -180,7 +170,7 @@ int PicoReset(void)
// ..but do not reset SekCycle* to not desync with addons
// s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).
SekSetRealTAS(PicoAHW & PAHW_MCD);
SekSetRealTAS(PicoIn.AHW & PAHW_MCD);
Pico.m.dirtyPal = 1;
@ -193,21 +183,21 @@ int PicoReset(void)
PsndReset(); // pal must be known here
// create an empty "dma" to cause 68k exec start at random frame location
if (Pico.m.dma_xfers == 0 && !(PicoOpt & POPT_DIS_VDP_FIFO))
if (Pico.m.dma_xfers == 0 && !(PicoIn.opt & POPT_DIS_VDP_FIFO))
Pico.m.dma_xfers = rand() & 0x1fff;
SekFinishIdleDet();
if (PicoAHW & PAHW_MCD) {
if (PicoIn.AHW & PAHW_MCD) {
PicoResetMCD();
return 0;
}
// reinit, so that checksum checks pass
if (!(PicoOpt & POPT_DIS_IDLE_DET))
if (!(PicoIn.opt & POPT_DIS_IDLE_DET))
SekInitIdleDet();
if (PicoOpt & POPT_EN_32X)
if (PicoIn.opt & POPT_EN_32X)
PicoReset32x();
// reset sram state; enable sram access by default if it doesn't overlap with ROM
@ -225,9 +215,9 @@ int PicoReset(void)
// flush config changes before emu loop starts
void PicoLoopPrepare(void)
{
if (PicoRegionOverride)
if (PicoIn.regionOverride)
// force setting possibly changed..
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;
Pico.m.pal = (PicoIn.regionOverride == 2 || PicoIn.regionOverride == 8) ? 1 : 0;
Pico.m.dirtyPal = 1;
rendstatus_old = -1;
@ -310,17 +300,17 @@ void PicoFrame(void)
Pico.m.frame_count++;
if (PicoAHW & PAHW_SMS) {
if (PicoIn.AHW & PAHW_SMS) {
PicoFrameMS();
goto end;
}
if (PicoAHW & PAHW_32X) {
if (PicoIn.AHW & PAHW_32X) {
PicoFrame32x(); // also does MCD+32X
goto end;
}
if (PicoAHW & PAHW_MCD) {
if (PicoIn.AHW & PAHW_MCD) {
PicoFrameMCD();
goto end;
}
@ -336,7 +326,7 @@ end:
void PicoFrameDrawOnly(void)
{
if (!(PicoAHW & PAHW_SMS)) {
if (!(PicoIn.AHW & PAHW_SMS)) {
PicoFrameStart();
PicoDrawSync(223, 0);
} else {

View file

@ -72,22 +72,34 @@ extern void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
#define POPT_DIS_IDLE_DET (1<<19)
#define POPT_EN_32X (1<<20)
#define POPT_EN_PWM (1<<21)
extern int PicoOpt; // bitfield
#define PAHW_MCD (1<<0)
#define PAHW_32X (1<<1)
#define PAHW_SVP (1<<2)
#define PAHW_PICO (1<<3)
#define PAHW_SMS (1<<4)
extern int PicoAHW; // Pico active hw
#define PQUIRK_FORCE_6BTN (1<<0)
extern int PicoQuirks;
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
extern int PicoSVPCycles;
// the emulator is configured and some status is reported
// through this global state (not saved in savestates)
typedef struct
{
unsigned int opt; // POPT_* bitfield
unsigned short pad[2]; // Joypads, format is MXYZ SACB RLDU
unsigned short padInt[2]; // internal copy
unsigned short AHW; // active addon hardware: PAHW_* bitfield
unsigned short skipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff
unsigned short regionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
unsigned short autoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP
unsigned short quirks; // game-specific quirks: PQUIRK_*
} PicoInterface;
extern PicoInterface PicoIn;
void PicoInit(void);
void PicoExit(void);
void PicoPower(void);
@ -95,7 +107,6 @@ int PicoReset(void);
void PicoLoopPrepare(void);
void PicoFrame(void);
void PicoFrameDrawOnly(void);
extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
extern void (*PicoWriteSound)(int bytes); // called once per frame at the best time to send sound buffer (PsndOut) to hardware
extern void (*PicoMessage)(const char *msg); // callback to output text message from emu
typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;

View file

@ -35,8 +35,8 @@ static u32 PicoRead8_pico(u32 a)
{
case 0x01: d = PicoPicohw.r1; break;
case 0x03:
d = PicoPad[0]&0x1f; // d-pad
d |= (PicoPad[0]&0x20) << 2; // pen push -> C
d = PicoIn.pad[0]&0x1f; // d-pad
d |= (PicoIn.pad[0]&0x20) << 2; // pen push -> C
d = ~d;
break;

View file

@ -86,7 +86,7 @@ PICO_INTERNAL void PicoInitPico(void)
PicoLineHook = PicoLinePico;
PicoResetHook = PicoResetPico;
PicoAHW = PAHW_PICO;
PicoIn.AHW = PAHW_PICO;
memset(&PicoPicohw, 0, sizeof(PicoPicohw));
PicoPicohw.pen_pos[0] = 0x03c + 320/2;
PicoPicohw.pen_pos[1] = 0x200 + 240/2;

View file

@ -97,7 +97,7 @@ static int PicoFrameHints(void)
pevt_log_m68k_o(EVT_FRAME_START);
if ((PicoOpt&POPT_ALT_RENDERER) && !PicoSkipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled
if ((PicoIn.opt&POPT_ALT_RENDERER) && !PicoIn.skipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled
// draw a frame just after vblank in alternative render mode
// yes, this will cause 1 frame lag, but this is inaccurate mode anyway.
PicoFrameFull();
@ -106,7 +106,7 @@ static int PicoFrameHints(void)
#endif
skip = 1;
}
else skip=PicoSkipFrame;
else skip=PicoIn.skipFrame;
Pico.t.m68c_frame_start = Pico.t.m68c_aim;
pv->v_counter = Pico.m.scanline = 0;
@ -140,7 +140,7 @@ static int PicoFrameHints(void)
}
// decide if we draw this line
if (!skip && (PicoOpt & POPT_ALT_RENDERER))
if (!skip && (PicoIn.opt & POPT_ALT_RENDERER))
{
// find the right moment for frame renderer, when display is no longer blanked
if ((pv->reg[1]&0x40) || y > 100) {
@ -157,10 +157,10 @@ static int PicoFrameHints(void)
{
cycles = SekCyclesDone();
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
PicoSyncZ80(cycles);
#ifdef PICO_CD
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
pcd_sync_s68k(cycles, 0);
#endif
#ifdef PICO_32X
@ -195,7 +195,7 @@ static int PicoFrameHints(void)
pv->lwrite_cnt = 0;
Pico.video.status |= SR_EMPT;
memcpy(PicoPadInt, PicoPad, sizeof(PicoPadInt));
memcpy(PicoIn.padInt, PicoIn.pad, sizeof(PicoIn.padInt));
PAD_DELAY();
// Last H-Int (normally):
@ -225,14 +225,14 @@ static int PicoFrameHints(void)
}
cycles = SekCyclesDone();
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
PicoSyncZ80(cycles);
elprintf(EL_INTS, "zint");
z80_int();
}
#ifdef PICO_CD
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
pcd_sync_s68k(cycles, 0);
#endif
#ifdef PICO_32X
@ -313,7 +313,7 @@ static int PicoFrameHints(void)
// sync cpus
cycles = SekCyclesDone();
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
PicoSyncZ80(cycles);
if (PsndOut && ym2612.dacen && PsndDacLine < lines)
PsndDoDAC(lines - 1);
@ -321,7 +321,7 @@ static int PicoFrameHints(void)
PsndDoPSG(lines - 1);
#ifdef PICO_CD
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
pcd_sync_s68k(cycles, 0);
#endif
#ifdef PICO_32X

View file

@ -327,7 +327,7 @@ struct PicoMisc
unsigned char eeprom_cycle; // EEPROM cycle number
unsigned char eeprom_slave; // EEPROM slave word for X24C02 and better SRAMs
unsigned char eeprom_status;
unsigned char pad2;
unsigned char status; // rapid_ym2612, multi_ym_updates
unsigned short dma_xfers; // 18
unsigned char eeprom_wb[2]; // EEPROM latch/write buffer
unsigned int frame_count; // 1c for movies and idle det
@ -352,7 +352,7 @@ struct PicoEState
struct Pico *Pico;
void *PicoMem_vram;
void *PicoMem_cram;
int *PicoOpt;
unsigned int *PicoOpt;
unsigned char *Draw2FB;
unsigned short HighPal[0x100];
};
@ -705,8 +705,6 @@ void pcd_state_loaded_mem(void);
// pico.c
extern struct Pico Pico;
extern struct PicoMem PicoMem;
extern int PicoPadInt[2];
extern int emustatus;
extern void (*PicoResetHook)(void);
extern void (*PicoLineHook)(void);
PICO_INTERNAL int CheckDMA(void);

View file

@ -335,7 +335,7 @@ int SekIsIdleCode(unsigned short *dst, int bytes)
(*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX
(*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX
return 1;
if (PicoAHW & (PAHW_MCD|PAHW_32X))
if (PicoIn.AHW & (PAHW_MCD|PAHW_32X))
break;
// with no addons, there should be no need to wait
// for byte change anywhere
@ -362,7 +362,7 @@ int SekIsIdleCode(unsigned short *dst, int bytes)
return 1;
break;
case 12:
if (PicoAHW & (PAHW_MCD|PAHW_32X))
if (PicoIn.AHW & (PAHW_MCD|PAHW_32X))
break;
if ( (*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX
(dst[1]&0xf100) == 0x0000 && // arithmetic

View file

@ -108,12 +108,12 @@ static unsigned char z80_sms_in(unsigned short a)
break;
case 0xc0: /* I/O port A and B */
d = ~((PicoPad[0] & 0x3f) | (PicoPad[1] << 6));
d = ~((PicoIn.pad[0] & 0x3f) | (PicoIn.pad[1] << 6));
break;
case 0xc1: /* I/O port B and miscellaneous */
d = (Pico.ms.io_ctl & 0x80) | ((Pico.ms.io_ctl << 1) & 0x40) | 0x30;
d |= ~(PicoPad[1] >> 2) & 0x0f;
d |= ~(PicoIn.pad[1] >> 2) & 0x0f;
break;
}
@ -133,7 +133,7 @@ static void z80_sms_out(unsigned short a, unsigned char d)
case 0x40:
case 0x41:
if (PicoOpt & POPT_EN_PSG)
if (PicoIn.opt & POPT_EN_PSG)
SN76496Write(d);
break;
@ -255,7 +255,7 @@ void PicoFrameMS(void)
int lines = is_pal ? 313 : 262;
int cycles_line = is_pal ? 58020 : 58293; /* (226.6 : 227.7) * 256 */
int cycles_done = 0, cycles_aim = 0;
int skip = PicoSkipFrame;
int skip = PicoIn.skipFrame;
int lines_vis = 192;
int hint; // Hint counter
int nmi;
@ -263,7 +263,7 @@ void PicoFrameMS(void)
PsndStartFrame();
nmi = (PicoPad[0] >> 7) & 1;
nmi = (PicoIn.pad[0] >> 7) & 1;
if (!Pico.ms.nmi_state && nmi)
z80_nmi();
Pico.ms.nmi_state = nmi;

View file

@ -141,9 +141,9 @@ void PsndRerate(int preserve_state)
PsndClear();
// set mixer
PsndMix_32_to_16l = (PicoOpt & POPT_EN_STEREO) ? mix_32_to_16l_stereo : mix_32_to_16_mono;
PsndMix_32_to_16l = (PicoIn.opt & POPT_EN_STEREO) ? mix_32_to_16l_stereo : mix_32_to_16_mono;
if (PicoAHW & PAHW_PICO)
if (PicoIn.AHW & PAHW_PICO)
PicoReratePico();
}
@ -159,7 +159,7 @@ PICO_INTERNAL void PsndStartFrame(void)
}
PsndDacLine = PsndPsgLine = 0;
emustatus &= ~1;
Pico.m.status &= ~1;
dac_info[224] = PsndLen_use;
}
@ -183,7 +183,7 @@ PICO_INTERNAL void PsndDoDAC(int line_to)
if (!PsndOut)
return;
if (PicoOpt & POPT_EN_STEREO) {
if (PicoIn.opt & POPT_EN_STEREO) {
short *d = PsndOut + pos*2;
for (; len > 0; len--, d+=2) *d += dout;
} else {
@ -211,10 +211,10 @@ PICO_INTERNAL void PsndDoPSG(int line_to)
PsndPsgLine = line_to + 1;
if (!PsndOut || !(PicoOpt & POPT_EN_PSG))
if (!PsndOut || !(PicoIn.opt & POPT_EN_PSG))
return;
if (PicoOpt & POPT_EN_STEREO) {
if (PicoIn.opt & POPT_EN_STEREO) {
stereo = 1;
pos <<= 1;
}
@ -272,7 +272,7 @@ PICO_INTERNAL void PsndClear(void)
{
int len = PsndLen;
if (PsndLen_exc_add) len++;
if (PicoOpt & POPT_EN_STEREO)
if (PicoIn.opt & POPT_EN_STEREO)
memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned
else {
short *out = PsndOut;
@ -287,19 +287,19 @@ static int PsndRender(int offset, int length)
{
int buf32_updated = 0;
int *buf32 = PsndBuffer+offset;
int stereo = (PicoOpt & 8) >> 3;
int stereo = (PicoIn.opt & 8) >> 3;
offset <<= stereo;
pprof_start(sound);
if (PicoAHW & PAHW_PICO) {
if (PicoIn.AHW & PAHW_PICO) {
PicoPicoPCMUpdate(PsndOut+offset, length, stereo);
return length;
}
// Add in the stereo FM buffer
if (PicoOpt & POPT_EN_FM) {
if (PicoIn.opt & POPT_EN_FM) {
buf32_updated = YM2612UpdateOne(buf32, length, stereo, 1);
} else
memset32(buf32, 0, length<<stereo);
@ -308,14 +308,14 @@ static int PsndRender(int offset, int length)
(void)buf32_updated;
// CD: PCM sound
if (PicoAHW & PAHW_MCD) {
if (PicoIn.AHW & PAHW_MCD) {
pcd_pcm_update(buf32, length, stereo);
//buf32_updated = 1;
}
// CD: CDDA audio
// CD mode, cdda enabled, not data track, CDC is reading
if ((PicoAHW & PAHW_MCD) && (PicoOpt & POPT_EN_MCD_CDDA)
if ((PicoIn.AHW & PAHW_MCD) && (PicoIn.opt & POPT_EN_MCD_CDDA)
&& Pico_mcd->cdda_stream != NULL
&& !(Pico_mcd->s68k_regs[0x36] & 1))
{
@ -326,7 +326,7 @@ static int PsndRender(int offset, int length)
cdda_raw_update(buf32, length);
}
if ((PicoAHW & PAHW_32X) && (PicoOpt & POPT_EN_PWM))
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))
p32x_pwm_update(buf32, length, stereo);
// convert + limit to normal 16bit output
@ -348,33 +348,33 @@ PICO_INTERNAL void PsndGetSamples(int y)
if (y == 224)
{
if (emustatus & 2)
if (Pico.m.status & 2)
curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2);
else curr_pos = PsndRender(0, PsndLen_use);
if (emustatus & 1)
emustatus |= 2;
else emustatus &= ~2;
if (Pico.m.status & 1)
Pico.m.status |= 2;
else Pico.m.status &= ~2;
if (PicoWriteSound)
PicoWriteSound(curr_pos * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));
PicoWriteSound(curr_pos * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));
// clear sound buffer
PsndClear();
PsndDacLine = 224;
dac_info[224] = 0;
}
else if (emustatus & 3) {
emustatus|= 2;
emustatus&=~1;
else if (Pico.m.status & 3) {
Pico.m.status |= 2;
Pico.m.status &= ~1;
curr_pos = PsndRender(0, PsndLen/2);
}
}
PICO_INTERNAL void PsndGetSamplesMS(void)
{
int stereo = (PicoOpt & 8) >> 3;
int stereo = (PicoIn.opt & 8) >> 3;
int length = PsndLen_use;
// PSG
if (PicoOpt & POPT_EN_PSG)
if (PicoIn.opt & POPT_EN_PSG)
SN76496Update(PsndOut, length, stereo);
// upmix to "stereo" if needed
@ -385,7 +385,7 @@ PICO_INTERNAL void PsndGetSamplesMS(void)
}
if (PicoWriteSound != NULL)
PicoWriteSound(length * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));
PicoWriteSound(length * ((PicoIn.opt & POPT_EN_STEREO) ? 4 : 2));
PsndClear();
}

View file

@ -176,20 +176,20 @@ int YM2612PicoStateLoad2(int *tat, int *tbt);
#else
/* GP2X specific */
#include "../../platform/gp2x/940ctl.h"
extern int PicoOpt;
extern int PicoIn.opt;
#define YM2612Init(baseclock,rate) { \
if (PicoOpt&0x200) YM2612Init_940(baseclock, rate); \
if (PicoIn.opt&0x200) YM2612Init_940(baseclock, rate); \
else YM2612Init_(baseclock, rate); \
}
#define YM2612ResetChip() { \
if (PicoOpt&0x200) YM2612ResetChip_940(); \
if (PicoIn.opt&0x200) YM2612ResetChip_940(); \
else YM2612ResetChip_(); \
}
#define YM2612UpdateOne(buffer,length,stereo,is_buf_empty) \
(PicoOpt&0x200) ? YM2612UpdateOne_940(buffer, length, stereo, is_buf_empty) : \
(PicoIn.opt&0x200) ? YM2612UpdateOne_940(buffer, length, stereo, is_buf_empty) : \
YM2612UpdateOne_(buffer, length, stereo, is_buf_empty);
#define YM2612PicoStateLoad() { \
if (PicoOpt&0x200) YM2612PicoStateLoad_940(); \
if (PicoIn.opt&0x200) YM2612PicoStateLoad_940(); \
else YM2612PicoStateLoad_(); \
}
#endif /* __GP2X__ */

View file

@ -226,7 +226,7 @@ static int state_save(void *file)
areaWrite("PicoSEXT", 1, 8, file);
areaWrite(&ver, 1, 4, file);
if (!(PicoAHW & PAHW_SMS)) {
if (!(PicoIn.AHW & PAHW_SMS)) {
memset(buff, 0, sizeof(buff));
SekPackCpu(buff, 0);
CHECKED_WRITE_BUFF(CHUNK_M68K, buff);
@ -250,7 +250,7 @@ static int state_save(void *file)
CHECKED_WRITE_BUFF(CHUNK_Z80, buff_z80);
CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs);
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
{
buf2 = malloc(CHUNK_LIMIT_W);
if (buf2 == NULL)
@ -287,7 +287,7 @@ static int state_save(void *file)
}
#ifndef NO_32X
if (PicoAHW & PAHW_32X)
if (PicoIn.AHW & PAHW_32X)
{
unsigned char cpubuff[SH2_STATE_SIZE];
@ -406,9 +406,9 @@ static int state_load(void *file)
CHECKED_READ(1, &chunk);
CHECKED_READ(4, &len);
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
if (CHUNK_S68K <= chunk && chunk <= CHUNK_MISC_CD && !(PicoAHW & PAHW_MCD))
if (CHUNK_S68K <= chunk && chunk <= CHUNK_MISC_CD && !(PicoIn.AHW & PAHW_MCD))
R_ERROR_RETURN("cd chunk in non CD state?");
if (CHUNK_32X_FIRST <= chunk && chunk <= CHUNK_32X_LAST && !(PicoAHW & PAHW_32X))
if (CHUNK_32X_FIRST <= chunk && chunk <= CHUNK_32X_LAST && !(PicoIn.AHW & PAHW_32X))
Pico32xStartup();
switch (chunk)
@ -535,28 +535,28 @@ breakswitch:
}
readend:
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
PicoStateLoadedMS();
if (PicoAHW & PAHW_32X)
if (PicoIn.AHW & PAHW_32X)
Pico32xStateLoaded(1);
if (PicoLoadStateHook != NULL)
PicoLoadStateHook();
// must unpack 68k and z80 after banks are set up
if (!(PicoAHW & PAHW_SMS))
if (!(PicoIn.AHW & PAHW_SMS))
SekUnpackCpu(buff_m68k, 0);
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
SekUnpackCpu(buff_s68k, 1);
z80_unpack(buff_z80);
// due to dep from 68k cycles..
Pico.t.m68c_aim = Pico.t.m68c_cnt;
if (PicoAHW & PAHW_32X)
if (PicoIn.AHW & PAHW_32X)
Pico32xStateLoaded(0);
if (PicoAHW & PAHW_MCD)
if (PicoIn.AHW & PAHW_MCD)
{
SekCycleAimS68k = SekCycleCntS68k;
pcd_state_loaded();
@ -579,7 +579,7 @@ static int state_load_gfx(void *file)
int ver, len, found = 0, to_find = 4;
char buff[8];
if (PicoAHW & PAHW_32X)
if (PicoIn.AHW & PAHW_32X)
to_find += 2;
g_read_offs = 0;
@ -593,7 +593,7 @@ static int state_load_gfx(void *file)
CHECKED_READ(1, buff);
CHECKED_READ(4, &len);
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
if (buff[0] > CHUNK_FM && buff[0] <= CHUNK_MISC_CD && !(PicoAHW & PAHW_MCD))
if (buff[0] > CHUNK_FM && buff[0] <= CHUNK_MISC_CD && !(PicoIn.AHW & PAHW_MCD))
R_ERROR_RETURN("cd chunk in non CD state?");
switch (buff[0])
@ -723,7 +723,7 @@ void *PicoTmpStateSave(void)
memcpy(&t->video, &Pico.video, sizeof(Pico.video));
#ifndef NO_32X
if (PicoAHW & PAHW_32X) {
if (PicoIn.AHW & PAHW_32X) {
memcpy(&t->t32x.p32x, &Pico32x, sizeof(Pico32x));
memcpy(t->t32x.dram, Pico32xMem->dram, sizeof(Pico32xMem->dram));
memcpy(t->t32x.pal, Pico32xMem->pal, sizeof(Pico32xMem->pal));
@ -746,7 +746,7 @@ void PicoTmpStateRestore(void *data)
Pico.m.dirtyPal = 1;
#ifndef NO_32X
if (PicoAHW & PAHW_32X) {
if (PicoIn.AHW & PAHW_32X) {
memcpy(&Pico32x, &t->t32x.p32x, sizeof(Pico32x));
memcpy(Pico32xMem->dram, t->t32x.dram, sizeof(Pico32xMem->dram));
memcpy(Pico32xMem->pal, t->t32x.pal, sizeof(Pico32xMem->pal));

View file

@ -109,7 +109,7 @@ static void DmaSlow(int len, unsigned int source)
base = (u16 *)PicoMem.ram;
mask = 0xffff;
}
else if (PicoAHW & PAHW_MCD)
else if (PicoIn.AHW & PAHW_MCD)
{
u8 r3 = Pico_mcd->s68k_regs[3];
elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", r3);
@ -346,8 +346,8 @@ static NOINLINE void CommandChange(void)
static void DrawSync(int blank_on)
{
if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) &&
!PicoSkipFrame && Pico.est.DrawScanline <= Pico.m.scanline) {
if (Pico.m.scanline < 224 && !(PicoIn.opt & POPT_ALT_RENDERER) &&
!PicoIn.skipFrame && Pico.est.DrawScanline <= Pico.m.scanline) {
//elprintf(EL_ANOMALY, "sync");
PicoDrawSync(Pico.m.scanline, blank_on);
}
@ -376,7 +376,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
pvid->pending=0;
}
if (!(pvid->status & SR_VB) && !(PicoOpt&POPT_DIS_VDP_FIFO))
if (!(pvid->status & SR_VB) && !(PicoIn.opt&POPT_DIS_VDP_FIFO))
{
int use = pvid->type == 1 ? 2 : 1;
pvid->lwrite_cnt -= use;

View file

@ -104,17 +104,17 @@ void z80_reset(void)
*/
#ifdef FAST_Z80SP
// drZ80 is locked in single bank
drz80_sp_base = (PicoAHW & PAHW_SMS) ? 0xc000 : 0x0000;
drz80_sp_base = (PicoIn.AHW & PAHW_SMS) ? 0xc000 : 0x0000;
drZ80.Z80SP_BASE = z80_read_map[drz80_sp_base >> Z80_MEM_SHIFT] << 1;
#endif
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
drZ80.Z80SP = drZ80.Z80SP_BASE + 0xdff0; // simulate BIOS
// XXX: since we use direct SP pointer, it might make sense to force it to RAM,
// but we'll rely on built-in stack protection for now
#endif
#ifdef _USE_CZ80
Cz80_Reset(&CZ80);
if (PicoAHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
Cz80_Set_Reg(&CZ80, CZ80_SP, 0xdff0);
#endif
}