Re: A83: sprites


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

Re: A83: sprites




here this is a patch of code i had lying around it moves the sprite across 
the screen. No borderboundires though so it goes of the screen. It moves in 
the direction of the key pressed in 4 pixel intervals:
        .nolist
        #include "ion.inc"
        .list

kEnter	.equ 05h
kDown		.equ 04h
kLeft		.equ 02h
kRight	.equ 01h
kUp		.equ 03h


#define X saferam3
#define Y X+1

#ifdef TI83P
        .org    progstart-2
        .db     $BB,6D
#else
        .org    progstart
#endif
        ret
        jr      nc,Start
        .db     "ION Program",0

Start:
	ld	a,1
	ld	(X),a
	ld	(Y),a
	;Now X and Y are 0

	call	Put

getkey:
	bcall(_getkey)
	cp kLeft
	jp z,left
	cp kRight
	jp z,right
	cp kUp
	jp z,up
	cp kDown
	jp z,down
	cp kEnter
	jp z,enter

	jp getkey

left:

	call Put
	ld	a,(X)
	cp 0
	jp z, getkey
	jp nz, left2

left2:
	ld a,(X)
	dec	a	;0-5
	dec	a
	dec	a
	dec	a
	ld	(X),a
	call Put
	jp	z,Getkey

right:

	call Put
	ld	a,(X)
	cp 94
	jp z, getkey
	jp nz, right2

right2:
	ld a,(X)
	inc	a
	inc	a
	inc	a
	inc	a
	ld	(X),a
	call Put
	jp	z,Getkey

up:
	ld	a,(Y)
	cp 0
	jp z, getkey
	jp nz, up2

up2:
	call Put
	dec	a	; 0-63
	dec	a
	dec	a
	dec	a
	ld	(Y),a
	call Put
	jp	z,Getkey

down:

	ld	a,(Y)
	cp 62
	jp z, getkey
	jp nz, down2

down2:
	call Put
	inc	a
	inc	a
	inc	a
	inc	a
	inc	a
	ld	(Y),a
	call Put
	jp	z,Getkey


Put:
	ld	a,(Y)
	ld	l,a
	ld	a,(X)
	ld	b,8
	ld	ix,Sprite
	call	ionputsprite
	call	ionfastcopy
	ret

sprite:
  .db %11111111
  .db %10111101
  .db %11111111
  .db %00011000
  .db %11111111
  .db %00011000
  .db %00100100
  .db %01000010

enter:
	ret

.end
END

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com