}\r
\r
\r
+void sharedmem_deinit(void)\r
+{\r
+ munmap(shared_mem, 0x210000);\r
+ munmap(mp3_mem, MP3_SIZE_MAX);\r
+ shared_mem = mp3_mem = NULL;\r
+ shared_data = NULL;\r
+ shared_ctl = NULL;\r
+}\r
+\r
+\r
extern char **g_argv;\r
\r
/* none of the functions in this file should be called before this one */\r
int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)\r
{\r
int *ym_buf = shared_data->ym_buffer;\r
+ int ym_active_chs;\r
\r
//printf("YM2612UpdateOne_940()\n");\r
\r
if (CHECK_BUSY(JOB940_YM2612UPDATEONE)) wait_busy_940(JOB940_YM2612UPDATEONE);\r
\r
- // mix in ym buffer\r
- if (is_buf_empty) memcpy32(buffer, ym_buf, length<<stereo);\r
- // else TODO\r
+ ym_active_chs = shared_ctl->ym_active_chs;\r
\r
-// for (len = length << stereo; len > 0; len--)\r
-// {\r
-// *dest_buf++ += *ym_buf++;\r
-// }\r
+ // mix in ym buffer. is_buf_empty means nobody mixed there anything yet and it may contain trash\r
+ if (is_buf_empty && ym_active_chs) memcpy32(buffer, ym_buf, length<<stereo);\r
+ else memset32(buffer, 0, length<<stereo);\r
\r
if (shared_ctl->writebuffsel == 1) {\r
shared_ctl->writebuff0[writebuff_ptr] = 0xffff;\r
\r
add_job_940(JOB940_YM2612UPDATEONE);\r
\r
- return 1;\r
+ return ym_active_chs;\r
}\r
\r
\r
void sharedmem_init(void);\r
+void sharedmem_deinit(void);\r
\r
void YM2612Init_940(int baseclock, int rate);\r
void YM2612ResetChip_940(void);\r
# frontend\r
OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o asmutils.o cpuctrl.o\r
# 940 core control\r
-OBJS += 940ctl_ym2612.o\r
+OBJS += 940ctl.o\r
# Pico\r
OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \\r
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o\r
#define FRAMEBUFF_ADDR3 0x4000000-640*480*4\r
\r
static const int gp2x_screenaddrs[] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };\r
+static unsigned short gp2x_screenaddr_old[4];\r
\r
\r
/* video stuff */\r
gp2x_screen = gp2x_screens[0];\r
screensel = 0;\r
\r
+ gp2x_screenaddr_old[0] = gp2x_memregs[0x290E>>1];\r
+ gp2x_screenaddr_old[1] = gp2x_memregs[0x2910>>1];\r
+ gp2x_screenaddr_old[2] = gp2x_memregs[0x2912>>1];\r
+ gp2x_screenaddr_old[3] = gp2x_memregs[0x2914>>1];\r
+\r
// snd\r
mixerdev = open("/dev/mixer", O_RDWR);\r
if (mixerdev == -1)\r
Pause940(1);\r
\r
gp2x_video_changemode(15);\r
+ gp2x_memregs[0x290E>>1] = gp2x_screenaddr_old[0];\r
+ gp2x_memregs[0x2910>>1] = gp2x_screenaddr_old[1];\r
+ gp2x_memregs[0x2912>>1] = gp2x_screenaddr_old[2];\r
+ gp2x_memregs[0x2914>>1] = gp2x_screenaddr_old[3];\r
+\r
munmap(gp2x_screens[0], 640*480*4);\r
munmap((void *)gp2x_memregs, 0x10000);\r
close(memdev);\r
#include "gp2x.h"\r
#include "menu.h"\r
#include "emu.h"\r
+#include "940ctl.h"\r
#include "version.h"\r
\r
#include "squidgehack.h"\r
set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);\r
printf("done.\n"); fflush(stdout);\r
}\r
+ sharedmem_init();\r
emu_Init();\r
\r
engineState = PGS_Menu;\r
endloop:\r
\r
emu_Deinit();\r
+ sharedmem_deinit();\r
cpuctrl_deinit();\r
gp2x_deinit();\r
if(mmuhack_status)\r