A83: Why isn't it working


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

A83: Why isn't it working




I'm new to this mailing list, so hi :)
Ok, I created a program in basic that basically "snows" on the calculator.
The snow builds up and everything, and I'm happy with it except one problem,
it's very slow.  So, I attempted to make an ASM program (my second program, if
you include clrhome.asm :) ).   After reading many tutorials, I downloaded a
pixel program from ticalc.org, and changed it around so that it would snow.
Here is the program:
*************START OF PROGRAM*******************
;*****************This uses the following program:****************
;+------------------------------------------------------+
;|		        Pixel v1.0			|
;|		    by Joe Wingbermuehle		|
;|			12-23-1997			|
;+------------------------------------------------------+
; This is a useful routine to turn off, turn on, change
; the state of, or just test the state of an individual
; pixel on the screen.  To use it, just load xc,yc with
; the location of the pixel and load register a with the
; operation:
;	0-turn off
;	1-turn on
;	2-change state
;	3 or anything else-test
; the routine will return flag z=0 if the pixel is off
; or z=1 if the pixel is on (this will always happen
; no matter what a equals on entry).  Note:  the pixel
; is tested AFTER any operations the routine make.
; Therefore if a=0 on enty, z will be 0.
.NOLIST
#define end .end
#define END .end
#define equ .equ
#define EQU .equ
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org 9327h
;---------- Constants ----------
#define copyg		5164h
#define convop1		4EFCh
#define random		50B6h
#define fpmult		40AAh
#define setxxop2	4A78h
#define clrbuf		515Bh
#define	zc		      8265h

	.org		$9327	; start for all TI-83 asm programs
;---------------Start of snow program--------------
	call		clrbuf	; clear the graph buffer
	ld		a,0
	ld		(zc),a
main:	call		random	; get a random number in op1 (0-1)
	ld		a,96
	call		setxxop2	; 96->op2
	call		fpmult		; op1*op2->op1
	call		convop1		; op1->de
	ld		a,e		; e->a (d will ALWAYS be =0)
	call		davtwo
davtwo:	ld		(xc),a		; a->xc
	ld		a,(zc)		; (zc)->a
	cp		62		; a=62?
	jr		nz,down		; if not, run down
	call		next
        ld      	a,$FF	; 255->a (get the keyboard ready)
        out     	($01),a	; do it
        ld      	a,$FD	; 254->a (enable a section of the keyboard)
	out		($01),a	; do it
	in		a,($01)	; get the value back from the keyboard, store in a
	cp		191	; a=191? (clear key)
	jr		nz,davtwo	; if not, plot another pixel, else...
	ret		; exit the program

;---------- Show the snow --------
down:	ld		a,(zc)
	add		a,1
	ld		(zc),a
	ld		a,$03		; 3->a (test pixel)
	call		pixel		; do it!
	cp		0		; a=0? (The pixel is off)
	jr		z,davone	; If so, run davone
	ld		a,$00
	call		pixel
	call		copyg
	ret
;This erases the pixels as it goes down
davone: ld	a,(zc)
	sub	1
	ld	(zc),a
	ld	(yc),a
	ld	a,$01
	call	pixel
	call	copyg
	ld	a,(zc)
	add	a,1
	ld	(zc),a
	ret
;---------- Next -----------
next:	ld	a,0
	call	main
;---------- Pixel ----------
; input: xc,yc; a=action (0=off, 1=on, 2=change, 3=test)
; output: flag z=state (0=off, 1=on)
pixel:	push		af
	ld		a,(yc)
	ld		e,a
	ld		l,a
	ld		h,$00
	ld		d,h
	add		hl,de
	add		hl,de
	add		hl,hl
	add		hl,hl
	ld		bc,$8E29
	add		hl,bc
	ld		a,(xc)
	ld		e,a
	and		$07
	ld		c,a
	srl		e
	srl		e
	srl		e
	add		hl,de
	pop		af
	or		a
	jr		nz,px1
	call		pxt
	jr		z,pxx
	ld		a,(hl)
	xor		e
	ld		(hl),a
	jr		pxx
px1:	cp		$01
	jr		nz,px2
	call		pxt
	jr		nz,pxx
	ld		a,(hl)
	xor		e
	ld		(hl),a
	jr		pxx
px2:	cp		$02
	jr		nz,px3
	call		pxt
	ld		a,(hl)
	xor		e
	ld		(hl),a
pxx:	call		pxt
	ld		a,(hl)
	and		e
	ret
pxt:	ld		d,a
	ld		a,c
	ld		e,%10000000
	or		a
	jr		z,px4
	ld		b,c
px3:	rr		e
	djnz		px3
px4:	ld		a,d
	ret

;---------- Coordinate data for Pixel ----------
xc:	.db		$00
yc:	.db		$00

.end
END
****************************END OF PROGRAM******************
Ok, the program compiles fine, but when I run it it  displays 1 pixel (if any)
then quits.  Can someone tell me where my error is, and be free to put in any
optomizations you can find :)
Thanks for your time,
David