step 12 - add the missile objects
The 2LK has been revised to display both missile objects. Missile objects do not support Vertical Delay, so there's no need to prime ENAM0 or ENAM1.
ArenaLoop: ; 17 - (currently 17 from bpl ArenaLoop) ; continuation of line 2 of the 2LK ; this precalculates data that's used on line 1 of the 2LK tya ; 2 19 - 2LK loop counter in A for testing and #%11 ; 2 21 - test for every 4th time through the loop, bne SkipX ; 2 23 - (3 24) branch if not 4th time inc ArenaIndex ; 5 28 - if 4th time, increase index so new playfield data is used SkipX: ; 28 - use 28 as it's the longest path to here ldx #1 ; 2 30 - D1=0, so missile1 will be off lda #BOX_HEIGHT-1 ; 2 32 - height of box graphic dcp Missile1Draw ; 5 37 - Decrement Missile1Draw and compare with height bcs DoEnam1 ; 2 39 - (3 40) if Carry is Set, then missile1 is on current scanline .byte $24 ; 3 42 - $24 = BIT with zero page addressing, trick that ; causes the inx to be skipped DoEnam1: ; 40 - from bcs DoEnam1 inx ; 2 42 - D1=1, so ball will be ON lda #HUMAN_HEIGHT-1 ; 2 44 - height of the humanoid graphics, subtract 1 due to starting with 0 dcp Player1Draw ; 5 49 - Decrement Player1Draw and compare with height bcs DoDrawGrp1 ; 2 51 - (3 52) if Carry is Set, then player1 is on current scanline lda #0 ; 2 53 - otherwise use 0 to turn off player1 .byte $2C ; 4 57 - $2C = BIT with absolute addressing, trick that ; causes the lda (Player1Ptr),y to be skipped DoDrawGrp1: ; 52 - from bcs DoDrawGrp1 lda (Player1Ptr),y ; 5 57 - load the shape for player1 sta WSYNC ; 3 60 ;--------------------------------------- ; start of line 1 of the 2LK sta GRP1 ; 3 3 - @0-22, update player1 graphics stx ENAM1 ; 3 6 - @0-22, update missile1 graphics ldx ArenaIndex ; 3 9 lda ArenaPF0,x ; 4 13 - get current scanline's playfield pattern sta PF0 ; 3 16 - @0-22 and update it lda ArenaPF1,x ; 4 20 - get current scanline's playfield pattern sta PF1 ; 3 23 - @71-28 and update it lda ArenaPF2,x ; 4 27 - get current scanline's playfield pattern sta PF2 ; 3 30 - @60-39 ; precalculate data that's needed for line 2 of the 2LK ldx #1 ; 2 32 - D1=0, so missile0 will be off lda #BOX_HEIGHT-1 ; 2 34 - height of box graphic dcp Missile0Draw ; 5 39 - Decrement Missile0Draw and compare with height bcs DoEnam0 ; 2 41 - (3 42) if Carry is Set, then missile0 is on current scanline .byte $24 ; 3 44 - $24 = BIT with zero page addressing, trick that ; causes the inx to be skipped DoEnam0: ; 42 - from bcs DoEnam0 inx ; 2 44 - D1=1, so ball will be ON stx Temp ; 3 47 - save for line 2 ldx #1 ; 2 49 - D1=0, so ball will be off lda #BOX_HEIGHT-1 ; 2 51 - height of box graphic dcp BallDraw ; 5 56 - Decrement BallDraw and compare with height bcs DoEnabl ; 2 58 - (3 59) if Carry is Set, then ball is on current scanline .byte $24 ; 3 61 - $24 = BIT with zero page addressing, trick that ; causes the inx to be skipped DoEnabl: ; 59 - from bcs DoEnablPre inx ; 2 61 - D1=1, so ball will be ON lda #HUMAN_HEIGHT-1 ; 2 63 - height of the box graphics, dcp Player0Draw ; 5 68 - Decrement Player0Draw and compare with height bcs DoDrawGrp0 ; 2 70 - (3 71) if Carry is Set then player0 is on current scanline lda #0 ; 2 72 - otherwise use 0 to turn off player0 .byte $2C ; 4 76 - $2C = BIT with absolute addressing, trick that ; causes the lda (Player0Ptr),y to be skipped ; start of line 2 of the 2LK DoDrawGrp0: ; 71 - from bcs DoDrawGRP0 lda (Player0Ptr),y ; 5 76 - load the shape for player0 ;--------------------------------------- ; start of line 2 of the 2LK sta GRP0 ; 3 3 - @0-22, update player0 graphics stx ENABL ; 3 6 - @0-22, update ball graphics lda Temp ; 3 9 - get the precalced data for missile0 sta ENAM0 ; 3 12 - @0-22, update missile0 graphics dey ; 2 14 - decrease the 2LK loop counter bne ArenaLoop ; 2 16 - (3 17) branch if there's more Arena to draw sty PF0 ; 3 19 - @0-22, Y is 0, blank out playfield sty PF1 ; 3 22 - @71-28, Y is 0, blank out playfield sty PF2 ; 3 25 - @60-39, Y is 0, blank out playfield rts ; 6 31 - ReTurn from Subroutine
The 2 lines of the 2LK now work like this:
- updates player1, missile1, playfield, precalcs player0, missile0, ball for line 2
- updates player0, missile0, ball, precalcs player1, missile1 and playfield index for line 1
We didn't have enough time to update missile0 and missile1 on both lines of the 2LK. Since TIA doesn't offer a vertical delay feature for the missiles, they can never line up. This is just like the players didn't line up when VDELP0 and VDELP1 were not used. For our game, this isn't a problem.
One thing to notice about the revised 2LK is the 1st line uses exactly 76 cycles, so it no longer ends with a sta WSYNC.
PositionObjects has been modified to initialize 2 new variables, Missile0Draw and Missile1Draw, that are used by the 2LK to control when the missiles are drawn.
PositionObjects: ... ; prep missile0's Y position for 2LK lda ObjectY+2 ; get the missile's Y position lsr ; divide by 2 for 2LK sta Temp ; save for position calculation ; Missile0Draw = ARENA_HEIGHT + BOX_HEIGHT - Y position lda #(ARENA_HEIGHT + BOX_HEIGHT) sec sbc Temp sta Missile0Draw ; prep missile1's Y position for 2LK lda ObjectY+3 ; get the missile's Y position lsr ; divide by 2 for 2LK sta Temp ; save for position calculation ; Missile0Draw = ARENA_HEIGHT + BOX_HEIGHT - Y position lda #(ARENA_HEIGHT + BOX_HEIGHT) sec sbc Temp sta Missile1Draw
The routines are a little simpler than the others (for player0, player1 and ball) as the missiles don't have a Vertical Delay to set up. This is how the Arena looks with all the boxes drawn:
Not exactly right, is it? One thing we forgot to do was set the width of the missiles! We'd done that for the ball back in step 9 when we set the upper nybble of CTRLPF to 3:
TimerBar: ... lda Variation ; 3 20 lsr ; 2 22 - which Arena to show tay ; 2 24 - set for index ldx ArenaOffset,y ; 4 28 - set X for which arena to draw lda ArenaPF0,x ; 4 32 - reflect and priority for playfield and #%00000111 ; 2 34 - get the lower 3 bits for CTRLPF ora #%00110000 ; 2 36 - set ball to display as 8x pixel sta CTRLPF ; 3 39
Which is why the ball was the right width when we added it in step 11. The same setting is needed for the missiles, but it goes into NUSIZ0 and NUSIZ1 instead:
VerticalSync: ... lda #$30 ; sta NUSIZ0 ; set missile0 to be 8x sta NUSIZ1 ; set missile1 to be 8x ...
And now it looks correct:
OverScan was updated to detect collisions with the boxes drawn by the missiles:
OverScan: ... notP0BL: bit CXM0P ; V=player0/missile0 bvc notP0M0 ; if V is off then player0 did not collide with missile0 ldx #2 ; which box was collected jsr CollectBox ; update score and reposition box notP0M0: bit CXM1P ; N=player0/missile1 bpl notP0M1 ; if N is off then player0 did not collide with missile1 ldx #3 ; which box was collected jsr CollectBox ; update score and reposition box notP0M1: ... notP1BL: bit CXM0P ; N=player1/missile0 bpl notP1M0 ; if N is off then player1 did not collide with missile0 ldx #2 ; which box was collected jsr CollectBox ; update score and reposition box notP1M0: bit CXM1P ; V=player1/missile1 bvc notP1M1 ; if V is off then player1 did not collide with missile1 ldx #3 ; which box was collected jsr CollectBox ; update score and reposition box notP1M1:
A test run of the players collecting the boxes:
Lastly, on the off chance that somebody might roll the score, a new Digit graphic has been added:
And a minor change was made to CollectBox to display it and end the game if a player collected 100 boxes.
CollectBox: sed ; SEt Decimal flag clc ; CLear Carry bit lda #1 ; 1 point per box adc Score,y ; add to player's current score bcc Not100 ; if the Carry is clear, score did not roll sta GameState ; stop the game (A holds 0) lda #$BB ; B image is !! to show that score rolled Not100: sta Score,y ; and save it cld ; CLear Decimal flag jsr RandomLocation ; move box to new location rts
To test it I started up a game and used Stella's debugger to change the score to 99:
Then collected another box:
ROM
Source
0 Comments
Recommended Comments
There are no comments to display.