castleraider

changeset 337:1375b65e3313

More preparatory work for the ending sequence in an attempt to set up a framework for the desired effect.
author David Boddie <david@boddie.org.uk>
date Sun Oct 12 01:35:13 2014 +0200
parents b82acbb8d06c
children c1d0dbfbfa31
files ending.oph
diffstat 1 files changed, 75 insertions(+), 48 deletions(-) [+]
line diff
     1.1 --- a/ending.oph	Sun Oct 12 00:12:18 2014 +0200
     1.2 +++ b/ending.oph	Sun Oct 12 01:35:13 2014 +0200
     1.3 @@ -38,63 +38,33 @@
     1.4          sta $74
     1.5          jsr read_screen_address_bank1   ; $72,$73=address
     1.6  
     1.7 +        lda $72
     1.8 +        sta $78
     1.9          lda $73
    1.10          sec
    1.11          sbc #$0a    ; Subtract 8 rows ($a00) from the address.
    1.12 -        sta $73
    1.13 +        sta $79
    1.14          clc
    1.15  
    1.16 -        lda $72     ; Use $70,$71 for the source address.
    1.17 -        sta $70
    1.18 -        lda $73
    1.19 +        lda $78     ; Use $76,$77 for the source address.
    1.20 +        sta $76
    1.21 +        lda $79
    1.22          adc #$28    ; Find the corresponding bank 2 address.
    1.23 -        sta $71     ; This addition will not cause the carry flag to be set.
    1.24 +        sta $77     ; This addition will not cause the carry flag to be set.
    1.25  
    1.26 -        ; Traverse each column in the row
    1.27 +        stx $7a
    1.28 +        jsr plot_roll
    1.29 +        ldx $7a
    1.30  
    1.31 -        ldy #0
    1.32 -        game_completed_column_loop:
    1.33 -
    1.34 -            lda #4                          ; Draw from column 4 to column 35.
    1.35 -            sta $74
    1.36 -
    1.37 -            game_completed_copy_inner_loop:
    1.38 -
    1.39 -                lda ($70),y
    1.40 -                sta ($72),y
    1.41 -
    1.42 -                ;sty $75
    1.43 -                ;jsr gc_plot_roll
    1.44 -                ;ldy $75
    1.45 -
    1.46 -                jsr next_cell   ; Reuse a plotting routine to increase $72,$73
    1.47 -                                ; by 8 and $74 by 1.
    1.48 -
    1.49 -                lda $70
    1.50 -                adc #8
    1.51 -                sta $70
    1.52 -                lda $71
    1.53 -                adc #0
    1.54 -                sta $71
    1.55 -
    1.56 -                lda $74
    1.57 -                cmp #36
    1.58 -                bne game_completed_copy_inner_loop
    1.59 -
    1.60 -            ;iny
    1.61 -            ;cpy #8
    1.62 -            ;bne game_completed_column_loop
    1.63 -
    1.64 -        clc
    1.65          inc $75                     ; Increment the vertical counter.
    1.66 -        lda $75                     ; If at the bottom of the display area
    1.67 -        cmp #96                     ; then break out of the loop.
    1.68 -        beq game_completed_wait
    1.69 -
    1.70 -        and #$07                        ; Update the row counter (X) every
    1.71 -        bne game_completed_copy_loop    ; eight pixels.
    1.72 -        inx
    1.73 -        jmp game_completed_copy_loop
    1.74 +        lda $75
    1.75 +        and #$07
    1.76 +        sta $75
    1.77 +        bne game_completed_copy_loop
    1.78 +                                        ; Update the row counter (X) every
    1.79 +        inx                             ; eight pixels.
    1.80 +        cpx #12                         ; If not at the bottom of the area then
    1.81 +        bne game_completed_copy_loop    ; loop again.
    1.82  
    1.83      game_completed_wait:
    1.84  
    1.85 @@ -103,6 +73,63 @@
    1.86      clc
    1.87      rts
    1.88  
    1.89 +plot_roll:      ; $76,$77=start address of a row in the area to be copied
    1.90 +                ; $78,$79=start address of a row in the display area
    1.91 +                ; $75=offset within the row (0 - 7) to start from
    1.92 +
    1.93 +    lda $78     ; Set the initial destination address within the row.
    1.94 +    adc $75
    1.95 +    sta $78
    1.96 +
    1.97 +    lda $75
    1.98 +    tax         ; Use the row offset as an index.
    1.99 +    adc #8
   1.100 +    sta $7b     ; Define an end value for the index.
   1.101 +
   1.102 +    ldy #0
   1.103 +
   1.104 +    game_completed_column_loop: 
   1.105 +
   1.106 +        ldx #4
   1.107 +        plot_roll_restore_addresses_loop:
   1.108 +            dex
   1.109 +            lda $76,x
   1.110 +            sta $70,x
   1.111 +            cpx #0
   1.112 +            bne plot_roll_restore_addresses_loop
   1.113 +
   1.114 +        clc
   1.115 +
   1.116 +        lda #4                  ; Draw from column 4 to column 35.
   1.117 +        sta $74
   1.118 +
   1.119 +        plot_roll_pixel_row_loop: ; Traverse each column in the pixel row.
   1.120 +
   1.121 +            lda ($70),y
   1.122 +            sta ($72),y
   1.123 +
   1.124 +            jsr next_cell   ; Reuse a plotting routine to increase $72,$73
   1.125 +                            ; by 8 and $74 by 1.
   1.126 +
   1.127 +            lda $70
   1.128 +            adc #8
   1.129 +            sta $70
   1.130 +            lda $71
   1.131 +            adc #0
   1.132 +            sta $71
   1.133 +
   1.134 +            lda $74
   1.135 +            cmp #36
   1.136 +            bne plot_roll_pixel_row_loop
   1.137 +
   1.138 +        inc $75
   1.139 +        lda $75
   1.140 +        cmp $7b
   1.141 +        bne game_completed_column_loop
   1.142 +
   1.143 +    clc
   1.144 +    rts
   1.145 +
   1.146  completed_text: .byte 17,131, 28,2,16,17,5,  12, 26
   1.147                  .byte 17,130, 28,3,15,16,6, 12, 26
   1.148                  .byte 17,129, 28,4,14,15,7, 12, 26