mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-14 06:45:09 +01:00
Initial PSVITA port
This commit is contained in:
parent
153fb773d0
commit
fa9ef21b86
180
psp2/Makefile
Normal file
180
psp2/Makefile
Normal file
@ -0,0 +1,180 @@
|
||||
|
||||
# Makefile for genplus SDL
|
||||
#
|
||||
# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
|
||||
# modified by Eke-Eke <eke_eke31@yahoo.fr>
|
||||
#
|
||||
# Defines :
|
||||
# -DLSB_FIRST : for little endian systems.
|
||||
# -DLOGERROR : enable message logging
|
||||
# -DLOGVDP : enable VDP debug messages
|
||||
# -DLOGSOUND : enable AUDIO debug messages
|
||||
# -DLOG_SCD : enable SCD debug messages
|
||||
# -DLOG_CDD : enable CDD debug messages
|
||||
# -DLOG_CDC : enable CDC debug messages
|
||||
# -DLOG_PCM : enable PCM debug messages
|
||||
# -DLOGSOUND : enable AUDIO debug messages
|
||||
# -D8BPP_RENDERING - configure for 8-bit pixels (RGB332)
|
||||
# -D15BPP_RENDERING - configure for 15-bit pixels (RGB555)
|
||||
# -D16BPP_RENDERING - configure for 16-bit pixels (RGB565)
|
||||
# -D32BPP_RENDERING - configure for 32-bit pixels (RGB888)
|
||||
|
||||
NAME = gen_vita
|
||||
PSP_APP_NAME=GENPLUSGXVITA
|
||||
PSP_APP_VER=1.7.5
|
||||
|
||||
CC = arm-vita-eabi-gcc
|
||||
CFLAGS = -O3 -fomit-frame-pointer -Wall -Wno-strict-aliasing -ansi -std=c11 \
|
||||
-pedantic-errors -fno-unwind-tables -fno-asynchronous-unwind-tables -ftree-vectorize \
|
||||
-mfloat-abi=hard -ffast-math -fsingle-precision-constant -ftree-vectorizer-verbose=2 -fopt-info-vec-optimized -funroll-loops
|
||||
#-g -ggdb -pg
|
||||
#-fomit-frame-pointer
|
||||
LDFLAGS = -Wl,-q
|
||||
DEFINES = -DPSP_APP_NAME=\"$(PSP_APP_NAME)\" -DPSP_APP_VER=\"$(PSP_APP_VER)\" \
|
||||
-DLSB_FIRST -DUSE_15BPP_RENDERING -DUSE_LIBTREMOR -DALT_RENDERER -DALIGN_LONG -DHAVE_ALLOCA_H -DUSE_ABGR
|
||||
SRCDIR = ../core
|
||||
INCLUDES = -I$(SRCDIR) -I$(SRCDIR)/z80 -I$(SRCDIR)/m68k -I$(SRCDIR)/sound -I$(SRCDIR)/input_hw -I$(SRCDIR)/cart_hw -I$(SRCDIR)/cart_hw/svp -I$(SRCDIR)/cd_hw -I$(SRCDIR)/ntsc -I$(SRCDIR)/tremor -I$(SRCDIR)/../psp2
|
||||
LIBS = -lpsplib -lvita2d -lfreetype -lpng -lz -lm -lSceDisplay_stub -lSceGxm_stub \
|
||||
-lSceCtrl_stub -lSceAudio_stub -lSceRtc_stub -lScePower_stub -lSceAppUtil_stub
|
||||
#-ldebugnet -lSceNet_stub -lSceNetCtl_stub
|
||||
|
||||
OBJDIR = ./build_vita
|
||||
|
||||
OBJECTS = $(OBJDIR)/z80.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/m68kcpu.o \
|
||||
$(OBJDIR)/s68kcpu.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/genesis.o \
|
||||
$(OBJDIR)/vdp_ctrl.o \
|
||||
$(OBJDIR)/vdp_render.o \
|
||||
$(OBJDIR)/system.o \
|
||||
$(OBJDIR)/io_ctrl.o \
|
||||
$(OBJDIR)/mem68k.o \
|
||||
$(OBJDIR)/memz80.o \
|
||||
$(OBJDIR)/membnk.o \
|
||||
$(OBJDIR)/state.o \
|
||||
$(OBJDIR)/loadrom.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/input.o \
|
||||
$(OBJDIR)/gamepad.o \
|
||||
$(OBJDIR)/lightgun.o \
|
||||
$(OBJDIR)/mouse.o \
|
||||
$(OBJDIR)/activator.o \
|
||||
$(OBJDIR)/xe_1ap.o \
|
||||
$(OBJDIR)/teamplayer.o \
|
||||
$(OBJDIR)/paddle.o \
|
||||
$(OBJDIR)/sportspad.o \
|
||||
$(OBJDIR)/terebi_oekaki.o \
|
||||
$(OBJDIR)/graphic_board.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/sound.o \
|
||||
$(OBJDIR)/sn76489.o \
|
||||
$(OBJDIR)/ym2413.o \
|
||||
$(OBJDIR)/ym2612.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/blip_buf.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/eq.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/sram.o \
|
||||
$(OBJDIR)/svp.o \
|
||||
$(OBJDIR)/ssp16.o \
|
||||
$(OBJDIR)/ggenie.o \
|
||||
$(OBJDIR)/areplay.o \
|
||||
$(OBJDIR)/eeprom_93c.o \
|
||||
$(OBJDIR)/eeprom_i2c.o \
|
||||
$(OBJDIR)/eeprom_spi.o \
|
||||
$(OBJDIR)/md_cart.o \
|
||||
$(OBJDIR)/sms_cart.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/scd.o \
|
||||
$(OBJDIR)/cdd.o \
|
||||
$(OBJDIR)/cdc.o \
|
||||
$(OBJDIR)/gfx.o \
|
||||
$(OBJDIR)/pcm.o \
|
||||
$(OBJDIR)/cd_cart.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/sms_ntsc.o \
|
||||
$(OBJDIR)/md_ntsc.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/main.o \
|
||||
$(OBJDIR)/emumain.o \
|
||||
$(OBJDIR)/menu.o \
|
||||
$(OBJDIR)/config.o \
|
||||
$(OBJDIR)/error.o \
|
||||
$(OBJDIR)/unzip.o \
|
||||
$(OBJDIR)/fileio.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/bitwise.o \
|
||||
$(OBJDIR)/block.o \
|
||||
$(OBJDIR)/codebook.o \
|
||||
$(OBJDIR)/floor0.o \
|
||||
$(OBJDIR)/floor1.o \
|
||||
$(OBJDIR)/framing.o \
|
||||
$(OBJDIR)/info.o \
|
||||
$(OBJDIR)/mapping0.o \
|
||||
$(OBJDIR)/mdct.o \
|
||||
$(OBJDIR)/registry.o \
|
||||
$(OBJDIR)/res012.o \
|
||||
$(OBJDIR)/sharedbook.o \
|
||||
$(OBJDIR)/synthesis.o \
|
||||
$(OBJDIR)/vorbisfile.o \
|
||||
$(OBJDIR)/window.o
|
||||
|
||||
|
||||
all: $(NAME).velf
|
||||
|
||||
$(NAME).velf: $(NAME).elf
|
||||
#advice from xyzz strip before create elf
|
||||
arm-vita-eabi-strip -g $<
|
||||
#i put db.json there use your location
|
||||
vita-elf-create $< $@ db.json
|
||||
|
||||
$(NAME).elf: $(OBJDIR) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
|
||||
|
||||
$(OBJDIR) :
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/%.c $(SRCDIR)/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/sound/%.c $(SRCDIR)/sound/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/input_hw/%.c $(SRCDIR)/input_hw/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/%.c $(SRCDIR)/cart_hw/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/svp/%.c
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/svp/%.c $(SRCDIR)/cart_hw/svp/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cd_hw/%.c $(SRCDIR)/cd_hw/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/z80/%.c $(SRCDIR)/z80/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/m68k/%.c
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/ntsc/%.c $(SRCDIR)/ntsc/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/tremor/%.c $(SRCDIR)/tremor/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/tremor/%.c
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/../psp2/%.c $(SRCDIR)/../psp2/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(NAME).velf $(NAME).elf
|
54
psp2/config.c
Normal file
54
psp2/config.c
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
t_config config;
|
||||
|
||||
void set_config_defaults(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* sound options */
|
||||
config.psg_preamp = 150;
|
||||
config.fm_preamp = 100;
|
||||
config.hq_fm = 0;
|
||||
config.psgBoostNoise = 1;
|
||||
config.filter = 1;
|
||||
config.low_freq = 200;
|
||||
config.high_freq = 8000;
|
||||
config.lg = 1.0;
|
||||
config.mg = 1.0;
|
||||
config.hg = 1.0;
|
||||
config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */
|
||||
config.dac_bits = 14;
|
||||
config.ym2413 = 2; /* = AUTO (0 = always OFF, 1 = always ON) */
|
||||
config.mono = 0;
|
||||
|
||||
/* system options */
|
||||
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
|
||||
config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */
|
||||
config.vdp_mode = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
|
||||
config.master_clock = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
|
||||
config.force_dtack = 0;
|
||||
config.addr_error = 1;
|
||||
config.bios = 0;
|
||||
config.lock_on = 0; /* = OFF (can be TYPE_SK, TYPE_GG & TYPE_AR) */
|
||||
config.ntsc = 0;
|
||||
config.lcd = 0; /* 0.8 fixed point */
|
||||
|
||||
/* display options */
|
||||
config.overscan = 0; /* 3 = all borders (0 = no borders , 1 = vertical borders only, 2 = horizontal borders only) */
|
||||
config.gg_extra = 0; /* 1 = show extended Game Gear screen (256x192) */
|
||||
config.render = 0; /* 1 = double resolution output (only when interlaced mode 2 is enabled) */
|
||||
|
||||
/* controllers options */
|
||||
input.system[0] = SYSTEM_GAMEPAD;
|
||||
input.system[1] = SYSTEM_GAMEPAD;
|
||||
config.gun_cursor[0] = 1;
|
||||
config.gun_cursor[1] = 1;
|
||||
config.invert_mouse = 0;
|
||||
for (i=0;i<MAX_INPUTS;i++)
|
||||
{
|
||||
/* autodetected control pad type */
|
||||
config.input[i].padtype = DEVICE_PAD2B | DEVICE_PAD3B | DEVICE_PAD6B;
|
||||
}
|
||||
}
|
57
psp2/config.h
Normal file
57
psp2/config.h
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#define MAX_INPUTS 8
|
||||
#define MAX_KEYS 8
|
||||
#define MAXPATHLEN 1024
|
||||
|
||||
/****************************************************************************
|
||||
* Config Option
|
||||
*
|
||||
****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint8 padtype;
|
||||
} t_input_config;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 hq_fm;
|
||||
uint8 filter;
|
||||
uint8 psgBoostNoise;
|
||||
uint8 dac_bits;
|
||||
uint8 ym2413;
|
||||
int16 psg_preamp;
|
||||
int16 fm_preamp;
|
||||
uint32 lp_range;
|
||||
int16 low_freq;
|
||||
int16 high_freq;
|
||||
int16 lg;
|
||||
int16 mg;
|
||||
int16 hg;
|
||||
uint8 mono;
|
||||
uint8 system;
|
||||
uint8 region_detect;
|
||||
uint8 vdp_mode;
|
||||
uint8 master_clock;
|
||||
uint8 force_dtack;
|
||||
uint8 addr_error;
|
||||
uint8 bios;
|
||||
uint8 lock_on;
|
||||
uint8 hot_swap;
|
||||
uint8 invert_mouse;
|
||||
uint8 gun_cursor[2];
|
||||
uint8 overscan;
|
||||
uint8 gg_extra;
|
||||
uint8 ntsc;
|
||||
uint8 lcd;
|
||||
uint8 render;
|
||||
t_input_config input[MAX_INPUTS];
|
||||
} t_config;
|
||||
|
||||
/* Global variables */
|
||||
extern t_config config;
|
||||
extern void set_config_defaults(void);
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
4466
psp2/db.json
Normal file
4466
psp2/db.json
Normal file
File diff suppressed because it is too large
Load Diff
442
psp2/emumain.c
Normal file
442
psp2/emumain.c
Normal file
@ -0,0 +1,442 @@
|
||||
#include "emumain.h"
|
||||
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#include "time.h"
|
||||
#include <psp2/rtc.h>
|
||||
|
||||
#define SCE_KERNEL_OK 0
|
||||
|
||||
#include "psplib/pl_rewind.h"
|
||||
#include "psplib/pl_file.h"
|
||||
#include "psplib/pl_snd.h"
|
||||
#include "psplib/pl_perf.h"
|
||||
#include "psplib/pl_util.h"
|
||||
#include "psplib/pl_psp.h"
|
||||
#include "psplib/video.h"
|
||||
#include "psplib/ctrl.h"
|
||||
|
||||
#include "shared.h"
|
||||
#include "sound.h"
|
||||
#include "system.h"
|
||||
#include "md_ntsc.h"
|
||||
#include "sms_ntsc.h"
|
||||
|
||||
//#include <debugnet.h>
|
||||
|
||||
#define ip_server "192.168.1.130"
|
||||
#define port_server 18194
|
||||
|
||||
PspImage *Screen;
|
||||
pl_rewind Rewinder;
|
||||
|
||||
static pl_perf_counter FpsCounter;
|
||||
static int ClearScreen;
|
||||
static int ScreenX, ScreenY, ScreenW, ScreenH;
|
||||
static int TicksPerUpdate;
|
||||
static u32 TicksPerSecond;
|
||||
static u64 LastTick;
|
||||
static u64 CurrentTick;
|
||||
static int Frame;
|
||||
|
||||
static int Rewinding;
|
||||
|
||||
extern pl_file_path CurrentGame;
|
||||
extern EmulatorOptions Options;
|
||||
extern const u64 ButtonMask[];
|
||||
extern const int ButtonMapId[];
|
||||
extern struct ButtonConfig ActiveConfig;
|
||||
extern char *ScreenshotPath;
|
||||
|
||||
static short soundbuffer[SOUND_SAMPLES*2*10];
|
||||
static int soundPosWrite = 0;
|
||||
static int soundPosRead = 0;
|
||||
static SceUID console_mtx;
|
||||
|
||||
|
||||
|
||||
static inline void RenderVideo();
|
||||
static void AudioCallback(pl_snd_sample* buf,
|
||||
unsigned int samples,
|
||||
void *userdata);
|
||||
void MixerCallback(int16 **stream, int16 **output, int length);
|
||||
md_ntsc_t *md_ntsc;
|
||||
sms_ntsc_t *sms_ntsc;
|
||||
|
||||
int bEmulate;
|
||||
|
||||
void osd_input_update()
|
||||
{
|
||||
|
||||
/* Reset input */
|
||||
input.pad[0] = 0;
|
||||
input.analog[0][0] = 0x7F;
|
||||
|
||||
static SceCtrlData pad;
|
||||
static int autofire_status = 0;
|
||||
|
||||
/* Check the input */
|
||||
if (pspCtrlPollControls(&pad))
|
||||
{
|
||||
if (--autofire_status < 0)
|
||||
autofire_status = Options.AutoFire;
|
||||
|
||||
/* Parse input */
|
||||
int i, on, code;
|
||||
for (i = 0; ButtonMapId[i] >= 0; i++)
|
||||
{
|
||||
code = ActiveConfig.ButtonMap[ButtonMapId[i]];
|
||||
on = (pad.buttons & ButtonMask[i]) == ButtonMask[i];
|
||||
|
||||
/* Check to see if a button set is pressed. If so, unset it, so it */
|
||||
/* doesn't trigger any other combination presses. */
|
||||
if (on) pad.buttons &= ~ButtonMask[i];
|
||||
|
||||
if (code & AFI)
|
||||
{
|
||||
if (on && (autofire_status == 0))
|
||||
input.pad[0] |= CODE_MASK(code);
|
||||
continue;
|
||||
}
|
||||
else if (code & JOY)
|
||||
{
|
||||
if (on) {
|
||||
input.pad[0] |= CODE_MASK(code);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (code & SYS)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
if (CODE_MASK(code) == (INPUT_START))
|
||||
input.system[0] |= INPUT_START;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (code & SPC)
|
||||
{
|
||||
switch (CODE_MASK(code))
|
||||
{
|
||||
case SPC_MENU:
|
||||
if (on) bEmulate=0;
|
||||
break;
|
||||
case SPC_REWIND:
|
||||
Rewinding = on;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void InitEmulator()
|
||||
{
|
||||
|
||||
//debugNetInit(ip_server,port_server,DEBUG);
|
||||
|
||||
set_config_defaults();
|
||||
|
||||
ClearScreen = 0;
|
||||
|
||||
/* Initialize screen buffer */
|
||||
Screen = pspImageCreateVram(720, 576, PSP_IMAGE_16BPP);
|
||||
|
||||
// pspImageClear(Screen, 0x8000);
|
||||
|
||||
console_mtx = sceKernelCreateSema("sound_sema", 0, 0, 1, 0);
|
||||
/*if (console_mtx > 0) {
|
||||
debugNetPrintf(DEBUG,"Sound Mutex UID: 0x%08X\n", console_mtx);
|
||||
}*/
|
||||
|
||||
/* Set up bitmap structure */
|
||||
memset(&bitmap, 0, sizeof(t_bitmap));
|
||||
bitmap.width = Screen->Width;
|
||||
bitmap.height = Screen->Height;
|
||||
bitmap.pitch = (bitmap.width * 2);
|
||||
bitmap.data = (unsigned char *)Screen->Pixels;
|
||||
bitmap.viewport.changed = 3;
|
||||
|
||||
pl_snd_set_callback(0, AudioCallback, NULL);
|
||||
}
|
||||
|
||||
void RunEmulator()
|
||||
{
|
||||
float ratio;
|
||||
//debugNetPrintf(DEBUG,"RunEmulator\n");
|
||||
|
||||
pspImageClear(Screen, 0);
|
||||
//debugNetPrintf(DEBUG,"ImageClear\n");
|
||||
|
||||
|
||||
if(bitmap.viewport.changed & 1)
|
||||
{
|
||||
bitmap.viewport.changed &= ~1;
|
||||
|
||||
/* source bitmap */
|
||||
Screen->Viewport.Width = bitmap.viewport.w+2*bitmap.viewport.x;
|
||||
Screen->Viewport.Height = bitmap.viewport.h+2*bitmap.viewport.y;
|
||||
|
||||
}
|
||||
|
||||
/* Recompute screen size/position */
|
||||
switch (Options.DisplayMode)
|
||||
{
|
||||
default:
|
||||
case DISPLAY_MODE_UNSCALED:
|
||||
ScreenW = Screen->Viewport.Width;
|
||||
ScreenH = Screen->Viewport.Height;
|
||||
break;
|
||||
case DISPLAY_MODE_FIT_HEIGHT:
|
||||
ratio = (float)SCR_HEIGHT / (float)Screen->Viewport.Height;
|
||||
ScreenW = (float)bitmap.viewport.w * ratio - 2;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_FILL_SCREEN:
|
||||
ScreenW = SCR_WIDTH;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_2X:
|
||||
ScreenW = Screen->Viewport.Width*2;
|
||||
ScreenH = Screen->Viewport.Height*2;
|
||||
break;
|
||||
case DISPLAY_MODE_3X:
|
||||
ScreenW = Screen->Viewport.Width*3;
|
||||
ScreenH = Screen->Viewport.Height*3;
|
||||
break;
|
||||
}
|
||||
//debugNetPrintf(DEBUG,"screensize %d %d\n" ,Screen->Viewport.Width ,Screen->Viewport.Height);
|
||||
|
||||
ScreenX = (SCR_WIDTH / 2) - (ScreenW / 2);
|
||||
ScreenY = (SCR_HEIGHT / 2) - (ScreenH / 2);
|
||||
|
||||
/* Init performance counter */
|
||||
pl_perf_init_counter(&FpsCounter);
|
||||
|
||||
/* Recompute update frequency */
|
||||
TicksPerSecond = sceRtcGetTickResolution();
|
||||
if (Options.UpdateFreq)
|
||||
{
|
||||
TicksPerUpdate = TicksPerSecond
|
||||
/ (Options.UpdateFreq / (Options.Frameskip + 1));
|
||||
sceRtcGetCurrentTick(&LastTick);
|
||||
}
|
||||
Frame = 0;
|
||||
ClearScreen = 2;
|
||||
Rewinding = 0;
|
||||
|
||||
//pl_rewind_realloc(&Rewinder);
|
||||
|
||||
int frames_until_save = 0;
|
||||
|
||||
/* Resume sound */
|
||||
pl_snd_resume(0);
|
||||
|
||||
/* Wait for V. refresh */
|
||||
pspVideoWaitVSync();
|
||||
|
||||
bEmulate = 1;
|
||||
/* Main emulation loop */
|
||||
while (!ExitPSP&&bEmulate)
|
||||
{
|
||||
/* Rewind/save state */
|
||||
/*if (!Rewinding)
|
||||
{
|
||||
if (--frames_until_save <= 0)
|
||||
{
|
||||
frames_until_save = Options.RewindSaveRate;
|
||||
pl_rewind_save(&Rewinder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frames_until_save = Options.RewindSaveRate;
|
||||
if (!pl_rewind_restore(&Rewinder))
|
||||
continue;
|
||||
}*/
|
||||
|
||||
/* Run the system emulation for a frame */
|
||||
if (++Frame <= Options.Frameskip)
|
||||
{
|
||||
/* Skip frame */
|
||||
if (system_hw == SYSTEM_MCD)
|
||||
{
|
||||
system_frame_scd(1);
|
||||
}
|
||||
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||
{
|
||||
system_frame_gen(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
system_frame_sms(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (system_hw == SYSTEM_MCD)
|
||||
{
|
||||
system_frame_scd(0);
|
||||
}
|
||||
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||
{
|
||||
system_frame_gen(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
system_frame_sms(0);
|
||||
}
|
||||
|
||||
Frame = 0;
|
||||
/* Display */
|
||||
if(bitmap.viewport.changed & 1)
|
||||
{
|
||||
bitmap.viewport.changed &= ~1;
|
||||
|
||||
/* source bitmap */
|
||||
Screen->Viewport.Width = bitmap.viewport.w+2*bitmap.viewport.x;
|
||||
Screen->Viewport.Height = bitmap.viewport.h+2*bitmap.viewport.y;
|
||||
|
||||
/* Recompute screen size/position */
|
||||
switch (Options.DisplayMode)
|
||||
{
|
||||
default:
|
||||
case DISPLAY_MODE_UNSCALED:
|
||||
ScreenW = Screen->Viewport.Width;
|
||||
ScreenH = Screen->Viewport.Height;
|
||||
break;
|
||||
case DISPLAY_MODE_FIT_HEIGHT:
|
||||
ratio = (float)SCR_HEIGHT / (float)Screen->Viewport.Height;
|
||||
ScreenW = (float)bitmap.viewport.w * ratio - 2;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_FILL_SCREEN:
|
||||
ScreenW = SCR_WIDTH;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_2X:
|
||||
ScreenW = Screen->Viewport.Width*2;
|
||||
ScreenH = Screen->Viewport.Height*2;
|
||||
break;
|
||||
case DISPLAY_MODE_3X:
|
||||
ScreenW = Screen->Viewport.Width*3;
|
||||
ScreenH = Screen->Viewport.Height*3;
|
||||
break;
|
||||
}
|
||||
|
||||
ScreenX = (SCR_WIDTH / 2) - (ScreenW / 2);
|
||||
ScreenY = (SCR_HEIGHT / 2) - (ScreenH / 2);
|
||||
|
||||
}
|
||||
//debugNetPrintf(DEBUG,"main %d %d \n",soundPosRead,soundPosWrite);
|
||||
int size = audio_update(&soundbuffer[soundPosRead])*2;
|
||||
//debugNetPrintf(DEBUG,"filling %d \n",size);
|
||||
|
||||
soundPosRead +=size;
|
||||
if(soundPosRead+size>=(SOUND_SAMPLES*2*10)){
|
||||
soundPosRead = 0;
|
||||
}
|
||||
if((soundPosRead-soundPosWrite)>=(SOUND_SAMPLES*2)||(soundPosRead-soundPosWrite)<0){
|
||||
sceKernelSignalSema(console_mtx, 1); //lock
|
||||
}
|
||||
RenderVideo();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Stop sound */
|
||||
pl_snd_pause(0);
|
||||
}
|
||||
|
||||
void TrashEmulator()
|
||||
{
|
||||
pl_rewind_destroy(&Rewinder);
|
||||
|
||||
/* Trash screen */
|
||||
if (Screen) pspImageDestroy(Screen);
|
||||
|
||||
if (CurrentGame[0] != '\0')
|
||||
{
|
||||
/* Release emulation resources */
|
||||
audio_shutdown();
|
||||
error_shutdown();
|
||||
}
|
||||
//debugNetFinish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RenderVideo()
|
||||
{
|
||||
/* Update the display */
|
||||
pspVideoBegin();
|
||||
|
||||
/* Clear the buffer first, if necessary */
|
||||
if (ClearScreen >= 0)
|
||||
{
|
||||
ClearScreen--;
|
||||
pspVideoClearScreen();
|
||||
}
|
||||
|
||||
pspVideoPutImage(Screen, ScreenX, ScreenY, ScreenW, ScreenH);
|
||||
|
||||
/* Show FPS counter */
|
||||
if (Options.ShowFps)
|
||||
{
|
||||
static char fps_display[32];
|
||||
sprintf(fps_display, " %3.02f", pl_perf_update_counter(&FpsCounter));
|
||||
|
||||
int width = pspFontGetTextWidth(&PspStockFont, fps_display);
|
||||
int height = pspFontGetLineHeight(&PspStockFont);
|
||||
|
||||
pspVideoFillRect(SCR_WIDTH - width, 0, SCR_WIDTH, height, PSP_COLOR_BLACK);
|
||||
pspVideoPrint(&PspStockFont, SCR_WIDTH - width, 0, fps_display, PSP_COLOR_WHITE);
|
||||
}
|
||||
|
||||
pspVideoEnd();
|
||||
|
||||
/* Wait if needed */
|
||||
if (Options.UpdateFreq)
|
||||
{
|
||||
do { sceRtcGetCurrentTick(&CurrentTick); }
|
||||
while (CurrentTick - LastTick < TicksPerUpdate);
|
||||
LastTick = CurrentTick;
|
||||
}
|
||||
|
||||
/* Wait for VSync signal */
|
||||
if (Options.VSync)
|
||||
pspVideoWaitVSync();
|
||||
|
||||
/* Swap buffers */
|
||||
pspVideoSwapBuffers();
|
||||
}
|
||||
|
||||
static void AudioCallback(pl_snd_sample *buf,
|
||||
unsigned int samples,
|
||||
void *userdata)
|
||||
{
|
||||
int i;
|
||||
//debugNetPrintf(DEBUG,"wait %d %d \n",totalSamples,samples);
|
||||
if (!Rewinding)
|
||||
{
|
||||
short* ptr_s = (short*)buf;
|
||||
//debugNetPrintf(DEBUG,"wait %d %d \n",soundPosRead,soundPosWrite);
|
||||
if((soundPosRead-soundPosWrite)<SOUND_SAMPLES*2){
|
||||
sceKernelWaitSema(console_mtx, 1, 0); //lock
|
||||
//debugNetPrintf(DEBUG,"start %d %d \n",soundPosRead,soundPosWrite);
|
||||
}
|
||||
memcpy(ptr_s,&soundbuffer[soundPosWrite],sizeof(short)*samples*2);
|
||||
soundPosWrite +=samples*2;
|
||||
if(soundPosWrite+(samples*2)>=(SOUND_SAMPLES*2*10)){
|
||||
soundPosWrite = 0;
|
||||
}
|
||||
}
|
||||
else /* Render silence */
|
||||
for (i = 0; i < samples; i++)
|
||||
buf[i].stereo.l = buf[i].stereo.r = 0;
|
||||
}
|
77
psp2/emumain.h
Normal file
77
psp2/emumain.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef _EMUMAIN_H
|
||||
#define _EMUMAIN_H
|
||||
|
||||
|
||||
#define int32 int32_t
|
||||
#define int16 int16_t
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
#define ScePspDateTime SceDateTime
|
||||
|
||||
#define SOUND_FREQUENCY 48000
|
||||
#define SOUND_SAMPLES 832
|
||||
|
||||
void InitEmulator();
|
||||
void RunEmulator();
|
||||
void TrashEmulator();
|
||||
|
||||
#define DISPLAY_MODE_UNSCALED 0
|
||||
#define DISPLAY_MODE_FIT_HEIGHT 1
|
||||
#define DISPLAY_MODE_FILL_SCREEN 2
|
||||
#define DISPLAY_MODE_2X 3
|
||||
#define DISPLAY_MODE_3X 4
|
||||
|
||||
#define JOY 0x10000
|
||||
#define SYS 0x20000
|
||||
#define SPC 0x40000
|
||||
#define AFI 0x80000
|
||||
|
||||
#define CODE_MASK(x) (x & 0xffff)
|
||||
|
||||
#define SPC_MENU 1
|
||||
#define SPC_REWIND 2
|
||||
|
||||
#define MAP_BUTTONS 18
|
||||
|
||||
#define MAP_ANALOG_UP 0
|
||||
#define MAP_ANALOG_DOWN 1
|
||||
#define MAP_ANALOG_LEFT 2
|
||||
#define MAP_ANALOG_RIGHT 3
|
||||
#define MAP_BUTTON_UP 4
|
||||
#define MAP_BUTTON_DOWN 5
|
||||
#define MAP_BUTTON_LEFT 6
|
||||
#define MAP_BUTTON_RIGHT 7
|
||||
#define MAP_BUTTON_SQUARE 8
|
||||
#define MAP_BUTTON_CROSS 9
|
||||
#define MAP_BUTTON_CIRCLE 10
|
||||
#define MAP_BUTTON_TRIANGLE 11
|
||||
#define MAP_BUTTON_LTRIGGER 12
|
||||
#define MAP_BUTTON_RTRIGGER 13
|
||||
#define MAP_BUTTON_SELECT 14
|
||||
#define MAP_BUTTON_START 15
|
||||
#define MAP_BUTTON_LRTRIGGERS 16
|
||||
#define MAP_BUTTON_STARTSELECT 17
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ShowFps;
|
||||
int ControlMode;
|
||||
int ClockFreq;
|
||||
int DisplayMode;
|
||||
int VSync;
|
||||
int UpdateFreq;
|
||||
int Frameskip;
|
||||
int VertStrip;
|
||||
int SoundEngine;
|
||||
int SoundBoost;
|
||||
int AutoFire;
|
||||
int RewindSaveRate;
|
||||
int RewindReplayDelay;
|
||||
} EmulatorOptions;
|
||||
|
||||
struct ButtonConfig
|
||||
{
|
||||
unsigned int ButtonMap[MAP_BUTTONS];
|
||||
};
|
||||
|
||||
#endif // _EMUMAIN_H
|
35
psp2/error.c
Normal file
35
psp2/error.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
error.c --
|
||||
Error logging
|
||||
*/
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
static FILE *error_log;
|
||||
|
||||
void error_init(void)
|
||||
{
|
||||
#ifdef LOGERROR
|
||||
error_log = fopen("error.log","w");
|
||||
#endif
|
||||
}
|
||||
|
||||
void error_shutdown(void)
|
||||
{
|
||||
#ifdef LOGERROR
|
||||
if(error_log) fclose(error_log);
|
||||
#endif
|
||||
}
|
||||
|
||||
void error(char *format, ...)
|
||||
{
|
||||
#ifdef LOGERROR
|
||||
if (log_error)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
if(error_log) vfprintf(error_log, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
}
|
10
psp2/error.h
Normal file
10
psp2/error.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _ERROR_H_
|
||||
#define _ERROR_H_
|
||||
|
||||
/* Function prototypes */
|
||||
void error_init(void);
|
||||
void error_shutdown(void);
|
||||
void error(char *format, ...);
|
||||
|
||||
#endif /* _ERROR_H_ */
|
||||
|
154
psp2/fileio.c
Normal file
154
psp2/fileio.c
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* fileio.c
|
||||
*
|
||||
* Load a normal file, or ZIP/GZ archive into ROM buffer.
|
||||
* Returns loaded ROM size (zero if an error occured)
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald
|
||||
* modified by Eke-Eke (Genesis Plus GX)
|
||||
*
|
||||
* Redistribution and use of this code or any derivative works are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions may not be sold, nor may they be used in a commercial
|
||||
* product or activity.
|
||||
*
|
||||
* - Redistributions that are modified from the original source must include the
|
||||
* complete source code, including the source code for all components used by a
|
||||
* binary built from the modified sources. However, as a special exception, the
|
||||
* source code distributed need not include anything that is normally distributed
|
||||
* (in either source or binary form) with the major components (compiler, kernel,
|
||||
* and so on) of the operating system on which the executable runs, unless that
|
||||
* component itself accompanies the executable.
|
||||
*
|
||||
* - Redistributions must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#include "shared.h"
|
||||
#include <zlib.h>
|
||||
|
||||
static int check_zip(char *filename);
|
||||
|
||||
int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
if(check_zip(filename))
|
||||
{
|
||||
unz_file_info info;
|
||||
int ret = 0;
|
||||
char fname[256];
|
||||
|
||||
/* Attempt to open the archive */
|
||||
unzFile *fd = unzOpen(filename);
|
||||
if (!fd) return 0;
|
||||
|
||||
/* Go to first file in archive */
|
||||
ret = unzGoToFirstFile(fd);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get file informations and update filename */
|
||||
ret = unzGetCurrentFileInfo(fd, &info, fname, 256, NULL, 0, NULL, 0);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compressed filename extension */
|
||||
if (extension)
|
||||
{
|
||||
strncpy(extension, &fname[strlen(fname) - 3], 3);
|
||||
extension[3] = 0;
|
||||
}
|
||||
|
||||
/* Open the file for reading */
|
||||
ret = unzOpenCurrentFile(fd);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Retrieve uncompressed file size */
|
||||
size = info.uncompressed_size;
|
||||
if(size > maxsize)
|
||||
{
|
||||
size = maxsize;
|
||||
}
|
||||
|
||||
/* Read (decompress) the file */
|
||||
ret = unzReadCurrentFile(fd, buffer, size);
|
||||
if(ret != size)
|
||||
{
|
||||
unzCloseCurrentFile(fd);
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Close the current file */
|
||||
ret = unzCloseCurrentFile(fd);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Close the archive */
|
||||
ret = unzClose(fd);
|
||||
if(ret != UNZ_OK) return 0;
|
||||
}
|
||||
/*else
|
||||
{
|
||||
gzFile *gd = gzopen(filename, "rb");
|
||||
if (!gd) return 0;
|
||||
|
||||
size = gzread(gd, buffer, maxsize);
|
||||
|
||||
if (extension)
|
||||
{
|
||||
strncpy(extension, &filename[strlen(filename) - 3], 3);
|
||||
extension[3] = 0;
|
||||
}
|
||||
|
||||
gzclose(gd);
|
||||
}*/
|
||||
|
||||
/* Return loaded ROM size */
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
Verifies if a file is a ZIP archive or not.
|
||||
Returns: 1= ZIP archive, 0= not a ZIP archive
|
||||
*/
|
||||
static int check_zip(char *filename)
|
||||
{
|
||||
uint8 buf[2];
|
||||
FILE *fd = fopen(filename, "rb");
|
||||
if(!fd) return (0);
|
||||
fread(buf, 2, 1, fd);
|
||||
fclose(fd);
|
||||
if(memcmp(buf, "PK", 2) == 0) return (1);
|
||||
return (0);
|
||||
}
|
48
psp2/fileio.h
Normal file
48
psp2/fileio.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* fileio.c
|
||||
*
|
||||
* Load a normal file, or ZIP/GZ archive.
|
||||
* Returns loaded ROM size (zero if an error occured)
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald
|
||||
* modified by Eke-Eke (Genesis Plus GX)
|
||||
*
|
||||
* Redistribution and use of this code or any derivative works are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions may not be sold, nor may they be used in a commercial
|
||||
* product or activity.
|
||||
*
|
||||
* - Redistributions that are modified from the original source must include the
|
||||
* complete source code, including the source code for all components used by a
|
||||
* binary built from the modified sources. However, as a special exception, the
|
||||
* source code distributed need not include anything that is normally distributed
|
||||
* (in either source or binary form) with the major components (compiler, kernel,
|
||||
* and so on) of the operating system on which the executable runs, unless that
|
||||
* component itself accompanies the executable.
|
||||
*
|
||||
* - Redistributions must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef _FILEIO_H_
|
||||
#define _FILEIO_H_
|
||||
|
||||
/* Function prototypes */
|
||||
extern int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension);
|
||||
|
||||
#endif /* _FILEIO_H_ */
|
50
psp2/main.c
Normal file
50
psp2/main.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <psp2/moduleinfo.h>
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#include "psplib/pl_snd.h"
|
||||
#include "psplib/video.h"
|
||||
#include "psplib/pl_psp.h"
|
||||
#include "psplib/ctrl.h"
|
||||
#include <vita2d.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "emumain.h"
|
||||
|
||||
|
||||
PSP2_MODULE_INFO(0,1,PSP_APP_NAME)
|
||||
//PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER)
|
||||
|
||||
static void ExitCallback(void* arg)
|
||||
{
|
||||
ExitPSP = 1;
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
/* Initialize PSP */
|
||||
pl_psp_init("cache0:/GENPlusVITA/");
|
||||
pl_snd_init(SOUND_SAMPLES, 1);
|
||||
pspCtrlInit();
|
||||
pspVideoInit();
|
||||
|
||||
/* Initialize callbacks */
|
||||
pl_psp_register_callback(PSP_EXIT_CALLBACK,
|
||||
ExitCallback,
|
||||
NULL);
|
||||
pl_psp_start_callback_thread();
|
||||
|
||||
/* Start emulation */
|
||||
InitMenu();
|
||||
DisplayMenu();
|
||||
TrashMenu();
|
||||
|
||||
/* Release PSP resources */
|
||||
pl_snd_shutdown();
|
||||
pspVideoShutdown();
|
||||
pl_psp_shutdown();
|
||||
|
||||
return(0);
|
||||
}
|
11
psp2/main.h
Normal file
11
psp2/main.h
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
#ifndef _MAIN_H_
|
||||
#define _MAIN_H_
|
||||
|
||||
#define MAX_INPUTS 8
|
||||
|
||||
extern int debug_on;
|
||||
extern int log_error;
|
||||
extern int sdl_input_update(void);
|
||||
|
||||
#endif /* _MAIN_H_ */
|
1288
psp2/menu.c
Normal file
1288
psp2/menu.c
Normal file
File diff suppressed because it is too large
Load Diff
8
psp2/menu.h
Normal file
8
psp2/menu.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _MENU_H
|
||||
#define _MENU_H
|
||||
|
||||
void InitMenu();
|
||||
void DisplayMenu();
|
||||
void TrashMenu();
|
||||
|
||||
#endif
|
34
psp2/osd.h
Normal file
34
psp2/osd.h
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
#ifndef _OSD_H_
|
||||
#define _OSD_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "shared.h"
|
||||
#include "config.h"
|
||||
#include "error.h"
|
||||
#include "unzip.h"
|
||||
#include "fileio.h"
|
||||
|
||||
extern void osd_input_update(void);
|
||||
|
||||
|
||||
#define GG_ROM "./ggenie.bin"
|
||||
#define AR_ROM "./areplay.bin"
|
||||
#define SK_ROM "./sk.bin"
|
||||
#define SK_UPMEM "./sk2chip.bin"
|
||||
#define CD_BIOS_US "./bios_CD_U.bin"
|
||||
#define CD_BIOS_EU "./bios_CD_E.bin"
|
||||
#define CD_BIOS_JP "./bios_CD_J.bin"
|
||||
#define MD_BIOS "./bios_MD.bin"
|
||||
#define MS_BIOS_US "./bios_U.sms"
|
||||
#define MS_BIOS_EU "./bios_E.sms"
|
||||
#define MS_BIOS_JP "./bios_J.sms"
|
||||
#define GG_BIOS "./bios.gg"
|
||||
|
||||
#endif /* _OSD_H_ */
|
1294
psp2/unzip.c
Normal file
1294
psp2/unzip.c
Normal file
File diff suppressed because it is too large
Load Diff
273
psp2/unzip.h
Normal file
273
psp2/unzip.h
Normal file
@ -0,0 +1,273 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 0.15 beta, Mar 19th, 1998,
|
||||
|
||||
Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
|
||||
CAN CHANGE IN FUTURE VERSION !!
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip */
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||
"zlib/zlib111.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
Loading…
Reference in New Issue
Block a user