LZ: working etch a sketch prog


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

LZ: working etch a sketch prog



This is to the person wanting the etch-a-sketch thing working (I forgot 
your e-mail address)  Anyways, you had a check key loop with calls in it.
Let's say it called left because you pressed left.  When it returns, it 
will check the rest of the conditions after that.  When it returns, it 
checks the value in a, not the key pressed.  get it...:), good.  When 
your x was moving left, it would move back right after moving left.  The 
next left move would move onto a pixel already set, so you wouldn't 
notice it.
Got it...  When you have conditional CALL's in a row, make them jumps 
instead.  
Another thing, I renamed your variables instead of x and y.  There are 
two register pairs named ix and iy.  It's good to keep these things 
different so people or possibly the compiler won't get them confused


#include "ti-85.h"
.org 0
.db "By Frank Apap",0


XCOORD = $80E0                 ;X in mem
YCOORD = $80E1                  ; Y in mem


init:
 	ld a,4
 	out (5),a
 	ROM_CALL(CLEARLCD)
 	ld a,60                 ; x start
	ld (XCOORD),a
 	ld a,30               	; y start
 	ld (YCOORD),a


Start:
    	call GET_KEY   		; get a key
    	cp K_UP
    	JUMP_Z(up)
    	cp K_DOWN
    	JUMP_Z(down)
    	cp K_LEFT
    	JUMP_Z(left)
    	cp K_RIGHT
    	JUMP_Z(right)
    	cp $0F
    	JUMP_Z(clear)
    	cp $37
    	JUMP_Z(exit)
    	JUMP_(Start)
up:
  	ld a,(YCOORD)  		
  	inc a
  	ld (YCOORD),a
  	JUMP_(PlotPixel) 	


down:
     	ld a,(YCOORD)
     	dec a
     	ld (YCOORD),a 		
     	JUMP_(PlotPixel)


right:
  	ld a,(XCOORD)  		
  	inc a
  	ld (XCOORD),a
  	JUMP_(PlotPixel) 	; draw it  	; go back


left:
  	ld a,(XCOORD)                     
  	dec a                           
  	ld (XCOORD),a                        
  	JUMP_(PlotPixel) 	
 	 


clear:
    
    	ROM_CALL(CLEARLCD)
    	JUMP_(init)


PlotPixel:
    	ld a,(YCOORD) 		; LOAD Y into c
    	ld c,a
    	ld a,(XCOORD)  		; LOAD X into b
    	ld b,a
    	ROM_CALL(FIND_PIXEL)
    	ld de,$FC00
    	add hl,de
    	or (hl)
    	ld (hl),a
	JUMP_(Start)
    	


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




<pre>
-- 
Compliments of:
_-_-_-_-_-_-_-_
  Alan Bailey
  mailto:bailala@mw.sisna.com
  IRC:Abalone
  Web:http://www.mw.sisna.com/users/bailala/home.htm
</pre>