Skip Draw found in Berzerk???

Subject: Skip Draw found in Berzerk???
From: "Dennis Debro" <dennis@xxxxxxxxxxxxxxx>
Date: Mon, 25 Oct 2004 16:09:35 -0700 (PDT)
Hi there,

I know I said I'd take some time off from reverse-engineering games but I
had a few extra hours so I picked up Berzerk again.

It seems as Berzerk uses a form of SkipDraw. Now don't get your hopes up
too far. It doesn't use illegal opcodes like the more elegant one we know
and love :-) I looks more like my first attempt. Where two variables are
used (upper and lower boundaries) to determine if it's time to draw the
sprite.

Here's the evidence...

1) Look at where the sprites are located in ROM for player 0 (i.e. the
player and Evil Otto). They both start 169 (kernel height) bytes into the
page.

   .byte $00 ; |........| $FDA9
   .byte $18 ; |...XX...| $FDAA
   .byte $18 ; |...XX...| $FDAB
   .byte $00 ; |........| $FDAC
   .byte $3C ; |..XXXX  | $FDAD
   .byte $5A ; |.X.XX.X.| $FDAE
   .byte $5A ; |.X.XX.X.| $FDAF
   .byte $18 ; |...XX...| $FDB0
   .byte $18 ; |...XX...| $FDB1
   .byte $18 ; |...XX...| $FDB2
   .byte $1C ; |...XXX..| $FDB3
   .byte $00 ; |........| $FDB4

   .byte $00 ; |........| $FEA9
   .byte $3C ; |..XXXX..| $FEAA
   .byte $7E ; |.XXXXXX.| $FEAB
   .byte $DB ; |XX.XX.XX| $FEAC
   .byte $FF ; |XXXXXXXX| $FEAD
   .byte $BD ; |X.XXXX.X| $FEAE
   .byte $C3 ; |XX....XX| $FEAF
   .byte $7E ; |.XXXXXX.| $FEB0
   .byte $3C ; |..XXXX..| $FEB1
   .byte $00 ; |........| $FEB2
   .byte $00 ; |........| $FEB3
   .byte $00 ; |........| $FEB4


2) The routine at $FA04 calculates the graphic pointers...

CalculateP0GraphicPointers
   sta VDELP0
   lsr
   sta player0Scanline              ; the scan line to start drawing
   clc
   adc #H_PLAYER+1
   sta playerUpperBoundary          ; the upper player drawing boundary
   lda #H_KERNEL
   sec
   sbc player0Scanline
   clc
   adc playerGraphicLSB
   sta playerGraphicPointer
   rts

3) In the kernel instead of doing the elegant check we all know and love
Dan Hitchens does...
   sta WSYNC
;--------------------------------------
   SLEEP_3                    ; 3
   lda player0Graphic         ; 3
   sta GRP0                   ; 3 = @09
   lda (playerMissilePointer),y; 5
   sta ENAM0                  ; 3 = @17
   SLEEP_8                    ; 8
   cpy player0Scanline        ; 3 = @28
   bcc .waste15Cycles         ; 2³        form of skipDraw
   cpy playerUpperBoundary    ; 3
   bcs .waste10Cycles         ; 2³        form of skipDraw
   lda (playerGraphicPointer),y; 5
   sta player0Graphic         ; 3

The AA database only shows Dan Hitchens as doing Berzerk. Does anyone know
if he did any other games?

Take care,
Dennis


Current Thread