Re: LZ: New method didnt work either
[Prev][Next][Index][Thread]
Re: LZ: New method didnt work either
I think I'd put them in variables in memory within your program.
You can define a variable like this:
X .dw 30
Y .dw 60
That also means you don't have to initilize them in your code.
They'll start out at the right value when you run the program.
You'll also have to access them in a different way sinc you cant
know the actual starting address of your program. There's a
zshell call to do that but I don't remember it's name. It's
in your manual.
You've also got your X,Y's mixed up. I think you want up and
down to deal with Y and right and left to deal with X.
One thing you can do to avoid problems like that is to, when
things dont' seem to work, just sit down and read the whole
code from start to end, real slow, thinking about how it all
works together. When you get used to doing this, you'll spot a
lot of problems and also a lot of good opportunities to do stuff
you never thought of before.
I don't know if this solves any of your problems but I'm not
trying to debug your code. I just took a quick look and thats
what I saw. You probably should spend more time trying to figure
out these problems yourself first.
Barry
On Thu, 26 Sep 1996, Frank wrote:
> I am really getting confused i tried Barrym's idea of storing the X and Y
> values in memory but i still get the bug that it wont go left more the 3 or 4
> pixels but all other directions work... here is the new code:
>
> #include "ti-85.h"
> .org 0
> .db "By Frank Apap",0
>
> X = $80E0 ;X in mem
> Y = $80E1 ; Y in mem
> Init:
> ld a,4
> out (5),a
> ROM_CALL(CLEARLCD)
> ld a,30 ; x start
> ld (X),a
> ld a,60 ; y start
> ld (Y),a
>
> 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:
> ld a,(X) ; x=x+1
> inc a
> ld (X),a
> CALL_(PlotPixel) ; draw it
> ret
>
> down:
> ld a,(X)
> dec a
> ld (X),a ; x=x-1
> CALL_(PlotPixel)
> ret
>
> right:
> ld a,(Y) ; y=y+1
> inc a
> ld (Y),a
> CALL_(PlotPixel) ; draw it
> ret ; go back
>
> left:
> ld a,(Y) \
> dec a \
> ld (Y),a > IS SOMETHING WRONG?
> CALL_(PlotPixel) ; draw it /
> ret ; go back /
>
> clear:
>
> ROM_CALL(CLEARLCD)
> JUMP_(init)
>
> PlotPixel:
> ld a,(Y) ; LOAD Y into B
> ld b,a
> ld a,(X) ; LOAD X into C
> ld c,a
> 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
>
References: