A86: Re: first program


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

A86: Re: first program




First off you should have 2 bytes at the end to store your coords: this
makes it much easier to work with and shortens your code too: ie. x: .db
10/y:.db 4
then when you push up have have it decrement (_currow) now y and so on, this
way you shouldnt have any 'bugs' for moving that can happen easily when
trying to work with it the way you were. Then for your output routine just
_clrLCD/ld a,(x)/ld (_curcol),a/ld a,(y)/ld (_currow),a/ld hl,string/call
_puts/jr Loop. Hope that helps you

>
> I recently wrote this program that moves a character around the
> screen.  When you press prgm, the character changes.  I am having a few
> problems with it though. 1. When I move to the 6th row in the last
> collumn, it moves up one. After the next move it goes to where it should
> be.  Any ideas why?  2. the character change part works fine on vti, but
> not on my calculator.  When I press prgm, the character changes but the
> next time I move, it changes back to what it was originaly 'Y'.  These
> are probably just be dumb beginner mistakes, but if someone could help
> that would be great.
>
> #include "ti86asm.inc"
>
> .org _asm_exec_ram
>
>
>     call _clrLCD
>     call _homeup
>     ld hl,(_curRow)
>     jr output
> Loop:
>     call _getkey
>     cp kRight
>     jr z,move_right
>     cp kDown
>     jr z,move_down
>     cp kLeft
>     jr z,move_left
>     cp kUp
>     jr z,move_up
>     cp kPrgm
>     jr z,change_char
>     cp kExit
>     jr nz,Loop
>     ret
>
> move_right:
>     ld hl,(_curRow)
>     ld a,h
>     cp 20
>     jr z,Loop
>     inc h
>     jr output
>
> move_down:
>     ld hl,(_curRow)
>     ld a,l
>     cp 7
>     jr z,Loop
>     inc l
>     jr output
>
> move_left:
>     ld hl,(_curRow)
>     ld a,h
>     cp 0
>     jr z,Loop
>     dec h
>     jr output
>
> move_up:
>     ld hl,(_curRow)
>     ld a,l
>     cp 0
>     jr z,Loop
>     dec l
>     jr output
>
> output:
>     ld (_curRow),hl
>     push hl
>     call _clrLCD
>     ld hl,string
>     call _puts
>     pop hl
>     ld (_curRow),hl
>     jr Loop
>
> change_char:
>     ld a,(string)
>     inc a
>     ld (string),a
>     ld hl,(_curRow)
>     jr output
>
>
> string:
>     .db "Y",0
>
> .end
>
>



References: