📄 cpu_threaded.c
字号:
/* gameplaySP * * Copyright (C) 2006 Exophase <exophase@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */// Not-so-important todo:// - stm reglist writeback when base is in the list needs adjustment// - block memory needs psr swapping and user mode reg swapping#include <stdio.h>#include "common.h"u8 rom_translation_cache[ROM_TRANSLATION_CACHE_SIZE];u8 *rom_translation_ptr = rom_translation_cache;u8 ram_translation_cache[RAM_TRANSLATION_CACHE_SIZE];u8 *ram_translation_ptr = ram_translation_cache;u32 iwram_code_min = 0xFFFFFFFF;u32 iwram_code_max = 0xFFFFFFFF;u32 ewram_code_min = 0xFFFFFFFF;u32 ewram_code_max = 0xFFFFFFFF;u8 bios_translation_cache[BIOS_TRANSLATION_CACHE_SIZE];u8 *bios_translation_ptr = bios_translation_cache;u32 *rom_branch_hash[ROM_BRANCH_HASH_SIZE];// Defaultu32 idle_loop_target_pc = 0xFFFFFFFF;u32 force_pc_update_target = 0xFFFFFFFF;u32 translation_gate_target_pc[MAX_TRANSLATION_GATES];u32 translation_gate_targets = 0;u32 iwram_stack_optimize = 1;u32 allow_smc_ram_u8 = 1;u32 allow_smc_ram_u16 = 1;u32 allow_smc_ram_u32 = 1;typedef struct{ u8 *block_offset; u16 flag_data; u8 condition; u8 update_cycles;} block_data_type;typedef struct{ u32 branch_target; u8 *branch_source;} block_exit_type;#ifdef PSP_BUILD#include "psp/mips_emit.h"#else#include "x86/x86_emit.h"#endifextern u8 bit_count[256];#define arm_decode_data_proc_reg() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_data_proc_imm() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 imm; \ ror(imm, opcode & 0xFF, ((opcode >> 8) & 0x0F) * 2) \#define arm_decode_psr_reg() \ u32 psr_field = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_psr_imm() \ u32 psr_field = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 imm; \ ror(imm, opcode & 0xFF, ((opcode >> 8) & 0x0F) * 2) \#define arm_decode_branchx() \ u32 rn = opcode & 0x0F \#define arm_decode_multiply() \ u32 rd = (opcode >> 16) & 0x0F; \ u32 rn = (opcode >> 12) & 0x0F; \ u32 rs = (opcode >> 8) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_multiply_long() \ u32 rdhi = (opcode >> 16) & 0x0F; \ u32 rdlo = (opcode >> 12) & 0x0F; \ u32 rs = (opcode >> 8) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_swap() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_half_trans_r() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_half_trans_of() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 offset = ((opcode >> 4) & 0xF0) | (opcode & 0x0F) \#define arm_decode_data_trans_imm() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 offset = opcode & 0x0FFF \#define arm_decode_data_trans_reg() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 rd = (opcode >> 12) & 0x0F; \ u32 rm = opcode & 0x0F \#define arm_decode_block_trans() \ u32 rn = (opcode >> 16) & 0x0F; \ u32 reg_list = opcode & 0xFFFF \#define arm_decode_branch() \ s32 offset = ((s32)(opcode & 0xFFFFFF) << 8) >> 6 \#define thumb_decode_shift() \ u32 imm = (opcode >> 6) & 0x1F; \ u32 rs = (opcode >> 3) & 0x07; \ u32 rd = opcode & 0x07 \#define thumb_decode_add_sub() \ u32 rn = (opcode >> 6) & 0x07; \ u32 rs = (opcode >> 3) & 0x07; \ u32 rd = opcode & 0x07 \#define thumb_decode_add_sub_imm() \ u32 imm = (opcode >> 6) & 0x07; \ u32 rs = (opcode >> 3) & 0x07; \ u32 rd = opcode & 0x07 \#define thumb_decode_imm() \ u32 imm = opcode & 0xFF \#define thumb_decode_alu_op() \ u32 rs = (opcode >> 3) & 0x07; \ u32 rd = opcode & 0x07 \#define thumb_decode_hireg_op() \ u32 rs = (opcode >> 3) & 0x0F; \ u32 rd = ((opcode >> 4) & 0x08) | (opcode & 0x07) \#define thumb_decode_mem_reg() \ u32 ro = (opcode >> 6) & 0x07; \ u32 rb = (opcode >> 3) & 0x07; \ u32 rd = opcode & 0x07 \#define thumb_decode_mem_imm() \ u32 imm = (opcode >> 6) & 0x1F; \ u32 rb = (opcode >> 3) & 0x07; \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -