A83: coding problem


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

A83: coding problem



I am an 82asm programmer. A friend asked me to program a pong game. He had
already made the paddle. I finished his game up, but when he compiled it I
learned that it crashed his calc. Now I was wondering if anyone on the
mailing list could look at the routine and tell me what I did wrong.
Possibilities include:
Using an invalid or inapropriate CALL
Over writing some of the RAM outside of Textmem in defining variables. I
really want to know me what I did wrong.
Thanx,
Gerad
=============================================================
;sorry about the lack of comments
;most of the comments that are there are invalid

.NOLIST

#define equ .equ
#define EQU .equ
#define end .end
#DEFINE   PTRIGHT       8265h
#DEFINE   PTLEFT        8275h
#DEFINE   PTLEFT2       8285h
#DEFINE   PTRIGHT2      8295h
#define 	ballx             $8286
#define 	bally             $8287
#define	balldirx		$8288
#define 	balldiry          $828B
#define	oldballx		$8289 ;oldball makes for more mem used but
#define	oldbally		$828A ;better graphics
#define     lives             $828C
#define     score			$828D
#define	moveball		$828E
#include        "ti83asm.inc"
#include        "tokens.inc"
..LIST

kleft      .equ  253         
kright     .equ  251       
kclear     .equ  191

..org 9327h
        call _clrlcdfull
        call _grbufclr
        call _runindicoff
	 ld a, $01
	 ld (balldirx), a
	 ld (balldiry), a
	 ld (score), a
	 ld (moveball), a
	 ld a, $05
	 ld (ballx), a
	 ld (bally), a
	 ld (lives), a
	 ld (oldballx), a
	 ld (oldbally), a
	        ld b,30
	        ld a,b
        ld (PTLEFT),a
        ld c,1
        ld d,40
        ld a,d
        ld (PTRIGHT),a
        ld e,1
	ld h,1
	call _iline
        ld b,30
        ld a,b
        ld (PTLEFT2),a
        ld c,2
        ld d,40
        ld a,d
        ld (PTRIGHT2),a
        ld e,2
	ld h,1
	call _iline
 	ld hl, $0200
	 ld (Currow), hl
             ld hl, Pong ;**********says no pong label ! GERAD: OOPS!!!!
	 call _puts
	 ld hl, $0300
	 ld (currow), hl
	 ld hl, title1
	 call _puts
 	ld hl, $0400
 	ld (currow), hl
 	ld hl, title2
 	call _puts
 	ld hl, $0500
 	ld (currow), hl
 	ld hl, title3
 	call _puts
 	ld hl, $0700
 	ld (currow), hl
 	ld hl, version
 	call _puts
 	ld b, $AF
wait3:
 	halt
 	halt
        djnz wait3
 	call _clrlcdfull
LOOP:
        ld a,0ffh
        out (1),a
        ld a,0feh
        out (1),a
        in a,(1)
        cp kleft
        jr z,left
        cp kright
        jr z,right
        ld a,0ffh
        out (1),a
        ld a,0fdh
        out (1),a
        in a,(1)
        cp kclear
        jp z,quit
        jp wait2
left:
      ld a,(PTLEFT)
      dec a
      ld (PTLEFT),a
      ld b,a
      ld c,1
      ld a,(PTRIGHT)
      dec a
      ld (PTRIGHT),a
      ld d,a
      ld e,1
      ld h,1
      call _iline
      ld a,(PTRIGHT)
      inc a
      ld b,a
      ld c,1
      ld d,0
      call _ipoint
      ld a,(PTLEFT2)
      dec a
      ld (PTLEFT2),a
      ld b,a
      ld c,2
      ld a,(PTRIGHT2)
      dec a
      ld (PTRIGHT2),a
      ld d,a
      ld e,2
      ld h,1
      call _iline
      ld a,(PTRIGHT2)
      inc a
      ld b,a
      ld c,2
      ld d,0
      call _ipoint
      jp wait2       
right:
      ld a,(PTLEFT)
      inc a
      ld (PTLEFT),a
      ld b,a
      ld c,1
      ld a,(PTRIGHT)
      inc a
      ld (PTRIGHT),a
      ld d,a
      ld e,1
      ld h,1
      call _iline
      ld a,(PTLEFT)
      dec a
      ld b,a
      ld c,1
      ld d,0
      call _ipoint
      ld a,(PTLEFT2)
      inc a
      ld (PTLEFT2),a
      ld b,a
      ld c,2
      ld a,(PTRIGHT2)
      inc a
      ld (PTRIGHT2),a
      ld d,a
      ld e,2
      ld h,1
      call _iline
      ld a,(PTLEFT2)
      dec a
      ld b,a
      ld c,2
      ld d,0
      call _ipoint
      jr wait2
wait2:
 	ld a,(moveball)
 	cp $0A
 	jr z, drawball
 	inc a
 	ld (moveball), a
 	halt
 	halt
 	halt
 	halt
        jp loop
drawball:
	 ld a, $00
	 ld (moveball), a
	 ld d, $00
	 ld a, (oldballx)
	 ld b, a
	 ld a, (oldbally)
	 ld c, a
	 call _ipoint
	 ld d, $00
	 ld a, (oldballx)
	 ld b, a
	 ld a, (oldbally)
	 ld c, a
	 inc b
	 call _ipoint
	 ld d, $00
	 ld a, (oldballx)
	 ld b, a
	 ld a, (oldbally)
	 ld c, a
	 inc b
	 dec c
	 call _ipoint
	 ld d, $00
	 ld a, (oldballx)
	 ld b, a
	 ld a, (oldbally)
	 ld c, a
	 dec c
	 call _ipoint
	 ld d, $01
	 ld a, (ballx)
	 ld b, a
	 ld a, (bally)
	 ld c, a
	 call _ipoint
	 ld d, $01
	 ld a, (ballx)
 	ld b, a
 	ld a, (bally)
 	ld c, a
 	inc b
 	call _ipoint
 	ld d, $01
 	ld a, (ballx)
 	ld b, a
 	ld a, (bally)
 	ld c, a
 	dec c
 	inc b
 	call _ipoint
 	ld d, $01
 	ld a, (ballx)
 	ld b, a
 	ld a, (bally)
 	ld c, a
 	dec c
	call _ipoint
	 ld a, (balldiry)
	 cp $01
	 jr z, down
	 cp $02
         jp z, up
down:
	 ld a, (bally)
	 cp $3D                 ;Ryan is your pong paddle on the very last line?
	 jr z, changeup
	 ld (oldbally), a
	 inc a
	 inc a
	 ld (bally), a
	 ld a, (balldirx)
	 cp $01
         jp z, right1
	 cp $02
         jp z, left1
up:
	 ld a, (bally)
	 cp $01
         jp z, changedown
	 ld (oldbally), a
	 dec a
	 dec a
	 ld (bally), a
	 ld a, (balldirx)
	 cp $01
	 jr z, right1
	 cp $02
         jp z, left1
right1:
	 ld a, (ballx)
	 cp $5D
	 jr z, changeleft
	 ld (oldballx), a
	 inc a
	 inc a
	 ld (ballx), a
	 JP Loop
left1:
	 ld a, (ballx)
	 cp $01
	 jr z, changeright
	 ld (oldballx), a
	 dec a
	 dec a
	 ld (ballx), a
	 JP Loop
changeup:
	 ld a, (ballx)
	 ld b, a
	 ld a, (bally)
	 ld c, a
	 inc c
	 ld a, $03            ;CHECK _ipoint again
	 ld d, a
	 call _ipoint
	 jr z, next
	 inc b
 	call _ipoint
 	jr z, next
 	dec b
 	dec b
 	call _ipoint
 	jr z, next
        jp die
next:
	 ld a, (score)
	 inc a
	 ld (score), a
	 ld a, (bally)
 	ld (oldbally), a
 	dec a
 	dec a
 	ld (bally), a
 	ld a, $02
 	ld (balldiry), a
 	ld a, (balldirx)
 	cp $01
 	jr z, right1
 	cp $02
 	jr z, left1
changedown:
 	ld a, (bally)
 	ld (oldbally), a
 	inc a
 	inc a
 	ld (bally), a
 	ld a, $01
 	ld (balldiry), a
 	ld a, (balldirx)
 	cp $01
 	jr z, right1
 	cp $02
 	jr z, left1
changeleft:
	 ld a, (ballx)
	 ld (oldballx), a
	 inc a
	 inc a
	 ld (ballx), a
	 ld a, $02
	 ld (balldirx), a
	 JP Loop
changeright:
	 ld a, (ballx)
	 ld (oldballx), a
	 dec a
	 dec a
	 ld (ballx), a
	 ld a, $01
	 ld (balldirx), a
	 JP Loop
die:
	 ld a, (lives)
	 dec a
	 cp $01
	 jr z, quit
	 ld (lives), a
	 ld hl, $0000
	 ld (Currow), hl
	 ld hl, youdied
	 call _puts
	 ld a, $AF
	 ld b, a
display:
	 halt
         djnz display
	 ld hl, $0000
	 ld (Currow), hl
	 ld hl, spaces
	 call _puts
        jp next

quit:
         call _clrlcdfull
	 halt
	 ld hl, $0000
	 ld (currow), hl
	 ld hl, scorestrand
	 call _puts
	 ld hl, $0100
	 ld a, (score)
	 ld h, a
	 ld a, $00
	 ld l, a
	 call _dispHL
	 ld b, $FF
wait1:   ;*****aint no label wait1  plus you must call a sub routine GERAD:
This is a label
	 halt
           djnz wait1 ;can't find label plus relative branch exceeded
	ret
        	ei
youdied:
 	.db "    You Died    ",0
spaces:
 	.db "                ",0
pong:
 	.db "   Super Pong"
title1:
	 .db " Copyright 1997 ",0
title2:
	 .db "Ryan Detert and ",0
title3:
	 .db "Gerad Suyderhoud",0
version:
	 .db "Version  1.3beta",0
scorestrand:
 	.db "Your Score:",0

.end
END