RE: [stella] Ms. Pac Man, Mr. Do, striped playfields, and one-line kernels

Subject: RE: [stella] Ms. Pac Man, Mr. Do, striped playfields, and one-line kernels
From: "Thomas Jentzsch" <tjentzsch@xxxxxx>
Date: Thu, 02 Sep 2004 14:09:30 +0200
Lee wrote:
> Thomas's 9-cycle skipdraw would still need an additional 7 cycles to set the
> sprite, which puts me over budget.  I've never used skipdraw, so maybe I'm
> looking at it wrong. :)  14 cycles seems like a lot though, especially since
> I removed the ball highlight and have plugged the gap with a "SLEEP 7".  If
> you can see a way to do it in my code, please let me know.  (Search for
> "gameArea" in the source to find the game kernel.)

I am not sure about the planned restrictions for the inside area (REFLEX). How
wide can it become? Currently is has to stay inside the limits you are already 
using for the titlescreen, right? So the COLUPF writes have some little tolerance.

IMO there are plenty of free cycles left. Here is an example from the main part 
of the kernel:

.loop2            ;    -2
  lda ballShape,x ;+4   2
  sta GRP1        ;+3   5
  SLEEP 7         ;+7   12
  lda block1l,y   ;+4   16
  sta PF1         ;+3   *19*    Update left half of playfield
  lda block2l,y   ;+4   23
  sta PF2         ;+3   26
  lda (tryX),y    ;+5   31
  sta COLUPF      ;+3   *34*    Set board color
  lda block2r,y   ;+4   38
  sleep 7         ;+7   45
  sta PF2         ;+3   *48*    Update right half of playfield
  lda block1r,y   ;+4   52
  sta PF1         ;+3   55
  lda pcol        ;+3   58
  sleep 3         ;+3   61
  sta COLUPF      ;+3   *64*    Set paddle color
  dex             ;+2   66
  dec lineCount   ;+5   71
  bne .loop2      ;+3/2 *74*/73

First you can move the 2nd write to PF1 before the 2nd write to PF2. 
Then you can join two SLEEP (7+3) statements. Now we have moved 
all SLEEP statements outside the PFx writes.

Outside we now have:
- set paddle color (has to be delayed until 64..69!)
- update ball graphics (has to happen after 69)
- loop overhead (doesn't matter where)
- 17 free cycles (plenty enough! :-)

After some rearrangement the code looks like this (untested!):

.loop2            ;     58
  lda pcol        ;+3   61
  sta COLUPF      ;+3   *64*    Set paddle color
  SLEEP 17        ;+10  5 
  lda ballShape,x ;+4   9 
  sta GRP1        ;+3   12    
  lda block1l,y   ;+4   16
  sta PF1         ;+3   *19*    Update left half of playfield
  lda block2l,y   ;+4   23
  sta PF2         ;+3   26
  lda (tryX),y    ;+5   31
  sta COLUPF      ;+3   *34*    Set board color
  lda block1r,y   ;+4   38
  sta PF1         ;+3   41
  lda block2r,y   ;+4   45
  sta PF2         ;+3   *48*    Update right half of playfield
  dey             ;+2   50
  dec lineCount   ;+5   55
  bne .loop2      ;+3/2 *58*/57

So you have 24 cycles for skipDraw, which is more than enough. :-)

When using skipDraw, you will use Y for the scanline counter AND the
graphics data and X for the PF-data.


If neccessary we are also able to get rid of lineCount, this would 
reduce the additional overhead outside the loop:
  tya
  cmp Table,x
This is 100% flexible but will cost you one cycle inside the loop. 
(I am really missing cpy abs,x here)

Or you can do:
  tya
  and #(2^n-1)
But then then your rowheights are restricted to 2^n.

Hope that helps.

Have fun!
Thomas
_______________________________________________________
Thomas Jentzsch         | *** Every bit is sacred ! ***
tjentzsch at web dot de |
________________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt neu bei WEB.DE FreeMail: http://freemail.web.de/?mc=021193


Current Thread