Re: A82: Projects?


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

Re: A82: Projects?



I'm doing SameGame, but when I switched from using _GETKEY to the keyport, it
got really messed up.
I think the problem is that the port isnt reset properly (ya know, ld a, $FF
\ out (1), a), but a quick look at the source tells me that there is nothing
wrong.
So here is the part that doesnt seem to work:
(one note that since there are no non-alligned sprites in SameGame, de holds
the cursor position, which is an address in the graph memory, and bc is what
you add to the position when you move)

CURSOR:
	ld hl, CURSOR_PIECE		;load the cursor sprite
	ld bc, (PROGRAM_ADDR)
	add hl, bc
	CALL_(PUTPIECE)			;put the cursor
	ROM_CALL(_GRBUFCPY_V)		;copy the graph mem to the lcd
CURSOR_KEY_LOOP:
	ld a, $FF
	out (1), a
	ld a, $FE
	out (1), a
	in a, (1)
	bit 3, a				;up arrow
	jr z, MOVE_UP
	bit 0, a				;down arrow
	jr z, MOVE_DOWN
	bit 2, a				;right arrow
	jr z, MOVE_RIGHT
	bit 1, a				;left arrow
	jr z, MOVE_LEFT
	ld a, $BF				;the mask for 2nd detection
	out (1), a				;write to the port
	in a, (1)				;read the port
	bit 5, a				;if 2nd is pressed
	ret z					;return
	ld a, $FD				;the mask for Enter and Clear detection
	out (1), a				;write to the port
	in a, (1)				;read the port
	bit 0, a				;Enter
	ret z
	bit 6, a				;clear
	jr nz, CURSOR_KEY_LOOP		;keep checking for keypresses
	inc sp				;you want to "warp out" now, but to the shell, not TI-OS
	inc sp
	ret
CURSOR_ERASE:
	push bc
	ld hl, CURSOR_PIECE
	ld bc, (PROGRAM_ADDR)
	add hl, bc
	CALL_(PUTPIECE)			;erase the cursor by re-xoring it
	pop bc
	ex de, hl
	add hl, bc				;update cursor position
	ex de, hl
	jr CURSOR

MOVE_UP:
	ld bc, -96				;to move up 8 lines
	ld a, d				;higher byte of de
	cp $88				;if you're on the top row,
	jr nz, CURSOR_ERASE
	ld bc, $2A0				;wrap around and
	jr CURSOR_ERASE			;erase the cursor

MOVE_DOWN:
	ld bc, 96				;to move down 8 lines
	ld a, d				;higher byte of de
	cp $8B				;if you're on the bottom row,
	jr nz, CURSOR_ERASE
	ld bc, -$2A0			;wrap around and
	jr CURSOR_ERASE			;erase the cursor

MOVE_RIGHT:
	ld a, e				;lower byte of de
	ld hl, RIGHT_LIMITS
	ld bc, (PROGRAM_ADDR)
	add hl, bc
	ld bc, 8
	cpir
	jr z, MOVE_RIGHT_GO_ON
	ld bc, 1				;move right 1 byte
	jr CURSOR_ERASE			;if not on the right edge
MOVE_RIGHT_GO_ON:
	ld bc, -11				;wrap around and
	jr CURSOR_ERASE			;erase the cursor
RIGHT_LIMITS:
	.db $C3, $23, $83, $E3, $43, $A3, $03, $63

MOVE_LEFT:
	ld a, e				;lower byte of de
	ld hl, LEFT_LIMITS
	ld bc, (PROGRAM_ADDR)
	add hl, bc
	ld bc, 8
	cpir
	jr z, MOVE_LEFT_GO_ON
	ld bc, -1				;move right 1 byte
	jr CURSOR_ERASE			;if not on the right edge
MOVE_LEFT_GO_ON:
	ld bc, 11				;wrap around and
	jr CURSOR_ERASE			;erase the cursor
LEFT_LIMITS:
	.db $B8, $18, $78, $D8, $38, $98, $F8, $58

wow, it must have became really bloated...can anyone find out what's wrong?
when you move, it looks like the moves are just screwed up, but it really is
moving so many times so fast that it flickers
sometimes if you press clear or enter off of the opening screen, it rets you
my opinion: some how it doesnt clear the keyport.  I hope someone can help


on the lighter side, after I finish SameGame, I'll make a Mario Bros/Sqrxz
type game, based off of a crappy BASIC game I made that never got released
that will be my big project, and I think I'll benifit from the release of the
Sqrxz source (jumping, scrolling, etc.)

TIA,

~Adamman


Follow-Ups: