Gizmondo port updated to 1.51b

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@567 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-08-10 10:18:36 +00:00
parent fcf94fcc20
commit 84100c0fd5
17 changed files with 537 additions and 228 deletions

View file

@ -369,6 +369,10 @@ Well known way to improve the GP2X performance. You must restart the emulator
for the change of this option to take effect.
#endif
@@1. "Disable idle loop patching"
Idle loop patching is used to improve performance, but may cause compatibility
problems in some rare cases. Try disabling this if your game has problems.
Sega/Mega CD options
--------------------
@ -449,6 +453,9 @@ There are 3 options:
@@3. "Set to unscaled centered"
Adjust the resizing options to set game image to it's original size.
@@3. "Set to 4:3 scaled"
Scale the image up, but keep 4:3 aspect, by adding black borders.
@@3. "Set to fullscreen"
Adjust the resizing options to make the game image fullscreen.
@ -645,6 +652,11 @@ Additional thanks
Changelog
---------
1.51b
* Fixed a crash when uncompressed savestate is loaded.
* Fixed an idle loop detection related hanging problem.
* PSP: fixed another palette related regression.
1.51a
* Fixed a sync problem between main and sub 68k. Should fix the hanging
problem for some games.

View file

@ -41,11 +41,33 @@ void menu_flip(void);
#elif defined(__GIZ__)
// TODO
//#include "../gizmondo/giz.h"
#define SCREEN_WIDTH 321
#define SCREEN_BUFFER menu_screen
extern unsigned char *menu_screen;
#include "../gizmondo/giz.h"
#define BTN_NORTH BTN_STOP
#define BTN_SOUTH BTN_PLAY
#define BTN_WEST BTN_REW
#define BTN_EAST BTN_FWD
unsigned long wait_for_input(unsigned int interesting);
void menu_draw_begin(int use_bgbuff);
void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
void menu_draw_end(void);
#define SCREEN_WIDTH 321
#define SCREEN_HEIGHT 240
#define SCREEN_BUFFER ((giz_screen != NULL) ? giz_screen : menu_screen)
extern void *menu_screen;
extern void *giz_screen;
#define read_buttons(which) \
wait_for_input(which)
#define read_buttons_async(which) 0
#define menu_draw_begin() \
menu_draw_begin(1)
#define clear_screen() \
memset(SCREEN_BUFFER, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2)
#define darken_screen() \
menu_darken_bg(menu_screen, menu_screen, SCREEN_WIDTH*SCREEN_HEIGHT, 0)
// ------------------------------------

View file

@ -785,7 +785,7 @@ static void parse(const char *var, const char *val)
ret = custom_read(me, var, val);
}
}
if (!ret) lprintf("config_readsect: unhandled var: %s\n", var);
if (!ret) lprintf("config_readsect: unhandled var: \"%s\"\n", var);
}

View file

@ -1,6 +1,6 @@
# you may or may not need to change this
export CROSS = /opt/cegcc/arm-wince-cegcc/bin/
export CROSS = arm-wince-cegcc-
# settings
asm_memory = 1
@ -27,7 +27,7 @@ endif
ifeq "$(profile)" "2"
COPT_COMMON += -fprofile-use
endif
COPT = $(COPT_COMMON) -mtune=arm920t
CFLAGS = $(COPT_COMMON) -mcpu=arm920t -mtune=arm920t
ASFLAGS = -mcpu=arm920t -mfloat-abi=soft
GCC = $(CROSS)gcc
STRIP = $(CROSS)strip
@ -38,123 +38,147 @@ LD = $(CROSS)ld
OBJS += main.o emu.o menu.o giz.o asm_utils.o
# common
OBJS += ../common/emu.o ../common/menu.o ../common/fonts.o ../common/arm_utils.o \
../common/readpng.o ../common/mp3_helix.o
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
platform/common/arm_utils.o platform/common/readpng.o platform/common/mp3_helix.o
# Pico
ifeq "$(amalgamate)" "1"
OBJS += ../../PicoAll.o
OBJS += PicoAll.o
else
OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
../../Pico/Patch.o
OBJS += Pico/Area.o Pico/Cart.o Pico/Memory.o Pico/Misc.o Pico/Pico.o Pico/Sek.o \
Pico/VideoPort.o Pico/Draw2.o Pico/Draw.o Pico/Patch.o Pico/Debug.o
# Pico - CD
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o
OBJS += Pico/cd/Pico.o Pico/cd/Memory.o Pico/cd/Sek.o Pico/cd/LC89510.o \
Pico/cd/cd_sys.o Pico/cd/cd_file.o Pico/cd/gfx_cd.o Pico/cd/cue.o \
Pico/cd/Area.o Pico/cd/Misc.o Pico/cd/pcm.o Pico/cd/buffering.o
endif
# Pico - Pico
OBJS += Pico/Pico/Pico.o Pico/Pico/Memory.o Pico/Pico/xpcm.o
# Pico - carthw
OBJS += Pico/carthw/carthw.o Pico/carthw/svp/svp.o Pico/carthw/svp/Memory.o \
Pico/carthw/svp/ssp16.o Pico/carthw/svp/compiler.o Pico/carthw/svp/stub_arm.o
# asm stuff
ifeq "$(asm_render)" "1"
DEFINC += -D_ASM_DRAW_C
OBJS += ../../Pico/draw_asm.o ../../Pico/draw2_asm.o
OBJS += Pico/draw_asm.o Pico/draw2_asm.o
endif
ifeq "$(asm_memory)" "1"
DEFINC += -D_ASM_MEMORY_C
OBJS += ../../Pico/memory_asm.o
OBJS += Pico/memory_asm.o
endif
ifeq "$(asm_ym2612)" "1"
DEFINC += -D_ASM_YM2612_C
OBJS += ../../Pico/sound/ym2612_asm.o
OBJS += Pico/sound/ym2612_asm.o
endif
ifeq "$(asm_misc)" "1"
DEFINC += -D_ASM_MISC_C
OBJS += ../../Pico/misc_asm.o
OBJS += ../../Pico/cd/misc_asm.o
OBJS += Pico/misc_asm.o
OBJS += Pico/cd/misc_asm.o
endif
ifeq "$(asm_cdpico)" "1"
DEFINC += -D_ASM_CD_PICO_C
OBJS += ../../Pico/cd/pico_asm.o
OBJS += Pico/cd/pico_asm.o
endif
ifeq "$(asm_cdmemory)" "1"
DEFINC += -D_ASM_CD_MEMORY_C
OBJS += ../../Pico/cd/memory_asm.o
OBJS += Pico/cd/memory_asm.o
endif
# Pico - sound
ifneq "$(amalgamate)" "1"
OBJS += ../../Pico/sound/sound.o
OBJS += Pico/sound/sound.o
endif
OBJS += ../../Pico/sound/mix_asm.o
OBJS += ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o
OBJS += Pico/sound/mix_asm.o
OBJS += Pico/sound/sn76496.o Pico/sound/ym2612.o
# zlib
OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o
# unzip
OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
OBJS += unzip/unzip.o unzip/unzip_stream.o
# CPU cores
# Cyclone
DEFINC += -DEMU_C68K
OBJS += ../../cpu/Cyclone/proj/Cyclone.o
OBJS += cpu/Cyclone/proj/Cyclone.o cpu/Cyclone/tools/idle.o
# drz80
DEFINC += -D_USE_DRZ80
OBJS += ../../cpu/DrZ80/drz80.o
OBJS += cpu/DrZ80/drz80.o
vpath %.c = ../..
vpath %.s = ../..
vpath %.S = ../..
DIRS = platform platform/common Pico Pico/cd Pico/Pico Pico/sound Pico/carthw/svp \
zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80
all: PicoDrive.exe readme.txt
all: mkdirs PicoDrive.exe readme.txt
PicoDrive.exe : $(OBJS) ../common/helix/helix_mp3.a
PicoDrive.exe : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a
@echo ">>>" $@
$(GCC) -o $@ -static $(COPT) $^ -lm -lpng -Lkgsdk/ -lKGSDK -Wl,-Map=PicoDrive.map 2>&1 | \
grep -v ".idata$$4" # | grep -v "supports interworking, whereas"
$(GCC) -o $@ -static $(CFLAGS) $^ -lm -lpng -Lkgsdk/ -lKGSDK -Wl,-Map=PicoDrive.map \
2>&1 | grep -v ".idata$$4" # | grep -v "supports interworking, whereas"
ifeq ($(DEBUG),)
$(STRIP) $@
endif
ifeq "$(profile)" "1"
../../tools/gcda $@
endif
.c.o:
@echo ">>>" $<
$(GCC) $(COPT) $(DEFINC) -c $< -o $@
$(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@
#.s.o:
# @echo $<
# $(GCC) $(COPT) $(DEFINC) -c $< -o $@
# $(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@
../../Pico/draw_asm.o : ../../Pico/Draw.s
mkdirs:
mkdir -p $(DIRS)
Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c
Pico/draw_asm.o : ../../Pico/Draw.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/draw2_asm.o : ../../Pico/Draw2.s
Pico/draw2_asm.o : ../../Pico/Draw2.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/memory_asm.o : ../../Pico/Memory.s
Pico/memory_asm.o : ../../Pico/Memory.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s
Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/misc_asm.o : ../../Pico/Misc.s
Pico/misc_asm.o : ../../Pico/Misc.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s
Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s
Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
../../Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s
Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s
@echo ">>>" $@
@$(AS) $(ASFLAGS) $< -o $@
Pico/carthw/svp/stub_arm.o : ../../Pico/carthw/svp/stub_arm.S
@echo ">>>" $@
$(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@
# build Cyclone
../../cpu/Cyclone/proj/Cyclone.s:
cpu/Cyclone/proj/Cyclone.s:
@echo building Cyclone...
@make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h
Pico/Pico.o Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h
Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h
# build helix libs
../common/helix/helix_mp3.a:
make -C ../common/helix
../common/helix/$(CROSS)helix-mp3.a:
make -C ../common/helix clean all
readme.txt: ../../tools/textfilter ../base_readme.txt
../../tools/textfilter ../base_readme.txt $@ GIZ
@ -190,9 +214,9 @@ $(error need VER)
endif
endif
rel: PicoDrive.exe kgsdk/ARMV4IRel/KGSDK.dll readme.txt
zip -9 -j ../../PicoDrive_$(VER).zip $^
rel: PicoDrive.exe kgsdk/ARMV4IRel/KGSDK.dll ../game_def.cfg readme.txt
zip -9 -j ../../PicoDrive_giz_$(VER).zip $^
ln -s ../gp2x/skin skin
zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt
zip -9 -r ../../PicoDrive_giz_$(VER).zip skin -i \*.png -i \*.txt
rm skin

View file

@ -10,6 +10,7 @@
#include "../common/emu.h"
#include "../common/lprintf.h"
#include "../common/arm_utils.h"
#include "../common/config.h"
#include "emu.h"
#include "menu.h"
#include "giz.h"
@ -51,8 +52,8 @@ void emu_getMainDir(char *dst, int len)
static void emu_msg_cb(const char *msg)
{
if (giz_screen != NULL) Framework2D_UnlockBuffer();
giz_screen = Framework2D_LockBuffer(1);
if (giz_screen != NULL) fb_unlock();
giz_screen = fb_lock(1);
memset32((int *)((char *)giz_screen + 321*232*2), 0, 321*8*2/4);
emu_textOut16(4, 232, msg);
@ -61,19 +62,19 @@ static void emu_msg_cb(const char *msg)
/* assumption: emu_msg_cb gets called only when something slow is about to happen */
reset_timing = 1;
Framework2D_UnlockBuffer();
giz_screen = Framework2D_LockBuffer((currentConfig.EmuOpt&0x8000) ? 0 : 1);
fb_unlock();
giz_screen = fb_lock((currentConfig.EmuOpt&0x8000) ? 0 : 1);
}
void emu_stateCb(const char *str)
{
if (giz_screen != NULL) Framework2D_UnlockBuffer();
giz_screen = Framework2D_LockBuffer(1);
if (giz_screen != NULL) fb_unlock();
giz_screen = fb_lock(1);
clearArea(0);
blit("", str);
Framework2D_UnlockBuffer();
fb_unlock();
giz_screen = NULL;
Sleep(0); /* yield the CPU, the system may need it */
@ -114,33 +115,42 @@ void emu_Deinit(void)
PicoExit();
}
void emu_prepareDefaultConfig(void)
{
memset(&defaultConfig, 0, sizeof(defaultConfig));
defaultConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, 16bit rend
defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;
defaultConfig.s_PsndRate = 22050;
defaultConfig.s_PicoRegion = 0; // auto
defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
defaultConfig.s_PicoCDBuffers = 0;
defaultConfig.Frameskip = -1; // auto
defaultConfig.volume = 50;
defaultConfig.KeyBinds[ 2] = 1<<0; // SACB RLDU
defaultConfig.KeyBinds[ 3] = 1<<1;
defaultConfig.KeyBinds[ 0] = 1<<2;
defaultConfig.KeyBinds[ 1] = 1<<3;
defaultConfig.KeyBinds[ 5] = 1<<4;
defaultConfig.KeyBinds[ 6] = 1<<5;
defaultConfig.KeyBinds[ 7] = 1<<6;
defaultConfig.KeyBinds[ 4] = 1<<7;
defaultConfig.KeyBinds[13] = 1<<26; // switch rend
defaultConfig.KeyBinds[ 8] = 1<<27; // save state
defaultConfig.KeyBinds[ 9] = 1<<28; // load state
defaultConfig.KeyBinds[12] = 1<<29; // vol up
defaultConfig.KeyBinds[11] = 1<<30; // vol down
defaultConfig.scaling = 0;
defaultConfig.turbo_rate = 15;
}
void emu_setDefaultConfig(void)
{
memset(&currentConfig, 0, sizeof(currentConfig));
currentConfig.lastRomFile[0] = 0;
currentConfig.EmuOpt = 0x1f | 0x680; // | confirm_save, cd_leds, 16bit rend
currentConfig.PicoOpt = 0x07 | 0xc00; // | cd_pcm, cd_cdda
currentConfig.PsndRate = 22050;
currentConfig.PicoRegion = 0; // auto
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
currentConfig.Frameskip = -1; // auto
currentConfig.volume = 50;
currentConfig.KeyBinds[ 2] = 1<<0; // SACB RLDU
currentConfig.KeyBinds[ 3] = 1<<1;
currentConfig.KeyBinds[ 0] = 1<<2;
currentConfig.KeyBinds[ 1] = 1<<3;
currentConfig.KeyBinds[ 5] = 1<<4;
currentConfig.KeyBinds[ 6] = 1<<5;
currentConfig.KeyBinds[ 7] = 1<<6;
currentConfig.KeyBinds[ 4] = 1<<7;
currentConfig.KeyBinds[13] = 1<<26; // switch rend
currentConfig.KeyBinds[ 8] = 1<<27; // save state
currentConfig.KeyBinds[ 9] = 1<<28; // load state
currentConfig.KeyBinds[12] = 1<<29; // vol up
currentConfig.KeyBinds[11] = 1<<30; // vol down
currentConfig.PicoCDBuffers = 0;
currentConfig.scaling = 0;
defaultConfig.turbo_rate = 15;
memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
PicoOpt = currentConfig.s_PicoOpt;
PsndRate = currentConfig.s_PsndRate;
PicoRegionOverride = currentConfig.s_PicoRegion;
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
PicoCDBuffers = currentConfig.s_PicoCDBuffers;
}
@ -214,6 +224,9 @@ static void blit(const char *fps, const char *notice)
Pico.m.dirtyPal = 0;
vidConvCpyRGB565(localPal, Pico.cram, 0x40);
}
// a hack for VR
if (PicoRead16Hook == PicoSVPRead16)
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);
if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000;
if (currentConfig.EmuOpt&0x4000)
lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000;
@ -229,7 +242,7 @@ static void blit(const char *fps, const char *notice)
if (Pico.video.reg[0xC]&8) { // shadow/hilight mode
//vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);
//vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40); // TODO?
blockcpy(localPal+0xc0, localPal+0x40, 0x40*2);
memcpy32((void *)(localPal+0xc0), (void *)(localPal+0x40), 0x40*2/4);
localPal[0xc0] = 0x0600;
localPal[0xd0] = 0xc000;
localPal[0xe0] = 0x0000; // reserved pixels for OSD
@ -262,13 +275,13 @@ static void blit(const char *fps, const char *notice)
static void clearArea(int full)
{
if (giz_screen == NULL)
giz_screen = Framework2D_LockBuffer(1);
giz_screen = fb_lock(1);
if (full) memset32(giz_screen, 0, 320*240*2/4);
else memset32((int *)((char *)giz_screen + 321*232*2), 0, 321*8*2/4);
if (currentConfig.EmuOpt&0x8000) {
Framework2D_UnlockBuffer();
giz_screen = Framework2D_LockBuffer(0);
fb_unlock();
giz_screen = fb_lock(0);
if (full) memset32(giz_screen, 0, 320*240*2/4);
else memset32((int *)((char *)giz_screen + 321*232*2), 0, 321*8*2/4);
}
@ -276,7 +289,7 @@ static void clearArea(int full)
static void vidResetMode(void)
{
giz_screen = Framework2D_LockBuffer(1);
giz_screen = fb_lock(1);
if (PicoOpt&0x10) {
} else if (currentConfig.EmuOpt&0x80) {
@ -297,11 +310,11 @@ static void vidResetMode(void)
memset32(giz_screen, 0, 321*240*2/4);
if (currentConfig.EmuOpt&0x8000) {
Framework2D_UnlockBuffer();
giz_screen = Framework2D_LockBuffer(0);
fb_unlock();
giz_screen = fb_lock(0);
memset32(giz_screen, 0, 321*240*2/4);
}
Framework2D_UnlockBuffer();
fb_unlock();
giz_screen = NULL;
}
@ -354,14 +367,14 @@ void emu_forcedFrame(int opts)
currentConfig.EmuOpt |= 0x80;
if (giz_screen == NULL)
giz_screen = Framework2D_LockBuffer(1);
giz_screen = fb_lock(1);
PicoDrawSetColorFormat(1);
PicoScanBegin = EmuScanBegin16;
Pico.m.dirtyPal = 1;
PicoFrameDrawOnly();
Framework2D_UnlockBuffer();
fb_unlock();
giz_screen = NULL;
PicoOpt = po_old;
@ -378,7 +391,7 @@ static void RunEvents(unsigned int which)
if (PsndOut != NULL)
FrameworkAudio_SetPause(1);
if (giz_screen == NULL)
giz_screen = Framework2D_LockBuffer(1);
giz_screen = fb_lock(1);
if ( emu_checkSaveFile(state_slot) &&
(( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load
(!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save
@ -507,6 +520,10 @@ static void updateKeys(void)
prevEvents = (allActions[0] | allActions[1]) >> 16;
}
void emu_platformDebugCat(char *str)
{
// nothing
}
static void simpleWait(DWORD until)
{
@ -717,17 +734,17 @@ void emu_Loop(void)
if (currentConfig.EmuOpt&0x80)
/* be sure correct framebuffer is locked */
giz_screen = Framework2D_LockBuffer((currentConfig.EmuOpt&0x8000) ? 0 : 1);
giz_screen = fb_lock((currentConfig.EmuOpt&0x8000) ? 0 : 1);
PicoFrame();
if (giz_screen == NULL)
giz_screen = Framework2D_LockBuffer((currentConfig.EmuOpt&0x8000) ? 0 : 1);
giz_screen = fb_lock((currentConfig.EmuOpt&0x8000) ? 0 : 1);
blit(fpsbuff, notice);
if (giz_screen != NULL) {
Framework2D_UnlockBuffer();
fb_unlock();
giz_screen = NULL;
}
@ -735,7 +752,7 @@ void emu_Loop(void)
Framework2D_WaitVSync();
if (currentConfig.EmuOpt&0x8000)
Framework2D_Flip();
fb_flip();
// check time
tval = GetTickCount();

View file

@ -1,26 +1,33 @@
#include <windows.h>
#include <stdio.h>
#include <version.h>
#include "giz.h"
#include "kgsdk/Framework.h"
#include "kgsdk/Framework2D.h"
#include "giz.h"
#include "version.h"
#define LOG_FILE "log.log"
void *giz_screen = NULL;
static FILE *logf = NULL;
void lprintf_al(const char *fmt, ...)
#if 0
static int directfb_init(void);
static void directfb_fini(void);
#endif
void lprintf(const char *fmt, ...)
{
va_list vl;
if (logf == NULL)
{
logf = fopen(LOG_FILE, "w");
logf = fopen(LOG_FILE, "r+");
//logf = fopen(LOG_FILE, "a");
if (logf == NULL)
return;
}
fseek(logf, 0, SEEK_END);
//if (strchr(fmt, '\n'))
// fprintf(logf, "%lu: ", GetTickCount());
@ -43,31 +50,38 @@ void giz_init(HINSTANCE hInstance, HINSTANCE hPrevInstance)
{
int ret;
lprintf("PicoDrive v" VERSION " (c) notaz, 2006,2007\n");
lprintf("\n\nPicoDrive v" VERSION " (c) notaz, 2006-2008\n");
lprintf("%s %s\n\n", __DATE__, __TIME__);
ret = Framework_Init(hInstance, hPrevInstance);
if (!ret)
{
lprintf_al("Framework_Init() failed\n");
lprintf("Framework_Init() failed\n");
exit(1);
}
ret = Framework2D_Init();
if (!ret)
{
lprintf_al("Framework2D_Init() failed\n");
lprintf("Framework2D_Init() failed\n");
exit(1);
}
#if 0
ret = directfb_init();
if (ret != 0)
{
lprintf("directfb_init() failed\n");
}
#endif
// test screen
giz_screen = Framework2D_LockBuffer(1);
giz_screen = fb_lock(1);
if (giz_screen == NULL)
{
lprintf_al("Framework2D_LockBuffer() failed\n");
lprintf("fb_lock() failed\n");
exit(1);
}
lprintf("Framework2D_LockBuffer returned %p\n", giz_screen);
Framework2D_UnlockBuffer();
lprintf("fb_lock() returned %p\n", giz_screen);
fb_unlock();
giz_screen = NULL;
}
@ -75,7 +89,173 @@ void giz_deinit(void)
{
Framework2D_Close();
Framework_Close();
#if 0
directfb_fini();
#endif
giz_log_close();
}
#define PAGE_SIZE 0x1000
#define CACHE_SYNC_INSTRUCTIONS 0x002 /* discard all cached instructions */
#define CACHE_SYNC_WRITEBACK 0x004 /* write back but don't discard data cache*/
WINBASEAPI BOOL WINAPI CacheRangeFlush(LPVOID pAddr, DWORD dwLength, DWORD dwFlags);
WINBASEAPI BOOL WINAPI VirtualCopy(LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD fdwProtect);
void cache_flush_d_inval_i(void *start_addr, void *end_addr)
{
int size = end_addr - start_addr;
CacheRangeFlush(start_addr, size, CACHE_SYNC_WRITEBACK);
CacheRangeFlush(start_addr, size, CACHE_SYNC_INSTRUCTIONS);
}
#if 0
static void *mmap_phys(unsigned int addr, int pages)
{
void *mem;
int ret;
mem = VirtualAlloc(0, pages*PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
if (mem == NULL)
{
lprintf("VirtualAlloc failed\n");
return NULL;
}
ret = VirtualCopy(mem, (void *)addr, pages*PAGE_SIZE, PAGE_READWRITE | PAGE_NOCACHE);
if (ret == 0)
{
lprintf("VirtualFree failed\n");
VirtualFree(mem, 0, MEM_RELEASE);
return NULL;
}
return mem;
}
static void munmap_phys(void *ptr)
{
VirtualFree(ptr, 0, MEM_RELEASE);
}
// FB
static int directfb_initialized = 0;
static int directfb_addrs[2] = { 0, 0 };
static void *directfb_ptrs[2] = { NULL, NULL };
static int directfb_sel = 0; // the one currently displayed
static volatile unsigned int *memregs = NULL;
/*static void xdump(void)
{
int i;
for (i = 0; i < 0x1000/4; i += 4)
{
lprintf("%04x: %08x %08x %08x %08x\n", i*4, memregs[i],
memregs[i+1], memregs[i+2], memregs[i+3]);
}
}*/
static int directfb_init(void)
{
memregs = mmap_phys(0xac009000, 1);
if (memregs == NULL)
{
lprintf("can't access hw regs\n");
return -1;
}
// fake lock
Framework2D_LockBuffer(1);
// 0xAC00905C
directfb_addrs[0] = memregs[0x5c>>2];
lprintf("fb0 is at %08x\n", directfb_addrs[0]);
Framework2D_UnlockBuffer();
directfb_ptrs[0] = mmap_phys(directfb_addrs[0], (321*240*2+PAGE_SIZE-1) / PAGE_SIZE);
if (directfb_ptrs[0] == NULL)
{
lprintf("failed to map fb0\n");
goto fail0;
}
// use directx to discover other buffer
xdump();
Framework2D_Flip();
lprintf("---\n");
xdump();
exit(1);
//Framework2D_LockBuffer(1);
directfb_addrs[1] = memregs[0x5c>>2] + 0x30000;
lprintf("fb1 is at %08x\n", directfb_addrs[1]);
//Framework2D_UnlockBuffer();
directfb_ptrs[1] = mmap_phys(directfb_addrs[1], (321*240*2+PAGE_SIZE-1) / PAGE_SIZE);
if (directfb_ptrs[1] == NULL)
{
lprintf("failed to map fb1\n");
goto fail1;
}
directfb_initialized = 1;
directfb_sel = 1;
return 0;
fail1:
munmap_phys(directfb_ptrs[0]);
fail0:
munmap_phys((void *)memregs);
return -1;
}
static void directfb_fini(void)
{
if (!directfb_initialized) return;
munmap_phys(directfb_ptrs[0]);
munmap_phys(directfb_ptrs[1]);
munmap_phys((void *)memregs);
}
void *directfb_lock(int is_front)
{
int which;
if (!directfb_initialized)
// fall back to directx
return Framework2D_LockBuffer(is_front);
if (is_front)
which = directfb_sel;
else
which = directfb_sel ^ 1; // return backbuffer when possible
return directfb_ptrs[which];
}
void directfb_unlock(void)
{
if (!directfb_initialized)
// fall back to directx
Framework2D_UnlockBuffer();
}
void directfb_flip(void)
{
if (!directfb_initialized) {
Framework2D_Flip();
return;
}
directfb_sel ^= 1;
// doesn't work
memregs[0x5c>>2] = directfb_addrs[directfb_sel];
}
#endif

View file

@ -2,11 +2,47 @@ extern void *giz_screen;
void giz_init();
void giz_deinit(void);
void lprintf_al(const char *fmt, ...);
void lprintf(const char *fmt, ...);
#define lprintf lprintf_al
void *directfb_lock(int unused);
void directfb_unlock(void);
void directfb_flip(void);
#if 1
#define fb_lock Framework2D_LockBuffer
#define fb_unlock Framework2D_UnlockBuffer
#define fb_flip Framework2D_Flip
#else
#define fb_lock directfb_lock
#define fb_unlock directfb_unlock
#define fb_flip directfb_flip
#endif
#ifndef _FRAMEWORK_H
// bah, some copy-pasta
enum FRAMEWORK_BUTTONTYPES
{
FRAMEWORK_BUTTON_DPAD_LEFT = 0,
FRAMEWORK_BUTTON_DPAD_RIGHT,
FRAMEWORK_BUTTON_DPAD_UP,
FRAMEWORK_BUTTON_DPAD_DOWN,
FRAMEWORK_BUTTON_STOP,
FRAMEWORK_BUTTON_PLAY,
FRAMEWORK_BUTTON_FORWARD,
FRAMEWORK_BUTTON_REWIND,
FRAMEWORK_BUTTON_LEFT_SHOULDER,
FRAMEWORK_BUTTON_RIGHT_SHOULDER,
FRAMEWORK_BUTTON_HOME,
FRAMEWORK_BUTTON_VOLUME,
FRAMEWORK_BUTTON_BRIGHTNESS,
FRAMEWORK_BUTTON_ALARM,
FRAMEWORK_BUTTON_POWER,
FRAMEWORK_BUTTON_COUNT
};
#endif
// button mappings, include kgsdk/Framework.h to use
#define BTN_LEFT (1 << FRAMEWORK_BUTTON_DPAD_LEFT)
#define BTN_RIGHT (1 << FRAMEWORK_BUTTON_DPAD_RIGHT)
#define BTN_UP (1 << FRAMEWORK_BUTTON_DPAD_UP)

View file

@ -10,12 +10,15 @@
#include "emu.h"
#include "../common/menu.h"
#include "../common/emu.h"
#include "../common/config.h"
#include "version.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
emu_prepareDefaultConfig();
emu_ReadConfig(0, 0);
config_readlrom(PicoConfigFile);
giz_init(hInstance, hPrevInstance);
emu_Init();
menu_init();

View file

@ -14,6 +14,9 @@
#include <dirent.h> // for opendir
#include <windows.h>
#include "kgsdk/Framework.h"
#include "kgsdk/Framework2D.h"
#include "giz.h"
#include "emu.h"
#include "menu.h"
@ -22,8 +25,6 @@
#include "../common/emu.h"
#include "../common/readpng.h"
#include "version.h"
#include "kgsdk/Framework.h"
#include "kgsdk/Framework2D.h"
#include <Pico/PicoInt.h>
#include <Pico/Patch.h>
@ -31,7 +32,7 @@
#define gizKeyUnkn "???"
static const char * const gizKeyNames[] = {
const char * const keyNames[] = {
"LEFT", "RIGHT", "UP", "DOWN", "STOP", "PLAY", "FORWARD", "REWIND",
"L", "R", "HOME", "VOLUME", "BRIGHTNESS", "ALARM", "POWER", gizKeyUnkn,
gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn,
@ -41,12 +42,12 @@ static const char * const gizKeyNames[] = {
static unsigned char *bg_buffer = gfx_buffer + 321*240*2;
unsigned char *menu_screen = gfx_buffer; /* draw here and blit later, to avoid flicker */
static void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
static void menu_prepare_bg(int use_game_bg);
static unsigned int inp_prev = 0;
static unsigned long wait_for_input(unsigned int interesting)
unsigned long wait_for_input(unsigned int interesting)
{
unsigned long ret;
static int repeats = 0, wait = 20;
@ -84,25 +85,25 @@ static unsigned long wait_for_input(unsigned int interesting)
}
static void menu_draw_begin(int use_bgbuff)
void menu_draw_begin(int use_bgbuff)
{
if (use_bgbuff)
memcpy32((int *)menu_screen, (int *)bg_buffer, 321*240*2/4);
}
static void menu_draw_end(void)
void menu_draw_end(void)
{
giz_screen = Framework2D_LockBuffer(0);
giz_screen = fb_lock(0);
if (giz_screen == NULL)
{
lprintf_al("%s: Framework2D_LockBuffer() returned NULL\n", __FUNCTION__);
lprintf("%s: Framework2D_LockBuffer() returned NULL\n", __FUNCTION__);
return;
}
memcpy32(giz_screen, (int *)menu_screen, 321*240*2/4);
Framework2D_UnlockBuffer();
fb_unlock();
giz_screen = NULL;
Framework2D_Flip(1);
fb_flip();
}
@ -265,10 +266,10 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out,
BOOL bRet;
wdir = malloc(sizeof(wdir[0]) * MAX_PATH);
if (wdir == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
if (wdir == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
namelist = malloc(sizeof(*namelist) * name_alloc);
if (namelist == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
if (namelist == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
// try to read first..
len = cstr2wstr(wdir, dir);
@ -313,7 +314,7 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out,
void *tmp;
name_alloc *= 2;
tmp = realloc(namelist, sizeof(*namelist) * name_alloc);
if (tmp == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
if (tmp == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }
namelist = tmp;
}
@ -631,8 +632,8 @@ static char *action_binds(int player_idx, int action_mask)
if (currentConfig.KeyBinds[i] & action_mask)
{
if (player_idx >= 0 && ((currentConfig.KeyBinds[i] >> 16) & 3) != player_idx) continue;
if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, gizKeyNames[i]); break; }
else strcpy(strkeys, gizKeyNames[i]);
if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, keyNames[i]); break; }
else strcpy(strkeys, keyNames[i]);
}
}
@ -789,7 +790,7 @@ static void kc_sel_loop(void)
if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if (inp & BTN_PLAY) {
int is_6button = currentConfig.PicoOpt & 0x020;
int is_6button = PicoOpt & 0x020;
switch (selected_id) {
case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return;
case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return;
@ -808,20 +809,21 @@ static void kc_sel_loop(void)
menu_entry cdopt_entries[] =
{
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_USA, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1 },
{ "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1 },
{ "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &currentConfig.PicoOpt, 0x0800, 0, 0, 1 },
{ "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &currentConfig.PicoOpt, 0x0400, 0, 0, 1 },
{ NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1 },
{ "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &currentConfig.PicoOpt, 0x8000, 0, 0, 1 },
{ "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&currentConfig.PicoOpt, 0x1000, 0, 0, 1 },
{ "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &currentConfig.PicoOpt, 0x2000, 0, 0, 1 },
{ "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_USA, NULL, 0, 0, 0, 1, 0 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },
{ "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },
{ "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },
{ "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 },
{ NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },
{ "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 },
{ "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoOpt, 0x1000, 0, 0, 1, 1 },
{ "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoOpt, 0x2000, 0, 0, 1, 1 },
{ "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1, 0 },
};
#define CDOPT_ENTRY_COUNT (sizeof(cdopt_entries) / sizeof(cdopt_entries[0]))
const int cdopt_entry_count = CDOPT_ENTRY_COUNT;
struct bios_names_t
@ -882,17 +884,20 @@ static void cd_menu_loop_options(void)
char *bios, *p;
if (emu_findBios(4, &bios)) { // US
for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++;
for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--);
if (*p == '/') p++;
strncpy(bios_names.us, p, sizeof(bios_names.us)); bios_names.us[sizeof(bios_names.us)-1] = 0;
} else strcpy(bios_names.us, "NOT FOUND");
if (emu_findBios(8, &bios)) { // EU
for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++;
for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--);
if (*p == '/') p++;
strncpy(bios_names.eu, p, sizeof(bios_names.eu)); bios_names.eu[sizeof(bios_names.eu)-1] = 0;
} else strcpy(bios_names.eu, "NOT FOUND");
if (emu_findBios(1, &bios)) { // JP
for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++;
for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--);
if (*p == '/') p++;
strncpy(bios_names.jp, p, sizeof(bios_names.jp)); bios_names.jp[sizeof(bios_names.jp)-1] = 0;
} else strcpy(bios_names.jp, "NOT FOUND");
@ -957,17 +962,20 @@ static void cd_menu_loop_options(void)
menu_entry opt2_entries[] =
{
{ "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 },
{ "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &currentConfig.PicoOpt,0x0004, 0, 0, 1 },
{ "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &currentConfig.PicoOpt,0x0001, 0, 0, 1 },
{ "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&currentConfig.PicoOpt,0x0002, 0, 0, 1 },
{ "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, &currentConfig.EmuOpt, 0x8000, 0, 0, 1 },
{ "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, &currentConfig.EmuOpt, 0x2000, 0, 0, 1 },
{ "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, &currentConfig.EmuOpt, 0x0008, 0, 0, 1 },
{ "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, &currentConfig.EmuOpt, 0x0020, 0, 0, 1 },
{ "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1 },
{ "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 },
{ "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 },
{ "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 },
{ "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, &currentConfig.EmuOpt, 0x8000, 0, 0, 1, 1 },
{ "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, &currentConfig.EmuOpt, 0x2000, 0, 0, 1, 1 },
{ "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, &currentConfig.EmuOpt, 0x0008, 0, 0, 1, 1 },
{ "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, &currentConfig.EmuOpt, 0x0020, 0, 0, 1, 1 },
{ "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 },
{ "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 },
{ "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 },
};
#define OPT2_ENTRY_COUNT (sizeof(opt2_entries) / sizeof(opt2_entries[0]))
const int opt2_entry_count = OPT2_ENTRY_COUNT;
static void draw_amenu_options(int menu_sel)
@ -1026,26 +1034,27 @@ static void amenu_loop_options(void)
menu_entry opt_entries[] =
{
{ NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 },
{ "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 },
{ "Scanline mode (faster)", MB_ONOFF, MA_OPT_INTERLACED, &currentConfig.EmuOpt, 0x4000, 0, 0, 1 },
{ "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, &currentConfig.scaling, 0x0001, 0, 3, 1 },
{ "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, &currentConfig.EmuOpt, 0x0002, 0, 0, 1 },
{ NULL, MB_RANGE, MA_OPT_FRAMESKIP, &currentConfig.Frameskip, 0, -1, 16, 1 },
{ "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, &currentConfig.EmuOpt, 0x0004, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1 },
{ "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, &currentConfig.EmuOpt, 0x0001, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },
{ "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 },
{ "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 },
{ "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 },
{ "Save cfg for current game only",MB_NONE,MA_OPT_SAVECFG_GAME,NULL, 0, 0, 0, 1 },
{ NULL, MB_NONE, MA_OPT_LOADCFG, NULL, 0, 0, 0, 1 },
{ "Scanline mode (faster)", MB_ONOFF, MA_OPT_INTERLACED, &currentConfig.EmuOpt, 0x4000, 0, 0, 1, 1 },
{ "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, &currentConfig.scaling, 0x0001, 0, 3, 1, 1 },
{ "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, &currentConfig.EmuOpt, 0x0002, 0, 0, 1, 1 },
{ NULL, MB_RANGE, MA_OPT_FRAMESKIP, &currentConfig.Frameskip, 0, -1, 16, 1, 1 },
{ "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, &currentConfig.EmuOpt, 0x0004, 0, 0, 1, 1 },
{ NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 },
{ NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1, 1 },
{ "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, &currentConfig.EmuOpt, 0x0001, 0, 0, 1, 1 },
{ NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1, 1 },
{ "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1, 1 },
{ "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1, 0 },
{ "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1, 0 },
{ NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1, 0 },
{ "Save cfg for current game only",MB_NONE,MA_OPT_SAVECFG_GAME,NULL, 0, 0, 0, 1, 0 },
{ NULL, MB_NONE, MA_OPT_LOADCFG, NULL, 0, 0, 0, 1, 0 },
};
#define OPT_ENTRY_COUNT (sizeof(opt_entries) / sizeof(opt_entries[0]))
const int opt_entry_count = OPT_ENTRY_COUNT;
static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *param)
@ -1055,7 +1064,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
switch (entry->id)
{
case MA_OPT_RENDERER:
if (currentConfig.PicoOpt&0x10)
if (PicoOpt&0x10)
str = " 8bit fast";
else if (currentConfig.EmuOpt&0x80)
str = "16bit accurate";
@ -1070,8 +1079,8 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
text_out16(x, y, "Frameskip %s", str24);
break;
case MA_OPT_SOUND_QUALITY:
str = (currentConfig.PicoOpt&0x08)?"stereo":"mono";
text_out16(x, y, "Sound Quality: %5iHz %s", currentConfig.PsndRate, str);
str = (PicoOpt&0x08)?"stereo":"mono";
text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);
break;
case MA_OPT_REGION:
text_out16(x, y, "Region: %s", me_region_name(PicoRegionOverride, PicoAutoRgnOrder));
@ -1153,8 +1162,6 @@ static void region_prevnext(int right)
static void menu_options_save(void)
{
PicoOpt = currentConfig.PicoOpt;
PsndRate = currentConfig.PsndRate;
if (PicoRegionOverride) {
// force setting possibly changed..
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;
@ -1172,9 +1179,6 @@ static int menu_loop_options(void)
unsigned long inp = 0;
menu_id selected_id;
currentConfig.PicoOpt = PicoOpt;
currentConfig.PsndRate = PsndRate;
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);
menu_sel_max = me_count_enabled(opt_entries, OPT_ENTRY_COUNT) - 1;
@ -1192,30 +1196,30 @@ static int menu_loop_options(void)
switch (selected_id) {
case MA_OPT_RENDERER:
if (inp & BTN_LEFT) {
if ((currentConfig.PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) {
currentConfig.PicoOpt&= ~0x10;
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) {
PicoOpt&= ~0x10;
currentConfig.EmuOpt |= 0x80;
}
} else {
if (!(currentConfig.PicoOpt&0x10) || (currentConfig.EmuOpt &0x80)) {
currentConfig.PicoOpt|= 0x10;
if (!(PicoOpt&0x10) || (currentConfig.EmuOpt &0x80)) {
PicoOpt|= 0x10;
currentConfig.EmuOpt &= ~0x80;
}
}
break;
case MA_OPT_SOUND_QUALITY:
if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 &&
!(currentConfig.PicoOpt&0x08))
if ((inp & BTN_RIGHT) && PsndRate == 44100 &&
!(PicoOpt&0x08))
{
currentConfig.PsndRate = 11025;
currentConfig.PicoOpt |= 8;
} else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 &&
(currentConfig.PicoOpt&0x08) && !(PicoAHW&1))
PsndRate = 11025;
PicoOpt |= 8;
} else if ((inp & BTN_LEFT) && PsndRate == 11025 &&
(PicoOpt&0x08) && !(PicoAHW&1))
{
currentConfig.PsndRate = 44100;
currentConfig.PicoOpt &= ~8;
PsndRate = 44100;
PicoOpt &= ~8;
} else
currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT);
PsndRate = sndrate_prevnext(PsndRate, inp & BTN_RIGHT);
break;
case MA_OPT_REGION:
region_prevnext(inp & BTN_RIGHT);
@ -1326,16 +1330,16 @@ static void draw_menu_credits(void)
menu_entry main_entries[] =
{
{ "Resume game", MB_NONE, MA_MAIN_RESUME_GAME, NULL, 0, 0, 0, 0 },
{ "Save State", MB_NONE, MA_MAIN_SAVE_STATE, NULL, 0, 0, 0, 0 },
{ "Load State", MB_NONE, MA_MAIN_LOAD_STATE, NULL, 0, 0, 0, 0 },
{ "Reset game", MB_NONE, MA_MAIN_RESET_GAME, NULL, 0, 0, 0, 0 },
{ "Load new ROM/ISO", MB_NONE, MA_MAIN_LOAD_ROM, NULL, 0, 0, 0, 1 },
{ "Change options", MB_NONE, MA_MAIN_OPTIONS, NULL, 0, 0, 0, 1 },
{ "Configure controls", MB_NONE, MA_MAIN_CONTROLS, NULL, 0, 0, 0, 1 },
{ "Credits", MB_NONE, MA_MAIN_CREDITS, NULL, 0, 0, 0, 1 },
{ "Patches / GameGenie",MB_NONE, MA_MAIN_PATCHES, NULL, 0, 0, 0, 0 },
{ "Exit", MB_NONE, MA_MAIN_EXIT, NULL, 0, 0, 0, 1 }
{ "Resume game", MB_NONE, MA_MAIN_RESUME_GAME, NULL, 0, 0, 0, 0, 0 },
{ "Save State", MB_NONE, MA_MAIN_SAVE_STATE, NULL, 0, 0, 0, 0, 0 },
{ "Load State", MB_NONE, MA_MAIN_LOAD_STATE, NULL, 0, 0, 0, 0, 0 },
{ "Reset game", MB_NONE, MA_MAIN_RESET_GAME, NULL, 0, 0, 0, 0, 0 },
{ "Load new ROM/ISO", MB_NONE, MA_MAIN_LOAD_ROM, NULL, 0, 0, 0, 1, 0 },
{ "Change options", MB_NONE, MA_MAIN_OPTIONS, NULL, 0, 0, 0, 1, 0 },
{ "Configure controls", MB_NONE, MA_MAIN_CONTROLS, NULL, 0, 0, 0, 1, 0 },
{ "Credits", MB_NONE, MA_MAIN_CREDITS, NULL, 0, 0, 0, 1, 0 },
{ "Patches / GameGenie",MB_NONE, MA_MAIN_PATCHES, NULL, 0, 0, 0, 0, 0 },
{ "Exit", MB_NONE, MA_MAIN_EXIT, NULL, 0, 0, 0, 1, 0 }
};
#define MAIN_ENTRY_COUNT (sizeof(main_entries) / sizeof(main_entries[0]))
@ -1434,10 +1438,10 @@ static void menu_loop_root(void)
{
char curr_path[MAX_PATH], *selfname;
FILE *tstf;
if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) )
if ( (tstf = fopen(lastRomFile, "rb")) )
{
fclose(tstf);
strcpy(curr_path, currentConfig.lastRomFile);
strcpy(curr_path, lastRomFile);
}
else
getcwd(curr_path, MAX_PATH);
@ -1484,7 +1488,7 @@ static void menu_loop_root(void)
}
// warning: alignment
static void menu_darken_bg(void *dst, const void *src, int pixels, int darker)
void menu_darken_bg(void *dst, const void *src, int pixels, int darker)
{
unsigned int *dest = dst;
const unsigned int *srce = src;
@ -1513,11 +1517,11 @@ static void menu_prepare_bg(int use_game_bg)
{
// darken the active framebuffer
if (giz_screen == NULL)
giz_screen = Framework2D_LockBuffer(1);
giz_screen = fb_lock(1);
memset(bg_buffer, 0, 321*8*2);
menu_darken_bg(bg_buffer + 321*8*2, (char *)giz_screen + 321*8*2, 321*224, 1);
memset(bg_buffer + 321*232*2, 0, 321*8*2);
Framework2D_UnlockBuffer();
fb_unlock();
giz_screen = NULL;
}
else
@ -1582,10 +1586,10 @@ int menu_loop_tray(void)
menu_gfx_prepare();
if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) )
if ( (tstf = fopen(lastRomFile, "rb")) )
{
fclose(tstf);
strcpy(curr_path, currentConfig.lastRomFile);
strcpy(curr_path, lastRomFile);
}
else
{

View file

@ -18,6 +18,9 @@
// pico.c
#define CAN_HANDLE_240_LINES 1
// logging emu events
#define EL_LOGMASK (EL_STATUS|EL_IDLE) // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO|EL_INTS|EL_CDPOLL) // xffff
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
#define dprintf(x...)

View file

@ -1,2 +1,2 @@
#define VERSION "1.34"
#define VERSION "1.51b"

View file

@ -1,6 +1,14 @@
@ vim:filetype=armasm
.global cache_flush_d_inval_i
cache_flush_d_inval_i:
mov r2, #0x0 @ must be 0 ???
swi 0x9f0002
bx lr
.global clut_line @ void *dest, void *src, unsigned short *pal, int pixels_mask
clut_line:

View file

@ -135,12 +135,13 @@ void emu_Deinit(void)
void emu_prepareDefaultConfig(void)
{
memset(&defaultConfig, 0, sizeof(defaultConfig));
defaultConfig.EmuOpt = 0x9f | 0x00700; // | <- ram_tmng, confirm_save, cd_leds
defaultConfig.EmuOpt = 0x8f | 0x00600; // | <- confirm_save, cd_leds
defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC;
defaultConfig.s_PicoOpt |= POPT_ACC_SPRITES|POPT_EN_MCD_GFX;
defaultConfig.s_PicoOpt &= ~POPT_EN_SVP_DRC; // crashes :(
defaultConfig.EmuOpt &= ~8; // no save gzip
defaultConfig.s_PsndRate = 44100;
defaultConfig.s_PicoRegion = 0; // auto
defaultConfig.s_PicoRegion = 0;
defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
defaultConfig.s_PicoCDBuffers = 0;
defaultConfig.Frameskip = 0;
@ -938,6 +939,7 @@ void emu_Loop(void)
}
bench_fps += frames_shown;
sprintf(fpsbuff, "%3i/%3i/%3i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);
printf("%s\n", fpsbuff);
#else
if (currentConfig.EmuOpt & 2) {
sprintf(fpsbuff, "%3i/%3i", frames_shown, frames_done);