Re: LZ: Making fixed int progs


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

Re: LZ: Making fixed int progs



Micah/Richard Brodsky wrote:
> 
> 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?


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.


<pre>
-- 
Real name: Jimmy Mårdell
Email....: mailto:mja@algonet.se
IRC-name.: Yarin
WWW......: http://www.algonet.se/~mja


"Strap me down with disillusion 
  Tie me up in lifelines
   Nothing stops my thoughts from breeding
    Nothing's stopping my mind" - Leather Strip
</pre>


References: