From: notaz Date: Thu, 8 Feb 2007 23:19:53 +0000 (+0000) Subject: audio improvement wip X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4dfd9f4230a2677501756b6121024593f1b37d86;p=libpicofe.git audio improvement wip git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@33 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/gp2x/940ctl_ym2612.c b/gp2x/940ctl.c similarity index 93% rename from gp2x/940ctl_ym2612.c rename to gp2x/940ctl.c index bd88c71..5c53761 100644 --- a/gp2x/940ctl_ym2612.c +++ b/gp2x/940ctl.c @@ -333,6 +333,16 @@ void sharedmem_init(void) } +void sharedmem_deinit(void) +{ + munmap(shared_mem, 0x210000); + munmap(mp3_mem, MP3_SIZE_MAX); + shared_mem = mp3_mem = NULL; + shared_data = NULL; + shared_ctl = NULL; +} + + extern char **g_argv; /* none of the functions in this file should be called before this one */ @@ -433,19 +443,17 @@ void YM2612ResetChip_940(void) int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty) { int *ym_buf = shared_data->ym_buffer; + int ym_active_chs; //printf("YM2612UpdateOne_940()\n"); if (CHECK_BUSY(JOB940_YM2612UPDATEONE)) wait_busy_940(JOB940_YM2612UPDATEONE); - // mix in ym buffer - if (is_buf_empty) memcpy32(buffer, ym_buf, length<ym_active_chs; -// for (len = length << stereo; len > 0; len--) -// { -// *dest_buf++ += *ym_buf++; -// } + // mix in ym buffer. is_buf_empty means nobody mixed there anything yet and it may contain trash + if (is_buf_empty && ym_active_chs) memcpy32(buffer, ym_buf, length<writebuffsel == 1) { shared_ctl->writebuff0[writebuff_ptr] = 0xffff; @@ -467,7 +475,7 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty) add_job_940(JOB940_YM2612UPDATEONE); - return 1; + return ym_active_chs; } diff --git a/gp2x/940ctl_ym2612.h b/gp2x/940ctl.h similarity index 89% rename from gp2x/940ctl_ym2612.h rename to gp2x/940ctl.h index 186a6df..95e9a07 100644 --- a/gp2x/940ctl_ym2612.h +++ b/gp2x/940ctl.h @@ -1,4 +1,5 @@ void sharedmem_init(void); +void sharedmem_deinit(void); void YM2612Init_940(int baseclock, int rate); void YM2612ResetChip_940(void); diff --git a/gp2x/Makefile b/gp2x/Makefile index 5efe302..d4de0ec 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -34,7 +34,7 @@ OBJCOPY = $(CROSS)objcopy # frontend OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o asmutils.o cpuctrl.o # 940 core control -OBJS += 940ctl_ym2612.o +OBJS += 940ctl.o # Pico OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \ ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 18c5e48..b02a685 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -52,6 +52,7 @@ void *gp2x_screen; #define FRAMEBUFF_ADDR3 0x4000000-640*480*4 static const int gp2x_screenaddrs[] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 }; +static unsigned short gp2x_screenaddr_old[4]; /* video stuff */ @@ -269,6 +270,11 @@ void gp2x_init(void) gp2x_screen = gp2x_screens[0]; screensel = 0; + gp2x_screenaddr_old[0] = gp2x_memregs[0x290E>>1]; + gp2x_screenaddr_old[1] = gp2x_memregs[0x2910>>1]; + gp2x_screenaddr_old[2] = gp2x_memregs[0x2912>>1]; + gp2x_screenaddr_old[3] = gp2x_memregs[0x2914>>1]; + // snd mixerdev = open("/dev/mixer", O_RDWR); if (mixerdev == -1) @@ -288,6 +294,11 @@ void gp2x_deinit(void) Pause940(1); gp2x_video_changemode(15); + gp2x_memregs[0x290E>>1] = gp2x_screenaddr_old[0]; + gp2x_memregs[0x2910>>1] = gp2x_screenaddr_old[1]; + gp2x_memregs[0x2912>>1] = gp2x_screenaddr_old[2]; + gp2x_memregs[0x2914>>1] = gp2x_screenaddr_old[3]; + munmap(gp2x_screens[0], 640*480*4); munmap((void *)gp2x_memregs, 0x10000); close(memdev); diff --git a/gp2x/main.c b/gp2x/main.c index 5422b2b..23d6241 100644 --- a/gp2x/main.c +++ b/gp2x/main.c @@ -12,6 +12,7 @@ #include "gp2x.h" #include "menu.h" #include "emu.h" +#include "940ctl.h" #include "version.h" #include "squidgehack.h" @@ -94,6 +95,7 @@ int main(int argc, char *argv[]) set_RAM_Timings(6, 4, 1, 1, 1, 2, 2); printf("done.\n"); fflush(stdout); } + sharedmem_init(); emu_Init(); engineState = PGS_Menu; @@ -134,6 +136,7 @@ int main(int argc, char *argv[]) endloop: emu_Deinit(); + sharedmem_deinit(); cpuctrl_deinit(); gp2x_deinit(); if(mmuhack_status)