Re: A86: Sprite hits sprite


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

Re: A86: Sprite hits sprite




Thank you so much.  How would I incorporate that into my program though.  I
tried it like this, but it didn't work:

#include "asm86.h"
#include "ti86asm.inc"		; I took out the other 2 because they weren't needed

.org _asm_exec_ram

		call _clrScrn
        call _runindicoff
		ld b,0
        ld c,120
        ld a,1
		ld (NUM),a
		ld hl,Eater
		call FastSprite
        
Main_Prog:
		push bc
        push hl
        call GET_KEY		; this was the main problem causer.  Getkey was
				; destroying your registers.  Fixed via push/pop.
        pop hl
        pop bc
        cp K_EXIT
        ret z
        cp K_LEFT
        jp z,LEFT
        cp K_RIGHT
        jp z,RIGHT	

Bug_Move:
		push hl
		push bc
		ld b,15
		ld a,(NUM)
		ld c,a
		ld hl,Bug
		call FastSprite
		ld a,(NUM)
		inc a
		halt
		halt
		halt
		halt
		halt
		halt
		halt
		halt
		halt
		ld (NUM),a
		call FastSprite

CheckHit:
		ld a,h
		sub d
		jr nc,SkipCarryX
		neg

SkipCarryX:
		cp 8
		jr nc,NoHit
		ld a,l
		sub e
		jr nc,SkipCarryY
		neg

SkipCarryY:
		cp 8
		jr nc,NoHit

Hit:
		ret

NoHit:
		pop hl
		pop bc
		jp Main_Prog	

LEFT:
		call FastSprite		; first called to erase pic from old coords
		ld a,b
		sub 3
		ld b,a			; modify coords
        call FastSprite		; disp the sprite in it' new position
        jp Main_Prog		; do it again

RIGHT:
        call FastSprite        
		ld a,b
		add a,3
		ld b,a
		call FastSprite
        jp Main_Prog

.end

I left out the FastSprite.  The program worked by making it so my little guy
on the bottom move about 2 times.  Then it just messed up.

THANX
Dan