X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2F940ctl.c;h=9498858b8a9937d5e9a6cacc979b5a66da395b73;hb=31a77bded36b72459ab1e203f48c8760c83435ed;hp=6c52cca25a561ceae9a423d3022025462b67a445;hpb=fb88e614316e559b8c2e419da97619218c046b2f;p=libpicofe.git diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index 6c52cca..9498858 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -14,9 +14,11 @@ #include "gp2x.h" #include "emu.h" #include "menu.h" -#include "asmutils.h" #include "mp3.h" +#include "../common/arm_utils.h" +#include "../common/menu.h" #include "../../Pico/PicoInt.h" +#include "../../Pico/sound/ym2612.h" #include "../../Pico/sound/mix.h" /* we will need some gp2x internals here */ @@ -29,7 +31,8 @@ static _940_data_t *shared_data = 0; _940_ctl_t *shared_ctl = 0; unsigned char *mp3_mem = 0; -#define MP3_SIZE_MAX (0x1000000 - 4*640*480) +#define MP3_SIZE_MAX (0x400000 + 0x800000) // 12M +#define CODE940_FILE "pico940.bin" int crashed_940 = 0; @@ -49,11 +52,10 @@ static FILE *loaded_mp3 = 0; /* these will be managed locally on our side */ extern int *ym2612_dacen; extern INT32 *ym2612_dacout; -extern void *ym2612_regs; - 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 *addr_A1; /* address line A1 */ + +static int dacen; static INT32 dacout; static UINT8 ST_address; /* address register */ static UINT8 ST_status; /* status flag */ @@ -111,19 +113,19 @@ int YM2612Write_940(unsigned int a, unsigned int v) switch( a ) { case 0: /* address port 0 */ - if (!addr_A1 && ST_address == v) + if (!*addr_A1 && ST_address == v) return 0; /* address already selected, don't send this command to 940 */ ST_address = v; /* don't send DAC or timer related address changes to 940 */ - if (!addr_A1 && (v & 0xf0) == 0x20 && + if (!*addr_A1 && (v & 0xf0) == 0x20 && (v == 0x24 || v == 0x25 || v == 0x26 || v == 0x2a)) return 0; - addr_A1 = 0; + *addr_A1 = 0; upd = 0; break; case 1: /* data port 0 */ - if (addr_A1 != 0) { + if (*addr_A1 != 0) { return 0; /* verified on real YM2608 */ } @@ -182,15 +184,15 @@ int YM2612Write_940(unsigned int a, unsigned int v) break; case 2: /* address port 1 */ - if (addr_A1 && ST_address == v) + if (*addr_A1 && ST_address == v) return 0; ST_address = v; - addr_A1 = 1; + *addr_A1 = 1; upd = 0; break; case 3: /* data port 1 */ - if (addr_A1 != 1) { + if (*addr_A1 != 1) { return 0; /* verified on real YM2608 */ } @@ -311,7 +313,7 @@ static void add_job_940(int job) void YM2612PicoStateLoad_940(void) { - int i, old_A1 = addr_A1; + int i, old_A1 = *addr_A1; /* make sure JOB940_PICOSTATELOAD gets done before next JOB940_YM2612UPDATEONE */ add_job_940(JOB940_PICOSTATELOAD); @@ -329,7 +331,7 @@ void YM2612PicoStateLoad_940(void) YM2612Write_940(3, REGS[i|0x100]); } - addr_A1 = old_A1; + *addr_A1 = old_A1; } @@ -342,7 +344,9 @@ static void internal_reset(void) ST_TAC = 0; ST_TB = 0; ST_TBC = 0; - dacen = 0; + dacen = 0; + dacout = 0; + ST_address= 0; } @@ -360,7 +364,7 @@ void sharedmem_init(void) shared_data = (_940_data_t *) (shared_mem+0x100000); /* this area must not get buffered on either side */ shared_ctl = (_940_ctl_t *) (shared_mem+0x200000); - mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000); + mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2400000); if (mp3_mem == MAP_FAILED) { printf("mmap(mp3_mem) failed with %i\n", errno); @@ -409,15 +413,15 @@ void YM2612Init_940(int baseclock, int rate) binpath[1023] = 0; for (i = strlen(binpath); i > 0; i--) if (binpath[i] == '/') { binpath[i] = 0; break; } - strcat(binpath, "/code940.bin"); + strcat(binpath, "/" CODE940_FILE); fp = fopen(binpath, "rb"); if(!fp) { - memset(gp2x_screen, 0, 320*240); - gp2x_text_out8(10, 100, "failed to open required file:"); - gp2x_text_out8(10, 110, "code940.bin"); - gp2x_video_flip(); + memset(gp2x_screen, 0, 320*240*2); + text_out16(10, 100, "failed to open required file:"); + text_out16(10, 110, CODE940_FILE); + gp2x_video_flip2(); printf("failed to open %s\n", binpath); exit(1); } @@ -437,7 +441,11 @@ void YM2612Init_940(int baseclock, int rate) memset(shared_data, 0, sizeof(*shared_data)); memset(shared_ctl, 0, sizeof(*shared_ctl)); + /* cause local ym2612 to init REGS */ + YM2612Init_(baseclock, rate); + REGS = YM2612GetRegs(); + addr_A1 = (INT32 *) (REGS + 0x200); ym2612_dacen = &dacen; ym2612_dacout = &dacout; @@ -599,7 +607,6 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 if (loaded_mp3 != f) { - // printf("loading mp3... "); fflush(stdout); if (PicoMessage != NULL) { fseek(f, 0, SEEK_END); @@ -608,8 +615,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 } fseek(f, 0, SEEK_SET); fread(mp3_mem, 1, MP3_SIZE_MAX, f); - // if (feof(f)) printf("done.\n"); - // else printf("done. mp3 too large, not all data loaded.\n"); + if (!feof(f)) printf("Warning: mp3 was too large, not all data loaded.\n"); shared_ctl->mp3_len = ftell(f); loaded_mp3 = f;