From 4274ca78bab7334a67e079252e3202b15e39e0e9 Mon Sep 17 00:00:00 2001 From: RPG Hacker Date: Sat, 13 Jan 2024 18:47:33 +0100 Subject: [PATCH] Simplified more multiplications --- patches/vwf_dialogues/vwf_dialogues.asm | 30 +++++++++---------------- patches/vwf_dialogues/vwfroutines.asm | 21 +++++------------ 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/patches/vwf_dialogues/vwf_dialogues.asm b/patches/vwf_dialogues/vwf_dialogues.asm index 13c0335..274535c 100644 --- a/patches/vwf_dialogues/vwf_dialogues.asm +++ b/patches/vwf_dialogues/vwf_dialogues.asm @@ -3932,6 +3932,7 @@ endif .End jmp Buffer_End + HandleVWFStackByte1: .Pull @@ -3950,7 +3951,8 @@ HandleVWFStackByte1: sta !vwf_tm_stack_index_1 pla sta !vwf_tm_stack_1,x - rts + rts + HandleVWFStackByte2: .Pull @@ -3970,20 +3972,16 @@ HandleVWFStackByte2: pla sta !vwf_tm_stack_2,x rts + GetFont: - lda #$06 ; Multiply font number with 6 - sta.w select(!use_sa1_mapping,$2251,$211B) - stz.w select(!use_sa1_mapping,$2252,$211B) - stz.w select(!use_sa1_mapping,$2250,$211C) - lda !vwf_font - sta.w select(!use_sa1_mapping,$2253,$211C) -if !use_sa1_mapping - stz $2254 - nop -endif rep #$21 - lda.w select(!use_sa1_mapping,$2306,$2134) + lda !vwf_font + and.w #$00FF + asl ; This essentially multiplies by 6 (implemented as a 4n + 2n) + sta $00 + asl + adc $00 adc.w #FontTable ; Add starting address sta $00 sep #$20 @@ -3997,13 +3995,7 @@ endif iny cpy #$06 bne .Loop - rts - -; RPG Hacker: This might make 16-bit builds notably slower. -; Though maybe not, since VWF_GenerateVWF isn't usually called for more than one character. -GetFontLong: - jsr GetFont - rtl + rts GetDestination: diff --git a/patches/vwf_dialogues/vwfroutines.asm b/patches/vwf_dialogues/vwfroutines.asm index 8e59a0d..476e897 100644 --- a/patches/vwf_dialogues/vwfroutines.asm +++ b/patches/vwf_dialogues/vwfroutines.asm @@ -109,7 +109,7 @@ elseif !vwf_bit_mode == VWF_BitMode.16Bit ldy.w !vwf_char+1 sty.w !vwf_font jsr .GetFont - ldy.b $05 + ldy.b $05 ; Required here because .GetFont overwrites $0E sty.b $0E lda.b $03 clc @@ -298,21 +298,12 @@ endif ; made it incompatible with the other one, and this is simply the easiest way to fix that. if !vwf_bit_mode == VWF_BitMode.16Bit .GetFont: - sep #$20 - lda.b #$06 ; Multiply font number with 6 - sta.l select(!use_sa1_mapping,$2251,$211B) - lda.b #$00 - sta.l select(!use_sa1_mapping,$2252,$211B) - sta.l select(!use_sa1_mapping,$2250,$211C) lda.w !vwf_font - sta.l select(!use_sa1_mapping,$2253,$211C) -if !use_sa1_mapping - lda.b #$00 - sta.l $2254 - nop -endif - rep #$20 - lda.l select(!use_sa1_mapping,$2306,$2134) + and.w #$00FF + asl ; This essentially multiplies by 6 (implemented as a 4n + 2n) + sta $0E + asl + adc $0E clc adc.w #FontTable ; Add starting address sta.b $00