Re: [stella] incoming source

Subject: Re: [stella] incoming source
From: Ben Larson <benjamin_e_larson@xxxxxxxxx>
Date: Wed, 15 Dec 2004 07:05:37 -0800 (PST)
Ok, thanks Thomas.  I will have to look over all your
suggestions now and get back to work I suppose. :)

As far as calling the first subroutine before
initializing the stack...the weird thing is that it
seems to work OK anyway on the real hardware without
corrupting any memory values (at least when I've
tested it with my supercharger).  Is the stack pointer
automatically set to a default value in the hardware
maybe...?

Ben

--- Thomas Jentzsch <tjentzsch@xxxxxx> wrote:

> Ben Larson wrote:
> > Thomas J. requested the source for 'Incoming' from
> me over on the
> > Atariage forums last week in order to do some
> space optimization, so
> > I figured I'd just post it here.
> 
> Ok, I am a bit lazy, so I'll just give you some
> hints for gaining
> space now: :-)
> 
> 1. Testing bits:
> Test Bit7:
>   lda status
>   and #%10000000
>   bne .somewhere
> better:
>   bit status
>   bmi .somewhere
>   
> Test Bit6:
>   lda status
>   and #%01000000
>   bne .somewhere
> better:
>   bit status
>   bvs .somewhere
> 
> Test Bit0:
>   lda status
>   and #%00000001
>   bne .somewhere
> better:
>   lda status
>   lsr
>   bcs .somewhere
> 
> Since you are doing this very often, this should
> save a lot of bytes.
> 
> 2. Random number generation:
> This code should do the whole job and is *much*
> shorter:
>   lda random    ; initialize to non-zero at start
>   lsr
>   bcs .skipEor
>   eor #$b2      ; various values possible here
> .skipEor:
>   sta random
> 
> It always creates a whole new random byte. It is not
> as random as your
> code, but I highly doubt anyone will notice a
> difference.
> 
> 3. Maths:
> You are doing a lot of 16 bit math (e.g. shots), so
> you could use a
> subroutine like:
> Add16:
>   clc
>   adc $00,x
>   sta $00,x
>   tya
>   adc $01,x
>   sta $01,x
>   rts
>   
> Arrange your variables, so that the high-byte always
> follows the
> low-byte and then load the address of the low-byte
> into X
> 
> You can even make the code more useful:
> Add16_0
>   ldy #0       ; add value < 256
> Add16:
>   clc
>   adc $00,x
>   sta $00,x
>   tya
>   adc $01,x
>   sta $01,x
>   rts
> 
> You can also you this for subtracting, just add
> negative values.
> 
> 4. Use non-BCD variables when you do a lot of
> calculations with them
> (e.g. P1/2Power). It's easier to convert them for
> display only than
> having to convert them for calculations.
> 
> 5. Make you code more universal, e.g. don't code
> twice for player 1
> and player 2. Rearrange your variables and code so
> that a player 1
> variable precedes the matching player 2 variable.
> And use GRP0 for
> player 1 and GRP1 for player 2. Then you can loop
> over the code twice.
> 
> And maybe better call them player 0 and 1 ;-)
> 
> 
> Ok, if implementing those tips doesn't give you
> enough bytes, I still
> know plenty of more bytes to gain. :-)
> 
> BTW:
> You are calling the first subroutine before
> initializing the stack!
> 
> Have fun!
> Thomas                            
>
_______________________________________________________
> Thomas Jentzsch         | *** Every bit is sacred !
> ***
> tjentzsch at web dot de |
> 
> 
> Archives (includes files) at
> http://www.biglist.com/lists/stella/archives/
> Unsub & more at http://stella.biglist.com
>
--~----------------------------------------------------------------
> You are subscribed as: benjamin_e_larson@xxxxxxxxx
> To unsubscribe, send email to:
>   stella-unsub-145252@xxxxxxxxxxxxxxxxxx
> Or go to:
>  
>
http://stella.biglist.com/unsub/stella/benjamin_e_larson@xxxxxxxxx
> --~--
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

Current Thread