From eac69717338922e6bb55076e57d7674080291fe9 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 3 Sep 2011 00:58:39 +0300 Subject: [PATCH] revive PC build, support Linux --- common.h | 4 ++-- cpu_threaded.c | 14 ++++++++++---- gui.c | 6 +++--- x86/Makefile | 6 +++--- x86/x86_stub.S | 46 +++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/common.h b/common.h index 6b1cf95..c3c03ba 100644 --- a/common.h +++ b/common.h @@ -114,8 +114,8 @@ typedef signed char s8; typedef unsigned short int u16; typedef signed short int s16; - typedef unsigned long u32; - typedef signed long s32; + typedef unsigned int u32; + typedef signed int s32; typedef unsigned long long int u64; typedef signed long long int s64; diff --git a/cpu_threaded.c b/cpu_threaded.c index 62e2991..c1d85a8 100644 --- a/cpu_threaded.c +++ b/cpu_threaded.c @@ -2837,7 +2837,7 @@ u8 function_cc *block_lookup_address_##type(u32 pc) \ char buffer[256]; \ sprintf(buffer, "bad jump %x (%x) (%x)\n", pc, reg[REG_PC], \ last_instruction); \ - printf(buffer); \ + printf("%s", buffer); \ quit(); \ } \ block_address = (u8 *)(-1); \ @@ -3407,8 +3407,10 @@ void flush_translation_cache_ram() invalidate_icache_region(ram_translation_cache, (ram_translation_ptr - ram_translation_cache) + 0x100); #endif - ram_translation_ptr = ram_translation_cache; +#ifdef ARM_ARCH last_ram_translation_ptr = ram_translation_cache; +#endif + ram_translation_ptr = ram_translation_cache; ram_block_tag_top = 0x0101; if(iwram_code_min != 0xFFFFFFFF) { @@ -3462,9 +3464,11 @@ void flush_translation_cache_rom() invalidate_icache_region(rom_translation_cache, rom_translation_ptr - rom_translation_cache + 0x100); #endif +#ifdef ARM_ARCH + last_rom_translation_ptr = rom_translation_cache; +#endif rom_translation_ptr = rom_translation_cache; - last_rom_translation_ptr = rom_translation_cache; memset(rom_branch_hash, 0, sizeof(rom_branch_hash)); } @@ -3474,10 +3478,12 @@ void flush_translation_cache_bios() invalidate_icache_region(bios_translation_cache, bios_translation_ptr - bios_translation_cache + 0x100); #endif +#ifdef ARM_ARCH + last_bios_translation_ptr = bios_translation_cache; +#endif bios_block_tag_top = 0x0101; bios_translation_ptr = bios_translation_cache; - last_bios_translation_ptr = bios_translation_cache; memset(bios_rom + 0x4000, 0, 0x4000); } diff --git a/gui.c b/gui.c index 165c669..a08bb63 100644 --- a/gui.c +++ b/gui.c @@ -832,10 +832,10 @@ s32 load_config_file() { u8 config_path[512]; - #if (defined(PSP_BUILD) || defined(ARM_ARCH)) && !defined(_WIN32_WCE) - sprintf(config_path, "%s/%s", main_path, GPSP_CONFIG_FILENAME); - #else + #if defined(_WIN32) || defined(_WIN32_WCE) sprintf(config_path, "%s\\%s", main_path, GPSP_CONFIG_FILENAME); + #else + sprintf(config_path, "%s/%s", main_path, GPSP_CONFIG_FILENAME); #endif file_open(config_file, config_path, read); diff --git a/x86/Makefile b/x86/Makefile index e0a5767..c9bf680 100644 --- a/x86/Makefile +++ b/x86/Makefile @@ -15,9 +15,9 @@ BIN ?= gpsp.exe # Platform specific definitions VPATH += .. -CFLAGS += -DPC_BUILD +CFLAGS += -DPC_BUILD -m32 INCLUDES = -I${PREFIX}/include `sdl-config --cflags` -LIBS = -L${PREFIX}/lib `sdl-config --libs` -mconsole -lz +LIBS = -L${PREFIX}/lib `sdl-config --libs` -mconsole -lz -m32 # Compilation: @@ -27,7 +27,7 @@ LIBS = -L${PREFIX}/lib `sdl-config --libs` -mconsole -lz ${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< %.o: %.S - ${AS} -o $@ $< + ${CC} ${CFLAGS} -c -o $@ $< all: ${OBJS} ${CC} ${OBJS} ${LIBS} -o ${BIN} diff --git a/x86/x86_stub.S b/x86/x86_stub.S index 8fc16b7..31aa9b1 100644 --- a/x86/x86_stub.S +++ b/x86/x86_stub.S @@ -18,6 +18,46 @@ .align 4 +#ifndef _WIN32 +#define _x86_update_gba x86_update_gba +#define _x86_indirect_branch_arm x86_indirect_branch_arm +#define _x86_indirect_branch_thumb x86_indirect_branch_thumb +#define _x86_indirect_branch_dual x86_indirect_branch_dual +#define _execute_store_u8 execute_store_u8 +#define _execute_store_u16 execute_store_u16 +#define _execute_store_u32 execute_store_u32 +#define _execute_store_cpsr execute_store_cpsr +#define _execute_arm_translate execute_arm_translate +#define _step_debug_x86 step_debug_x86 +#define _memory_map_read memory_map_read +#define _memory_map_write memory_map_write +#define _reg reg +#define _oam_update oam_update +#define _iwram iwram +#define _ewram ewram +#define _vram vram +#define _oam_ram oam_ram +#define _bios_rom bios_rom +#define _io_registers io_registers +#define _spsr spsr + +#define _step_debug step_debug +#define _update_gba update_gba +#define _block_lookup_address_arm block_lookup_address_arm +#define _block_lookup_address_thumb block_lookup_address_thumb +#define _block_lookup_address_dual block_lookup_address_dual +#define _write_io_register8 write_io_register8 +#define _write_io_register16 write_io_register16 +#define _write_io_register32 write_io_register32 +#define _palette_ram palette_ram +#define _palette_ram_converted palette_ram_converted +#define _flush_translation_cache_ram flush_translation_cache_ram +#define _write_eeprom write_eeprom +#define _write_backup write_backup +#define _write_rtc write_rtc +#define _execute_store_cpsr_body execute_store_cpsr_body +#endif + .global _x86_update_gba .global _x86_indirect_branch_arm .global _x86_indirect_branch_thumb @@ -88,7 +128,7 @@ mov REG_CPSR(%ebx), %edx shr $\shift, %edx and $0x01, %edx - mov %edx, _reg + \offset + mov %edx, \offset(%ebx) .endm .macro extract_flags @@ -472,7 +512,7 @@ lookup_pc_arm: # eax: cycle counter _execute_arm_translate: - movl $_reg, %ebx # load base register + movl (_reg), %ebx # load base register extract_flags # load flag variables movl %eax, %edi # load edi cycle counter @@ -496,6 +536,6 @@ _step_debug_x86: .comm _memory_map_read 0x8000 .comm _memory_map_write 0x8000 -.comm _reg 0x100 +.comm _reg 4 -- 2.39.5