A86: first program


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

A86: first program




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



Follow-Ups: