Skip to content

Commit

Permalink
Simplified more multiplications
Browse files Browse the repository at this point in the history
  • Loading branch information
RPGHacker committed Jan 13, 2024
1 parent 8b95108 commit 4274ca7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 34 deletions.
30 changes: 11 additions & 19 deletions patches/vwf_dialogues/vwf_dialogues.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3932,6 +3932,7 @@ endif

.End
jmp Buffer_End


HandleVWFStackByte1:
.Pull
Expand All @@ -3950,7 +3951,8 @@ HandleVWFStackByte1:
sta !vwf_tm_stack_index_1
pla
sta !vwf_tm_stack_1,x
rts
rts


HandleVWFStackByte2:
.Pull
Expand All @@ -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
Expand All @@ -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:
Expand Down
21 changes: 6 additions & 15 deletions patches/vwf_dialogues/vwfroutines.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4274ca7

Please sign in to comment.