No Subject


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

No Subject




I can't get this to work! Sorry, I tried for quite a long time trying to
make this work. I just need someone else (for a different perspective) to
see what is wrong. It's supposed to just wait for you to press F1 2 times
then quit. That's the main concept, but there is a greater program
(obviously). I know there are easier ways to just wait for two keypresses.

Thanx,
Dave

PS: Sorry for posting the whole thing, I tried to cut it down a lot...


#include "ti86asm.inc"
#include "asm86.h"

p_health		= $8001
p_attack		= $8002
p_defence		= $8003
e_health		= $8005
e_attack		= $8006
e_defence		= $8007

 ld a,20			; load stats...
 ld (p_health),a		; this will be done another way later
 ld a,10
 ld (p_attack),a
 ld a,3
 ld (p_defence),a

 ld hl,10			; I used HL for a mem-addressing
 ld (e_health),hl		; reason which isn't shown here
 ld hl,5
 ld (e_attack),hl
 ld hl,2
 ld (e_defence),hl

keyloop:
 call GET_KEY
 cp K_F1
 jr z,fight
 cp K_F5
 jr z,exit
 jr keyloop

fight:
 ld a,(e_defence)		; load enemy defence
 ld c,a			; put into C
 ld a,(p_attack)		; load player attack
 sub c			; sub defence from attack
 ld c,a
 ld a,(e_health)		; load enemy health
 sub c			; subtract resultant attack force
 ld (e_health),a		; save new health
 cp 0				; if greater than zero...
 jr nc, keyloop		; ...return to loop
 jr exit

exit:
 ret				; quit




Follow-Ups: