Re: LZ: Running programs through ints


[Prev][Next][Index][Thread]

Re: LZ: Running programs through ints



Micah/Richard Brodsky wrote:
> 
> I guess I'll ask my question again (I asked it a while ago and got no
> response).
> 
> >I couldn't get an int handler to run a prog using rst 10h and rst 20h. I know
> it was pointing to the right >spot, but the program goes crazy (TIOS memory
> error, random chars on the top line of the screen). I >had it load
> PROGRAM_ADDR with a new value, but it must need more. Any ideas?
> Specifically, could someone release the code that Game Wizard used to run it's
> main program through the int handler?
> --MZB


What? I did answer that, and here's the answer:


----------> Previous post >-----------


Strange that it didn't work, because I used that method in Game Wizard. Since
you can't store the whole program in the interrupt handler you have to search
up a program an run it. GWiz interrupt handler looks up Game Wizard and execute
it two bytes after it starts. The beginning looks something like this:


.org 0
.db "Game Wizard 0.9",0


 jr InitGWiz
 JUMP_(MenuHandler)
InitGWiz:


and the interrupt handler that deals with rst 10h and 20h looks like this:


 ld hl,FindStr   ; FindStr is stored in $90A4, so not adding with program_addr
 rst 20h
 rst 10h
 jr c,ExitInt    ; Program not found
 ld hl,ExitInt
 push hl         ; push the return address so when returning after jp(hl), ExitInt
                 ; will be reached
 ld hl,5
 add hl,de
 ld (PROGRAM_ADDR),hl   ; Store the new program addr which is five bytes ahead
Loop:
 ld a,(hl)
 or a
 jr z,Execute    ; This loop increase the address until the name description is over.
 inc hl
 jr Loop
Execute:
 inc hl          ; Inc with another byte to point one byte after the description.
 inc hl          ; And inc with another two byte to skip jr IntGWiz.
 inc hl
 jp (hl)         ; And run it.


-------------------------------------------------------------------------
| Jimmy Mårdell                 | "Trying to get a grip of life          |
| mailto:mja@algonet.se         |  with all these fears i cannot hide    |
| http://www.algonet.se/~mja    |  But how to keep an open mind          |
|                               |  when i'm so fucked up i could die"    |
-------------------------------------------------------------------------


References: