Re: LZ: That didnt work


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

Re: LZ: That didnt work



Frank wrote:
> 
> I have tried what barrym said ... but it didnt help... here is the code ...
> and all that is wrong is it wont leave the program... it just freezes on the
> exiting text#include "ti-85.h"
> .org 0
> .db "By Frank Apap",0
> 
> Init:
>  ld a,4
>  out (5),a
>  ROM_CALL(CLEARLCD)
>  ld b,40                   ; x start
>  ld c,30                   ; y start
> 
> Start:
>     call GET_KEY   ; get a key
>     cp $04         ; up ?
>      jr nz,nextkey
>     CALL_Z(up)
>      JUMP_(Start)
> 
> nextkey:
>     cp $01         ; down
>     CALL_Z(down)
> 
>     cp $02           ; left?
>     CALL_Z(left)
> 
>     cp $03        ; right
>     CALL_Z(right)
> 
>     cp $37              ;exit
>     JUMP_Z(exit)
> 
>     cp $0F   ;clear
>     JUMP_Z(clear)
> 
>     JUMP_(Start)    ; loop
> up:
>   inc c  ; x=x+1
>   CALL_(PlotPixel) ; draw it
>   JUMP_(Start)
> 
> down:
>      dec c ; x=x-1
>      CALL_(PlotPixel)
>      JUMP_(Start)
> 
> right:
>   inc b  ; y=y+1
>   CALL_(PlotPixel) ; draw it
>   JUMP_(Start)    ; go back
> 
> left:
>   dec b  ; y=y-1
>   CALL_(PlotPixel) ; draw it		;cause these are calls
>   JUMP_(Start)   ; go back
> clear:
>     ROM_CALL(CLEARLCD)
>     JUMP_(init)
> 
> PlotPixel:
>     ROM_CALL(FIND_PIXEL)
>     ld de,$FC00
>     add hl,de
>     or (HL)
>     ld (HL),a
>     JUMP_(Start)		;right here should be return, not jump
> 
> exit:
>      ROM_CALL(CLEARLCD)
>      ld hl,$1A1A
>      ld ($8333), hl
>      ld hl, (PROGRAM_ADDR)
>      ld de,bye
>      add hl,de
>      ROM_CALL(D_ZM_STR)
> exitloop:
>    call GET_KEY
>    cp $37
>    ret z
>    jr exitloop
> 
> 
> bye: .db "BYE THANKS FOR TESTING",0
> .end


I decided to look at this cause it's been here a while.  I noticed you have calls to 
plotpixel, but at the end of plotpixel, you jump back to start.  Since you have a call, 
the next ret will go back to where that came from.  The next ret is at the end, which 
will take you back to after the call.  To solve this, put a ret at the end of plotpixel, 
not a JUMP_(
<pre>
-- 
Compliments of:
_-_-_-_-_-_-_-_
  Alan Bailey
  mailto:bailala@mw.sisna.com
  IRC:Abalone
  Web:http://www.mw.sisna.com/users/bailala/home.htm
</pre>


References: