Skip to content

Commit

Permalink
VWF Test Suite works
Browse files Browse the repository at this point in the history
  • Loading branch information
RPGHacker committed Apr 10, 2024
1 parent 78e4455 commit c45b937
Show file tree
Hide file tree
Showing 6 changed files with 813 additions and 162 deletions.
24 changes: 24 additions & 0 deletions patches/vwf_dialogues/data/testing/data/vwfmessages.asm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@
%vwf_claim_varram(box_anim_test_show_close, 1)


%vwf_register_test_suite_category("BasicCommands", "Basic Commands")
%vwf_register_test("BasicCommands", "Hub", $0050)
%vwf_register_test("BasicCommands", "Test 1", $0050)
%vwf_register_test("BasicCommands", "Test 2", $0050)
%vwf_register_test("BasicCommands", "Test 3", $0050)
%vwf_register_test("BasicCommands", "Test 4", $0050)
%vwf_register_test("BasicCommands", "Test 5", $0050)
%vwf_register_test("BasicCommands", "Test 6", $0050)
%vwf_register_test("BasicCommands", "Test 7", $0050)
%vwf_register_test("BasicCommands", "Test 8", $0050)
%vwf_register_test("BasicCommands", "Test 9", $0050)
%vwf_register_test("BasicCommands", "Test 10", $0050)
%vwf_register_test("BasicCommands", "Test 11", $0050)
%vwf_register_test("BasicCommands", "Test 12", $0050)
%vwf_register_test("BasicCommands", "Test 13", $0050)
%vwf_register_test("BasicCommands", "Test 14", $0050)
%vwf_register_test("BasicCommands", "Test 15", $0050)
%vwf_register_test("BasicCommands", "Test 16", $0050)
%vwf_register_test("BasicCommands", "Test 17", $0050)
%vwf_register_test("BasicCommands", "Test 18", $0050)
%vwf_register_test("BasicCommands", "Test 19", $0050)
%vwf_register_test("BasicCommands", "Test 20", $0050)


; Messages:

; RPG Hacker: Really, message $0050 (Yoshi's House) is the most important one for us, since it's the quickest one to get to.
Expand Down
1 change: 1 addition & 0 deletions patches/vwf_dialogues/package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ IF EXIST "./%patchname%.zip" (

"C:\Program Files\7-Zip\7z.exe" rn ./%patchname%.zip code/external/vwfsharedroutines.asm code/blocks/display_once_on_touch/vwfsharedroutines.asm
"C:\Program Files\7-Zip\7z.exe" a ./%patchname%.zip code/external/vwfsharedroutines.asm
"C:\Program Files\7-Zip\7z.exe" d ./%patchname%.zip vwftestsuite.asm

cd ..\..

Expand Down
2 changes: 2 additions & 0 deletions patches/vwf_dialogues/patch_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def main() -> None:

if options.messages_file == 'smw':
vwf_dialogues_asm.include_paths[0] = os.path.join(os.path.dirname(__file__), 'data/smw')
else:
vwf_dialogues_asm.defines.append('vwf_enable_test_suite=true')

if options.bit_mode == '16-bit':
vwf_dialogues_asm.defines.append('vwf_bit_mode=VWF_BitMode.16Bit')
Expand Down
160 changes: 1 addition & 159 deletions patches/vwf_dialogues/testing/uberasm/code/gamemode_code.asm
Original file line number Diff line number Diff line change
@@ -1,151 +1,7 @@
; This is here twice intentionally, to test the include guard.
incsrc "vwfsharedroutines.asm"
incsrc "vwfsharedroutines.asm"

macro write_stripe_image_header(x_pos, y_pos, data_size)
!temp_length = ((<data_size>)-1)

db %01010000|((<y_pos>&%100000)>>2)|((<x_pos>&%100000)>>3)|((<y_pos>&%011000)>>3)
db ((<y_pos>&%000111)<<5)|(<x_pos>&%011111)
db %00000000|((!temp_length&%11111100000000)>>8)
db !temp_length&%00000011111111

undef "temp_length"
endmacro

macro define_stripe_image_raw_line(x_pos, y_pos, ...)
!magic_token ?= .X
!magic_token += X

!magic_token:
%write_stripe_image_header(<x_pos>, <y_pos>, ..End-..Start)

..Start:
for i = 0..sizeof(...)
db <...[!i]>
db $39
endfor
..End:
endmacro

macro define_stripe_image_text_line(x_pos, y_pos, text)
pushtable

;!temp_property_byte #= %00111001
!temp_property_byte = 39

'A' = $!{temp_property_byte}00
'B' = $!{temp_property_byte}01
'C' = $!{temp_property_byte}02
'D' = $!{temp_property_byte}03
'E' = $!{temp_property_byte}04
'F' = $!{temp_property_byte}05
'G' = $!{temp_property_byte}06
'H' = $!{temp_property_byte}07
'I' = $!{temp_property_byte}08
'J' = $!{temp_property_byte}09
'K' = $!{temp_property_byte}0A
'L' = $!{temp_property_byte}0B
'M' = $!{temp_property_byte}0C
'N' = $!{temp_property_byte}0D
'O' = $!{temp_property_byte}0E
'P' = $!{temp_property_byte}0F

'Q' = $!{temp_property_byte}10
'R' = $!{temp_property_byte}11
'S' = $!{temp_property_byte}12
'T' = $!{temp_property_byte}13
'U' = $!{temp_property_byte}14
'V' = $!{temp_property_byte}15
'W' = $!{temp_property_byte}16
'X' = $!{temp_property_byte}17
'Y' = $!{temp_property_byte}18
'Z' = $!{temp_property_byte}19
'!' = $!{temp_property_byte}1A
'.' = $!{temp_property_byte}1B
'-' = $!{temp_property_byte}1C
',' = $!{temp_property_byte}1D
'?' = $!{temp_property_byte}1E
' ' = $!{temp_property_byte}1F

'a' = $!{temp_property_byte}40
'b' = $!{temp_property_byte}41
'c' = $!{temp_property_byte}42
'd' = $!{temp_property_byte}43
'e' = $!{temp_property_byte}44
'f' = $!{temp_property_byte}45
'g' = $!{temp_property_byte}46
'h' = $!{temp_property_byte}47
'i' = $!{temp_property_byte}48
'j' = $!{temp_property_byte}49
'k' = $!{temp_property_byte}4A
'l' = $!{temp_property_byte}4B
'm' = $!{temp_property_byte}4C
'n' = $!{temp_property_byte}4D
'o' = $!{temp_property_byte}4E
'p' = $!{temp_property_byte}4F

'q' = $!{temp_property_byte}50
'r' = $!{temp_property_byte}51
's' = $!{temp_property_byte}52
't' = $!{temp_property_byte}53
'u' = $!{temp_property_byte}54
'v' = $!{temp_property_byte}55
'w' = $!{temp_property_byte}56
'x' = $!{temp_property_byte}57
'y' = $!{temp_property_byte}58
'z' = $!{temp_property_byte}59
'#' = $!{temp_property_byte}5A
'(' = $!{temp_property_byte}5B
')' = $!{temp_property_byte}5C
''' = $!{temp_property_byte}5D : ''' = $!{temp_property_byte}5D

; Used as cursor character
'>' = $!{temp_property_byte}5E

undef "temp_property_byte"

!magic_token ?= .X
!magic_token += X

!magic_token:
%write_stripe_image_header(<x_pos>, <y_pos>, ..End-..Start)

..Start:
dw "<text>"
..End:

pulltable
endmacro

macro stripe_image_end()
db $FF
endmacro

macro transfer_stripe_image(address, size)
rep #$30

ldx.w #(<address>)

lda $7F837B
clc
adc.w #$7F837D
tay

lda.w #(<size>)
pha
dec
clc
adc $7F837B
sta $7F837B
pla

phb
mvn bank($7F837D), bank(<address>)
plb

sep #$30
endmacro

gamemode_0:
RTS
gamemode_1:
Expand Down Expand Up @@ -224,22 +80,8 @@ gamemode_14:
error "Whoops, VWF_DisplayAMessage routine not found. Did you patch UberASM before VWF Dialogues Patch?"
endif


lda.b #%00001000
tsb $3E
lda.b #%00000100
trb $40

%transfer_stripe_image(.TestImage, .TestImageEnd-.TestImage)

RTS

.TestImage
%define_stripe_image_raw_line(1, 32, $1F, $1F, $1F, $1F, $1F, $1F, $1F)
%define_stripe_image_text_line(2, 32, "Test")
%stripe_image_end()
.TestImageEnd

gamemode_15:
RTS
gamemode_16:
Expand Down
51 changes: 48 additions & 3 deletions patches/vwf_dialogues/vwf_dialogues.asm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if !use_sa1_mapping
endif

!vwf_debug_vblank_time ?= false
!vwf_enable_test_suite ?= false


!vwf_var_rampos #= 0
Expand Down Expand Up @@ -198,6 +199,11 @@ endmacro
%vwf_claim_varram(current_box_color, 6)
%vwf_claim_varram(current_box_frame, 1)

if !vwf_enable_test_suite != false
%vwf_claim_varram(current_test_suite_page, 1)
%vwf_claim_varram(current_test_suite_row, 1)
endif

!vwf_buffer_empty_tile = !vwf_gfx_ram
!vwf_buffer_bg_tile = !vwf_gfx_ram+$10
!vwf_buffer_frame = !vwf_gfx_ram+$20
Expand Down Expand Up @@ -749,8 +755,13 @@ endif
.NoOriginalMessageBoxRequested
; New code: If our own message box is open, also don't simulate frame.
lda !vwf_freeze_sprites
beq .RunGameFrame
if !vwf_enable_test_suite != false
bne .FreezeGame
lda !vwf_current_test_suite_page
endif
beq .RunGameFrame

.FreezeGame
jml remap_rom($00A1E3) ; Skip frame simulation

.RunGameFrame
Expand Down Expand Up @@ -793,6 +804,16 @@ NMIHijack:
jml remap_rom($00827A)

.NoSpecialIrqMode
if !vwf_enable_test_suite != false
lda !vwf_current_test_suite_page
beq .NoTestSuiteNMI

jsr TestSuiteNMI

bra .NMIEndWithoutHDMA
.NoTestSuiteNMI
endif

lda !vwf_mode
tax
lda.l .NMITable,x
Expand Down Expand Up @@ -864,14 +885,17 @@ endif
lda.b #$01
sta $2112

lda remap_ram($0DAE)
sta $2100
.NMIEnd
lda remap_ram($0D9F)
if !vwf_enable_smb3_status_bar_layer_3_hdma_fix_hack != false
and.b #%11111110
endif
sta $420C

.NMIEndWithoutHDMA
lda remap_ram($0DAE)
sta $2100

ldx.b #$81 ; Disable IRQ
if !use_sa1_mapping == false
stx $4200
Expand Down Expand Up @@ -986,6 +1010,15 @@ endif
jmp (.Routinetable,x)

.End
if !vwf_enable_test_suite != false
lda !vwf_mode
bne .RealEnd

jsr ProcessTestSuiteInput

.RealEnd
endif

if !use_sa1_mapping
else
plp ; Return
Expand Down Expand Up @@ -6069,6 +6102,12 @@ BackupTilemap:

Emptytile:
db $00,$20



if !vwf_enable_test_suite != false
incsrc vwftestsuite.asm
endif



Expand Down Expand Up @@ -6135,6 +6174,12 @@ MainDataStart:
%vwf_next_bank()

%vwf_generate_pointers()

if !vwf_enable_test_suite != false
%vwf_next_bank()
%vwf_generate_test_suite_tables()
%vwf_generate_test_suite_stripe_images()
endif


; Shared routine tables go here.
Expand Down
Loading

0 comments on commit c45b937

Please sign in to comment.