From what I heard, most of the slowdown seen in hack are due to blocktool's ASM code, wich take more cycle to execute each time a custom block is inserted. Here a partial disassembly of the code used:
Code
;;;;;;;;;;;;;;;;;;;;;;;;;
;blktool ASM disassembly;
;;;;;;;;;;;;;;;;;;;;;;;;;
org $86F690
$86/F690: JSL Below ;entry point for below offset
org $90BB2E
Below:
$10/BB2E: REP #$20
$10/BB30: LDA #$BB97
$10/BB33: STA $7EBD00
$10/BB37: LDA #$BBA3
$10/BB3A: STA $7EBD02
$10/BB3E: LDA #$0006
$10/BB41: STA $7EBD04
$10/BB45: LDA #$BBAF
$10/BB48: STA $7EBD06
$10/BB4C: JSR Main
org $90BFEA
Main:
$10/BFEA: PHX
$10/BFEB: PHY
$10/BFEC: PHB
$10/BFED: PHK
$10/BFEE: PLB
$10/BFEF: REP #$30
$10/BFF1: LDA $7EBD06
$10/BFF5: STA $05
$10/BFF7: LDA $7EBD04 ;\
$10/BFFB: AND #$00FF ; |load the number of blocks and store it into X
$10/BFFE: TAX ;/
$10/BFFF: LDA #$0000 ;\
$10/C002: TAY ;/reset Y to $0000
$10/C003: LDA $7EBD00
$10/C007: STA $00
loop:
$10/C009: LDA ($05),y
$10/C00B: BEQ label2
$10/C00D: LDA ($00),y
$10/C00F: CMP $03
$10/C011: BEQ toblockcode
$10/C013: BRA label1
label2:
$90/C015: INY
$90/C016: SEP #$20
$90/C018: LDA ($00),y
$90/C01A: DEY
$90/C01B: CMP $04
$90/C01D: REP #$20
$90/C01F: BEQ toblockcode
label1:
$10/C021: INY
$10/C022: INY
$10/C023: DEX
$10/C024: BNE loop
$10/C026: SEP #$30 ;\
$10/C028: PLB ; |
$10/C029: PLY ; |if no match found, exit
$10/C02A: PLX ; |
$10/C02B: RTS ;/
toblockcode:
$10/C02C: REP #$20
$10/C02E: NOP ;\
$10/C02F: NOP ; |w00t at useless NOPs
$10/C030: NOP ;/
$10/C031: LDA $7EBD02 ;\
$10/C035: STA $00 ; |load the pointer to the block code
$10/C037: LDA ($00),y ; |
$10/C039: STA $00 ;/
$10/C03B: SEP #$30
$10/C03D: PLB
$10/C03E: PLY
$10/C03F: PLX
$10/C040: LDA #$00
$10/C042: STA $7EBD06
$10/C046: JMP ($0000) ;jump to custom block code
The Main part is executed 8 time(one for each blocktool offset), I already "fixed" it by converting the main part to SuperFX ASM
Code
SNES Part:
org $10BFF1
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Blktool optimisation code;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
blktoolfix:
LDA $7EBD06 ;\
sta $7F16 ; |
lda $7EBD04 ; |
and #$00FF ; |
sta $7F14 ; |
lda $7EBD00 ; |
sta $7F10 ; |
lda $7EBD02 ; |
sta $7F12 ; |
lda $03 ; |store Various RAM adress used by the ASM to SRAM so SuperFX can acess them
sta $7F1C ; |
sep #$30 ; |
phb ; |
pla ; |
sta $7F0F ;/
lda #$03 ;\
sta $7FFF ;/ set function 3(blktool optimiser) to get exected by SuperFX
Finishcode: JSL !SuperFXinit ;start SuperFX
lda $7FFF
beq Finishcode
lda $7F18 ;\if no custom block found...
BNE toblockcode ;/ return
PLB
PLY
PLX
RTS
toblockcode:
PLB
PLY
PLX
LDA #$00 ;\
STA $7EBD06 ;/ not sure what is the point of this, but the original blktool ASM to do this
jmp ($7F1A) ;jump to the custom block code
SuperFXPart:
superblktool:
lm r2, (#1F10) ;
lm r3, (#1F12) ;
lm r12, (#1F14) ; load the data previously stored by the SNES CPU
lm r4, (#1F16) ;
ibt r5, #00
lm r0, (#1f0f)
lm r6, (#1f1C)
romb
cache
move r13,r15
move r14, r4
with r14
add r5
getb
inc r14
getbh
add r0
BEQ label2
nop
move r14,r2
with r14
add r5
getb
inc r14
getbh
cmp r6
Beq blockfound
nop
BRA label1
nop
label2:
move r14,r2
with r14
add r5
inc r14
with r1
getb
from r6
hib
cmp r1
BEq blockfound
nop
label1:
inc r5
loop
inc r5
IBT R0, #00
SM (#1f18), r0
stop
nop
jmp r10 ;Wannabe rts P
nop
blockfound:
IbT R0, #01
SM (#1f18), r0
move r14, r3
with r14
add r5
getb
inc r14
getbh
sm (#1f1A), r0
ibt r0, #00
sm (#1FFF), r0
stop
nop
jmp r10 ;Wannabe rts P
nop
the problem is that blktool ASM's location is dynamic, wich mean I can't make a patch to change it since the location is not the smae for all hacks :S
Follow Us On