LZ: Problem with code


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

LZ: Problem with code



Hi! Here's a program I'm having a lot of trouble with.  If you can help,
please do, I'm eager to get this program out not long before school
starts.  Thanks a lot!!  


  _  _  /--
 / \/ \/  -camels@juno.com
-======   -formerly cwang@pacx.com
 || ||






;Here's my program.  It doesn't seem to work.  The comments refer to what
;I'm _TRYING_ to do or what it supposed to do.


#include "TI-85.H"
.org 0
.db "Health dec",0


HEALTH = $80DF                  ;Location of HEALTH value


BEGIN:
        LD A,4
        OUT (5),A
        ROM_CALL(CLEARLCD)
        LD A,00                 ;set the value of HEALTH to 00
        LD (HEALTH),A


KEY1:
        CALL GET_KEY            ;If you press enter, it goes to the main
        CP $9                   ;program section, press exit to exit
        JUMP_Z(LOSE)
        CP $37
        RET Z
        JR KEY1


LOSE:
        LD BC,$0101             ;This is supposed to show the value of
        LD ($800C),BC           ;HEALTH but it doesn't want to.
        LD HL,HEALTH            ;It says 32991 every time.
        ROM_CALL(D_HL_DECI)
        LD A,HEALTH             ;I'm trying to find the value of HEALTH and
        CP 00                   ;go to the place where the apropriate
actions
        JUMP_NZ(LOSE0)          ;are performed.  There are 5 levels for HEALH
        LD A,HEALTH             ;(there should be 5 levels).  They should
be
        CP 01                   ;00-no damage, 01-damaged once,
02-damaged 
        JUMP_Z(LOSE1)           ;twice, etc.  05 should mean dead.  Here
the
        LD A,HEALTH             ;values being compared are supposed to be
the
        CP 02                   ;current value for HEALTH.  They will be
inc
        JUMP_Z(LOSE2)           ;later in the program.  What's wrong now is 
        LD A,HEALTH             ;that it will never get to LOSE1 or LOSE2,
        CP 03                   ;always goes to LOSE0
        JUMP_Z(LOSE3)
        LD A,HEALTH
        CP 04
        JUMP_Z(DEAD)		;this label is in the real program,
but it's 				;kinda long so I didn't want to
put it in here


LOSE0:
        LD A,1                  ;This is where HEALTH should be incremented
        LD (HEALTH),A
        LD B,96


LOSE0A:                         ;INC HORIZONTAL
        INC B                   ;This part draws the damage indication.
        LD A,B                  ;It draws a line from (97,8) to (97,12)
        CP 101                  ;first then 97 becomes 98 and the same
thing
        JUMP_Z(START)           ;happens.  This part works.
        LD C,7


LOSE0B:                          ;INC VERT
        CALL_(DRAWPIXEL)         ;Here's where the actual drawing occurs.
        INC C			;DRAWPIXEL is Mangus's routine.
        LD A,C
        CP 12
        JUMP_Z(LOSE0A)
        JUMP_(LOSE0B)


LOSE1:                          ;It won't get here!!!
        LD A,2
        LD (HEALTH),A
        LD B,100


LOSE1A:                 ;INC HORIZONTAL
        INC B
        LD A,B
        CP 105
        JUMP_Z(START)
        LD C,8
LOSE1B:                 ;INC VERT
        CALL_(DRAWPIXEL)
        INC C
        LD A,C
        CP 12
        JUMP_Z(LOSE1A)
        JUMP_(LOSE1B)




;...[snip] all this section is the same as LOSE0 with different b and
HEALTH
;values.  It goes from LOSE2 to LOSE3.  There's also a bunch of other
things I ;didn't feel like including here for the sake of size.


.end