X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2F940ctl.c;h=075b82783793ac2e445033f4ce277d397afcd068;hb=c7a4ff64287b12487c7e9cc13ce3b7d2aa6e1f06;hp=f2e98a9954ecb47240703bb5e7f5a2984678f69f;hpb=79cad122559536a7831b121c5ec798847102d0de;p=libpicofe.git diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index f2e98a9..075b827 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -1,3 +1,6 @@ +// Code for communication with ARM940 and control of it. +// (c) Copyright 2007, Grazvydas "notaz" Ignotas + #include #include #include @@ -11,8 +14,9 @@ #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/mix.h" @@ -26,7 +30,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; @@ -285,7 +290,7 @@ static void wait_busy_940(int job) gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]); printf("last lr: %08x, lastjob: %i\n", shared_ctl->last_lr, shared_ctl->lastjob); - strcpy(menuErrorMsg, "940 crashed."); + strcpy(menuErrorMsg, "940 crashed, too much overclock?"); engineState = PGS_Menu; crashed_940 = 1; } @@ -310,6 +315,12 @@ void YM2612PicoStateLoad_940(void) { int i, old_A1 = addr_A1; + /* make sure JOB940_PICOSTATELOAD gets done before next JOB940_YM2612UPDATEONE */ + add_job_940(JOB940_PICOSTATELOAD); + if (CHECK_BUSY(JOB940_PICOSTATELOAD)) wait_busy_940(JOB940_PICOSTATELOAD); + + writebuff_ptr = 0; + // feed all the registers and update internal state for(i = 0; i < 0x100; i++) { YM2612Write_940(0, i); @@ -321,8 +332,6 @@ void YM2612PicoStateLoad_940(void) } addr_A1 = old_A1; - -// add_job_940(JOB940_PICOSTATELOAD); } @@ -353,7 +362,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); @@ -402,15 +411,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); } @@ -592,7 +601,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); @@ -601,8 +609,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;