Re: LZ: Me agian Same Problem


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

Re: LZ: Me agian Same Problem



barrym wrote:
> 
> On Thu, 26 Sep 1996, Frank  wrote:
> 
> > Well i still cannot figure out why the program (etch a sketch ) has this
> > bug... the bug is that it will only draw a few pixels to the left (but as many
> > as wanted to all other directions).... the only thing i noticed is that maybe
> > the problem comes into play b/c left: is the last of the directional labels
> > here is the new code... if anyone sees the problem let me know thanx...
> 
> Youre not doing anything to retain the values in b and c.
> Your rom calls probably are clobbering them,
> 
> Try pushing them before a rom call and popping them aftward,
> like this:
> 
>         push bc
>         rom_call(xxx)
>         pop  bc
> 
> But really the best solution if youre gonna add to the program is to
> store them in memory and free up bc for other stuff you'll need it
> for.
> 
> Barry
> > #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,40                   ; y start
> >
> > Start:
> >     call GET_KEY   ; get a key
> >     cp K_UP
> >     CALL_Z(up)
> >     cp K_DOWN
> >     CALL_Z(down)
> >     cp K_LEFT
> >     CALL_Z(left)
> >     cp K_RIGHT
> >     CALL_Z(right)
> >     cp 0F
> >     JUMP_Z(clear)
> >     cp $37
> >     JUMP_Z(exit)
> >     jr Start
> > up:
> >   inc c  ; x=x+1
> >   CALL_(PlotPixel) ; draw it
> >   ret
> >
> > down:
> >      dec c ; x=x-1
> >      CALL_(PlotPixel)
> >      ret
> >
> > right:
> >   inc b  ; y=y+1
> >   CALL_(PlotPixel) ; draw it
> >   ret    ; go back
> >
> > left:
> >   dec b  ; y=y-1
> >   CALL_(PlotPixel) ; draw it
> >   ret   ;                                 Maybe this is wrong? not sure
> > clear:
> >     ROM_CALL(CLEARLCD)
> >     JUMP_(init)
> >
> > PlotPixel:
> >     ROM_CALL(FIND_PIXEL)
> >     ld de,$FC00
> >     add hl,de
> >     or (HL)
> >     ld (HL),a
> >     ret
> >
> > 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 nz,exitloop
> >
> > bye: .db "BYE THANKS FOR TESTING",0
> > .end
> >
> >


Yup, that's it.  CLEARLCD trashes hl,bc, and de.  So you can put the push 
and pop in like barry said.  If you want to use mem, the text mem starts 
at $80DF, and is 168 bytes (not that that matters).  just go:
	ld ($80DF),bc
	...  		;then
	ld bc,($80DF)
This way you caould keep the mem for later use too.
<pre>
-- 
Compliments of:
_-_-_-_-_-_-_-_
  Alan Bailey
  mailto:bailala@mw.sisna.com
  IRC:Abalone
  Web:http://www.mw.sisna.com/users/bailala/home.htm
</pre>


References: