diff --git a/arm/arm_stub.S b/arm/arm_stub.S index f0b7f52..8e6cc9b 100644 --- a/arm/arm_stub.S +++ b/arm/arm_stub.S @@ -43,8 +43,8 @@ _##symbol: #define CPU_HALT_STATE (30 * 4) #define CHANGED_PC_STATUS (31 * 4) #define COMPLETED_FRAME (32 * 4) - -#define MAIN_THREAD_SP (33 * 4) +#define OAM_UPDATED (33 * 4) +#define MAIN_THREAD_SP (34 * 4) #define reg_a0 r0 #define reg_a1 r1 diff --git a/cpu.h b/cpu.h index fc57626..2b250ca 100644 --- a/cpu.h +++ b/cpu.h @@ -85,7 +85,8 @@ typedef enum CPU_MODE = 29, CPU_HALT_STATE = 30, CHANGED_PC_STATUS = 31, - COMPLETED_FRAME = 32 + COMPLETED_FRAME = 32, + OAM_UPDATED = 33 } ext_reg_numbers; typedef enum @@ -146,7 +147,6 @@ extern u8 *ram_translation_ptr; extern u32 idle_loop_target_pc; extern u32 iwram_stack_optimize; -extern u32 direct_map_vram; extern u32 translation_gate_targets; extern u32 translation_gate_target_pc[MAX_TRANSLATION_GATES]; diff --git a/gba_memory.c b/gba_memory.c index a51f183..e647304 100644 --- a/gba_memory.c +++ b/gba_memory.c @@ -342,14 +342,9 @@ gamepak_swap_entry_type *gamepak_memory_map; // a lot. FILE *gamepak_file_large = NULL; -u32 direct_map_vram = 0; - // Writes to these respective locations should trigger an update // so the related subsystem may react to it. -// If OAM is written to: -u32 oam_update = 1; - // If GBC audio is written to: u32 gbc_sound_update = 0; @@ -755,7 +750,7 @@ cpu_alert_type function_cc write_io_register8(u32 address, u32 value) u32 dispcnt = io_registers[REG_DISPCNT]; if((value & 0x07) != (dispcnt & 0x07)) - oam_update = 1; + reg[OAM_UPDATED] = 1; address8(io_registers, 0x00) = value; break; @@ -1171,7 +1166,7 @@ cpu_alert_type function_cc write_io_register16(u32 address, u32 value) { u32 dispcnt = io_registers[REG_DISPCNT]; if((value & 0x07) != (dispcnt & 0x07)) - oam_update = 1; + reg[OAM_UPDATED] = 1; address16(io_registers, 0x00) = value; break; @@ -1934,7 +1929,7 @@ void function_cc write_rtc(u32 address, u32 value) \ case 0x07: \ /* OAM RAM */ \ - oam_update = 1; \ + reg[OAM_UPDATED] = 1; \ address##type(oam_ram, address & 0x3FF) = value; \ break; \ \ @@ -2529,7 +2524,7 @@ dma_region_type dma_region_map[16] = dma_smc_vars_##type() #define dma_oam_ram_dest() \ - oam_update = 1 \ + reg[OAM_UPDATED] = 1 \ #define dma_vars_oam_ram(type) \ dma_oam_ram_##type() \ @@ -3331,7 +3326,7 @@ void gba_load_state(const void* src) wipe_caches(); #endif - oam_update = 1; + reg[OAM_UPDATED] = 1; gbc_sound_update = 1; for(i = 0; i < 512; i++) diff --git a/main.c b/main.c index 73371e4..2a82338 100644 --- a/main.c +++ b/main.c @@ -158,7 +158,7 @@ u32 update_gba(void) if((dispstat & 0x01) == 0) { u32 i; - if(oam_update) + if(reg[OAM_UPDATED]) oam_update_count++; if(no_alpha) diff --git a/psp/mips_emit.h b/psp/mips_emit.h index b996f2b..d24c174 100644 --- a/psp/mips_emit.h +++ b/psp/mips_emit.h @@ -2512,7 +2512,8 @@ u8 swi_hle_handle[256] = #define ReOff_SaveR1 (21*4) // 3 save scratch regs #define ReOff_SaveR2 (22*4) #define ReOff_SaveR3 (23*4) -#define ReOff_GP_Save (32*4) // GP_SAVE +#define ReOff_OamUpd (33*4) // OAM_UPDATED +#define ReOff_GP_Save (34*4) // GP_SAVE // Saves all regs to their right slot and loads gp #define emit_save_regs(save_a2) { \ @@ -2873,9 +2874,8 @@ static void emit_pmemst_stub( // Post processing store: // Signal that OAM was updated if (region == 7) { - u32 palcaddr = (u32)&oam_update; - mips_emit_lui(reg_temp, ((palcaddr + 0x8000) >> 16)); - mips_emit_sw(reg_base, reg_temp, palcaddr & 0xffff); // Write any nonzero data + // Write any nonzero data + mips_emit_sw(reg_base, reg_base, ReOff_OamUpd); generate_function_return_swap_delay(); } else { diff --git a/psp/mips_stub.S b/psp/mips_stub.S index 3d046d8..cc3a220 100644 --- a/psp/mips_stub.S +++ b/psp/mips_stub.S @@ -52,6 +52,7 @@ .global reg .global spsr .global reg_mode +.global oam_update # MIPS register layout: @@ -116,7 +117,8 @@ .equ CPU_HALT_STATE, (30 * 4) .equ CHANGED_PC_STATUS, (31 * 4) .equ COMPLETED_FRAME, (32 * 4) -.equ GP_SAVE, (33 * 4) +.equ OAM_UPDATED, (33 * 4) +.equ GP_SAVE, (34 * 4) .equ SPSR_BASE, (0x900) .equ REGMODE_BASE, (0x900 + 24) diff --git a/video.c b/video.c index 23cd368..4221f25 100644 --- a/video.c +++ b/video.c @@ -4429,10 +4429,10 @@ void update_scanline(void) // If OAM has been modified since the last scanline has been updated then // reorder and reprofile the OBJ lists. - if(oam_update) + if(reg[OAM_UPDATED]) { order_obj(video_mode); - oam_update = 0; + reg[OAM_UPDATED] = 0; } order_layers((dispcnt >> 8) & active_layers[video_mode]); diff --git a/x86/x86_stub.S b/x86/x86_stub.S index 9dd3fdd..948572c 100644 --- a/x86/x86_stub.S +++ b/x86/x86_stub.S @@ -28,7 +28,6 @@ _##symbol: #ifndef _WIN32 # External symbols (data + functions) -#define _oam_update oam_update #define _iwram iwram #define _ewram ewram #define _vram vram @@ -50,7 +49,6 @@ _##symbol: #define _execute_store_cpsr_body execute_store_cpsr_body #endif -.global _oam_update .global _iwram .global _ewram .global _vram @@ -75,6 +73,7 @@ _##symbol: .equ CPU_HALT_STATE, (30 * 4) .equ CHANGED_PC_STATUS, (31 * 4) .equ COMPLETED_FRAME, (32 * 4) +.equ OAM_UPDATED, (33 * 4) # destroys ecx and edx @@ -241,7 +240,7 @@ ext_store_vram8b: ret ext_store_oam8: - movl $1, _oam_update # flag OAM update + movl $1, OAM_UPDATED(%ebx) # flag OAM update and $0x3FE, %eax # wrap around address and align to 16bits mov %dl, %dh # copy lower 8bits of value into full 16bits mov %dx, _oam_ram(%eax) # perform 16bit store @@ -332,7 +331,7 @@ ext_store_vram16b: ret ext_store_oam16: - movl $1, _oam_update # flag OAM update + movl $1, OAM_UPDATED(%ebx) # flag OAM update and $0x3FF, %eax # wrap around address mov %dx, _oam_ram(%eax) # perform 16bit store ret @@ -410,7 +409,7 @@ ext_store_vram32b: ret ext_store_oam32: - movl $1, _oam_update # flag OAM update + movl $1, OAM_UPDATED(%ebx) # flag OAM update and $0x3FF, %eax # wrap around address mov %edx, _oam_ram(%eax) # perform 32bit store ret