Take 3
Once again, Frantic is being rebooted
While working on Stay Frosty 2, Thomas Jentzsch suggested redoing the kernel to use VDELBL. It puts the ball on vertical delay with updates synced to GRP1. It's a clever idea - but due to how SF2 is designed that would have required me to draw the snowman using player(sprite) 1 instead of player 0, which would cause problems in the horizon due to object priorities:
I thought it could be useful for Frantic and Timmy, as their sprite usage is way more flexible, so I added a note to the top of their source files to look into it when I resumed work on those projects.
The kernel after the prior reboot was this:
KernelLoopNoWSYNC: ; at this point the registers hold the following: ; A - graphics for player 0 ; X - enable for missile 0 ; Y - enable for missile 1 & PF0 for right side of screen ; PF0 and PF1 have already been updated for left side of room ; GRP1 (on VDEL) has been preloaded with player 1 graphics ; at cycle 76/0 sta GRP0 ; 3 3 - before 25 - updates GRP1 too via VDEL lda #<DS_COLUP0 ; 2 5 sta COLUP0 ; 3 8 - before 25 lda #<DS_COLUP1 ; 2 10 sta COLUP1 ; 3 13 - before 25 stx ENAM0 ; 3 16 - before 25 sty ENAM1 ; 3 19 - before 25 lda #<DS_EVENT_BL ; 2 21 - bit 7 triggers kernel event sta ENABL ; 3 24 - before 25 TESTB: bmi KernelEvent ; 2 26 - 3 27 if taken HM: sty PF0 ; 3 29 - PF0R, 28-49 lda #<DS_PF2L ; 2 31 sta PF2 ; 3 34 - PF2L, before 38 ldy DS_PF0R_M1 ; 4 38 - any after sty PF0, loads for next line lda #<DS_PF1R ; 2 40 sta PF1 ; 3 43 - PF1R, 39-54 lda #<AMPLITUDE ; 2 45 - any sta AUDV0 ; 3 48 - any lda #<DS_PF2R ; 2 50 sta PF2 ; 3 53 - PF2R, 50-65 ldx DS_PF0L_M0 ; 4 57 stx PF0 ; 3 60 - PF0L, after 55 lda #<DS_GRP1 ; 2 62 sta GRP1 ; 3 65 - any, on VDEL lda #<DS_PF1L ; 2 67 sta.w PF1 ; 4 71 - PF1L, 66 - 28 lda #<DS_GRP0 ; 2 73 jmp KernelLoopNoWSYNC ; 3 76/0
An untested rewrite is this:
KernelLoop: ; at this point the registers hold the following: ; A - graphics for player 1 ; Y - enable for missile 1 & PF0 for right side of screen ; PF0 and PF1 have already been updated for left side of room ; GRP0 (on VDEL) has been preloaded with player 1 graphics ; BL (on VDEL) has been preenabled with missile data ; at cycle 73 sta GRP1 ; 3 76/0 - before 25 - updates GRP0 & BL via VDEL lda #<DS_COLUP0 ; 2 2 sta COLUP0 ; 3 5 - before 25 lda #<DS_COLUP1 ; 2 7 sta COLUP1 ; 3 10 - before 25 sty ENAM1 ; 3 13 - before 25 lda #<DS_EVENT_M0 ; 2 15 - bit 7 triggers kernel event sta ENAM0 ; 3 18 - before 25 sbmi KernelEvent ; 2 20 - 3 21 if taken lda #<AMPLITUDE ; 2 22 sta AUDV0 ; 3 25 sty PF0 ; 3 28 - PF0R, 28-49 lda #<DS_PF2L ; 2 30 sta PF2 ; 3 33 - PF2L, before 38 ldy DS_PF0R_M1 ; 4 37 - any after sty PF0, loads for next line lda #<DS_PF1R ; 2 39 sta PF1 ; 3 42 - PF1R, 39-54 lda #<DS_GRP0 ; 2 44 sta GRP0 ; 3 47 - any, on VDEL lda #<DS_PF2R ; 2 49 sta PF2 ; 3 52 - PF2R, 50-65 lda #<DS_PF0L_BL ; 2 54 sta PF0 ; 3 57 - PF0L, after 55 sta ENABL ; 3 60 SLEEP 3 ; 3 63 lda #<DS_PF1L ; 2 65 sta PF1 ; 3 68 - PF1L, 66 - 28 lda #<DS_GRP1 ; 2 70 - any, on VDEL jmp KernelLoop ; 3 73
There's a few differences
- loop starts at cycle 73 instead of 76/0
- Updates for GRP0 and GRP1 have been swapped
- Updates of M0 and BL have been swapped
- A, instead of X, is used for reading datastream DS_PF0L_BL
These changes help us out in a couple ways:
- the ball object no longer gets sheared (not an issue for Frantic, but could be for future games that utilize this kernel)
- there's 2 extra free cycles, which will potentially allow me to reduce the number of scanlines needed to reposition the players (currently player 0 takes 6, player 1 takes 5). Fewer scanlines means the players could be reused more frequently (reducing the occurance of flicker) and the 6507 code would be smaller (saving precious ROM).
6 Comments
Recommended Comments