From 4742480dcabcbd9d23fd8cb9a655fc8c9c314513 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 30 May 2009 22:47:25 +0300 Subject: [PATCH] wiz port wip --- common.h | 2 -- gp2x/Makefile | 24 +++++++++++++++---- gp2x/arm_stub.S | 22 ++++++++++++------ gp2x/gp2x.c | 61 +++++++++++++++++++++++++++++++++++++++++++++---- gp2x/gp2x.h | 10 +++++--- gui.c | 5 ++++ input.c | 18 +-------------- main.c | 7 +++--- video.c | 9 ++++++-- 9 files changed, 115 insertions(+), 43 deletions(-) diff --git a/common.h b/common.h index f111348..b58228b 100644 --- a/common.h +++ b/common.h @@ -268,8 +268,6 @@ typedef u32 fixed16_16; #define vprintf(format, ap) \ vfprintf(stderr, format, ap) \ - void gp2x_overclock(void); - // #define STDIO_DEBUG #endif diff --git a/gp2x/Makefile b/gp2x/Makefile index c17af14..be06a86 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -4,26 +4,42 @@ # Global definitions +ifeq ($(WIZ),1) +PREFIX = /opt/arm-openwiz-linux-gnu +CC = $(PREFIX)/bin/arm-openwiz-linux-gnu-gcc +STRIP = $(PREFIX)/bin/arm-openwiz-linux-gnu-strip +else PREFIX = /opt/open2x/gcc-4.1.1-glibc-2.3.6 CC = $(PREFIX)/bin/arm-open2x-linux-gcc STRIP = $(PREFIX)/bin/arm-open2x-linux-strip +endif OBJS = main.o cpu.o memory.u video.o input.o sound.o gp2x.o gui.o \ - cheats.o zip.o cpu_threaded.z cpuctrl_mmsp2.o \ - arm_stub.o video_blend.o flush_cache.o + cheats.o zip.o cpu_threaded.z arm_stub.o video_blend.o \ + flush_cache.o warm.o sys_cacheflush.o BIN = gpsp.gpe # Platform specific definitions VPATH += .. CFLAGS += -DARM_ARCH -DGP2X_BUILD +ifeq ($(WIZ),1) +CFLAGS += -DWIZ_BUILD +endif # NOTE: -funroll-loops will slow down compiling considerably CFLAGS += -O3 -std=c99 -msoft-float -funsigned-char -fno-common \ -fno-builtin \ INCLUDES = `$(PREFIX)/bin/sdl-config --cflags` -I$(PREFIX)/include LIBS = `$(PREFIX)/bin/sdl-config --libs` \ - -lm -ldl -lpthread -lz -static + -lm -ldl -lpthread -lz +ifneq ($(WIZ),1) +OBJS += cpuctrl_mmsp2.o +LIBS += -static +endif + +CFLAGS += -ggdb +LIBS += -ggdb # Compilation: @@ -43,7 +59,7 @@ LIBS = `$(PREFIX)/bin/sdl-config --libs` \ all: $(OBJS) $(CC) $(OBJS) $(LIBS) -o $(BIN) - $(STRIP) $(BIN) +# $(STRIP) $(BIN) clean: rm -f *.o *.u *.z $(BIN) diff --git a/gp2x/arm_stub.S b/gp2x/arm_stub.S index 17512ba..bff4ad0 100644 --- a/gp2x/arm_stub.S +++ b/gp2x/arm_stub.S @@ -996,17 +996,25 @@ step_debug_arm: restore_flags() add pc, lr, #4 @ return, skipping PC -invalidate_icache_region: - mov r2, #0x0 - swi 0x9f0002 - bx lr +#include "warm.h" + +invalidate_icache_region: + mov r2,r1 + mov r1,r0 + mov r0,#WOP_I_INVALIDATE + b warm_cache_op_range invalidate_cache_region: - mov r2, #0x1 - swi 0x9f0002 + sub r2,r1,r0 + mov r1,r0 + mov r0,#(WOP_D_CLEAN|WOP_I_INVALIDATE) + b warm_cache_op_range - bx lr +@ mov r2, #0 +@ swi 0x9f0002 + +@ bx lr .comm memory_map_read 0x8000 diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 608907f..88f1731 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -24,6 +24,7 @@ #include #include "../common.h" #include "gp2x.h" +#include "warm.h" extern int main_cpuspeed(int argc, char *argv[]); extern SDL_Surface* screen; @@ -31,9 +32,10 @@ extern SDL_Surface* screen; u32 gp2x_audio_volume = 74/2; u32 gpsp_gp2x_dev_audio = 0; u32 gpsp_gp2x_dev = 0; +u32 gpsp_gp2x_gpiodev = 0; -volatile u16 *gpsp_gp2x_memregs; -volatile u32 *gpsp_gp2x_memregl; +static volatile u16 *gpsp_gp2x_memregs; +static volatile u32 *gpsp_gp2x_memregl; unsigned short *gp2x_memregs; static volatile u16 *MEM_REG; @@ -55,7 +57,7 @@ s32 gp2x_load_mmuhack() return 0; } -void gp2x_overclock() +void gp2x_init() { gpsp_gp2x_dev = open("/dev/mem", O_RDWR); gpsp_gp2x_dev_audio = open("/dev/mixer", O_RDWR); @@ -63,6 +65,10 @@ void gp2x_overclock() (unsigned long *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gpsp_gp2x_dev, 0xc0000000); gpsp_gp2x_memregs = (unsigned short *)gpsp_gp2x_memregl; +#ifdef WIZ_BUILD + gpsp_gp2x_gpiodev = open("/dev/GPIO", O_RDONLY); +#endif + warm_init(); clear_screen(0); // main_cpuspeed(0, NULL); @@ -76,9 +82,13 @@ void gp2x_quit() munmap((void *)gpsp_gp2x_memregl, 0x10000); close(gpsp_gp2x_dev_audio); close(gpsp_gp2x_dev); +#ifdef WIZ_BUILD + close(gpsp_gp2x_gpiodev); +#endif - chdir("/usr/gp2x"); - execl("gp2xmenu", "gp2xmenu", NULL); + //chdir("/usr/gp2x"); + //execl("gp2xmenu", "gp2xmenu", NULL); + exit(0); } void gp2x_sound_volume(u32 volume_up) @@ -95,3 +105,44 @@ void gp2x_sound_volume(u32 volume_up) ioctl(gpsp_gp2x_dev_audio, SOUND_MIXER_WRITE_PCM, &volume); } +u32 gpsp_gp2x_joystick_read(void) +{ +#ifdef WIZ_BUILD + u32 value = 0; + read(gpsp_gp2x_gpiodev, &value, 4); + if(value & 0x02) + value |= 0x05; + if(value & 0x08) + value |= 0x14; + if(value & 0x20) + value |= 0x50; + if(value & 0x80) + value |= 0x41; + return value; +#else + u32 value = (gpsp_gp2x_memregs[0x1198 >> 1] & 0x00FF); + + if(value == 0xFD) + value = 0xFA; + if(value == 0xF7) + value = 0xEB; + if(value == 0xDF) + value = 0xAF; + if(value == 0x7F) + value = 0xBE; + + return ~((gpsp_gp2x_memregs[0x1184 >> 1] & 0xFF00) | value | + (gpsp_gp2x_memregs[0x1186 >> 1] << 16)); +#endif +} + +#ifdef WIZ_BUILD +void cpuctrl_init(void) +{ +} + +void set_FCLK(u32 MHZ) +{ +} +#endif + diff --git a/gp2x/gp2x.h b/gp2x/gp2x.h index f0b2914..15b4a90 100644 --- a/gp2x/gp2x.h +++ b/gp2x/gp2x.h @@ -15,16 +15,20 @@ enum GP2X_B = 1 << 13, GP2X_X = 1 << 14, GP2X_Y = 1 << 15, +#ifdef WIZ_BUILD + GP2X_VOL_UP = 1 << 16, + GP2X_VOL_DOWN = 1 << 17, + GP2X_PUSH = 1 << 18, +#else GP2X_VOL_DOWN = 1 << 22, GP2X_VOL_UP = 1 << 23, - GP2X_PUSH = 1 << 27 + GP2X_PUSH = 1 << 27, +#endif }; extern u32 gpsp_gp2x_dev_audio; extern u32 gpsp_gp2x_dev; -extern volatile u16 *gpsp_gp2x_memregs; -extern volatile u32 *gpsp_gp2x_memregl; void gp2x_sound_volume(u32 volume_up); void gp2x_quit(); diff --git a/gui.c b/gui.c index 21e1023..8a90aac 100644 --- a/gui.c +++ b/gui.c @@ -1281,10 +1281,15 @@ u32 menu(u16 *original_screen) &audio_buffer_size_number, 10, #endif +#ifdef PSP_BUILD "Set the size (in bytes) of the audio buffer. Larger values may result\n" "in slightly better performance at the cost of latency; the lowest\n" "value will give the most responsive audio.\n" "This option requires gpSP to be restarted before it will take effect.", +#else + "Set the size (in bytes) of the audio buffer.\n" + "This option requires gpSP restart to take effect.", +#endif 10), submenu_option(NULL, "Back", "Return to the main menu.", 12) }; diff --git a/input.c b/input.c index 2b17f50..3eee0b0 100644 --- a/input.c +++ b/input.c @@ -375,23 +375,7 @@ u32 gamepad_config_map[16] = }; extern u32 gp2x_fps_debug; - -u32 gpsp_gp2x_joystick_read(void) -{ - u32 value = (gpsp_gp2x_memregs[0x1198 >> 1] & 0x00FF); - - if(value == 0xFD) - value = 0xFA; - if(value == 0xF7) - value = 0xEB; - if(value == 0xDF) - value = 0xAF; - if(value == 0x7F) - value = 0xBE; - - return ~((gpsp_gp2x_memregs[0x1184 >> 1] & 0xFF00) | value | - (gpsp_gp2x_memregs[0x1186 >> 1] << 16)); -} +extern u32 gpsp_gp2x_joystick_read(void); gui_action_type get_gui_input() { diff --git a/main.c b/main.c index ac891cb..64329d0 100644 --- a/main.c +++ b/main.c @@ -49,6 +49,7 @@ u64 frame_count_initial_timestamp = 0; u64 last_frame_interval_timestamp; u32 gp2x_fps_debug = 0; +void gp2x_init(void); void gp2x_quit(void); #else @@ -194,14 +195,14 @@ int main(int argc, char *argv[]) #ifdef GP2X_BUILD if(gp2x_load_mmuhack() == -1) - delay_us(2500000); +;// delay_us(2500000); #endif #ifdef PSP_BUILD sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, vblank_interrupt_handler, NULL); sceKernelEnableSubIntr(PSP_VBLANK_INT, 0); -#else +#elif !defined(GP2X_BUILD) freopen("CON", "wb", stdout); #endif @@ -229,7 +230,7 @@ int main(int argc, char *argv[]) #ifdef GP2X_BUILD // Overclocking GP2X and MMU patch goes here - gp2x_overclock(); + gp2x_init(); #endif #ifdef GP2X_BUILD diff --git a/video.c b/video.c index 1240377..5a1181f 100644 --- a/video.c +++ b/video.c @@ -88,8 +88,13 @@ static void Ge_Finish_Callback(int id, void *arg) #else #ifdef GP2X_BUILD -#include "SDL_gp2x.h" -SDL_Surface *hw_screen; + #ifdef WIZ_BUILD + static void SDL_GP2X_AllowGfxMemory() {} + #include + #else + #include "SDL_gp2x.h" + #endif + SDL_Surface *hw_screen; #endif SDL_Surface *screen; const u32 video_scale = 1; -- 2.39.2