|
Subject: Space Savers From: "Edwin Blink" <edwin.blink@xxxxxxx> Date: Fri, 3 Sep 2004 16:42:12 +0200 |
Some more space space saving ideas:
-Rom Mirroring
-Initialisation savings
--------------------------------------------------------------------------
Take advantage of rom mirroring and use the last two ROM bytes for code too.
you can add these two bytes to continous ROM space by addressing them
2K or 4K below there real origin. Example:
;- Start of rom -
ORG $F000 ;for 4K ROM
;continued reset code from end of rom (see end)
...
;- end of rom space -
ORG $FFFC ;Reset vector
.WORD START-$1000 ;for 4K and $0800 for 2K ROM
START
SEI ;first instructions of standard reset code
CLD
;^continue at start of rom ^
;--------------------------------------------------------------
;When having several variables (more than two bytes) that must be
initialised
during start-up (default game type or high score for example) then instead
of using
LDA #xx/STA xx to initialise them. they could be copied from rom in one go.
with 10 bytes code
LDX LENGTH-1
VINIT
LDA DEFAULTS,X
STA VARS,X
DEX
BPL VINIT
One byte can be kicked out of the above code again by integrating the code
with Clean start code:
;VARS: start of variables that require initialisation
;DEFAULTS: default values somewher at end of rom
;VARLENGTH: number of variable bytes to initialize (must be >3 to save
bytes)
SEI
CLD
LDX #$00
TXA ;A is 0 the reset value
CLRLP
;// integrated copy code
;first all ram is cleared then when clearing the tia
;vars are initialized with their defaults.
CPX VARLENGTH+1 ;time to init vars?
BNE VARSK ;branch skip var part
LDA DEFAULTS-1,X ;get default value
STA VARS-1,X ;initialize var
VARSK
;\\end integrated copy code
DEX ;start with location $xxFF and downwards
TXS ;stack range $01FF-$0180 overlaps ram, $017F-$0100 overlaps tia
PHA ;clear ram/register
BNE CLRLP
STA SWACNT ;Set PORTB to inputs
STA SWBCNT ;Set PORTA to inputs
;Just with 4 default variables there is already a byte saving of 3 bytes!
;-----------------------------------------------------------
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [stella] archives?, Thomas Jentzsch | Thread | Re: [stella] Space Savers, Dennis Debro |
| Re: [stella] archives?, Paul Slocum | Date | Aw: [stella] Space Savers, cybergoth |
| Month |