X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Fcode940%2F940.c;h=0df19453db952452f7a61cc2f54f8954413e7984;hb=e7aac0621a351feda374bb722729c0af500b62d4;hp=4a1e718e3082820a6c0590ec9e7ed7441492e166;hpb=2433f409129279095926eb00cf8ab429738f80dd;p=picodrive.git diff --git a/platform/gp2x/code940/940.c b/platform/gp2x/code940/940.c index 4a1e718..0df1945 100644 --- a/platform/gp2x/code940/940.c +++ b/platform/gp2x/code940/940.c @@ -1,8 +1,11 @@ +// The top-level functions for the ARM940 +// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas + #include "940shared.h" static _940_data_t *shared_data = (_940_data_t *) 0x00100000; static _940_ctl_t *shared_ctl = (_940_ctl_t *) 0x00200000; -static unsigned char *mp3_data = (unsigned char *) 0x01000000; +static unsigned char *mp3_data = (unsigned char *) 0x00400000; YM2612 *ym2612_940; // from init.s @@ -15,6 +18,8 @@ void drain_wb(void); // is changed by other core just before we update it void set_if_not_changed(int *val, int oldval, int newval); +void _memcpy(void *dst, const void *src, int count); + // asm volatile ("mov r0, #0" ::: "r0"); // asm volatile ("mcr p15, 0, r0, c7, c6, 0" ::: "r0"); /* flush dcache */ // asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer */ @@ -55,6 +60,26 @@ static void mp3_decode(void) set_if_not_changed(&shared_ctl->mp3_offs, mp3_offs, readPtr - mp3_data); } +static void ym_flush_writes(void) +{ + UINT16 *wbuff; + int i; + + if (shared_ctl->writebuffsel == 1) { + wbuff = shared_ctl->writebuff1; + } else { + wbuff = shared_ctl->writebuff0; + } + + /* playback all writes */ + for (i = 2048; i > 0; i--) { + UINT16 d = *wbuff++; + if (d == 0xffff) break; + if (d == 0xfffe) continue; + YM2612Write_(d >> 8, d); + } +} + static void ym_update(int *ym_buffer) { int i, dw; @@ -83,7 +108,8 @@ static void ym_update(int *ym_buffer) YM2612Write_(d >> 8, d); } - if (two_upds) { + if (two_upds) + { int len1 = shared_ctl->length / 2; shared_ctl->ym_active_chs = YM2612UpdateOne_(ym_buffer, len1, shared_ctl->stereo, 1); @@ -142,6 +168,20 @@ void Main940(void) YM2612PicoStateLoad_(); break; + case JOB940_PICOSTATESAVE2: + YM2612PicoStateSave2(0, 0); + _memcpy(shared_ctl->writebuff0, ym2612_940->REGS, 0x200); + break; + + case JOB940_PICOSTATELOAD2_PREP: + ym_flush_writes(); + break; + + case JOB940_PICOSTATELOAD2: + _memcpy(ym2612_940->REGS, shared_ctl->writebuff0, 0x200); + YM2612PicoStateLoad2(0, 0); + break; + case JOB940_YM2612UPDATEONE: ym_update(ym_buffer); break;