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

Subject: [stella] trick to using select switch as a toggle?
From: KirkIsrael@xxxxxxxxxxxxx
Date: 30 Aug 2003 22:05:33 -0000
Me again.

Putting yesterday's Title Screen kernal into my main game.
Went pretty well.  Now I'm trying to get the game to start 
when Reset is hit, and to change game player moders 
((1P vs Computer) vs (1P vs 2P)) when select is hit.
But the Select isn't registering every hit, or maybe 
my code to toggle what's supposed to be a zero,not-zero
boolean is suspect?  (Right now for convenience I'm using
full bytes for booleans, which is wasteful, if I need the 
RAM and still have cycles I'll start using better masking 
techniques) I didn't see anything in Stella about having
to reset SWCHB, so I'm assuming I could just poll it whenever
I need to...

My toggle code is this -- I JMP over the code during normal
program execution, but I placed it before the rest of the 
"reset the title screen" code, so if select is hit, the title
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.

;------------------------snip----------------------------
TitleStart
; if we've jumped here, we don't want to switch the player mode...
	JMP DoneSwitchingPlayerCount
;if we jump HERE, select is hit and we want to swap how many players we have
SwitchPlayerCount
	LDA SWCHB
	AND #%00000010 ;is game select STILL hit???
	BNE SwitchPlayerCount ;if so keep waiting..
	;toggle  booleanGameIsTwoPlayers - could I just use EOR?
	LDA booleanGameIsTwoPlayers
	BEQ IsTwoPlayersWasZero
	LDA #0
	STA booleanGameIsTwoPlayers
	JMP DoneSwitchingPlayerCount
IsTwoPlayersWasZero
	LDA #1
	STA booleanGameIsTwoPlayers
DoneSwitchingPlayerCount
;------------------------snip----------------------------


and I jump to that with code like 

;------------------------snip----------------------------
TitleMainLoop
	LDA SWCHB
	AND #%00000001 ;is game reset?
	BNE TitleResetWasNotHit ;if so jump to MainGame
	JMP MainGameStart
TitleResetWasNotHit
	LDA SWCHB
	AND #%00000010 ;is game select?
	BEQ SwitchPlayerCount ;if so jump to Swap Number of Players
;------------------------snip----------------------------


(I had to JMP instand of branch because it was too far away)


Thanks for any insight into what I'm doing wrong...
I really thought the select loop would handle it.
Also, I dunno, maybe at somepoint I need to rethink
how I handle reset and select, so it doesn't kill the 
frame refresh? Or do most games just let the tv
go nuts as long as those buttons are held?

Full source at the bottom of http://alienbill.com/joustpong/

Also, I finally upgraded to the latest DASM...mine was pretty
old. And I started using macro.h for its SLEEP macro
(though you know, if ROM space is an issue, wouldn't something involving
loops be better than just writing out NOPs? or am I not 
understanding what's going on?)

Finally, I notice that the VCS.H from http://www.atari2600.org/dasm
says "do not distribute this" file (macro.h only asks that modified
version not be distributed)--so is it not ok to put it on my game
journal page, even though (theoretically) it might need that particular
version to compile it? (I don't think any budding 2600 programmers would
grab the vcs.h from that particular journal...)

Thanks,
Kirk

-- 
KirkIsrael@xxxxxxxxxxxxx    http://kisrael.com
 "SANTA HAS A TUMOR IN HIS HEAD THE SIZE OF AN OLIVE. MAYBE IT WILL GO 
  AWAY TOMORROW BUT I DON'T THINK SO."
    --sign language by Crumpet the Macy's SantaLand Elf (David Sedaris)


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


Current Thread