Re: [stella] Baubles; some progress, some problems...

Subject: Re: [stella] Baubles; some progress, some problems...
From: "Thomas Jentzsch" <tjentzsch@xxxxxx>
Date: Wed, 14 Nov 2001 09:53:54 +0100
Jake Patterson wrote:
> On the top, starting from the left, is the lives remaining indicator, then
> the time remaining, then the current level.  The latter two will be two
> hex digits, and the lives remaining indicator will be tick marks.
> My program displays the lives remaining properly, but not the other two
> fields for some reason.  I can't quite figure that out.

I found two errors:
1. you forgot to fill the LevelWeAreOnBuffer variables
2. the LevelWeAreOnBuffer variables overlap with the next variables. That won't happen any more, if you follow Glenn's suggestions.

> Also, in the area with the scrolling "zero" text, which will be the actual
> play area, I have spent all of the cycles displaying that and have none
> left over to display P0, P1, and the ball, which my game will call for.  I
> fear it will be necessary to sacrifice the vertical blue border and go to
> a two scanline kernel in order to make it work.  I'm hoping someone here
> will think of something I have missed that may make my design possible :-)

1. you are wasting way to many cycles (24!) for coloring the playfield. That won't work, when you want to add players too. And your colour changes will change the players colors too. You should use COLUPF for this. (But I bet, that would still cost to many cycles.)

2. This code is looking very elegant, but unfortunately is to inefficient:
     LDX BufferPointer               ; [0]  + 3
     LDX NextTableRecord             ; [43] + 3
     LDA ScrollTablePage,X           ; [46] + 4
     STA BufferPointer               ; [50] + 3
     INX                             ; [53] + 2
     LDA ScrollTablePage,X           ; [55] + 4
     STA NextTableRecord             ; [59] + 3

As ScrollTablePage is defined now, the NextTableRecord variable is simply increased by two every line and BufferPointer is increased by one every 14th line. 

That way, your table allows you to scroll your data without checking, if a new 14 line block starts and if yes, if your block counter has to be reset to zero. That's the idea? Right?

It's a very good idea, doing this with a table. But it costs to many cycles (and a lot of ROM too). If I count correct, you need 22 cylces.

First change: Throw away your table based approach :)
Second change: Count your indexes down to zero, that makes checking faster.

Now you could simply do something like:
    LDX BufferPointer   ;3
    DEC LineCounter     ;5
    BNE .ok             ;2³
    LDA  #14            ;2
    STA LineCounter     ;3
    DEC BufferPointer   ;5
    BNE .ok             ;2³
    LDA #0              ;2
    STA BufferPointer   ;3
...and it would be even slower (worst case: 27 cycles) than your approach. :(

But now you have a lot of options:

Remove BufferPointer and use X instead, that saves a lot (9) of cycles. Now we are already faster (18 cycles) than your solution 
    DEC LineCounter     ;5
    BNE .ok             ;2³
    LDA  #14            ;2
    STA LineCounter     ;3
    DEX                 ;2
    BNE .ok             ;2³
    LDX #0              ;2

Then you could repeat the data X (was BufferPointer) is pointing at. That will cost you some ROM, but now you never have to check and reset X (4 more cycles won -> 14 cycles):
    DEC LineCounter     ;5
    BNE .ok             ;2³
    LDA  #14            ;2
    STA LineCounter     ;3
    INX                 ;2   X is counting up again, that makes initialisation easier

Now it is getting a bit more complicated.
You could use the Y variable instead of LineCounter and make your blocks 2^4 (=16) lines high. Finally you are down to 11 cycles :)
    TYA                 ;2
    EOR Offset          ;3
    AND #15             ;2
    BNE .ok             ;2³
    INX                 ;2

The contents of the Offset variable depends on PlayfieldY, it should be something like (PlayfieldY*2) or -(PlayfieldY*2). You have to test this. 

3. If you need even more cycles, don't change PF0 and make the game area a bit smaller.

Have fun!
Thomas Jentzsch         | *** Every bit is sacred ! ***
tjentzsch at web dot de |

Berufsunfähigskeitversicherung von Mamax bei WEB.DE. 
Jetzt informieren!

Archives (includes files) at
Unsub & more at

Current Thread