Re: [stella] trick to using select switch as a toggle?

Subject: Re: [stella] trick to using select switch as a toggle?
From: KirkIsrael@xxxxxxxxxxxxx
Date: 31 Aug 2003 15:36:46 -0000
I think the method I came up with is pretty reliable,
and doesn't worry so much about timing.

I'm using one variable, booleanSelectSwitchIsDown ,
and ultimately it toggles another boolean, 
booleanGameIsTwoPlayers 


	LDA SWCHB
	AND #%00000010 ;is game select?
	BNE TitleSelectIsNotDownNow;if so proceed, if not branch
TitleSelectIsDownNow
	LDA #1
	STA booleanSelectSwitchIsDown ;record that's down now
	JMP TitleDoneCheckingSelect ;and go onour way
TitleSelectIsNotDownNow
;so the switch is currently now up
	LDA booleanSelectSwitchIsDown ;see if it was on before
	BNE TitleSelectWasAlreadyOn
TitleSelectWasNotOn ; it wasn't on b4, it's still not on, no prob
	JMP TitleDoneCheckingSelect
TitleSelectWasAlreadyOn ;it's not on now, they just let go
	LDA #0
	STA booleanSelectSwitchIsDown ;record that it's not on

	LDA booleanGameIsTwoPlayers 
	EOR #%11111111 ;toggle the boolean for # of players
	STA booleanGameIsTwoPlayers 

TitleDoneCheckingSelect


Not super efficient, but it gets the job done.
I had to work up to this code by just changing the color
of the screen if select was down for each frame...
that proved to me that there was no funny business with
select, it can be read without too much hassle.

Another advantage of the current code is that the game
keeps playing until select is released, it doesn't go into
freaky no screen refresh land.

cheers,
k
-- 
KirkIsrael@xxxxxxxxxxxxx    http://kisrael.com
 "The real problem with having mind-controlled zombies as my servants is that 
  it's tough to get up a really sincere-sounding round of cheers when 
  I've come up with a plan I think is worth cheering." --Maximus, X-Factor


----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread