Re: RE: [stella] "Zombie" optimizations

Subject: Re: RE: [stella] "Zombie" optimizations
From: Christopher Tumber <christophertumber@xxxxxxxxxx>
Date: Fri, 17 Jan 2003 13:12:32 -0500
This is the code I'm using in Space Instigators to draw the shots. I'm posting it because it's so different the DCP-Solution maybe it sparks some ideas... 

      lda Scanline                 ;3 Cycles 2 Bytes
      sbc DrawnShot_Pos_Y          ;3 Cycles 2 Bytes
      lsr                          ;2 Cycles 1 Byte
      tax                          ;2 Cycles 1 Byte
      lda Player_Shot_Data_Table,x ;4 Cycles 3 Bytes
      sta ENABL                    ;3 Cycles 2 Bytes

;17 Cycles - Could be 15 Cycles by removing the lsr and widening the table

       org $fe00   ;You really, really want this at the start of a page!
Player_Shot_Data_Table:
      .byte 2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
      .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
      .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
      .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
      .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
      .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
      .byte 0,0,0,0,0,0,0,0


Scanline is a variable which contains the current scanline, I use X and Y extensively during the kernal for calcs so I had to keep track of Scanline in RAM which does cost me an extra 3 cycles per "INC Scanline" over INY but so it goes. You'll obviously want to substitue TYA for LDA Scanline.

DrawnShot_Pos_Y is the current vertical position of the shot.

Originally the table was 255 bytes wide giving 1 scanline of resolution. Since I didn't need that resolution, I cut the table in half so now it's 2 scanline resolution with a much smaller table but at the cost of the 2 cycle LSR. If you need the 2 cycles back then remove the LSR and widen the table again. Or add a second LSR and halve the table again (&etc).

For "Mortal Kurling" I'm using a similar routine but one which contains data for both ENABL (on/off) and CTRLPF (width). However, the extra 5 (7-2 for larger table) cycles to do this eliminates any advantage over your NEW (which I should probably.. uh.. borrow now) routine but since you're only actually checking and enabling ENAM0 on the first scanline perhaps some hybrid routine which also skips ENABL after the fist Scanline and uses a different table to eliminate the need for the two ASLs? (Would use a lot of ROM). Nah, then you're just back to your solution with the added overhead of another indexed LDA.

Anyway, this is really just intended to be "food for thought"...

      lda BallData,x ;4
      sta ENABL      ;3
      asl            ;2
      asl            ;2
      sta CTRLPF     ;3


       org $fe00   ;You really, really want this at the start of a page!
BallData: .byte 2,2+8,2+4+8,2+8,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
          .byte 0,0,0,0,0


Chris...

----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread