Jump to content
  • entries
    657
  • comments
    2,692
  • views
    898,519

Stay Frosty, Part 3


SpiceWare

1,311 views

The following weekend I created a test level to check the update timing for the kernel. The time critical section of the kernel is when the ice blocks are being drawn as everything (snowman & color, nose, melt trail, fireball, 6 playfield updates) had the potential for being drawn:

 

blogentry-3056-0-11662100-1467471571_thumb.png

 

Looked great, but I had to drop both the nose and the melt trail as there wasn't enough time to update everything during that critical section :(

  • 36 cycles to update playfields
  • 21 cycles to draw snowman
  • 8 cycles to update fireball
  • 7 cycles loop control
  • ---------
  • 72 cycles total

Normally I would use sprite drawing logic of DoDraw, which would take 26 cycles to update & color the snowman, but there wasn't enough time for 5 additional cycles in that loop. Instead, I used a Mask:

        lda (FrostyImagePtr),y ; 5  5
        and (FrostyMaskPtr),y  ; 5 10
        sta GRP0               ; 3 13
        lda (FrostyColorPtr),y ; 5 18
        sta COLUP0             ; 3 21
 


The tradeoff of using a Mask is you need more RAM (for the mask pointer) and more ROM for the mask itself. The Mask is a block of $ff sized the same as the full-health snowman, with blocks of $00 on either side:

 

BlankGraphic
        repeat 50 ; 148-26
        .byte 0
        repend
        repeat 25
        .byte $ff
        repend
FrostyMask
        repeat 50 ; 148-26
        .byte 0
        repend
 


Now, that I'm more familiar with DASM, I would recode that as:

 

        align 256
BlankGraphic:
        ds 50, $00
        ds 26, $ff
FrostyMask:
        ds 50, $00
 


In hindsight I probably should have looked into using SwitchDraw to eliminate the Mask's extra RAM and ROM requirements as the Y register isn't used to count down the scan lines for the entire screen; instead, Y counts down the height of each platform zone. This means the Y's value is always between 0 and 127, which is one of the prerequisites for SwitchDraw. You can get a good overview of a number of sprite drawing options in this post by vdub_bobby.

 

The playfield is only updated during the scanlines with ice or platforms, leaving quite a bit of time in the "air" above the ice. It's during this time that the player 1 is repositioned to draw the next fireball. In this early build the reposition routine has an X position limit of 0-146, which can be seen by moving fireball on the bottom platform. This was due to needing to update the snowman's sprite and color during the reposition logic. I hadn't yet looked into increasing the range, but felt that the limit would be acceptable if I couldn't change it.

 

The kernel was repeated 5 times to support 5 zones (platform levels). 109 bytes of RAM were required to keep track of it all!

Heights          ds 1*SECTIONS    ; heights of the levels
FireBallX        ds 2*SECTIONS    ; fireball positions, 2 per section
IceData          ds 6*SECTIONS    ; ice blocks
Platforms        ds 6*SECTIONS-6  ; platforms                                 
FrostyImagePtr   ds 2*SECTIONS
FrostyMaskPtr    ds 2*SECTIONS
FrostyColorPtr   ds 2*SECTIONS
FireImagePtr     ds 2*SECTIONS
 

 

ROM:

frosty071111.bin

 

Source:

sf_source071111.zip

 

 

Blog entry covers November 5-11(AM), 2007

  • Like 2

3 Comments


Recommended Comments

Now, that I'm more familiar with DASM, I would recode that as:

        align 256
BlankGraphic:
        ds 50, $00
        ds 26, $ff
FrostyMask:
        ds 50, $00 

 

That is a handy tip as it makes the list file so much easier to read. I never liked how repeat-repend would spit out every instance in the list file making it very long. I used to get around that by not choosing not to use repeat-repend and manually putting in all the bytes, or using repeat-repend with LIST OFF and LIST ON. Great tip though with using designated space!

Link to comment

That is a handy tip as it makes the list file so much easier to read.

I like how it's easier to read in the source; but wow, that's a *huge* improvement in the listing.

 

ds:

00 00 00 00*	      align	256
   1049  fb00				   BlankGraphic
   1050  fb00		       00 00 00 00*	      ds	50, $00
   1051  fb32		       ff ff ff ff*	      ds	26, $ff
   1052  fb4c				   FrostyMask
   1053  fb4c		       00 00 00 00*	      ds	50, $00

repeat:

   1048  fb00		       00 00 00 00*	      align	256
   1049  fb00				   BlankGraphic
   1050  fb00					      repeat	50	; 148-26
   1051  fb00		       00		      .byte.b	0
   1050  fb00					      repend
   1051  fb01		       00		      .byte.b	0
   1050  fb01					      repend
   1051  fb02		       00		      .byte.b	0
   1050  fb02					      repend
   1051  fb03		       00		      .byte.b	0
   1050  fb03					      repend
   1051  fb04		       00		      .byte.b	0
   1050  fb04					      repend
   1051  fb05		       00		      .byte.b	0
   1050  fb05					      repend
   1051  fb06		       00		      .byte.b	0
   1050  fb06					      repend
   1051  fb07		       00		      .byte.b	0
   1050  fb07					      repend
   1051  fb08		       00		      .byte.b	0
   1050  fb08					      repend
   1051  fb09		       00		      .byte.b	0
   1050  fb09					      repend
   1051  fb0a		       00		      .byte.b	0
   1050  fb0a					      repend
   1051  fb0b		       00		      .byte.b	0
   1050  fb0b					      repend
   1051  fb0c		       00		      .byte.b	0
   1050  fb0c					      repend
   1051  fb0d		       00		      .byte.b	0
   1050  fb0d					      repend
   1051  fb0e		       00		      .byte.b	0
   1050  fb0e					      repend
   1051  fb0f		       00		      .byte.b	0
   1050  fb0f					      repend
   1051  fb10		       00		      .byte.b	0
   1050  fb10					      repend
   1051  fb11		       00		      .byte.b	0
   1050  fb11					      repend
   1051  fb12		       00		      .byte.b	0
   1050  fb12					      repend
   1051  fb13		       00		      .byte.b	0
   1050  fb13					      repend
   1051  fb14		       00		      .byte.b	0
   1050  fb14					      repend
   1051  fb15		       00		      .byte.b	0
   1050  fb15					      repend
   1051  fb16		       00		      .byte.b	0
   1050  fb16					      repend
   1051  fb17		       00		      .byte.b	0
   1050  fb17					      repend
   1051  fb18		       00		      .byte.b	0
   1050  fb18					      repend
   1051  fb19		       00		      .byte.b	0
   1050  fb19					      repend
   1051  fb1a		       00		      .byte.b	0
   1050  fb1a					      repend
   1051  fb1b		       00		      .byte.b	0
   1050  fb1b					      repend
   1051  fb1c		       00		      .byte.b	0
   1050  fb1c					      repend
   1051  fb1d		       00		      .byte.b	0
   1050  fb1d					      repend
   1051  fb1e		       00		      .byte.b	0
   1050  fb1e					      repend
   1051  fb1f		       00		      .byte.b	0
   1050  fb1f					      repend
   1051  fb20		       00		      .byte.b	0
   1050  fb20					      repend
   1051  fb21		       00		      .byte.b	0
   1050  fb21					      repend
   1051  fb22		       00		      .byte.b	0
   1050  fb22					      repend
   1051  fb23		       00		      .byte.b	0
   1050  fb23					      repend
   1051  fb24		       00		      .byte.b	0
   1050  fb24					      repend
   1051  fb25		       00		      .byte.b	0
   1050  fb25					      repend
   1051  fb26		       00		      .byte.b	0
   1050  fb26					      repend
   1051  fb27		       00		      .byte.b	0
   1050  fb27					      repend
   1051  fb28		       00		      .byte.b	0
   1050  fb28					      repend
   1051  fb29		       00		      .byte.b	0
   1050  fb29					      repend
   1051  fb2a		       00		      .byte.b	0
   1050  fb2a					      repend
   1051  fb2b		       00		      .byte.b	0
   1050  fb2b					      repend
   1051  fb2c		       00		      .byte.b	0
   1050  fb2c					      repend
   1051  fb2d		       00		      .byte.b	0
   1050  fb2d					      repend
   1051  fb2e		       00		      .byte.b	0
   1050  fb2e					      repend
   1051  fb2f		       00		      .byte.b	0
   1050  fb2f					      repend
   1051  fb30		       00		      .byte.b	0
   1050  fb30					      repend
   1051  fb31		       00		      .byte.b	0
   1052  fb32					      repend
   1053  fb32					      repeat	26
   1054  fb32		       ff		      .byte.b	$ff
   1053  fb32					      repend
   1054  fb33		       ff		      .byte.b	$ff
   1053  fb33					      repend
   1054  fb34		       ff		      .byte.b	$ff
   1053  fb34					      repend
   1054  fb35		       ff		      .byte.b	$ff
   1053  fb35					      repend
   1054  fb36		       ff		      .byte.b	$ff
   1053  fb36					      repend
   1054  fb37		       ff		      .byte.b	$ff
   1053  fb37					      repend
   1054  fb38		       ff		      .byte.b	$ff
   1053  fb38					      repend
   1054  fb39		       ff		      .byte.b	$ff
   1053  fb39					      repend
   1054  fb3a		       ff		      .byte.b	$ff
   1053  fb3a					      repend
   1054  fb3b		       ff		      .byte.b	$ff
   1053  fb3b					      repend
   1054  fb3c		       ff		      .byte.b	$ff
   1053  fb3c					      repend
   1054  fb3d		       ff		      .byte.b	$ff
   1053  fb3d					      repend
   1054  fb3e		       ff		      .byte.b	$ff
   1053  fb3e					      repend
   1054  fb3f		       ff		      .byte.b	$ff
   1053  fb3f					      repend
   1054  fb40		       ff		      .byte.b	$ff
   1053  fb40					      repend
   1054  fb41		       ff		      .byte.b	$ff
   1053  fb41					      repend
   1054  fb42		       ff		      .byte.b	$ff
   1053  fb42					      repend
   1054  fb43		       ff		      .byte.b	$ff
   1053  fb43					      repend
   1054  fb44		       ff		      .byte.b	$ff
   1053  fb44					      repend
   1054  fb45		       ff		      .byte.b	$ff
   1053  fb45					      repend
   1054  fb46		       ff		      .byte.b	$ff
   1053  fb46					      repend
   1054  fb47		       ff		      .byte.b	$ff
   1053  fb47					      repend
   1054  fb48		       ff		      .byte.b	$ff
   1053  fb48					      repend
   1054  fb49		       ff		      .byte.b	$ff
   1053  fb49					      repend
   1054  fb4a		       ff		      .byte.b	$ff
   1053  fb4a					      repend
   1054  fb4b		       ff		      .byte.b	$ff
   1055  fb4c					      repend
   1056  fb4c				   FrostyMask
   1057  fb4c					      repeat	50	; 148-26
   1058  fb4c		       00		      .byte.b	0
   1057  fb4c					      repend
   1058  fb4d		       00		      .byte.b	0
   1057  fb4d					      repend
   1058  fb4e		       00		      .byte.b	0
   1057  fb4e					      repend
   1058  fb4f		       00		      .byte.b	0
   1057  fb4f					      repend
   1058  fb50		       00		      .byte.b	0
   1057  fb50					      repend
   1058  fb51		       00		      .byte.b	0
   1057  fb51					      repend
   1058  fb52		       00		      .byte.b	0
   1057  fb52					      repend
   1058  fb53		       00		      .byte.b	0
   1057  fb53					      repend
   1058  fb54		       00		      .byte.b	0
   1057  fb54					      repend
   1058  fb55		       00		      .byte.b	0
   1057  fb55					      repend
   1058  fb56		       00		      .byte.b	0
   1057  fb56					      repend
   1058  fb57		       00		      .byte.b	0
   1057  fb57					      repend
   1058  fb58		       00		      .byte.b	0
   1057  fb58					      repend
   1058  fb59		       00		      .byte.b	0
   1057  fb59					      repend
   1058  fb5a		       00		      .byte.b	0
   1057  fb5a					      repend
   1058  fb5b		       00		      .byte.b	0
   1057  fb5b					      repend
   1058  fb5c		       00		      .byte.b	0
   1057  fb5c					      repend
   1058  fb5d		       00		      .byte.b	0
   1057  fb5d					      repend
   1058  fb5e		       00		      .byte.b	0
   1057  fb5e					      repend
   1058  fb5f		       00		      .byte.b	0
   1057  fb5f					      repend
   1058  fb60		       00		      .byte.b	0
   1057  fb60					      repend
   1058  fb61		       00		      .byte.b	0
   1057  fb61					      repend
   1058  fb62		       00		      .byte.b	0
   1057  fb62					      repend
   1058  fb63		       00		      .byte.b	0
   1057  fb63					      repend
   1058  fb64		       00		      .byte.b	0
   1057  fb64					      repend
   1058  fb65		       00		      .byte.b	0
   1057  fb65					      repend
   1058  fb66		       00		      .byte.b	0
   1057  fb66					      repend
   1058  fb67		       00		      .byte.b	0
   1057  fb67					      repend
   1058  fb68		       00		      .byte.b	0
   1057  fb68					      repend
   1058  fb69		       00		      .byte.b	0
   1057  fb69					      repend
   1058  fb6a		       00		      .byte.b	0
   1057  fb6a					      repend
   1058  fb6b		       00		      .byte.b	0
   1057  fb6b					      repend
   1058  fb6c		       00		      .byte.b	0
   1057  fb6c					      repend
   1058  fb6d		       00		      .byte.b	0
   1057  fb6d					      repend
   1058  fb6e		       00		      .byte.b	0
   1057  fb6e					      repend
   1058  fb6f		       00		      .byte.b	0
   1057  fb6f					      repend
   1058  fb70		       00		      .byte.b	0
   1057  fb70					      repend
   1058  fb71		       00		      .byte.b	0
   1057  fb71					      repend
   1058  fb72		       00		      .byte.b	0
   1057  fb72					      repend
   1058  fb73		       00		      .byte.b	0
   1057  fb73					      repend
   1058  fb74		       00		      .byte.b	0
   1057  fb74					      repend
   1058  fb75		       00		      .byte.b	0
   1057  fb75					      repend
   1058  fb76		       00		      .byte.b	0
   1057  fb76					      repend
   1058  fb77		       00		      .byte.b	0
   1057  fb77					      repend
   1058  fb78		       00		      .byte.b	0
   1057  fb78					      repend
   1058  fb79		       00		      .byte.b	0
   1057  fb79					      repend
   1058  fb7a		       00		      .byte.b	0
   1057  fb7a					      repend
   1058  fb7b		       00		      .byte.b	0
   1057  fb7b					      repend
   1058  fb7c		       00		      .byte.b	0
   1057  fb7c					      repend
   1058  fb7d		       00		      .byte.b	0
   1059  fb7e					      repend
  • Like 1
Link to comment

Yeah, repeat-repend can be very long. BTW you can also do a similar space fill with ORG statements, where you can tell DASM what value the unpopulated bytes should be.

   ORG $F000, $EA

That would fill the unused bytes with $EA.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...