Re: [stella] Euchre: squeezing in more

Subject: Re: [stella] Euchre: squeezing in more
From: Thomas Jentzsch <tjentzsch@xxxxxx>
Date: Thu, 8 Aug 2002 22:31:11 +0200
Erik Eid wrote:
> I am still not finished with the game.  As I mentioned, there's a few rough
> edges to clean up; the remaining 78 bytes will help make that happen.  If I 
> have enough space afterward, I can look into implementing the suggestions 
> given by the list readers.  I also still have to create a PAL version.  (Then 
> there's also a manual to consider...)

You should check some of your JMP statements if you can replace them with
Bxx.

And change you StageJumpTable code from JSR, RTS into a real table
containing the high and low addresses of the subroutines. Then you can
simply jump directly there from StageJump.

    ldy Stage
    lda StageJumpTableLow,y
    sta T2
    lda StageJumpTableHigh,y
    sta T2+1                 ; = T3
    jsr StageJump
    jmp EndCase

StageJump:
    jmp (T2)

StageJumpTableLow:
    .byte <PerformNewGame, <PerformNewHand, ...

StageJumpTableHigh:
    .byte >PerformNewGame, >PerformNewHand, ...

The RTS from the subroutines will return you directly to jmp Endcase. :-)


You can save a few more bytes whenever you call a subroutine more than
once with the same parameter.
Eg.
   ldx #0
   jsr PositionPlayer

Change your code into:
   jsr PositionPlayer0
   ...
PositionPlayer0:
   ldx #0
PositionPlayer:

If you need more than one parameter more than once, use this little
trick:
PositionPlayer1:
   ldx #1
   .byte $2c ; opcode for bit abs
PositionPlayer0:
   ldx #0
PositionPlayer:

And I noticed that you very often still use this sequence:
   ldx #0
   jsr PositionPlayer
   ldx #1
   jsr PositionPlayer

You should always use inx here (or you could add that inx into the
subroutine).

And finally (for now):
You are very often setting both players to fixed positions. If you use
tables for the fixed positions, you could do something like this:
  ldy #id+1          ; offset into position table offsets
  jsr PosPlayers
  ...
PosPlayers:
  ldx #1
.loopPlayer:
  lda PosTable,y
  jsr PositionPlayer
  dey
  dex
  bpl .loopPlayer
  rts

PosTable:
  .byte LeftScorePos, RightScorePos
  .byte LeftTrickPos, RightTrickPos
  .byte ...

To avoid saving/restoring y here, you should use SBC instead of DEY
inside PositionPlayer: 
PositionPlayer:
    sta WSYNC
    ror T1  ; waste 5 cycles
    sta HMP0,x
    and #$0f
    sec
P0
    sbc #1
    bpl P0
    sta RESP0,x
    rts

All together that should give you plenty enough bytes for many
suggestions. ;-) 

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://www.biglist.com/lists/stella/


Current Thread