test(asar): fix ROM patch fixtures
This commit is contained in:
@@ -52,6 +52,7 @@ class AsarRomIntegrationTest : public RomDependentTest {
|
|||||||
std::ofstream simple_file(simple_patch_path_);
|
std::ofstream simple_file(simple_patch_path_);
|
||||||
simple_file << R"(
|
simple_file << R"(
|
||||||
; Simple Asar patch for real ROM testing
|
; Simple Asar patch for real ROM testing
|
||||||
|
lorom
|
||||||
org $008000
|
org $008000
|
||||||
yaze_test_entry:
|
yaze_test_entry:
|
||||||
sei ; Disable interrupts
|
sei ; Disable interrupts
|
||||||
@@ -98,24 +99,20 @@ yaze_test_data:
|
|||||||
gameplay_file << R"(
|
gameplay_file << R"(
|
||||||
; Gameplay modification patch for testing
|
; Gameplay modification patch for testing
|
||||||
; This modifies Link's starting health and magic
|
; This modifies Link's starting health and magic
|
||||||
|
lorom
|
||||||
|
|
||||||
; Increase Link's maximum health
|
!player_health = $7EF36C
|
||||||
org $7EF36C
|
!player_magic = $7EF36E
|
||||||
db $A0 ; 160/8 = 20 hearts (was usually $60 = 12 hearts)
|
|
||||||
|
|
||||||
; Increase Link's maximum magic
|
|
||||||
org $7EF36E
|
|
||||||
db $80 ; Full magic meter
|
|
||||||
|
|
||||||
; Custom routine for health restoration
|
; Custom routine for health restoration
|
||||||
org $00C000
|
org $00C000
|
||||||
yaze_health_restore:
|
yaze_health_restore:
|
||||||
sep #$20 ; 8-bit A
|
sep #$20 ; 8-bit A
|
||||||
lda #$A0 ; Full health
|
lda #$A0 ; Full health
|
||||||
sta $7EF36C ; Current health
|
sta !player_health ; Current health
|
||||||
|
|
||||||
lda #$80 ; Full magic
|
lda #$80 ; Full magic
|
||||||
sta $7EF36E ; Current magic
|
sta !player_magic ; Current magic
|
||||||
|
|
||||||
rep #$20 ; 16-bit A
|
rep #$20 ; 16-bit A
|
||||||
rtl
|
rtl
|
||||||
@@ -132,6 +129,7 @@ org $008012
|
|||||||
std::ofstream symbols_file(symbols_patch_path_);
|
std::ofstream symbols_file(symbols_patch_path_);
|
||||||
symbols_file << R"(
|
symbols_file << R"(
|
||||||
; Comprehensive symbol test for Asar integration
|
; Comprehensive symbol test for Asar integration
|
||||||
|
lorom
|
||||||
|
|
||||||
; Define some constants
|
; Define some constants
|
||||||
!player_x = $7E0020
|
!player_x = $7E0020
|
||||||
@@ -181,18 +179,34 @@ update_player:
|
|||||||
|
|
||||||
; Process movement
|
; Process movement
|
||||||
bit #$08 ; Up
|
bit #$08 ; Up
|
||||||
beq +
|
beq yaze_skip_up
|
||||||
dec !player_y
|
lda !player_y
|
||||||
+ bit #$04 ; Down
|
sec
|
||||||
beq +
|
sbc #$01
|
||||||
inc !player_y
|
sta !player_y
|
||||||
+ bit #$02 ; Left
|
yaze_skip_up:
|
||||||
beq +
|
bit #$04 ; Down
|
||||||
dec !player_x
|
beq yaze_skip_down
|
||||||
+ bit #$01 ; Right
|
lda !player_y
|
||||||
beq +
|
clc
|
||||||
inc !player_x
|
adc #$01
|
||||||
+
|
sta !player_y
|
||||||
|
yaze_skip_down:
|
||||||
|
bit #$02 ; Left
|
||||||
|
beq yaze_skip_left
|
||||||
|
lda !player_x
|
||||||
|
sec
|
||||||
|
sbc #$01
|
||||||
|
sta !player_x
|
||||||
|
yaze_skip_left:
|
||||||
|
bit #$01 ; Right
|
||||||
|
beq yaze_skip_right
|
||||||
|
lda !player_x
|
||||||
|
clc
|
||||||
|
adc #$01
|
||||||
|
sta !player_x
|
||||||
|
yaze_skip_right:
|
||||||
|
|
||||||
rep #$20
|
rep #$20
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@@ -331,9 +345,8 @@ TEST_F(AsarRomIntegrationTest, GameplayModificationPatch) {
|
|||||||
// Check health modification at 0x7EF36C -> ROM offset would need calculation
|
// Check health modification at 0x7EF36C -> ROM offset would need calculation
|
||||||
// For a proper test, we'd need to convert SNES addresses to ROM offsets
|
// For a proper test, we'd need to convert SNES addresses to ROM offsets
|
||||||
|
|
||||||
// Check if custom routine was inserted at 0xC000 -> ROM offset 0x18000 (in
|
// Check if custom routine was inserted at $00:C000 -> ROM offset $004000 (LoROM)
|
||||||
// LoROM)
|
const uint32_t rom_offset = 0x4000;
|
||||||
const uint32_t rom_offset = 0x18000; // Bank $00:C000 in LoROM
|
|
||||||
if (rom_offset < rom_copy.size()) {
|
if (rom_offset < rom_copy.size()) {
|
||||||
// Check for SEP #$20 instruction (0xE2 0x20)
|
// Check for SEP #$20 instruction (0xE2 0x20)
|
||||||
EXPECT_EQ(rom_copy[rom_offset], 0xE2);
|
EXPECT_EQ(rom_copy[rom_offset], 0xE2);
|
||||||
|
|||||||
Reference in New Issue
Block a user