[TI ASM] Title Menu Problem

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
Svinter
New Member
Posts: 18
Joined: Tue 22 Feb, 2005 12:11 am
Location: Space Mountain Land

[TI ASM] Title Menu Problem

Post by Svinter »

First off I've been lurking around these forums after being attracted by the Metroid project (its true...Im a metroid addict) and Id like to thank the people who post help on these forums since it's helped me grasp some of the basics of z80 asm.

Now to my real problem. I'm trying out my first attempt at a full fledged game, but I can't seem to get past the whole title screen menu thing. I have a picture for the title screen in hex as a variable in the code with the different choices in it already ('Play' at row 36, 'Rules' at row 43, 'Credits' at row 50, and 'Quit' at row 57), and my code works when displaying the cursor (a * character) but I can't get it to clear out the previous space that the cursor was at when up or down was pressed.

This code clears the space that the cursor was at, but move the cursor up to the top of the screen for some reason. (am I going about it all wrong)? Thanks in advance!

Code: Select all

;Heavily commented just so I can keep my train of thought going

.nolist			;standard ION header 

#define TI83P    	;change this if on 83 to TI83 

#define equ .EQU 
#define EQU .EQU 
#define end .END 
#define END .END
_Random		EQU 4B79h
_Intgr		EQU 405Dh 

#include "ion.inc" 
#include "keys.inc" 
	.list 	
	.org ProgStart-2 
	.db $BB,$6D 
	ret 		
	jr nc,Start 
	.db "LCR Alpha",0 
Start:				;title menu routine
	bcall(_indicatoroff)	;Runindicator off and Clear screen
	bcall(_clrlcdf)
	ld bc,12*64		;Prepare Graph Buffer for _grbufcpy to display Title screen 
	ld de,PlotSScreen
	ld hl,Title
	ldir
	bcall(_grbufcpy)	;Display Title Screen
Drawcursor:
	ld a,(Menucurpos)	;Load the cursor position to draw cursor
	ld (penrow),a
	ld a,0
	ld (pencol),a
	ld a,'*'
	bcall(_vputmap)		;Draw it.
Keyloop:
	bcall(_getkey)		;Simple, get a key and check it
	cp $03
	jr z,Up
	cp $04
	jr z,Down
	cp $05
	jr z,Enter
	jr Keyloop
Up:
	ld a,(Menucurpos)	;Check if cursor can go up
	cp $21
	jr z,Keyloop
	ld a,(pencol)		;Set column back 6 to clear previous space
	sub 6	
	ld (pencol),a
	ld b,5			;load a number into B to set # of times to put a space to clear
	call Clearspace		;call Clearspace to put next instruction on stack to be returned to
	ld a,(Menucurpos)
	sub 7			;move the penrow up 7 pixels to display cursor up 1 space
	ld (Menucurpos),a
	jr Drawcursor		;Go draw the new cursor
Down:
	ld a,(Menucurpos)
	cp $36
	jr z,Keyloop
	ld a,(pencol)		;Set column back 6 to clear previous space
	sub 6	
	ld (pencol),a
	ld b,5			;load a number into B to set # of times to put a space to clear
	call Clearspace		;call Clearspace to put next instruction on stack to be returned to
	ld a,(Menucurpos)
	add a,7			;move the penrow down 7 pixels to display cursor down 1 space
	ld (Menucurpos),a
	jr Drawcursor		;Go draw the new cursor
Clearspace:
	ld a,$20		;Draw a space in column 0 and advance it 5 times to clear space
	bcall(_vputmap)	
	dec b
	jr nz,Clearspace	
	add a,7
	ld (Menucurpos),a
	ret			;go back to whichever label it came from
Enter:
	jr Quit
Quit:
	ret

........
....


Menucurpos:
	.db $21
jbshaler
Maxcoderz Staff
Posts: 22
Joined: Fri 17 Dec, 2004 8:35 pm
Location: Michigan

Post by jbshaler »

I think it's because of the lines in the Clearspace routine where you "add a,7
\ ld (Menucurpos),a". You don't want to change the cursor value here.

Hope it helps!
Guest

Post by Guest »

Wow, stupid mistake :oops: Guess I have to be more attentive with this asm stuff, thanks! (id be looking at the wrong place for days)
Post Reply