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

Subject: Re: [stella] trick to using select switch as a toggle?
From: Rob <kudla@xxxxxxxxx>
Date: Sun, 31 Aug 2003 00:00:22 -0400
On Saturday 30 August 2003 18:05, KirkIsrael@xxxxxxxxxxxxx wrote:
> screen values are restored.  I do a tight loop until
> the select button is released, to prevent multiple counting
> of the select, but that didn't work.

I'd been wrestling with the same problem lately.  I haven't 
actually written the code to fix it, but here's the theory I 
came up with while driving home one night this week :P  (I guess 
I'll write my theory in assembler here and work it into what you 
posted, but no guarantees it'll build... I don't even have dasm 
on the same machine as my mail client at the moment.)

This costs a byte (actually 4 bits, so I guess I'll stick your 
playercount flag in a 5th) of RAM.  Suppose that byte is called 
SwitchFlags.  The effect I'm envisioning is that if you hold 
down the select key, the number of players gets toggled about 
twice a second (more useful for games with more than 2 options 
accessible by select) but the display of the title screen isn't 
otherwise disturbed.  (Holding down the reset button should 
result in the first frame of your game being displayed till you 
let go, but unless you start some annoying music on the first 
frame like Parker Bros. Frogger I think this is okay ;) )

TitleStart
; if we've jumped here, we don't want to switch the player 
; mode... Kirk, I actually don't get what this is here for
        JMP DoneSwitchingPlayerCount
; if we jump HERE, we want to deal with the switches...
HandleSwitches
        LDA SWCHB
        AND #%00000001 ;is game start down?
	BEQ CheckSelect ; if not, try select
	JMP MainGameStart
CheckSelect
        LDA SWCHB
        AND #%00000010 ;is game select down?
	BNE SelectIsDown
	LDA #%11110000 ; if not, clear keybounce timer
	ORA SwitchFlags
	STA SwitchFlags
	JMP DoneSwitchingPlayerCount
SelectIsDown
	LDA SwitchFlags
	AND #%00001111 ; check keybounce timer
	BEQ TogglePlayerCount ; if not waiting, toggle the player count
	DEC SwitchFlags ; otherwise, tick the clock and wait some more
	JMP DoneSwitchingPlayerCount
TogglePlayerCount
	LDA SwitchFlags
	EOR #%00010000 ; toggle player count bit
	ORA #%00001111 ; reset keybounce timer
	STA SwitchFlags ; and save....
DoneSwitchingPlayerCount
	(VBLANK code continues....)


Rob

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


Current Thread