org $008069, I think. Barebones "How to find an org, and hijack" below.
Since it looks like you're fulfilling you're own Timer request, here's how we'd try finding the
org ######
First you need to decide where you want to to run your hijack "conceptually" (I'm thinking whatever code updates the true frame counter at $13 is a good bet).
Then you search through SMWDisc.txt (all.log), the disassembly, to find where that value gets updated. Then you decide which of those locations you're going to use (sometimes the choice matters). Then you insert the hijack,
without causing side-effects (this is usually the tricky part).
I looked through and found this guy:
Code$008070: E6 13 INC $13 ; Increment frame number
But a JSL Hijack is 5 bytes so you need to squeeze and re-arrange to fit it in:
Code$008061: 20 50 92 JSR $9250 ;
$008064: A9 03 LDA #$03 ;\ Set OAM name base to #$03, clear the name and allow 8x8 and 16x16 sprites
$008066: 8D 01 21 STA $2101 ;/
$008069: E6 10 INC $10 ; Bypass the loop the first time
$00806B: A5 10 LDA $10 ;\ Loop until $10 isn't 00 (through interrupt?)
$00806D: F0 FC BEQ $FC [$806B] ;/
$00806F: 58 CLI ; Enable IRQ
$008070: E6 13 INC $13 ; Increment frame number
$008072: 20 22 93 JSR $9322 ;
You likely can't move much, and don't want to add too much processing time where you do hijack. Normally you fold the hijacked code into your hijack if it doesn't fit (sometimes it can fit if you're just straight-up replacing old code). Relative and local stuff (JSR, BEQ, etc) are harder to move. Also you might need to pad with NOP so that you return on a full instruction and not halfway through one.
here we pull 5 bytes minimum worth of instructions out of the original code (3 instructions of 2 bytes each) and fill remainder with NOPs (You could do
NOP #2 if you needed 2, btw). Then we shove the code inside the hijack.
Codeorg $008069
autoclean JSL Timer
NOP
.....
Timer:
INC $10
.loop:
LDA $10
BEQ .loop
; Rest of Timer:
; Maybe save some stuff here
To prevent side-effects you may need to save the registers or anything else you touch. You may also have timing side-effects, especially if you're code is longer or does a lot, in which case you probably need to find a different hijack point or work faster.
Hopefully that's
a right hijack point. If not then maybe inside
JSR $9322 is? Alternatively you could look to see where some other similar code does a hijack. (UberASM for example must have GameMode Hijacks, they're probably better/safer hijack points as well). Also, it can sometimes be useful to look at the
Hijack Map