X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2F940ctl.c;h=f217dea6bb02d76086c958a7f01c4042bb267330;hb=e1cd546fc7ec6f3c83a5b0f50e2d4ea93b139e3c;hp=9498858b8a9937d5e9a6cacc979b5a66da395b73;hpb=31a77bded36b72459ab1e203f48c8760c83435ed;p=libpicofe.git diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index 9498858..f217dea 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -14,9 +14,10 @@ #include "gp2x.h" #include "emu.h" #include "menu.h" -#include "mp3.h" +#include "../common/mp3.h" #include "../common/arm_utils.h" #include "../common/menu.h" +#include "../common/emu.h" #include "../../Pico/PicoInt.h" #include "../../Pico/sound/ym2612.h" #include "../../Pico/sound/mix.h" @@ -32,7 +33,7 @@ _940_ctl_t *shared_ctl = 0; unsigned char *mp3_mem = 0; #define MP3_SIZE_MAX (0x400000 + 0x800000) // 12M -#define CODE940_FILE "pico940.bin" +#define CODE940_FILE "pico940_v2.bin" int crashed_940 = 0; @@ -50,22 +51,12 @@ static FILE *loaded_mp3 = 0; } /* these will be managed locally on our side */ -extern int *ym2612_dacen; -extern INT32 *ym2612_dacout; static UINT8 *REGS = 0; /* we will also keep local copy of regs for savestates and such */ static INT32 *addr_A1; /* address line A1 */ static int dacen; static INT32 dacout; static UINT8 ST_address; /* address register */ -static UINT8 ST_status; /* status flag */ -static UINT8 ST_mode; /* mode CSM / 3SLOT */ -static int ST_TA; /* timer a */ -static int ST_TAC; /* timer a maxval */ -static int ST_TAT; /* timer a ticker */ -static UINT8 ST_TB; /* timer b */ -static int ST_TBC; /* timer b maxval */ -static int ST_TBT; /* timer b ticker */ static int writebuff_ptr = 0; @@ -83,16 +74,16 @@ static int set_timers( int v ) /* b2 = timer enable a */ /* b1 = load b */ /* b0 = load a */ - change = (ST_mode ^ v) & 0xc0; - ST_mode = v; + change = (ym2612_st->mode ^ v) & 0xc0; + ym2612_st->mode = v; /* reset Timer b flag */ if( v & 0x20 ) - ST_status &= ~2; + ym2612_st->status &= ~2; /* reset Timer a flag */ if( v & 0x10 ) - ST_status &= ~1; + ym2612_st->status &= ~1; return change; } @@ -138,30 +129,30 @@ int YM2612Write_940(unsigned int a, unsigned int v) switch( addr ) { case 0x24: { // timer A High 8 - int TAnew = (ST_TA & 0x03)|(((int)v)<<2); - if(ST_TA != TAnew) { + int TAnew = (ym2612_st->TA & 0x03)|(((int)v)<<2); + if (ym2612_st->TA != TAnew) { // we should reset ticker only if new value is written. Outrun requires this. - ST_TA = TAnew; - ST_TAC = (1024-TAnew)*18; - ST_TAT = 0; + ym2612_st->TA = TAnew; + ym2612_st->TAC = (1024-TAnew)*18; + ym2612_st->TAT = 0; } return 0; } case 0x25: { // timer A Low 2 - int TAnew = (ST_TA & 0x3fc)|(v&3); - if(ST_TA != TAnew) { - ST_TA = TAnew; - ST_TAC = (1024-TAnew)*18; - ST_TAT = 0; + int TAnew = (ym2612_st->TA & 0x3fc)|(v&3); + if (ym2612_st->TA != TAnew) { + ym2612_st->TA = TAnew; + ym2612_st->TAC = (1024-TAnew)*18; + ym2612_st->TAT = 0; } return 0; } case 0x26: // timer B - if(ST_TB != v) { - ST_TB = v; - ST_TBC = (256-v)<<4; - ST_TBC *= 18; - ST_TBT = 0; + if (ym2612_st->TB != v) { + ym2612_st->TB = v; + ym2612_st->TBC = (256-v)<<4; + ym2612_st->TBC *= 18; + ym2612_st->TBT = 0; } return 0; case 0x27: /* mode, timer control */ @@ -228,38 +219,6 @@ int YM2612Write_940(unsigned int a, unsigned int v) return 0; // cause the engine to do updates once per frame only } -UINT8 YM2612Read_940(void) -{ - return ST_status; -} - - -int YM2612PicoTick_940(int n) -{ - //int ret = 0; - - // timer A - if(ST_mode & 0x01 && (ST_TAT+=64*n) >= ST_TAC) { - ST_TAT -= ST_TAC; - if(ST_mode & 0x04) ST_status |= 1; - // CSM mode total level latch and auto key on -/* FIXME - if(ST_mode & 0x80) { - CSMKeyControll( &(ym2612_940->CH[2]) ); // Vectorman2, etc. - ret = 1; - } -*/ - } - - // timer B - if(ST_mode & 0x02 && (ST_TBT+=64*n) >= ST_TBC) { - ST_TBT -= ST_TBC; - if(ST_mode & 0x08) ST_status |= 2; - } - - return 0; -} - #define CHECK_BUSY(job) \ (gp2x_memregs[0x3b46>>1] & (1<<(job-1))) @@ -338,12 +297,14 @@ void YM2612PicoStateLoad_940(void) static void internal_reset(void) { writebuff_ptr = 0; - ST_mode = 0; - ST_status = 0; /* normal mode */ - ST_TA = 0; - ST_TAC = 0; - ST_TB = 0; - ST_TBC = 0; + ym2612_st->mode = 0; + ym2612_st->status = 0; /* normal mode */ + ym2612_st->TA = 0; + ym2612_st->TAC = 0; + ym2612_st->TAT = 0; + ym2612_st->TB = 0; + ym2612_st->TBC = 0; + ym2612_st->TBT = 0; dacen = 0; dacout = 0; ST_address= 0; @@ -473,7 +434,7 @@ void YM2612Init_940(int baseclock, int rate) void YM2612ResetChip_940(void) { - printf("YM2612ResetChip_940()\n"); + //printf("YM2612ResetChip_940()\n"); if (shared_data == NULL) { printf("YM2612ResetChip_940: reset before init?\n"); return; @@ -532,9 +493,8 @@ void mp3_update(int *buffer, int length, int stereo) int length_mp3; int cdda_on; - // not data track, CDC is reading, playback was started, track not ended - cdda_on = !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1) && - loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len; + // playback was started, track not ended + cdda_on = loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len; if (!cdda_on) return; @@ -648,18 +608,17 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 int mp3_get_offset(void) { - int offs1024 = 0; + unsigned int offs1024 = 0; int cdda_on; - cdda_on = (PicoMCD & 1) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && + cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1) && loaded_mp3; if (cdda_on) { offs1024 = shared_ctl->mp3_offs << 7; - offs1024 /= shared_ctl->mp3_len; - offs1024 <<= 3; + offs1024 /= shared_ctl->mp3_len >> 3; } - printf("offs1024=%i (%i/%i)\n", offs1024, shared_ctl->mp3_offs, shared_ctl->mp3_len); + printf("offs1024=%u (%i/%i)\n", offs1024, shared_ctl->mp3_offs, shared_ctl->mp3_len); return offs1024; }