From: notaz Date: Wed, 18 Oct 2017 23:38:20 +0000 (+0300) Subject: rearrange globals X-Git-Tag: v1.93~33 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93f9619ed819dee07948416c98ca2f1c70a22666;p=picodrive.git rearrange globals scripted find/replace gives slightly better code on ARM, less unnecessary asm, ~400 bytes saved --- diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index 27ff9812..3f174a03 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -26,7 +26,7 @@ void drc_cmn_init(void) tcache, DRC_TCACHE_SIZE, ret); #ifdef __arm__ - if (PicoOpt & POPT_EN_DRC) + if (PicoIn.opt & POPT_EN_DRC) { static int test_done; if (!test_done) diff --git a/pico/32x/32x.c b/pico/32x/32x.c index 1c166cee..c10e1486 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -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(); diff --git a/pico/32x/memory.c b/pico/32x/memory.c index f3b70067..399c8bd1 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -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); diff --git a/pico/cart.c b/pico/cart.c index f17ce5e7..3148f36d 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -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; diff --git a/pico/carthw/svp/svp.c b/pico/carthw/svp/svp.c index 8861de04..c50eb850 100644 --- a/pico/carthw/svp/svp.c +++ b/pico/carthw/svp/svp.c @@ -30,8 +30,9 @@ #include #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; } diff --git a/pico/cd/gfx.c b/pico/cd/gfx.c index a2c97be0..e3434e11 100644 --- a/pico/cd/gfx.c +++ b/pico/cd/gfx.c @@ -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--) diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 72488343..51d9d403 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -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); } diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 6890b576..22694389 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -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); diff --git a/pico/cd/pcm.c b/pico/cd/pcm.c index 77bfa300..27fb2ac9 100644 --- a/pico/cd/pcm.c +++ b/pico/cd/pcm.c @@ -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; diff --git a/pico/debug.c b/pico/debug.c index 82ae8a55..d4fb575a 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -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(); diff --git a/pico/draw.c b/pico/draw.c index 83010a49..0939f3fe 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -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; } diff --git a/pico/media.c b/pico/media.c index b7fa7f56..f9b053bd 100644 --- a/pico/media.c +++ b/pico/media.c @@ -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: diff --git a/pico/memory.c b/pico/memory.c index e747552f..b49956e3 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -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) diff --git a/pico/memory_arm.S b/pico/memory_arm.S index 87846d6c..bfe8ca10 100644 --- a/pico/memory_arm.S +++ b/pico/memory_arm.S @@ -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 diff --git a/pico/mode4.c b/pico/mode4.c index 37f752bb..8c063857 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -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); diff --git a/pico/patch.c b/pico/patch.c index d534a2c9..c0c5b00f 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -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); diff --git a/pico/pico.c b/pico/pico.c index bf9df268..2e561c61 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -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 { diff --git a/pico/pico.h b/pico/pico.h index f1687f51..be02ef3a 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -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; diff --git a/pico/pico/memory.c b/pico/pico/memory.c index 7c3a6463..ae262076 100644 --- a/pico/pico/memory.c +++ b/pico/pico/memory.c @@ -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; diff --git a/pico/pico/pico.c b/pico/pico/pico.c index d893f9df..077b9b21 100644 --- a/pico/pico/pico.c +++ b/pico/pico/pico.c @@ -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; diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index d2a1d94c..50b8ced1 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -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 diff --git a/pico/pico_int.h b/pico/pico_int.h index f356d40d..fa7979cc 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -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); diff --git a/pico/sek.c b/pico/sek.c index a40e3081..84c048e3 100644 --- a/pico/sek.c +++ b/pico/sek.c @@ -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 diff --git a/pico/sms.c b/pico/sms.c index 9e80c984..748c3265 100644 --- a/pico/sms.c +++ b/pico/sms.c @@ -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; diff --git a/pico/sound/sound.c b/pico/sound/sound.c index a67ebcca..56ffe3f8 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -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<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(); } diff --git a/pico/sound/ym2612.h b/pico/sound/ym2612.h index 73a36a84..a2921b22 100644 --- a/pico/sound/ym2612.h +++ b/pico/sound/ym2612.h @@ -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__ */ diff --git a/pico/state.c b/pico/state.c index 69e8be06..100f4237 100644 --- a/pico/state.c +++ b/pico/state.c @@ -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)); diff --git a/pico/videoport.c b/pico/videoport.c index b5e3f86c..355489e9 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -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; diff --git a/pico/z80if.c b/pico/z80if.c index b69495e7..da2043e4 100644 --- a/pico/z80if.c +++ b/pico/z80if.c @@ -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 } diff --git a/platform/common/config_file.c b/platform/common/config_file.c index e66d4e1c..2d1186d7 100644 --- a/platform/common/config_file.c +++ b/platform/common/config_file.c @@ -266,9 +266,9 @@ static int custom_read(menu_entry *me, const char *var, const char *val) if (*tmp == 'Z' || *tmp == 'z') tmp++; while (*tmp == ' ') tmp++; if (strcasecmp(tmp, "stereo") == 0) { - PicoOpt |= POPT_EN_STEREO; + PicoIn.opt |= POPT_EN_STEREO; } else if (strcasecmp(tmp, "mono") == 0) { - PicoOpt &= ~POPT_EN_STEREO; + PicoIn.opt &= ~POPT_EN_STEREO; } else return 0; return 1; @@ -279,31 +279,31 @@ static int custom_read(menu_entry *me, const char *var, const char *val) { const char *p = val + 5, *end = val + strlen(val); int i; - PicoRegionOverride = PicoAutoRgnOrder = 0; + PicoIn.regionOverride = PicoIn.autoRgnOrder = 0; for (i = 0; p < end && i < 3; i++) { while (*p == ' ') p++; if (p[0] == 'J' && p[1] == 'P') { - PicoAutoRgnOrder |= 1 << (i*4); + PicoIn.autoRgnOrder |= 1 << (i*4); } else if (p[0] == 'U' && p[1] == 'S') { - PicoAutoRgnOrder |= 4 << (i*4); + PicoIn.autoRgnOrder |= 4 << (i*4); } else if (p[0] == 'E' && p[1] == 'U') { - PicoAutoRgnOrder |= 8 << (i*4); + PicoIn.autoRgnOrder |= 8 << (i*4); } while (*p != ' ' && *p != 0) p++; if (*p == 0) break; } } else if (strcasecmp(val, "Auto") == 0) { - PicoRegionOverride = 0; + PicoIn.regionOverride = 0; } else if (strcasecmp(val, "Japan NTSC") == 0) { - PicoRegionOverride = 1; + PicoIn.regionOverride = 1; } else if (strcasecmp(val, "Japan PAL") == 0) { - PicoRegionOverride = 2; + PicoIn.regionOverride = 2; } else if (strcasecmp(val, "USA") == 0) { - PicoRegionOverride = 4; + PicoIn.regionOverride = 4; } else if (strcasecmp(val, "Europe") == 0) { - PicoRegionOverride = 8; + PicoIn.regionOverride = 8; } else return 0; return 1; diff --git a/platform/common/emu.c b/platform/common/emu.c index 85e1ba77..822fec73 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -171,8 +171,8 @@ static const char *find_bios(int *region, const char *cd_fname) ret = emu_read_config(cd_fname, 0); if (!ret) emu_read_config(NULL, 0); - if (PicoRegionOverride) { - *region = PicoRegionOverride; + if (PicoIn.regionOverride) { + *region = PicoIn.regionOverride; lprintf("override region to %s\n", *region != 4 ? (*region == 8 ? "EU" : "JAP") : "USA"); } @@ -266,16 +266,16 @@ static char *emu_make_rom_id(const char *fname) static char id_string[3+0xe*3+0x3*3+0x30*3+3]; int pos, swab = 1; - if (PicoAHW & PAHW_MCD) { + if (PicoIn.AHW & PAHW_MCD) { strcpy(id_string, "CD|"); swab = 0; } - else if (PicoAHW & PAHW_SMS) + else if (PicoIn.AHW & PAHW_SMS) strcpy(id_string, "MS|"); else strcpy(id_string, "MD|"); pos = 3; - if (!(PicoAHW & PAHW_SMS)) { + if (!(PicoIn.AHW & PAHW_SMS)) { pos += extract_text(id_string + pos, media_id_header + 0x80, 0x0e, swab); // serial id_string[pos] = '|'; pos++; pos += extract_text(id_string + pos, media_id_header + 0xf0, 0x03, swab); // region @@ -296,7 +296,7 @@ static char *emu_make_rom_id(const char *fname) // buffer must be at least 150 byte long void emu_get_game_name(char *str150) { - int ret, swab = (PicoAHW & PAHW_MCD) ? 0 : 1; + int ret, swab = (PicoIn.AHW & PAHW_MCD) ? 0 : 1; char *s, *d; ret = extract_text(str150, media_id_header + 0x50, 0x30, swab); // overseas name @@ -315,22 +315,22 @@ static void system_announce(void) const char *sys_name, *tv_standard, *extra = ""; int fps; - if (PicoAHW & PAHW_SMS) { + if (PicoIn.AHW & PAHW_SMS) { sys_name = "Master System"; #ifdef NO_SMS extra = " [no support]"; #endif - } else if (PicoAHW & PAHW_PICO) { + } else if (PicoIn.AHW & PAHW_PICO) { sys_name = "Pico"; - } else if ((PicoAHW & (PAHW_32X|PAHW_MCD)) == (PAHW_32X|PAHW_MCD)) { + } else if ((PicoIn.AHW & (PAHW_32X|PAHW_MCD)) == (PAHW_32X|PAHW_MCD)) { sys_name = "32X + Mega CD"; if ((Pico.m.hardware & 0xc0) == 0x80) sys_name = "32X + Sega CD"; - } else if (PicoAHW & PAHW_MCD) { + } else if (PicoIn.AHW & PAHW_MCD) { sys_name = "Mega CD"; if ((Pico.m.hardware & 0xc0) == 0x80) sys_name = "Sega CD"; - } else if (PicoAHW & PAHW_32X) { + } else if (PicoIn.AHW & PAHW_32X) { sys_name = "32X"; } else { sys_name = "MegaDrive"; @@ -451,7 +451,7 @@ int emu_reload_rom(const char *rom_fname_in) } // make quirks visible in UI - if (PicoQuirks & PQUIRK_FORCE_6BTN) + if (PicoIn.quirks & PQUIRK_FORCE_6BTN) currentConfig.input_dev0 = PICO_INPUT_PAD_6BTN; menu_romload_end(); @@ -470,12 +470,12 @@ int emu_reload_rom(const char *rom_fname_in) PicoSetInputDevice(0, indev); PicoSetInputDevice(1, indev); - PicoOpt |= POPT_DIS_VDP_FIFO; // no VDP fifo timing + PicoIn.opt |= POPT_DIS_VDP_FIFO; // no VDP fifo timing if (movie_data[0xF] >= 'A') { if (movie_data[0x16] & 0x80) { - PicoRegionOverride = 8; + PicoIn.regionOverride = 8; } else { - PicoRegionOverride = 4; + PicoIn.regionOverride = 4; } PicoReset(); // TODO: bits 6 & 5 @@ -486,7 +486,7 @@ int emu_reload_rom(const char *rom_fname_in) else { system_announce(); - PicoOpt &= ~POPT_DIS_VDP_FIFO; + PicoIn.opt &= ~POPT_DIS_VDP_FIFO; } strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1); @@ -603,10 +603,10 @@ void emu_prep_defconfig(void) void emu_set_defconfig(void) { memcpy(¤tConfig, &defaultConfig, sizeof(currentConfig)); - PicoOpt = currentConfig.s_PicoOpt; + PicoIn.opt = currentConfig.s_PicoOpt; PsndRate = currentConfig.s_PsndRate; - PicoRegionOverride = currentConfig.s_PicoRegion; - PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder; + PicoIn.regionOverride = currentConfig.s_PicoRegion; + PicoIn.autoRgnOrder = currentConfig.s_PicoAutoRgnOrder; } int emu_read_config(const char *rom_fname, int no_defaults) @@ -767,20 +767,20 @@ static void update_movie(void) lprintf("END OF MOVIE.\n"); } else { // MXYZ SACB RLDU - PicoPad[0] = ~movie_data[offs] & 0x8f; // ! SCBA RLDU - if(!(movie_data[offs] & 0x10)) PicoPad[0] |= 0x40; // C - if(!(movie_data[offs] & 0x20)) PicoPad[0] |= 0x10; // A - if(!(movie_data[offs] & 0x40)) PicoPad[0] |= 0x20; // B - PicoPad[1] = ~movie_data[offs+1] & 0x8f; // ! SCBA RLDU - if(!(movie_data[offs+1] & 0x10)) PicoPad[1] |= 0x40; // C - if(!(movie_data[offs+1] & 0x20)) PicoPad[1] |= 0x10; // A - if(!(movie_data[offs+1] & 0x40)) PicoPad[1] |= 0x20; // B - PicoPad[0] |= (~movie_data[offs+2] & 0x0A) << 8; // ! MZYX - if(!(movie_data[offs+2] & 0x01)) PicoPad[0] |= 0x0400; // X - if(!(movie_data[offs+2] & 0x04)) PicoPad[0] |= 0x0100; // Z - PicoPad[1] |= (~movie_data[offs+2] & 0xA0) << 4; // ! MZYX - if(!(movie_data[offs+2] & 0x10)) PicoPad[1] |= 0x0400; // X - if(!(movie_data[offs+2] & 0x40)) PicoPad[1] |= 0x0100; // Z + PicoIn.pad[0] = ~movie_data[offs] & 0x8f; // ! SCBA RLDU + if(!(movie_data[offs] & 0x10)) PicoIn.pad[0] |= 0x40; // C + if(!(movie_data[offs] & 0x20)) PicoIn.pad[0] |= 0x10; // A + if(!(movie_data[offs] & 0x40)) PicoIn.pad[0] |= 0x20; // B + PicoIn.pad[1] = ~movie_data[offs+1] & 0x8f; // ! SCBA RLDU + if(!(movie_data[offs+1] & 0x10)) PicoIn.pad[1] |= 0x40; // C + if(!(movie_data[offs+1] & 0x20)) PicoIn.pad[1] |= 0x10; // A + if(!(movie_data[offs+1] & 0x40)) PicoIn.pad[1] |= 0x20; // B + PicoIn.pad[0] |= (~movie_data[offs+2] & 0x0A) << 8; // ! MZYX + if(!(movie_data[offs+2] & 0x01)) PicoIn.pad[0] |= 0x0400; // X + if(!(movie_data[offs+2] & 0x04)) PicoIn.pad[0] |= 0x0100; // Z + PicoIn.pad[1] |= (~movie_data[offs+2] & 0xA0) << 4; // ! MZYX + if(!(movie_data[offs+2] & 0x10)) PicoIn.pad[1] |= 0x0400; // X + if(!(movie_data[offs+2] & 0x40)) PicoIn.pad[1] |= 0x0100; // Z } } @@ -809,9 +809,9 @@ char *emu_get_save_fname(int load, int is_sram, int slot, int *time) if (is_sram) { - strcpy(ext, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); + strcpy(ext, (PicoIn.AHW & PAHW_MCD) ? ".brm" : ".srm"); romfname_ext(saveFname, sizeof(static_buff), - (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext); + (PicoIn.AHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext); if (!load) return saveFname; @@ -885,9 +885,9 @@ int emu_save_load_game(int load, int sram) int sram_size; unsigned char *sram_data; int truncate = 1; - if (PicoAHW & PAHW_MCD) + if (PicoIn.AHW & PAHW_MCD) { - if (PicoOpt & POPT_EN_MCD_RAMCART) { + if (PicoIn.opt & POPT_EN_MCD_RAMCART) { sram_size = 0x12000; sram_data = Pico.sv.data; if (sram_data) @@ -912,7 +912,7 @@ int emu_save_load_game(int load, int sram) ret = fread(sram_data, 1, sram_size, sramFile); ret = ret > 0 ? 0 : -1; fclose(sramFile); - if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART)) + if ((PicoIn.AHW & PAHW_MCD) && (PicoIn.opt&POPT_EN_MCD_RAMCART)) memcpy(Pico_mcd->bram, sram_data, 0x2000); } else { // sram save needs some special processing @@ -974,7 +974,7 @@ void emu_set_fastforward(int set_on) PsndRerate(1); is_on = 0; // mainly to unbreak pcm - if (PicoAHW & PAHW_MCD) + if (PicoIn.AHW & PAHW_MCD) pcd_state_loaded(); } } @@ -1034,11 +1034,11 @@ void run_events_pico(unsigned int events) return; /* handle other input modes */ - if (PicoPad[0] & 1) pico_pen_y--; - if (PicoPad[0] & 2) pico_pen_y++; - if (PicoPad[0] & 4) pico_pen_x--; - if (PicoPad[0] & 8) pico_pen_x++; - PicoPad[0] &= ~0x0f; // release UDLR + if (PicoIn.pad[0] & 1) pico_pen_y--; + if (PicoIn.pad[0] & 2) pico_pen_y++; + if (PicoIn.pad[0] & 4) pico_pen_x--; + if (PicoIn.pad[0] & 8) pico_pen_x++; + PicoIn.pad[0] &= ~0x0f; // release UDLR lim_x = (Pico.video.reg[12]&1) ? 319 : 255; if (pico_pen_y < 8) @@ -1057,7 +1057,7 @@ void run_events_pico(unsigned int events) PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y); } -static void do_turbo(int *pad, int acts) +static void do_turbo(unsigned short *pad, int acts) { static int turbo_pad = 0; static unsigned char turbo_cnt[3] = { 0, 0, 0 }; @@ -1159,13 +1159,13 @@ void emu_update_input(void) pl_actions[0] = actions[IN_BINDTYPE_PLAYER12]; pl_actions[1] = actions[IN_BINDTYPE_PLAYER12] >> 16; - PicoPad[0] = pl_actions[0] & 0xfff; - PicoPad[1] = pl_actions[1] & 0xfff; + PicoIn.pad[0] = pl_actions[0] & 0xfff; + PicoIn.pad[1] = pl_actions[1] & 0xfff; if (pl_actions[0] & 0x7000) - do_turbo(&PicoPad[0], pl_actions[0]); + do_turbo(&PicoIn.pad[0], pl_actions[0]); if (pl_actions[1] & 0x7000) - do_turbo(&PicoPad[1], pl_actions[1]); + do_turbo(&PicoIn.pad[1], pl_actions[1]); events = actions[IN_BINDTYPE_EMU] & PEV_MASK; @@ -1181,7 +1181,7 @@ void emu_update_input(void) events &= ~prev_events; - if (PicoAHW == PAHW_PICO) + if (PicoIn.AHW == PAHW_PICO) run_events_pico(events); if (events) run_events_ui(events); @@ -1202,14 +1202,14 @@ static void mkdir_path(char *path_with_reserve, int pos, const char *name) void emu_cmn_forced_frame(int no_scale, int do_emu) { - int po_old = PicoOpt; + int po_old = PicoIn.opt; memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4); - PicoOpt &= ~POPT_ALT_RENDERER; - PicoOpt |= POPT_ACC_SPRITES; + PicoIn.opt &= ~POPT_ALT_RENDERER; + PicoIn.opt |= POPT_ACC_SPRITES; if (!no_scale) - PicoOpt |= POPT_EN_SOFTSCALE; + PicoIn.opt |= POPT_EN_SOFTSCALE; PicoDrawSetOutFormat(PDF_RGB555, 1); Pico.m.dirtyPal = 1; @@ -1218,7 +1218,7 @@ void emu_cmn_forced_frame(int no_scale, int do_emu) else PicoFrameDrawOnly(); - PicoOpt = po_old; + PicoIn.opt = po_old; } void emu_init(void) @@ -1293,7 +1293,7 @@ void emu_sound_start(void) if (currentConfig.EmuOpt & EOPT_EN_SOUND) { - int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0; + int is_stereo = (PicoIn.opt & POPT_EN_STEREO) ? 1 : 0; PsndRerate(Pico.m.frame_count ? 1 : 0); @@ -1470,9 +1470,9 @@ void emu_loop(void) emu_update_input(); if (skip) { int do_audio = diff > -target_frametime_x3 * 2; - PicoSkipFrame = do_audio ? 1 : 2; + PicoIn.skipFrame = do_audio ? 1 : 2; PicoFrame(); - PicoSkipFrame = 0; + PicoIn.skipFrame = 0; } else { PicoFrame(); diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c index 0f9fa612..bd2b9159 100644 --- a/platform/common/menu_pico.c +++ b/platform/common/menu_pico.c @@ -281,7 +281,7 @@ static void menu_loop_patches(void) // -------------- key config -------------- -// PicoPad[] format: MXYZ SACB RLDU +// PicoIn.pad[] format: MXYZ SACB RLDU me_bind_action me_ctrl_actions[] = { { "UP ", 0x0001 }, @@ -410,10 +410,10 @@ static const char h_scfx[] = "Emulate scale/rotate ASIC chip for graphics effe static menu_entry e_menu_cd_options[] = { mee_onoff_h("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, EOPT_EN_CD_LEDS, h_cdleds), - mee_onoff_h("CDDA audio", MA_CDOPT_CDDA, PicoOpt, POPT_EN_MCD_CDDA, h_cdda), - mee_onoff_h("PCM audio", MA_CDOPT_PCM, PicoOpt, POPT_EN_MCD_PCM, h_cdpcm), - mee_onoff_h("SaveRAM cart", MA_CDOPT_SAVERAM, PicoOpt, POPT_EN_MCD_RAMCART, h_srcart), - mee_onoff_h("Scale/Rot. fx", MA_CDOPT_SCALEROT_CHIP, PicoOpt, POPT_EN_MCD_GFX, h_scfx), + mee_onoff_h("CDDA audio", MA_CDOPT_CDDA, PicoIn.opt, POPT_EN_MCD_CDDA, h_cdda), + mee_onoff_h("PCM audio", MA_CDOPT_PCM, PicoIn.opt, POPT_EN_MCD_PCM, h_cdpcm), + mee_onoff_h("SaveRAM cart", MA_CDOPT_SAVERAM, PicoIn.opt, POPT_EN_MCD_RAMCART, h_srcart), + mee_onoff_h("Scale/Rot. fx", MA_CDOPT_SCALEROT_CHIP, PicoIn.opt, POPT_EN_MCD_GFX, h_scfx), mee_end, }; @@ -464,9 +464,9 @@ static const char h_sh2cycles[] = "Cycles/millisecond (similar to DOSBox)\n" static menu_entry e_menu_32x_options[] = { - mee_onoff_h ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X, h_32x_enable), + mee_onoff_h ("32X enabled", MA_32XOPT_ENABLE_32X, PicoIn.opt, POPT_EN_32X, h_32x_enable), mee_enum ("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, renderer_names32x), - mee_onoff_h ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM, h_pwm), + mee_onoff_h ("PWM sound", MA_32XOPT_PWM, PicoIn.opt, POPT_EN_PWM, h_pwm), mee_cust_h ("Master SH2 cycles", MA_32XOPT_MSH2_CYCLES, mh_opt_sh2cycles, mgn_opt_sh2cycles, h_sh2cycles), mee_cust_h ("Slave SH2 cycles", MA_32XOPT_SSH2_CYCLES, mh_opt_sh2cycles, mgn_opt_sh2cycles, h_sh2cycles), mee_end, @@ -491,15 +491,15 @@ static int menu_loop_32x_options(int id, int keys) static menu_entry e_menu_adv_options[] = { mee_onoff ("SRAM/BRAM saves", MA_OPT_SRAM_STATES, currentConfig.EmuOpt, EOPT_EN_SRAM), - mee_onoff ("Disable sprite limit", MA_OPT2_NO_SPRITE_LIM, PicoOpt, POPT_DIS_SPRITE_LIM), - mee_onoff ("Emulate Z80", MA_OPT2_ENABLE_Z80, PicoOpt, POPT_EN_Z80), - mee_onoff ("Emulate YM2612 (FM)", MA_OPT2_ENABLE_YM2612, PicoOpt, POPT_EN_FM), - mee_onoff ("Emulate SN76496 (PSG)", MA_OPT2_ENABLE_SN76496,PicoOpt, POPT_EN_PSG), + mee_onoff ("Disable sprite limit", MA_OPT2_NO_SPRITE_LIM, PicoIn.opt, POPT_DIS_SPRITE_LIM), + mee_onoff ("Emulate Z80", MA_OPT2_ENABLE_Z80, PicoIn.opt, POPT_EN_Z80), + mee_onoff ("Emulate YM2612 (FM)", MA_OPT2_ENABLE_YM2612, PicoIn.opt, POPT_EN_FM), + mee_onoff ("Emulate SN76496 (PSG)", MA_OPT2_ENABLE_SN76496,PicoIn.opt, POPT_EN_PSG), mee_onoff ("gzip savestates", MA_OPT2_GZIP_STATES, currentConfig.EmuOpt, EOPT_GZIP_SAVES), mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG), - mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET), + mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoIn.opt, POPT_DIS_IDLE_DET), mee_onoff ("Disable frame limiter", MA_OPT2_NO_FRAME_LIMIT,currentConfig.EmuOpt, EOPT_NO_FRMLIMIT), - mee_onoff ("Enable dynarecs", MA_OPT2_DYNARECS, PicoOpt, POPT_EN_DRC), + mee_onoff ("Enable dynarecs", MA_OPT2_DYNARECS, PicoIn.opt, POPT_EN_DRC), mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC), MENU_OPTIONS_ADV mee_end, @@ -556,15 +556,15 @@ static int sndrate_prevnext(int rate, int dir) i += dir ? 1 : -1; if (i > 4) { - if (!(PicoOpt & POPT_EN_STEREO)) { - PicoOpt |= POPT_EN_STEREO; + if (!(PicoIn.opt & POPT_EN_STEREO)) { + PicoIn.opt |= POPT_EN_STEREO; return rates[0]; } return rates[4]; } if (i < 0) { - if (PicoOpt & POPT_EN_STEREO) { - PicoOpt &= ~POPT_EN_STEREO; + if (PicoIn.opt & POPT_EN_STEREO) { + PicoIn.opt &= ~POPT_EN_STEREO; return rates[4]; } return rates[0]; @@ -579,24 +579,24 @@ static void region_prevnext(int right) int i; if (right) { - if (!PicoRegionOverride) { + if (!PicoIn.regionOverride) { for (i = 0; i < 6; i++) - if (rgn_orders[i] == PicoAutoRgnOrder) break; - if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1]; - else PicoRegionOverride=1; + if (rgn_orders[i] == PicoIn.autoRgnOrder) break; + if (i < 5) PicoIn.autoRgnOrder = rgn_orders[i+1]; + else PicoIn.regionOverride=1; } else - PicoRegionOverride <<= 1; - if (PicoRegionOverride > 8) - PicoRegionOverride = 8; + PicoIn.regionOverride <<= 1; + if (PicoIn.regionOverride > 8) + PicoIn.regionOverride = 8; } else { - if (!PicoRegionOverride) { + if (!PicoIn.regionOverride) { for (i = 0; i < 6; i++) - if (rgn_orders[i] == PicoAutoRgnOrder) break; - if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1]; + if (rgn_orders[i] == PicoIn.autoRgnOrder) break; + if (i > 0) PicoIn.autoRgnOrder = rgn_orders[i-1]; } else - PicoRegionOverride >>= 1; + PicoIn.regionOverride >>= 1; } } @@ -667,7 +667,7 @@ static const char *mgn_opt_sound(int id, int *offs) { const char *str2; *offs = -8; - str2 = (PicoOpt & POPT_EN_STEREO) ? "stereo" : "mono"; + str2 = (PicoIn.opt & POPT_EN_STEREO) ? "stereo" : "mono"; sprintf(static_buff, "%5iHz %s", PsndRate, str2); return static_buff; } @@ -676,7 +676,7 @@ static const char *mgn_opt_region(int id, int *offs) { static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" }; static const char *names_short[] = { "", " JP", " JP", " US", " EU" }; - int code = PicoRegionOverride; + int code = PicoIn.regionOverride; int u, i = 0; *offs = -6; @@ -689,7 +689,7 @@ static const char *mgn_opt_region(int id, int *offs) } else { strcpy(static_buff, "Auto:"); for (u = 0; u < 3; u++) { - code = (PicoAutoRgnOrder >> u*4) & 0xf; + code = (PicoIn.autoRgnOrder >> u*4) & 0xf; for (i = 0; code; code >>= 1, i++) ; strcat(static_buff, names_short[i]); @@ -887,9 +887,9 @@ static void debug_menu_loop(void) if (inp & PBTN_MA2) pv->debug_p ^= PVD_KILL_32X; if (inp & PBTN_MOK) { PsndOut = NULL; // just in case - PicoSkipFrame = 1; + PicoIn.skipFrame = 1; PicoFrame(); - PicoSkipFrame = 0; + PicoIn.skipFrame = 0; while (inp & PBTN_MOK) inp = in_menu_wait_any(NULL, -1); } break; @@ -1023,7 +1023,7 @@ static int main_menu_handler(int id, int keys) } break; case MA_MAIN_CHANGE_CD: - if (PicoAHW & PAHW_MCD) { + if (PicoIn.AHW & PAHW_MCD) { // if cd is loaded, cdd_unload() triggers eject and // returns 1, else we'll select and load new CD here if (!cdd_unload()) @@ -1081,7 +1081,7 @@ void menu_loop(void) me_enable(e_menu_main, MA_MAIN_SAVE_STATE, PicoGameLoaded); me_enable(e_menu_main, MA_MAIN_LOAD_STATE, PicoGameLoaded); me_enable(e_menu_main, MA_MAIN_RESET_GAME, PicoGameLoaded); - me_enable(e_menu_main, MA_MAIN_CHANGE_CD, PicoAHW & PAHW_MCD); + me_enable(e_menu_main, MA_MAIN_CHANGE_CD, PicoIn.AHW & PAHW_MCD); me_enable(e_menu_main, MA_MAIN_PATCHES, PicoPatches != NULL); menu_enter(PicoGameLoaded); @@ -1168,7 +1168,7 @@ void menu_update_msg(const char *msg) /* hidden options for config engine only */ static menu_entry e_menu_hidden[] = { - mee_onoff("Accurate sprites", MA_OPT_ACC_SPRITES, PicoOpt, 0x080), + mee_onoff("Accurate sprites", MA_OPT_ACC_SPRITES, PicoIn.opt, 0x080), mee_onoff("autoload savestates", MA_OPT_AUTOLOAD_SAVE, g_autostateld_opt, 1), mee_end, }; diff --git a/platform/common/mp3.c b/platform/common/mp3.c index b2bcaf40..6c823ad4 100644 --- a/platform/common/mp3.c +++ b/platform/common/mp3.c @@ -115,7 +115,7 @@ void mp3_start_play(void *f_, int pos1024) cdda_out_pos = 0; decoder_active = 0; - if (!(PicoOpt & POPT_EN_MCD_CDDA) || f == NULL) // cdda disabled or no file? + if (!(PicoIn.opt & POPT_EN_MCD_CDDA) || f == NULL) // cdda disabled or no file? return; fseek(f, 0, SEEK_END); diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 30c6651b..96a49cf5 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -145,7 +145,7 @@ static void blit(const char *fps, const char *notice) { int emu_opt = currentConfig.EmuOpt; - if (PicoOpt&0x10) + if (PicoIn.opt&0x10) { int lines_flags = 224; // 8bit fast renderer @@ -154,7 +154,7 @@ static void blit(const char *fps, const char *notice) vidConvCpyRGB565(localPal, Pico.cram, 0x40); } // a hack for VR - if (PicoAHW & PAHW_SVP) + if (PicoIn.AHW & PAHW_SVP) memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328); if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000; if (currentConfig.EmuOpt&0x4000) @@ -196,7 +196,7 @@ static void blit(const char *fps, const char *notice) if (emu_opt & 2) osd_text(OSD_FPS_X, h, fps); } - if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD)) + if ((emu_opt & 0x400) && (PicoIn.AHW & PAHW_MCD)) cd_leds(); } @@ -220,7 +220,7 @@ static void vidResetMode(void) { giz_screen = fb_lock(1); - if (PicoOpt&0x10) { + if (PicoIn.opt&0x10) { } else if (currentConfig.EmuOpt&0x80) { PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetCallbacks(EmuScanBegin16, NULL); @@ -228,7 +228,7 @@ static void vidResetMode(void) PicoDrawSetOutFormat(PDF_NONE, 0); PicoDrawSetCallbacks(EmuScanBegin8, NULL); } - if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) { + if ((PicoIn.opt&0x10) || !(currentConfig.EmuOpt&0x80)) { // setup pal for 8-bit modes localPal[0xc0] = 0x0600; localPal[0xd0] = 0xc000; @@ -278,21 +278,21 @@ static void updateSound(int len) static void SkipFrame(void) { - PicoSkipFrame=1; + PicoIn.skipFrame=1; PicoFrame(); - PicoSkipFrame=0; + PicoIn.skipFrame=0; } /* forced frame to front buffer */ void pemu_forced_frame(int no_scale, int do_emu) { - int po_old = PicoOpt; + int po_old = PicoIn.opt; int eo_old = currentConfig.EmuOpt; - PicoOpt &= ~0x10; - PicoOpt |= POPT_ACC_SPRITES; + PicoIn.opt &= ~0x10; + PicoIn.opt |= POPT_ACC_SPRITES; if (!no_scale) - PicoOpt |= POPT_EN_SOFTSCALE; + PicoIn.opt |= POPT_EN_SOFTSCALE; currentConfig.EmuOpt |= 0x80; if (giz_screen == NULL) @@ -306,7 +306,7 @@ void pemu_forced_frame(int no_scale, int do_emu) fb_unlock(); giz_screen = NULL; - PicoOpt = po_old; + PicoIn.opt = po_old; currentConfig.EmuOpt = eo_old; } @@ -350,12 +350,12 @@ static void RunEvents(unsigned int which) } if (which & 0x0400) // switch renderer { - if (PicoOpt&0x10) { PicoOpt&=~0x10; currentConfig.EmuOpt |= 0x80; } - else { PicoOpt|= 0x10; currentConfig.EmuOpt &= ~0x80; } + if (PicoIn.opt&0x10) { PicoIn.opt&=~0x10; currentConfig.EmuOpt |= 0x80; } + else { PicoIn.opt|= 0x10; currentConfig.EmuOpt &= ~0x80; } vidResetMode(); - if (PicoOpt&0x10) { + if (PicoIn.opt&0x10) { strcpy(noticeMsg, " 8bit fast renderer"); } else if (currentConfig.EmuOpt&0x80) { strcpy(noticeMsg, "16bit accurate renderer"); @@ -392,11 +392,11 @@ static void updateKeys(void) keys &= CONFIGURABLE_KEYS; - PicoPad[0] = allActions[0] & 0xfff; - PicoPad[1] = allActions[1] & 0xfff; + PicoIn.pad[0] = allActions[0] & 0xfff; + PicoIn.pad[1] = allActions[1] & 0xfff; - if (allActions[0] & 0x7000) emu_DoTurbo(&PicoPad[0], allActions[0]); - if (allActions[1] & 0x7000) emu_DoTurbo(&PicoPad[1], allActions[1]); + if (allActions[0] & 0x7000) emu_DoTurbo(&PicoIn.pad[0], allActions[0]); + if (allActions[1] & 0x7000) emu_DoTurbo(&PicoIn.pad[1], allActions[1]); events = (allActions[0] | allActions[1]) >> 16; @@ -455,8 +455,8 @@ void pemu_loop(void) // make sure we are in correct mode vidResetMode(); - if (currentConfig.scaling) PicoOpt|=0x4000; - else PicoOpt&=~0x4000; + if (currentConfig.scaling) PicoIn.opt|=0x4000; + else PicoIn.opt&=~0x4000; Pico.m.dirtyPal = 1; oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc; @@ -466,17 +466,17 @@ void pemu_loop(void) reset_timing = 1; // prepare CD buffer - if (PicoAHW & PAHW_MCD) PicoCDBufferInit(); + if (PicoIn.AHW & PAHW_MCD) PicoCDBufferInit(); // prepare sound stuff PsndOut = NULL; if (currentConfig.EmuOpt & 4) { int ret, snd_excess_add, stereo; - if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) { + if (PsndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) { PsndRerate(Pico.m.frame_count ? 1 : 0); } - stereo=(PicoOpt&8)>>3; + stereo=(PicoIn.opt&8)>>3; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; snd_cbuf_samples = (PsndRate< 22050) co = 11; - if (PicoOpt&8) shift++; + if (PicoIn.opt&8) shift++; if (audio_skew < 0) { adj = -((-audio_skew) >> shift); if (audio_skew > -(6<>=1; @@ -674,7 +674,7 @@ void pemu_loop(void) } - if (PicoAHW & PAHW_MCD) PicoCDBufferFree(); + if (PicoIn.AHW & PAHW_MCD) PicoCDBufferFree(); if (PsndOut != NULL) { PsndOut = snd_cbuff = NULL; diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index dd6740a3..232701ad 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -501,7 +501,7 @@ static void draw_savestate_bg(int slot) } if (file) { - if (PicoAHW & 1) { + if (PicoIn.AHW & 1) { PicoCdLoadStateGfx(file); } else { areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file @@ -703,7 +703,7 @@ menu_entry ctrlopt_entries[] = { "Player 1", MB_NONE, MA_CTRL_PLAYER1, NULL, 0, 0, 0, 1, 0 }, { "Player 2", MB_NONE, MA_CTRL_PLAYER2, NULL, 0, 0, 0, 1, 0 }, { "Emulator controls", MB_NONE, MA_CTRL_EMU, NULL, 0, 0, 0, 1, 0 }, - { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 }, + { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoIn.opt, 0x020, 0, 0, 1, 1 }, { "Turbo rate", MB_RANGE, MA_CTRL_TURBO_RATE, ¤tConfig.turbo_rate, 0, 1, 30, 1, 1 }, { "Done", MB_NONE, MA_CTRL_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -756,7 +756,7 @@ static void kc_sel_loop(void) if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_PLAY) { - int is_6button = PicoOpt & 0x020; + int is_6button = PicoIn.opt & 0x020; switch (selected_id) { case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return; @@ -779,12 +779,12 @@ menu_entry cdopt_entries[] = { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, - { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, - { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, + { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoIn.opt, 0x0800, 0, 0, 1, 1 }, + { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoIn.opt, 0x0400, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, - { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, - { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoOpt, 0x1000, 0, 0, 1, 1 }, - { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoOpt, 0x2000, 0, 0, 1, 1 }, + { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoIn.opt, 0x8000, 0, 0, 1, 1 }, + { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoIn.opt, 0x1000, 0, 0, 1, 1 }, + { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoIn.opt, 0x2000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -927,16 +927,16 @@ static void cd_menu_loop_options(void) menu_entry opt2_entries[] = { - { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 }, - { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 }, - { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 }, - { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 }, + { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoIn.opt, 0x40000, 0, 0, 1, 1 }, + { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoIn.opt, 0x00004, 0, 0, 1, 1 }, + { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoIn.opt, 0x00001, 0, 0, 1, 1 }, + { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoIn.opt, 0x00002, 0, 0, 1, 1 }, { "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, ¤tConfig.EmuOpt, 0x8000, 0, 0, 1, 1 }, { "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1, 1 }, { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1, 1 }, - { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 }, - { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 }, + { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoIn.opt, 0x20000, 0, 0, 1, 1 }, + { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoIn.opt, 0x80000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1001,7 +1001,7 @@ static void amenu_loop_options(void) menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, - { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, + { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoIn.opt, 0x080, 0, 0, 0, 1 }, { "Scanline mode (faster)", MB_ONOFF, MA_OPT_INTERLACED, ¤tConfig.EmuOpt, 0x4000, 0, 0, 1, 1 }, { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x0001, 0, 3, 1, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1, 1 }, @@ -1030,7 +1030,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para switch (entry->id) { case MA_OPT_RENDERER: - if (PicoOpt&0x10) + if (PicoIn.opt&0x10) str = " 8bit fast"; else if (currentConfig.EmuOpt&0x80) str = "16bit accurate"; @@ -1045,11 +1045,11 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para text_out16(x, y, "Frameskip %s", str24); break; case MA_OPT_SOUND_QUALITY: - str = (PicoOpt&0x08)?"stereo":"mono"; + str = (PicoIn.opt&0x08)?"stereo":"mono"; text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str); break; case MA_OPT_REGION: - text_out16(x, y, "Region: %s", me_region_name(PicoRegionOverride, PicoAutoRgnOrder)); + text_out16(x, y, "Region: %s", me_region_name(PicoIn.regionOverride, PicoIn.autoRgnOrder)); break; case MA_OPT_CONFIRM_STATES: switch ((currentConfig.EmuOpt >> 9) & 5) { @@ -1108,31 +1108,31 @@ static void region_prevnext(int right) static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 }; int i; if (right) { - if (!PicoRegionOverride) { + if (!PicoIn.regionOverride) { for (i = 0; i < 6; i++) - if (rgn_orders[i] == PicoAutoRgnOrder) break; - if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1]; - else PicoRegionOverride=1; + if (rgn_orders[i] == PicoIn.autoRgnOrder) break; + if (i < 5) PicoIn.autoRgnOrder = rgn_orders[i+1]; + else PicoIn.regionOverride=1; } - else PicoRegionOverride<<=1; - if (PicoRegionOverride > 8) PicoRegionOverride = 8; + else PicoIn.regionOverride<<=1; + if (PicoIn.regionOverride > 8) PicoIn.regionOverride = 8; } else { - if (!PicoRegionOverride) { + if (!PicoIn.regionOverride) { for (i = 0; i < 6; i++) - if (rgn_orders[i] == PicoAutoRgnOrder) break; - if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1]; + if (rgn_orders[i] == PicoIn.autoRgnOrder) break; + if (i > 0) PicoIn.autoRgnOrder = rgn_orders[i-1]; } - else PicoRegionOverride>>=1; + else PicoIn.regionOverride>>=1; } } static void menu_options_save(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; } - if (!(PicoOpt & 0x20)) { + if (!(PicoIn.opt & 0x20)) { // unbind XYZ MODE, just in case unbind_action(0xf00); } @@ -1162,28 +1162,28 @@ static int menu_loop_options(void) switch (selected_id) { case MA_OPT_RENDERER: if (inp & PBTN_LEFT) { - if ((PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) { - PicoOpt&= ~0x10; + if ((PicoIn.opt&0x10) || !(currentConfig.EmuOpt &0x80)) { + PicoIn.opt&= ~0x10; currentConfig.EmuOpt |= 0x80; } } else { - if (!(PicoOpt&0x10) || (currentConfig.EmuOpt &0x80)) { - PicoOpt|= 0x10; + if (!(PicoIn.opt&0x10) || (currentConfig.EmuOpt &0x80)) { + PicoIn.opt|= 0x10; currentConfig.EmuOpt &= ~0x80; } } break; case MA_OPT_SOUND_QUALITY: if ((inp & PBTN_RIGHT) && PsndRate == 44100 && - !(PicoOpt&0x08)) + !(PicoIn.opt&0x08)) { PsndRate = 11025; - PicoOpt |= 8; + PicoIn.opt |= 8; } else if ((inp & PBTN_LEFT) && PsndRate == 11025 && - (PicoOpt&0x08) && !(PicoAHW&1)) + (PicoIn.opt&0x08) && !(PicoIn.AHW&1)) { PsndRate = 44100; - PicoOpt &= ~8; + PicoIn.opt &= ~8; } else PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT); break; diff --git a/platform/gp2x/940ctl.c b/platform/gp2x/940ctl.c index ff79c88a..99c25d64 100644 --- a/platform/gp2x/940ctl.c +++ b/platform/gp2x/940ctl.c @@ -424,7 +424,7 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty) int mp3dec_decode(FILE *f, int *file_pos, int file_len) { - if (!(PicoOpt & POPT_EXT_FM)) { + if (!(PicoIn.opt & POPT_EXT_FM)) { //mp3_update_local(buffer, length, stereo); return 0; } @@ -456,7 +456,7 @@ int mp3dec_decode(FILE *f, int *file_pos, int file_len) int mp3dec_start(FILE *f, int fpos_start) { - if (!(PicoOpt & POPT_EXT_FM)) { + if (!(PicoIn.opt & POPT_EXT_FM)) { //mp3_start_play_local(f, pos); return -1; } diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 01fd1629..3b3a234b 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -70,7 +70,7 @@ void pemu_prep_defconfig(void) void pemu_validate_config(void) { if (gp2x_dev_id != GP2X_DEV_GP2X) - PicoOpt &= ~POPT_EXT_FM; + PicoIn.opt &= ~POPT_EXT_FM; if (gp2x_dev_id != GP2X_DEV_WIZ) currentConfig.EmuOpt &= ~EOPT_WIZ_TEAR_FIX; @@ -83,7 +83,7 @@ void pemu_validate_config(void) static int get_renderer(void) { - if (PicoAHW & PAHW_32X) + if (PicoIn.AHW & PAHW_32X) return currentConfig.renderer32x; else return currentConfig.renderer; @@ -92,14 +92,14 @@ static int get_renderer(void) static void change_renderer(int diff) { int *r; - if (PicoAHW & PAHW_32X) + if (PicoIn.AHW & PAHW_32X) r = ¤tConfig.renderer32x; else r = ¤tConfig.renderer; *r += diff; // 8bpp fast is not there (yet?) - if ((PicoAHW & PAHW_SMS) && *r == RT_8BIT_FAST) + if ((PicoIn.AHW & PAHW_SMS) && *r == RT_8BIT_FAST) (*r)++; if (*r >= RT_COUNT) @@ -109,7 +109,7 @@ static void change_renderer(int diff) } #define is_16bit_mode() \ - (get_renderer() == RT_16BIT || (PicoAHW & PAHW_32X)) + (get_renderer() == RT_16BIT || (PicoIn.AHW & PAHW_32X)) static void (*osd_text)(int x, int y, const char *text); @@ -201,7 +201,7 @@ static void draw_pico_ptr(void) x = pico_pen_x + PICO_PEN_ADJUST_X; y = pico_pen_y + PICO_PEN_ADJUST_Y; - if (!(Pico.video.reg[12]&1) && !(PicoOpt & POPT_DIS_32C_BORDER)) + if (!(Pico.video.reg[12]&1) && !(PicoIn.opt & POPT_DIS_32C_BORDER)) x += 32; if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) { @@ -231,7 +231,7 @@ static int EmuScanEnd16_rot(unsigned int num) if ((num & 3) != 3) return 0; rotated_blit16(g_screen_ptr, rot_buff, num + 1, - !(Pico.video.reg[12] & 1) && !(PicoOpt & POPT_EN_SOFTSCALE)); + !(Pico.video.reg[12] & 1) && !(PicoIn.opt & POPT_EN_SOFTSCALE)); return 0; } @@ -342,7 +342,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) int emu_opt = currentConfig.EmuOpt; int ret; - if (PicoAHW & PAHW_32X) + if (PicoIn.AHW & PAHW_32X) ; // nothing to do else if (get_renderer() == RT_8BIT_FAST) { @@ -354,11 +354,11 @@ void pemu_finalize_frame(const char *fps, const char *notice) gp2x_video_setpalette(localPal, ret); } // a hack for VR - if (PicoAHW & PAHW_SVP) + if (PicoIn.AHW & PAHW_SVP) memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328); // do actual copy vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8, - !(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER)); + !(Pico.video.reg[12] & 1), !(PicoIn.opt & POPT_DIS_32C_BORDER)); } else if (get_renderer() == RT_8BIT_ACC) { @@ -375,9 +375,9 @@ void pemu_finalize_frame(const char *fps, const char *notice) osd_text(4, osd_y, notice); if (emu_opt & EOPT_SHOW_FPS) osd_text(osd_fps_x, osd_y, fps); - if ((PicoAHW & PAHW_MCD) && (emu_opt & EOPT_EN_CD_LEDS)) + if ((PicoIn.AHW & PAHW_MCD) && (emu_opt & EOPT_EN_CD_LEDS)) draw_cd_leds(); - if (PicoAHW & PAHW_PICO) + if (PicoIn.AHW & PAHW_PICO) draw_pico_ptr(); } @@ -472,7 +472,7 @@ static void vid_reset_mode(void) int gp2x_mode = 16; int renderer = get_renderer(); - PicoOpt &= ~POPT_ALT_RENDERER; + PicoIn.opt &= ~POPT_ALT_RENDERER; emu_scan_begin = NULL; emu_scan_end = NULL; @@ -487,7 +487,7 @@ static void vid_reset_mode(void) gp2x_mode = 8; break; case RT_8BIT_FAST: - PicoOpt |= POPT_ALT_RENDERER; + PicoIn.opt |= POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_NONE, 0); vidcpyM2 = vidcpy_m2; gp2x_mode = 8; @@ -497,7 +497,7 @@ static void vid_reset_mode(void) break; } - if (PicoAHW & PAHW_32X) { + if (PicoIn.AHW & PAHW_32X) { // Wiz 16bit is an exception, uses line rendering due to rotation mess if (renderer == RT_16BIT && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) { PicoDrawSetOutFormat(PDF_RGB555, 1); @@ -510,7 +510,7 @@ static void vid_reset_mode(void) } if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) { - if ((PicoAHW & PAHW_32X) || renderer == RT_16BIT) { + if ((PicoIn.AHW & PAHW_32X) || renderer == RT_16BIT) { emu_scan_begin = EmuScanBegin16_rot; emu_scan_end = EmuScanEnd16_rot; } @@ -549,12 +549,12 @@ static void vid_reset_mode(void) Pico.m.dirtyPal = 1; - PicoOpt &= ~POPT_EN_SOFTSCALE; + PicoIn.opt &= ~POPT_EN_SOFTSCALE; if (currentConfig.scaling == EOPT_SCALE_SW) - PicoOpt |= POPT_EN_SOFTSCALE; + PicoIn.opt |= POPT_EN_SOFTSCALE; // palette converters for 8bit modes - make_local_pal = (PicoAHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md; + make_local_pal = (PicoIn.AHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md; } void emu_video_mode_change(int start_line, int line_count, int is_32cols) @@ -569,10 +569,10 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) osd_y = 232; /* set up hwscaling here */ - PicoOpt &= ~POPT_DIS_32C_BORDER; + PicoIn.opt &= ~POPT_DIS_32C_BORDER; if (is_32cols && currentConfig.scaling == EOPT_SCALE_HW) { scalex = 256; - PicoOpt |= POPT_DIS_32C_BORDER; + PicoIn.opt |= POPT_DIS_32C_BORDER; osd_fps_x = OSD_FPS_X - 64; } @@ -607,7 +607,7 @@ void plat_video_toggle_renderer(int change, int is_menu_call) vid_reset_mode(); rendstatus_old = -1; - if (PicoAHW & PAHW_32X) + if (PicoIn.AHW & PAHW_32X) emu_status_msg(renderer_names32x[get_renderer()]); else emu_status_msg(renderer_names[get_renderer()]); @@ -626,7 +626,7 @@ static void RunEventsPico(unsigned int events) if (ret > 35000) { if (pdown_frames++ > 5) - PicoPad[0] |= 0x20; + PicoIn.pad[0] |= 0x20; pico_pen_x = px; pico_pen_y = py; @@ -654,7 +654,7 @@ void plat_update_volume(int has_changed, int is_up) gp2x_soc_t soc; soc = soc_detect(); - if ((PicoOpt & POPT_EN_STEREO) && soc == SOCID_MMSP2) + if ((PicoIn.opt & POPT_EN_STEREO) && soc == SOCID_MMSP2) need_low_volume = 1; if (has_changed) diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index 7d7ac93d..8e1da968 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -13,7 +13,7 @@ const char *men_scaling_opts[] = { "OFF", "software", "hardware", NULL }; mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), #define MENU_OPTIONS_ADV \ - mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \ + mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoIn.opt, POPT_EXT_FM), \ static menu_entry e_menu_adv_options[]; diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 7896ffbf..33ede0d2 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1115,13 +1115,13 @@ void *retro_get_memory_data(unsigned type) switch(type) { case RETRO_MEMORY_SAVE_RAM: - if (PicoAHW & PAHW_MCD) + if (PicoIn.AHW & PAHW_MCD) data = Pico_mcd->bram; else data = Pico.sv.data; break; case RETRO_MEMORY_SYSTEM_RAM: - if (PicoAHW & PAHW_SMS) + if (PicoIn.AHW & PAHW_SMS) data = PicoMem.zram; else data = PicoMem.ram; @@ -1142,7 +1142,7 @@ size_t retro_get_memory_size(unsigned type) switch(type) { case RETRO_MEMORY_SAVE_RAM: - if (PicoAHW & PAHW_MCD) + if (PicoIn.AHW & PAHW_MCD) // bram return 0x2000; @@ -1157,7 +1157,7 @@ size_t retro_get_memory_size(unsigned type) return (sum != 0) ? Pico.sv.size : 0; case RETRO_MEMORY_SYSTEM_RAM: - if (PicoAHW & PAHW_SMS) + if (PicoIn.AHW & PAHW_SMS) return 0x2000; else return sizeof(PicoMem.ram); @@ -1228,38 +1228,38 @@ static void update_variables(void) var.key = "picodrive_sprlim"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "enabled") == 0) - PicoOpt |= POPT_DIS_SPRITE_LIM; + PicoIn.opt |= POPT_DIS_SPRITE_LIM; else - PicoOpt &= ~POPT_DIS_SPRITE_LIM; + PicoIn.opt &= ~POPT_DIS_SPRITE_LIM; } var.value = NULL; var.key = "picodrive_ramcart"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "enabled") == 0) - PicoOpt |= POPT_EN_MCD_RAMCART; + PicoIn.opt |= POPT_EN_MCD_RAMCART; else - PicoOpt &= ~POPT_EN_MCD_RAMCART; + PicoIn.opt &= ~POPT_EN_MCD_RAMCART; } - OldPicoRegionOverride = PicoRegionOverride; + OldPicoRegionOverride = PicoIn.regionOverride; var.value = NULL; var.key = "picodrive_region"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "Auto") == 0) - PicoRegionOverride = 0; + PicoIn.regionOverride = 0; else if (strcmp(var.value, "Japan NTSC") == 0) - PicoRegionOverride = 1; + PicoIn.regionOverride = 1; else if (strcmp(var.value, "Japan PAL") == 0) - PicoRegionOverride = 2; + PicoIn.regionOverride = 2; else if (strcmp(var.value, "US") == 0) - PicoRegionOverride = 4; + PicoIn.regionOverride = 4; else if (strcmp(var.value, "Europe") == 0) - PicoRegionOverride = 8; + PicoIn.regionOverride = 8; } // Update region, fps and sound flags if needed - if (Pico.rom && PicoRegionOverride != OldPicoRegionOverride) + if (Pico.rom && PicoIn.regionOverride != OldPicoRegionOverride) { PicoDetectRegion(); PicoLoopPrepare(); @@ -1300,14 +1300,14 @@ static void update_variables(void) var.key = "picodrive_drc"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "enabled") == 0) - PicoOpt |= POPT_EN_DRC; + PicoIn.opt |= POPT_EN_DRC; else - PicoOpt &= ~POPT_EN_DRC; + PicoIn.opt &= ~POPT_EN_DRC; } #endif #ifdef _3DS if(!ctr_svchack_successful) - PicoOpt &= ~POPT_EN_DRC; + PicoIn.opt &= ~POPT_EN_DRC; #endif } @@ -1321,11 +1321,11 @@ void retro_run(void) input_poll_cb(); - PicoPad[0] = PicoPad[1] = 0; + PicoIn.pad[0] = PicoIn.pad[1] = 0; for (pad = 0; pad < 2; pad++) for (i = 0; i < RETRO_PICO_MAP_LEN; i++) if (input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, i)) - PicoPad[pad] |= retro_pico_map[i]; + PicoIn.pad[pad] |= retro_pico_map[i]; PicoPatchApply(); PicoFrame(); @@ -1355,7 +1355,7 @@ void retro_init(void) sceBlock = getVMBlock(); #endif - PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 + PicoIn.opt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX | POPT_EN_32X|POPT_EN_PWM | POPT_ACC_SPRITES|POPT_DIS_32C_BORDER; @@ -1363,10 +1363,10 @@ void retro_init(void) #ifdef _3DS if (ctr_svchack_successful) #endif - PicoOpt |= POPT_EN_DRC; + PicoIn.opt |= POPT_EN_DRC; #endif PsndRate = 44100; - PicoAutoRgnOrder = 0x184; // US, EU, JP + PicoIn.autoRgnOrder = 0x184; // US, EU, JP vout_width = 320; vout_height = 240; diff --git a/platform/linux/emu.c b/platform/linux/emu.c index aee8d44c..ddde8dab 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -29,10 +29,8 @@ void pemu_prep_defconfig(void) void pemu_validate_config(void) { - extern int PicoOpt; -// PicoOpt &= ~POPT_EXT_FM; #ifndef __arm__ - PicoOpt &= ~POPT_EN_DRC; + PicoIn.opt &= ~POPT_EN_DRC; #endif } @@ -68,7 +66,7 @@ static void draw_cd_leds(void) void pemu_finalize_frame(const char *fps, const char *notice) { - if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) { + if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X)) { unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width; unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8; unsigned short *pal = Pico.est.HighPal; @@ -86,7 +84,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) if (currentConfig.EmuOpt & EOPT_SHOW_FPS) emu_osd_text16(g_screen_width - 60, g_screen_height - 8, fps); } - if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) + if ((PicoIn.AHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) draw_cd_leds(); } @@ -94,22 +92,22 @@ static void apply_renderer(void) { switch (currentConfig.renderer) { case RT_16BIT: - PicoOpt &= ~POPT_ALT_RENDERER; + PicoIn.opt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); break; case RT_8BIT_ACC: - PicoOpt &= ~POPT_ALT_RENDERER; + PicoIn.opt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_8BIT, 0); PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328); break; case RT_8BIT_FAST: - PicoOpt |= POPT_ALT_RENDERER; + PicoIn.opt |= POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_NONE, 0); break; } - if (PicoAHW & PAHW_32X) + if (PicoIn.AHW & PAHW_32X) PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); } diff --git a/platform/pandora/plat.c b/platform/pandora/plat.c index 2e9457a4..a2e70eb8 100644 --- a/platform/pandora/plat.c +++ b/platform/pandora/plat.c @@ -168,7 +168,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) emu_osd_text16(2, g_osd_y, notice); if (fps && fps[0] && (currentConfig.EmuOpt & EOPT_SHOW_FPS)) emu_osd_text16(g_osd_fps_x, g_osd_y, fps); - if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) + if ((PicoIn.AHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) draw_cd_leds(); } diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 8373a21a..8f77f395 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -309,7 +309,7 @@ static void blitscreen_clut(void) blit_16bit_mode = 0; } - if ((PicoOpt&0x10) && Pico.m.dirtyPal) + if ((PicoIn.opt&0x10) && Pico.m.dirtyPal) do_pal_update(0, 0); sceKernelDcacheWritebackAll(); @@ -395,7 +395,7 @@ static void dbg_text(void) /* called after rendering is done, but frame emulation is not finished */ void blit1(void) { - if (PicoOpt&0x10) + if (PicoIn.opt&0x10) { int i; unsigned char *pd; @@ -406,7 +406,7 @@ void blit1(void) memset32((int *)pd, 0xe0e0e0e0, 320/4); } - if (PicoAHW & PAHW_PICO) + if (PicoIn.AHW & PAHW_PICO) draw_pico_ptr(); blitscreen_clut(); @@ -424,7 +424,7 @@ static void blit2(const char *fps, const char *notice, int lagging_behind) //dbg_text(); - if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD)) + if ((emu_opt & 0x400) && (PicoIn.AHW & PAHW_MCD)) cd_leds(); if (currentConfig.EmuOpt & 0x2000) { // want vsync @@ -571,10 +571,10 @@ void pemu_sound_start(void) samples_made = samples_done = 0; - if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) { + if (PsndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) { PsndRerate(Pico.m.frame_count ? 1 : 0); } - stereo=(PicoOpt&8)>>3; + stereo=(PicoIn.opt&8)>>3; samples_block = Pico.m.pal ? SOUND_BLOCK_SIZE_PAL : SOUND_BLOCK_SIZE_NTSC; if (PsndRate <= 22050) samples_block /= 2; @@ -597,7 +597,7 @@ void pemu_sound_start(void) samples_made = samples_block; // send 1 empty block first.. PsndOut = sndBuffer; PsndRate_old = PsndRate; - PicoOpt_old = PicoOpt; + PicoOpt_old = PicoIn.opt; pal_old = Pico.m.pal; } } @@ -664,20 +664,20 @@ static void writeSound(int len) static void SkipFrame(void) { - PicoSkipFrame=1; + PicoIn.skipFrame=1; PicoFrame(); - PicoSkipFrame=0; + PicoIn.skipFrame=0; } void pemu_forced_frame(int no_scale, int do_emu) { - int po_old = PicoOpt; + int po_old = PicoIn.opt; int eo_old = currentConfig.EmuOpt; - PicoOpt &= ~POPT_ALT_RENDERER; - PicoOpt |= POPT_ACC_SPRITES; + PicoIn.opt &= ~POPT_ALT_RENDERER; + PicoIn.opt |= POPT_ACC_SPRITES; if (!no_scale) - PicoOpt |= POPT_EN_SOFTSCALE; + PicoIn.opt |= POPT_EN_SOFTSCALE; currentConfig.EmuOpt |= 0x80; vidResetMode(); @@ -692,7 +692,7 @@ void pemu_forced_frame(int no_scale, int do_emu) blit1(); sceGuSync(0,0); - PicoOpt = po_old; + PicoIn.opt = po_old; currentConfig.EmuOpt = eo_old; } @@ -703,7 +703,7 @@ static void RunEventsPico(unsigned int events, unsigned int keys) if (pico_inp_mode != 0) { - PicoPad[0] &= ~0x0f; // release UDLR + PicoIn.pad[0] &= ~0x0f; // release UDLR if (keys & PBTN_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; } if (keys & PBTN_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; } if (keys & PBTN_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; } @@ -754,12 +754,12 @@ static void RunEvents(unsigned int which) } if (which & 0x0400) // switch renderer { - if (PicoOpt&0x10) { PicoOpt&=~0x10; currentConfig.EmuOpt |= 0x80; } - else { PicoOpt|= 0x10; currentConfig.EmuOpt &= ~0x80; } + if (PicoIn.opt&0x10) { PicoIn.opt&=~0x10; currentConfig.EmuOpt |= 0x80; } + else { PicoIn.opt|= 0x10; currentConfig.EmuOpt &= ~0x80; } vidResetMode(); - if (PicoOpt & POPT_ALT_RENDERER) + if (PicoIn.opt & POPT_ALT_RENDERER) emu_status_msg("fast renderer"); else if (currentConfig.EmuOpt&0x80) emu_status_msg("accurate renderer"); @@ -794,11 +794,11 @@ static void updateKeys(void) keys &= CONFIGURABLE_KEYS; - PicoPad[0] = allActions[0] & 0xfff; - PicoPad[1] = allActions[1] & 0xfff; + PicoIn.pad[0] = allActions[0] & 0xfff; + PicoIn.pad[1] = allActions[1] & 0xfff; - if (allActions[0] & 0x7000) emu_DoTurbo(&PicoPad[0], allActions[0]); - if (allActions[1] & 0x7000) emu_DoTurbo(&PicoPad[1], allActions[1]); + if (allActions[0] & 0x7000) emu_DoTurbo(&PicoIn.pad[0], allActions[0]); + if (allActions[1] & 0x7000) emu_DoTurbo(&PicoIn.pad[1], allActions[1]); events = (allActions[0] | allActions[1]) >> 16; @@ -809,7 +809,7 @@ static void updateKeys(void) events &= ~prevEvents; - if (PicoAHW == PAHW_PICO) + if (PicoIn.AHW == PAHW_PICO) RunEventsPico(events, keys); if (events) RunEvents(events); if (movie_data) emu_updateMovie(); @@ -861,7 +861,7 @@ void pemu_loop(void) target_frametime = Pico.m.pal ? (1000000<<8)/50 : (1000000<<8)/60+1; reset_timing = 1; - if (PicoAHW & PAHW_MCD) { + if (PicoIn.AHW & PAHW_MCD) { // prepare CD buffer PicoCDBufferInit(); // mp3... @@ -986,7 +986,7 @@ void pemu_loop(void) updateKeys(); - if (!(PicoOpt&0x10)) + if (!(PicoIn.opt&0x10)) EmuScanPrepare(); PicoFrame(); @@ -1019,7 +1019,7 @@ void pemu_loop(void) emu_set_fastforward(0); - if (PicoAHW & PAHW_MCD) PicoCDBufferFree(); + if (PicoIn.AHW & PAHW_MCD) PicoCDBufferFree(); if (PsndOut != NULL) { pemu_sound_stop(); @@ -1039,7 +1039,7 @@ void pemu_loop(void) void emu_HandleResume(void) { - if (!(PicoAHW & PAHW_MCD)) return; + if (!(PicoIn.AHW & PAHW_MCD)) return; // reopen first CD track if (Pico_mcd->TOC.Tracks[0].F != NULL) diff --git a/platform/psp/menu.c b/platform/psp/menu.c index f01f0ae5..de63d345 100644 --- a/platform/psp/menu.c +++ b/platform/psp/menu.c @@ -506,7 +506,7 @@ static void draw_savestate_bg(int slot) } if (file) { - if (PicoAHW & PAHW_MCD) { + if (PicoIn.AHW & PAHW_MCD) { PicoCdLoadStateGfx(file); } else { areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file @@ -708,7 +708,7 @@ menu_entry ctrlopt_entries[] = { "Player 1", MB_NONE, MA_CTRL_PLAYER1, NULL, 0, 0, 0, 1, 0 }, { "Player 2", MB_NONE, MA_CTRL_PLAYER2, NULL, 0, 0, 0, 1, 0 }, { "Emulator controls", MB_NONE, MA_CTRL_EMU, NULL, 0, 0, 0, 1, 0 }, - { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 }, + { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoIn.opt, 0x020, 0, 0, 1, 1 }, { "Turbo rate", MB_RANGE, MA_CTRL_TURBO_RATE, ¤tConfig.turbo_rate, 0, 1, 30, 1, 1 }, { "Done", MB_NONE, MA_CTRL_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -763,7 +763,7 @@ static void kc_sel_loop(void) if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_CIRCLE) { - int is_6button = PicoOpt & POPT_6BTN_PAD; + int is_6button = PicoIn.opt & POPT_6BTN_PAD; switch (selected_id) { case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return; @@ -786,12 +786,12 @@ menu_entry cdopt_entries[] = { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, - { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, - { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, + { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoIn.opt, 0x0800, 0, 0, 1, 1 }, + { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoIn.opt, 0x0400, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, - { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, - { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoOpt, 0x1000, 0, 0, 1, 1 }, - { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoOpt, 0x2000, 0, 0, 1, 1 }, + { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoIn.opt, 0x8000, 0, 0, 1, 1 }, + { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoIn.opt, 0x1000, 0, 0, 1, 1 }, + { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoIn.opt, 0x2000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1115,14 +1115,14 @@ static void dispmenu_loop_options(void) menu_entry opt2_entries[] = { - { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 }, - { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 }, - { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 }, - { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496, &PicoOpt, 0x00002, 0, 0, 1, 1 }, + { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoIn.opt, 0x40000, 0, 0, 1, 1 }, + { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoIn.opt, 0x00004, 0, 0, 1, 1 }, + { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoIn.opt, 0x00001, 0, 0, 1, 1 }, + { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496, &PicoIn.opt, 0x00002, 0, 0, 1, 1 }, { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x00008, 0, 0, 1, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x00020, 0, 0, 1, 1 }, { "Status line in main menu", MB_ONOFF, MA_OPT2_STATUS_LINE, ¤tConfig.EmuOpt, 0x20000, 0, 0, 1, 1 }, - { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 }, + { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoIn.opt, 0x80000, 0, 0, 1, 1 }, { "Disable frame limiter", MB_ONOFF, MA_OPT2_NO_FRAME_LIMIT, ¤tConfig.EmuOpt, 0x40000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1182,7 +1182,7 @@ static void amenu_loop_options(void) menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, - { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, + { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoIn.opt, 0x080, 0, 0, 0, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x0004, 0, 0, 1, 1 }, @@ -1211,7 +1211,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para switch (entry->id) { case MA_OPT_RENDERER: - if (PicoOpt & 0x10) + if (PicoIn.opt & 0x10) str = "fast"; else if (currentConfig.EmuOpt & 0x80) str = "accurate"; @@ -1226,11 +1226,11 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para text_out16(x, y, "Frameskip %s", str24); break; case MA_OPT_SOUND_QUALITY: - str = (PicoOpt&0x08)?"stereo":"mono"; + str = (PicoIn.opt&0x08)?"stereo":"mono"; text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str); break; case MA_OPT_REGION: - text_out16(x, y, "Region: %s", me_region_name(PicoRegionOverride, PicoAutoRgnOrder)); + text_out16(x, y, "Region: %s", me_region_name(PicoIn.regionOverride, PicoIn.autoRgnOrder)); break; case MA_OPT_CONFIRM_STATES: switch ((currentConfig.EmuOpt >> 9) & 5) { @@ -1291,31 +1291,31 @@ static void region_prevnext(int right) static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 }; int i; if (right) { - if (!PicoRegionOverride) { + if (!PicoIn.regionOverride) { for (i = 0; i < 6; i++) - if (rgn_orders[i] == PicoAutoRgnOrder) break; - if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1]; - else PicoRegionOverride=1; + if (rgn_orders[i] == PicoIn.autoRgnOrder) break; + if (i < 5) PicoIn.autoRgnOrder = rgn_orders[i+1]; + else PicoIn.regionOverride=1; } - else PicoRegionOverride<<=1; - if (PicoRegionOverride > 8) PicoRegionOverride = 8; + else PicoIn.regionOverride<<=1; + if (PicoIn.regionOverride > 8) PicoIn.regionOverride = 8; } else { - if (!PicoRegionOverride) { + if (!PicoIn.regionOverride) { for (i = 0; i < 6; i++) - if (rgn_orders[i] == PicoAutoRgnOrder) break; - if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1]; + if (rgn_orders[i] == PicoIn.autoRgnOrder) break; + if (i > 0) PicoIn.autoRgnOrder = rgn_orders[i-1]; } - else PicoRegionOverride>>=1; + else PicoIn.regionOverride>>=1; } } static void menu_options_save(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; } - if (!(PicoOpt & POPT_6BTN_PAD)) { + if (!(PicoIn.opt & POPT_6BTN_PAD)) { // unbind XYZ MODE, just in case unbind_action(0xf00); } @@ -1344,11 +1344,11 @@ static int menu_loop_options(void) if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) { switch (selected_id) { case MA_OPT_RENDERER: - if ((PicoOpt & 0x10) || !(currentConfig.EmuOpt & 0x80)) { - PicoOpt &= ~0x10; + if ((PicoIn.opt & 0x10) || !(currentConfig.EmuOpt & 0x80)) { + PicoIn.opt &= ~0x10; currentConfig.EmuOpt |= 0x80; } else { - PicoOpt |= 0x10; + PicoIn.opt |= 0x10; currentConfig.EmuOpt &= ~0x80; } break; diff --git a/platform/psp/mp3.c b/platform/psp/mp3.c index 6cffc629..4ea3bdd7 100644 --- a/platform/psp/mp3.c +++ b/platform/psp/mp3.c @@ -466,7 +466,7 @@ int mp3_get_offset(void) // 0-1023 unsigned int offs1024 = 0; int cdda_on; - cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && + cdda_on = (PicoIn.AHW & PAHW_MCD) && (PicoIn.opt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1) && mp3_handle >= 0; if (cdda_on) { diff --git a/platform/win32/main.c b/platform/win32/main.c index cf2523a2..eb55e0e0 100644 --- a/platform/win32/main.c +++ b/platform/win32/main.c @@ -131,7 +131,7 @@ static HBITMAP png2hb(const char *fname, int is_480) static void PrepareForROM(void) { unsigned char *rom_data = NULL; - int i, ret, show = PicoAHW & PAHW_PICO; + int i, ret, show = PicoIn.AHW & PAHW_PICO; PicoGetInternal(PI_ROM, (pint_ret_t *) &rom_data); EnableMenuItem(mmain, 2, MF_BYPOSITION|(show ? MF_ENABLED : MF_GRAYED)); diff --git a/platform/win32/plat.c b/platform/win32/plat.c index e8f53898..a9cceb79 100644 --- a/platform/win32/plat.c +++ b/platform/win32/plat.c @@ -123,7 +123,7 @@ static int sndbuff[2*44100/50/2 + 4]; static void update_sound(int len) { /* avoid writing audio when lagging behind to prevent audio lag */ - if (PicoSkipFrame != 2) + if (PicoIn.skipFrame != 2) DSoundUpdate(sndbuff, (currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) ? 0 : 1); } @@ -139,7 +139,7 @@ void pemu_sound_start(void) { PsndRerate(0); - ret = DSoundInit(FrameWnd, PsndRate, (PicoOpt & POPT_EN_STEREO) ? 1 : 0, PsndLen); + ret = DSoundInit(FrameWnd, PsndRate, (PicoIn.opt & POPT_EN_STEREO) ? 1 : 0, PsndLen); if (ret != 0) { lprintf("dsound init failed\n"); return; diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c index 7e57383a..297a1969 100644 --- a/tools/mkoffsets.c +++ b/tools/mkoffsets.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) DUMP_EST(f, Pico); DUMP_EST(f, PicoMem_vram); DUMP_EST(f, PicoMem_cram); - DUMP_EST(f, PicoOpt); + DUMP_EST(f, PicoIn.opt); DUMP_EST(f, Draw2FB); DUMP_EST(f, HighPal); DUMP_PMEM(f, vram);