Re: [stella] Space Treat with score

Subject: Re: [stella] Space Treat with score
From: Thomas Jentzsch <tjentzsch@xxxxxx>
Date: Mon, 30 Dec 2002 23:07:34 +0100
Fabrizio wrote:

>At the moment I'm almost completely out of ROM space, but I'd
>still like to add a few more features...

Just a few quick peephole optimizations:

	LDA GameScreen
	BEQ StartIntroScreen
	CMP #5
	BCC ContinueApplicationLoop1
	JMP MainLoop
	CMP #1
	BEQ MainLoopIntroScreen
	CMP #2
	BEQ StartLevelScreen
	CMP #3
	BEQ MainLoopLevelScreen
	CMP #4
	BEQ StartGameScreen
You could save a few bytes here by reversing the order and 
using DEX/DEY.

In LoadLevelPointers you could use a table and a loop instead 
of the current code.

And you are quite ofting using code like this:
  JSR somewhere
Replace this with JMP and save one byte.

And here LDA #0 is superfluous:
	LDA plrLives
	BNE StartGameScreen
	LDA #0
	STA GameScreen

Here you could use LSR/BCS and save one byte:
	AND #%00000001
	BNE NoResetGame

And why don't you use X or Y here?
	LDA LevelCounter+1
	ADC #1
	STA LevelCounter+1
That would save you two bytes.

And instead of:
	CMP #10
	BNE NoResetLevelCounter
	LDA #0
	STA LevelCounter+1 could write:
	EOR #10
	BNE NoResetLevelCounter
	STA LevelCounter+1

Often a JMP can be safely replace by an unconditional branch. 
	LDA PfFuel+4
	BEQ Fuel3
	STA PfFuel+4
	JMP NoZeroFuelDelay
BPL will always work here

And sometimes some code rearrangement might help to reuse 
register values. Like here:
	LDA #0
	STA plrExploding
	LDA GoingUp
	BEQ ChangeDirectionAnim2
	LDA #0
	STA GoingUp	; Rimette il vecchio set di nemici (Anim)
If you use X or Y to load GoingUp, then you can reuse the 0 in 
the accu.

Or here:
	LDA FuelColor
	BEQ NoRestartFuelSound
	STA FuelColor
Replace with
	CMP FuelColor
	BEQ NoRestartFuelSound
	STA FuelColor

And if the LeftRandom subroutine would return random, you could 
avoid loading it again and again. ;)
Have fun!	

Archives (includes files) at
Unsub & more at

Current Thread