mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-29 04:31:49 +01:00
updated win32/sdl code
This commit is contained in:
parent
2b78421402
commit
8f5d6b38c6
@ -368,17 +368,14 @@ void dos_update_input(void)
|
|||||||
vdp_pal ^= 1;
|
vdp_pal ^= 1;
|
||||||
|
|
||||||
/* save YM2612 context */
|
/* save YM2612 context */
|
||||||
unsigned char *temp = memalign(32,YM2612GetContextSize());
|
unsigned char *temp = malloc(YM2612GetContextSize());
|
||||||
if (temp)
|
if (temp)
|
||||||
memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
|
memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
|
||||||
|
|
||||||
/* reinitialize all timings */
|
/* reinitialize all timings */
|
||||||
audio_init(snd.sample_rate, framerate);
|
audio_init(snd.sample_rate, snd.frame_rate);
|
||||||
system_init();
|
system_init();
|
||||||
|
|
||||||
/* restore SRAM */
|
|
||||||
memfile_autoload(config.sram_auto,-1);
|
|
||||||
|
|
||||||
/* restore YM2612 context */
|
/* restore YM2612 context */
|
||||||
if (temp)
|
if (temp)
|
||||||
{
|
{
|
||||||
|
@ -7,12 +7,19 @@
|
|||||||
# Defines :
|
# Defines :
|
||||||
# LSB_FIRST : for little endian systems.
|
# LSB_FIRST : for little endian systems.
|
||||||
# X86_ASM : enable x86 assembly optimizations
|
# X86_ASM : enable x86 assembly optimizations
|
||||||
|
# LOGERROR
|
||||||
|
# LOGVDP
|
||||||
|
# LOGSOUND
|
||||||
|
|
||||||
NAME = gen_sdl.exe
|
NAME = gen_sdl.exe
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = `sdl-config --cflags` -O6 -march=i686 -fomit-frame-pointer
|
CFLAGS = `sdl-config --cflags` -O6 -march=i686 -fomit-frame-pointer
|
||||||
DEFINES = -DLSB_FIRST -DX86_ASM -DLOGERROR=1 -DLOGVDP=1
|
#-g -ggdb -pg
|
||||||
|
#-fomit-frame-pointer
|
||||||
|
#LDFLAGS = -g -ggdb -pg
|
||||||
|
DEFINES = -DLSB_FIRST -DX86_ASM
|
||||||
|
|
||||||
INCLUDES = -I. -I.. -I../z80 -I../m68k -I../sound -I../cart_hw -I../cart_hw/svp -I../ntsc
|
INCLUDES = -I. -I.. -I../z80 -I../m68k -I../sound -I../cart_hw -I../cart_hw/svp -I../ntsc
|
||||||
LIBS = `sdl-config --libs` -lz -lm
|
LIBS = `sdl-config --libs` -lz -lm
|
||||||
|
|
||||||
|
@ -90,17 +90,22 @@ static void sdl_sound_update()
|
|||||||
int i;
|
int i;
|
||||||
short* p;
|
short* p;
|
||||||
|
|
||||||
SDL_LockAudio();
|
int size = audio_update();
|
||||||
p = (short*)sdl_sound.current_pos;
|
|
||||||
for(i = 0; i < snd.buffer_size; ++i) {
|
if (use_sound)
|
||||||
*p = snd.buffer[0][i];
|
{
|
||||||
++p;
|
SDL_LockAudio();
|
||||||
*p = snd.buffer[1][i];
|
p = (short*)sdl_sound.current_pos;
|
||||||
++p;
|
for(i = 0; i < size; ++i) {
|
||||||
|
*p = snd.buffer[0][i];
|
||||||
|
++p;
|
||||||
|
*p = snd.buffer[1][i];
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
sdl_sound.current_pos = (char*)p;
|
||||||
|
sdl_sound.current_emulated_samples += size * 2 * sizeof(short);
|
||||||
|
SDL_UnlockAudio();
|
||||||
}
|
}
|
||||||
sdl_sound.current_pos = (char*)p;
|
|
||||||
sdl_sound.current_emulated_samples += snd.buffer_size * 2 * sizeof(short);
|
|
||||||
SDL_UnlockAudio();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdl_sound_close()
|
static void sdl_sound_close()
|
||||||
@ -196,20 +201,28 @@ static void sdl_video_close()
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
SDL_sem* sem_sync;
|
SDL_sem* sem_sync;
|
||||||
|
unsigned ticks;
|
||||||
} sdl_sync;
|
} sdl_sync;
|
||||||
|
|
||||||
/* sync */
|
/* sync */
|
||||||
|
|
||||||
static Uint32 sdl_sync_timer_callback(Uint32 interval)
|
static Uint32 sdl_sync_timer_callback(Uint32 interval)
|
||||||
{
|
{
|
||||||
/*char caption[100];
|
SDL_SemPost(sdl_sync.sem_sync);
|
||||||
|
char caption[100];
|
||||||
char region[10];
|
char region[10];
|
||||||
if (region_code == REGION_USA) sprintf(region,"USA");
|
if (region_code == REGION_USA) sprintf(region,"USA");
|
||||||
else if (region_code == REGION_EUROPE) sprintf(region,"EUR");
|
else if (region_code == REGION_EUROPE) sprintf(region,"EUR");
|
||||||
else sprintf(region,"JAP");
|
else sprintf(region,"JAP");
|
||||||
sprintf(caption, "Genesis Plus/SDL - %s (%s) - %d fps - 0x%04X", rominfo.international, region, vdp_rate, realchecksum);
|
|
||||||
SDL_WM_SetCaption(caption, NULL);*/
|
sdl_sync.ticks++;
|
||||||
SDL_SemPost(sdl_sync.sem_sync);
|
if (sdl_sync.ticks == (vdp_pal ? 50 : 20))
|
||||||
|
{
|
||||||
|
int fps = vdp_pal ? (sdl_video.frames_rendered / 3) : sdl_video.frames_rendered;
|
||||||
|
sdl_sync.ticks = sdl_video.frames_rendered = 0;
|
||||||
|
sprintf(caption, "Genesis Plus/SDL - %s (%s) - 0x%04X - %d fps", rominfo.international, region, realchecksum, fps);
|
||||||
|
SDL_WM_SetCaption(caption, NULL);
|
||||||
|
}
|
||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +233,7 @@ static int sdl_sync_init()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sdl_sync.sem_sync = SDL_CreateSemaphore(0);
|
sdl_sync.sem_sync = SDL_CreateSemaphore(0);
|
||||||
|
sdl_sync.ticks = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,17 +319,14 @@ static int sdl_control_update(SDLKey keystate)
|
|||||||
vdp_pal ^= 1;
|
vdp_pal ^= 1;
|
||||||
|
|
||||||
/* save YM2612 context */
|
/* save YM2612 context */
|
||||||
unsigned char *temp = memalign(32,YM2612GetContextSize());
|
unsigned char *temp = malloc(YM2612GetContextSize());
|
||||||
if (temp)
|
if (temp)
|
||||||
memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
|
memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
|
||||||
|
|
||||||
/* reinitialize all timings */
|
/* reinitialize all timings */
|
||||||
audio_init(snd.sample_rate, framerate);
|
audio_init(snd.sample_rate, snd.frame_rate);
|
||||||
system_init();
|
system_init();
|
||||||
|
|
||||||
/* restore SRAM */
|
|
||||||
memfile_autoload(config.sram_auto,-1);
|
|
||||||
|
|
||||||
/* restore YM2612 context */
|
/* restore YM2612 context */
|
||||||
if (temp)
|
if (temp)
|
||||||
{
|
{
|
||||||
@ -536,7 +547,8 @@ int main (int argc, char **argv)
|
|||||||
SDL_UnlockSurface(sdl_video.surf_bitmap);
|
SDL_UnlockSurface(sdl_video.surf_bitmap);
|
||||||
|
|
||||||
/* initialize emulation */
|
/* initialize emulation */
|
||||||
audio_init(SOUND_FREQUENCY, vdp_pal ? 50 : 60);
|
audio_init(SOUND_FREQUENCY, vdp_pal ? 50:60);
|
||||||
|
//audio_init(SOUND_FREQUENCY, 1000000.0/16715.0);
|
||||||
system_init();
|
system_init();
|
||||||
|
|
||||||
/* load SRAM */
|
/* load SRAM */
|
||||||
@ -576,9 +588,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sdl_video_update();
|
sdl_video_update();
|
||||||
audio_update(snd.buffer_size);
|
sdl_sound_update();
|
||||||
if(use_sound)
|
|
||||||
sdl_sound_update();
|
|
||||||
|
|
||||||
if(!turbo_mode && sdl_sync.sem_sync && sdl_video.frames_rendered % 3 == 0)
|
if(!turbo_mode && sdl_sync.sem_sync && sdl_video.frames_rendered % 3 == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user