Merge pull request #56 from bmaupin/enable-psp-dynarec
Reenable dynarec for PSP
This commit is contained in:
commit
a6d35e0165
|
@ -1,3 +1,4 @@
|
||||||
|
*.a
|
||||||
*.o
|
*.o
|
||||||
*.u
|
*.u
|
||||||
*.z
|
*.z
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -217,9 +217,11 @@ else ifeq ($(platform), psp1)
|
||||||
CFLAGS += -DPSP -G0
|
CFLAGS += -DPSP -G0
|
||||||
CFLAGS += -I$(shell psp-config --pspsdk-path)/include
|
CFLAGS += -I$(shell psp-config --pspsdk-path)/include
|
||||||
CFLAGS += -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi
|
CFLAGS += -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi
|
||||||
CFLAGS += -fomit-frame-pointer -ffast-math -fstrict-aliasing
|
CFLAGS += -fomit-frame-pointer -ffast-math
|
||||||
CFLAGS += -falign-functions=32 -falign-loops -falign-labels -falign-jumps
|
CFLAGS += -falign-functions=32 -falign-loops -falign-labels -falign-jumps
|
||||||
STATIC_LINKING = 1
|
STATIC_LINKING = 1
|
||||||
|
HAVE_DYNAREC = 1
|
||||||
|
CPU_ARCH := mips
|
||||||
|
|
||||||
# Vita
|
# Vita
|
||||||
else ifeq ($(platform), vita)
|
else ifeq ($(platform), vita)
|
||||||
|
|
|
@ -29,6 +29,9 @@ endif
|
||||||
ifeq ($(CPU_ARCH), arm)
|
ifeq ($(CPU_ARCH), arm)
|
||||||
SOURCES_ASM += $(CORE_DIR)/arm/arm_stub.S
|
SOURCES_ASM += $(CORE_DIR)/arm/arm_stub.S
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(CPU_ARCH), mips)
|
||||||
|
SOURCES_ASM += $(CORE_DIR)/psp/mips_stub.S
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CPU_ARCH), arm)
|
ifeq ($(CPU_ARCH), arm)
|
||||||
|
|
14
common.h
14
common.h
|
@ -49,7 +49,7 @@
|
||||||
// Huge thanks to pollux for the heads up on using native file I/O
|
// Huge thanks to pollux for the heads up on using native file I/O
|
||||||
// functions on PSP for vastly improved memstick performance.
|
// functions on PSP for vastly improved memstick performance.
|
||||||
|
|
||||||
#ifdef PSP_BUILD
|
#ifdef PSP
|
||||||
#define fastcall
|
#define fastcall
|
||||||
|
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
|
@ -90,12 +90,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define GBA_SCREEN_WIDTH (240)
|
|
||||||
#define GBA_SCREEN_HEIGHT (160)
|
|
||||||
#define GBA_SCREEN_PITCH (240)
|
|
||||||
|
|
||||||
void switch_to_main_thread(void);
|
|
||||||
|
|
||||||
typedef unsigned char u8;
|
typedef unsigned char u8;
|
||||||
typedef signed char s8;
|
typedef signed char s8;
|
||||||
typedef unsigned short int u16;
|
typedef unsigned short int u16;
|
||||||
|
@ -133,6 +127,12 @@ void switch_to_main_thread(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GBA_SCREEN_WIDTH (240)
|
||||||
|
#define GBA_SCREEN_HEIGHT (160)
|
||||||
|
#define GBA_SCREEN_PITCH (240)
|
||||||
|
|
||||||
|
void switch_to_main_thread(void);
|
||||||
|
|
||||||
// These must be variables, not constants.
|
// These must be variables, not constants.
|
||||||
|
|
||||||
#define file_read_variable(filename_tag, variable) \
|
#define file_read_variable(filename_tag, variable) \
|
||||||
|
|
2
cpu.h
2
cpu.h
|
@ -119,7 +119,7 @@ s32 translate_block_arm(u32 pc, translation_region_type translation_region,
|
||||||
s32 translate_block_thumb(u32 pc, translation_region_type translation_region,
|
s32 translate_block_thumb(u32 pc, translation_region_type translation_region,
|
||||||
u32 smc_enable);
|
u32 smc_enable);
|
||||||
|
|
||||||
#if defined(PSP_BUILD)
|
#if defined(PSP)
|
||||||
|
|
||||||
#define ROM_TRANSLATION_CACHE_SIZE (1024 * 512 * 4)
|
#define ROM_TRANSLATION_CACHE_SIZE (1024 * 512 * 4)
|
||||||
#define RAM_TRANSLATION_CACHE_SIZE (1024 * 384)
|
#define RAM_TRANSLATION_CACHE_SIZE (1024 * 384)
|
||||||
|
|
|
@ -227,7 +227,7 @@ extern u8 bit_count[256];
|
||||||
u32 offset = opcode & 0x07FF \
|
u32 offset = opcode & 0x07FF \
|
||||||
|
|
||||||
|
|
||||||
#ifdef PSP_BUILD
|
#ifdef PSP
|
||||||
|
|
||||||
#include "psp/mips_emit.h"
|
#include "psp/mips_emit.h"
|
||||||
|
|
||||||
|
@ -257,8 +257,10 @@ static INLINE void RW_END(void)
|
||||||
|
|
||||||
/* Cache invalidation */
|
/* Cache invalidation */
|
||||||
|
|
||||||
#if defined(PSP_BUILD)
|
#if defined(PSP)
|
||||||
#define translate_invalidate_dcache() sceKernelDcacheWritebackAll()
|
#define translate_invalidate_dcache() sceKernelDcacheWritebackAll()
|
||||||
|
#define invalidate_icache_region(addr, size) (void)0
|
||||||
|
|
||||||
#elif defined(VITA)
|
#elif defined(VITA)
|
||||||
#define translate_invalidate_dcache_one(which) \
|
#define translate_invalidate_dcache_one(which) \
|
||||||
if (which##_translation_ptr > last_##which##_translation_ptr) \
|
if (which##_translation_ptr > last_##which##_translation_ptr) \
|
||||||
|
|
|
@ -343,7 +343,7 @@ gamepak_swap_entry_type *gamepak_memory_map;
|
||||||
// This is global so that it can be kept open for large ROMs to swap
|
// This is global so that it can be kept open for large ROMs to swap
|
||||||
// pages from, so there's no slowdown with opening and closing the file
|
// pages from, so there's no slowdown with opening and closing the file
|
||||||
// a lot.
|
// a lot.
|
||||||
#ifdef PSP_BUILD
|
#ifdef PSP
|
||||||
|
|
||||||
file_tag_type gamepak_file_large = -1;
|
file_tag_type gamepak_file_large = -1;
|
||||||
|
|
||||||
|
@ -2391,9 +2391,7 @@ static s32 load_game_config(char *gamepak_title, char *gamepak_code, char *gamep
|
||||||
fclose(config_file);
|
fclose(config_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PSP_BUILD
|
|
||||||
printf("game config missing\n");
|
printf("game config missing\n");
|
||||||
#endif
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2418,7 +2416,7 @@ static s32 load_gamepak_raw(const char *name)
|
||||||
|
|
||||||
file_close(gamepak_file);
|
file_close(gamepak_file);
|
||||||
|
|
||||||
#ifdef PSP_BUILD
|
#ifdef PSP
|
||||||
gamepak_file_large = -1;
|
gamepak_file_large = -1;
|
||||||
#else
|
#else
|
||||||
gamepak_file_large = NULL;
|
gamepak_file_large = NULL;
|
||||||
|
|
6
main.c
6
main.c
|
@ -280,13 +280,15 @@ void reset_gba(void)
|
||||||
reset_sound();
|
reset_sound();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 file_length(const char *dummy, FILE *fp)
|
#ifdef PSP
|
||||||
|
u32 file_length(const char *filename, s32 dummy)
|
||||||
{
|
{
|
||||||
#ifdef PSP_BUILD
|
|
||||||
SceIoStat stats;
|
SceIoStat stats;
|
||||||
sceIoGetstat(filename, &stats);
|
sceIoGetstat(filename, &stats);
|
||||||
return stats.st_size;
|
return stats.st_size;
|
||||||
#else
|
#else
|
||||||
|
u32 file_length(const char *dummy, FILE *fp)
|
||||||
|
{
|
||||||
u32 length;
|
u32 length;
|
||||||
|
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
|
|
4
main.h
4
main.h
|
@ -83,8 +83,8 @@ void main_write_savestate(void);
|
||||||
void main_read_savestate(void);
|
void main_read_savestate(void);
|
||||||
|
|
||||||
|
|
||||||
#ifdef PSP_BUILD
|
#ifdef PSP
|
||||||
u32 file_length(char *filename, s32 dummy);
|
u32 file_length(const char *filename, s32 dummy);
|
||||||
#else
|
#else
|
||||||
u32 file_length(const char *dummy, FILE *fp);
|
u32 file_length(const char *dummy, FILE *fp);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1553,9 +1553,13 @@ typedef enum
|
||||||
|
|
||||||
#define arm_generate_op_imm(name, load_op) \
|
#define arm_generate_op_imm(name, load_op) \
|
||||||
arm_decode_data_proc_imm(opcode); \
|
arm_decode_data_proc_imm(opcode); \
|
||||||
|
ror(imm, imm, imm_ror); \
|
||||||
arm_op_check_##load_op(); \
|
arm_op_check_##load_op(); \
|
||||||
generate_op_##name##_imm(arm_to_mips_reg[rd], arm_to_mips_reg[rn]) \
|
generate_op_##name##_imm(arm_to_mips_reg[rd], arm_to_mips_reg[rn]) \
|
||||||
|
|
||||||
|
#define arm_generate_op_imm_flags(name, load_op) \
|
||||||
|
arm_generate_op_imm(name, load_op) \
|
||||||
|
|
||||||
#define arm_data_proc(name, type, flags_op) \
|
#define arm_data_proc(name, type, flags_op) \
|
||||||
{ \
|
{ \
|
||||||
arm_generate_op_##type(name, yes); \
|
arm_generate_op_##type(name, yes); \
|
||||||
|
@ -2137,10 +2141,16 @@ u32 execute_store_cpsr_body(u32 _cpsr, u32 store_mask, u32 address)
|
||||||
mips_emit_addiu(arm_to_mips_reg[_rd], reg_r13, (imm * 4)); \
|
mips_emit_addiu(arm_to_mips_reg[_rd], reg_r13, (imm * 4)); \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
#define thumb_adjust_sp(value) \
|
#define thumb_adjust_sp_up() \
|
||||||
|
mips_emit_addiu(reg_r13, reg_r13, (imm * 4)); \
|
||||||
|
|
||||||
|
#define thumb_adjust_sp_down() \
|
||||||
|
mips_emit_addiu(reg_r13, reg_r13, -(imm * 4)); \
|
||||||
|
|
||||||
|
#define thumb_adjust_sp(direction) \
|
||||||
{ \
|
{ \
|
||||||
thumb_decode_add_sp(); \
|
thumb_decode_add_sp(); \
|
||||||
mips_emit_addiu(reg_r13, reg_r13, (value)); \
|
thumb_adjust_sp_##direction(); \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
// Decode types: shift, alu_op
|
// Decode types: shift, alu_op
|
||||||
|
@ -2203,6 +2213,9 @@ u32 execute_store_cpsr_body(u32 _cpsr, u32 store_mask, u32 address)
|
||||||
#define thumb_access_memory_generate_address_reg_imm(offset, reg_rb, reg_ro) \
|
#define thumb_access_memory_generate_address_reg_imm(offset, reg_rb, reg_ro) \
|
||||||
mips_emit_addiu(reg_a0, arm_to_mips_reg[reg_rb], (offset)) \
|
mips_emit_addiu(reg_a0, arm_to_mips_reg[reg_rb], (offset)) \
|
||||||
|
|
||||||
|
#define thumb_access_memory_generate_address_reg_imm_sp(offset, reg_rb, reg_ro) \
|
||||||
|
mips_emit_addiu(reg_a0, arm_to_mips_reg[reg_rb], (offset * 4)) \
|
||||||
|
|
||||||
#define thumb_access_memory_generate_address_reg_reg(offset, reg_rb, reg_ro) \
|
#define thumb_access_memory_generate_address_reg_reg(offset, reg_rb, reg_ro) \
|
||||||
mips_emit_addu(reg_a0, arm_to_mips_reg[reg_rb], arm_to_mips_reg[reg_ro]) \
|
mips_emit_addu(reg_a0, arm_to_mips_reg[reg_rb], arm_to_mips_reg[reg_ro]) \
|
||||||
|
|
||||||
|
|
|
@ -3343,8 +3343,13 @@ ror_zero_shift:
|
||||||
|
|
||||||
execute_arm_translate:
|
execute_arm_translate:
|
||||||
addu $17, $4, $0 # load cycle counter register
|
addu $17, $4, $0 # load cycle counter register
|
||||||
lui $16, %hi(reg) # load base register
|
|
||||||
addiu $16, %lo(reg)
|
lui $4, %hi(arm_reg) # load arm_reg address into $4
|
||||||
|
addiu $4, %lo(arm_reg)
|
||||||
|
|
||||||
|
jal move_reg # update reg to point to arm_reg
|
||||||
|
addu $16, $4, $0 # copy address of arm_reg into $16
|
||||||
|
|
||||||
extract_flags # load flag variables
|
extract_flags # load flag variables
|
||||||
|
|
||||||
and $1, $1, 0x20 # see if Thumb bit is set in flags
|
and $1, $1, 0x20 # see if Thumb bit is set in flags
|
||||||
|
@ -3405,9 +3410,10 @@ iac_loop:
|
||||||
memory_map_read:
|
memory_map_read:
|
||||||
.space 0x8000
|
.space 0x8000
|
||||||
|
|
||||||
reg:
|
# This must be between memory_map_read and memory_map_write because it's used
|
||||||
|
# to calculate their addresses elsewhere in this file.
|
||||||
|
arm_reg:
|
||||||
.space 0x100
|
.space 0x100
|
||||||
|
|
||||||
memory_map_write:
|
memory_map_write:
|
||||||
.space 0x8000
|
.space 0x8000
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue