I'm having trouble using iondetect. I've looked at the code for pheonix and for orzunoid, but I can't seem to figure out how iondetect works so I can make external levels for my program, Rush Hour Greyscale.
I've been able to figure out that each time iondetect is called, it searches for the next program in the vat (or variable in the vat, i don't know which it is), and checks if it matches a detection string that's the first line of data for that variable. However, either the documented returns are wrong, or i'm having wierd problems with Brass, I can't seem to get iondetect to detect any string.
Here's my sample code I've kind of copied and modified so I can test it.
Main program
Code:
Level program
Code:
Could someone tell me what i'm doing wrong? And no, the problem is not that I'm accidentally compiling my level program for ion/mirageos! It's being compiled correctly as nostub
I've been able to figure out that each time iondetect is called, it searches for the next program in the vat (or variable in the vat, i don't know which it is), and checks if it matches a detection string that's the first line of data for that variable. However, either the documented returns are wrong, or i'm having wierd problems with Brass, I can't seem to get iondetect to detect any string.
Here's my sample code I've kind of copied and modified so I can test it.
Main program
Code:
ld hl,(progptr) ;start of VAT, $FE6E
SearchLoop:
ld ix,ID ;ID searching for
call ionDetect
jr nz,SDone ;no more programs to search for
xor a
cp (hl) ;Didn't find what we're looking for, look at next item
jr nz,KeepSearching
bcall(_PutS) ;found it! since this is a test, we'll just display the level name of the first program we find and quit
bcall(_GetKey)
ret
KeepSearching:
ex de,hl
jr SearchLoop
SDone: ;went through all the programs, didn't find anything
ld hl,nfound
bcall(_PutS)
bcall(_GetKey)
ret ;not found
nfound
.db "not found",0
ID
.db $c9,"Level",0
Level program
Code:
.db $c9,"Level",0
.db "Sample program",0
Could someone tell me what i'm doing wrong? And no, the problem is not that I'm accidentally compiling my level program for ion/mirageos! It's being compiled correctly as nostub