castleraider

changeset 336:b82acbb8d06c

Moved more routines into the working area. Did more work on the ending sequence. Removed redundant CLC instructions to save space.
author David Boddie <david@boddie.org.uk>
date Sun Oct 12 00:12:18 2014 +0200
parents a58a3d4023de
children 1375b65e3313
files build.py code.oph ending.oph loader.oph monsters.oph plotting.oph routines/disable_sound.oph routines/wait_for_space_or_fire.oph sound.oph
diffstat 9 files changed, 94 insertions(+), 81 deletions(-) [+]
line diff
     1.1 --- a/build.py	Sat Oct 11 01:36:11 2014 +0200
     1.2 +++ b/build.py	Sun Oct 12 00:12:18 2014 +0200
     1.3 @@ -106,7 +106,9 @@
     1.4      "clear_bank1",
     1.5      "clear_bank2",
     1.6      "read_joystick_axis",
     1.7 -    "read_joystick_fire"
     1.8 +    "read_joystick_fire",
     1.9 +    "disable_sound",
    1.10 +    "wait_for_space_or_fire"
    1.11      ]
    1.12  
    1.13  def encode_in_game_data_and_routines(in_game_data_address):
    1.14 @@ -146,7 +148,7 @@
    1.15                                       in_game_title_text_length
    1.16      
    1.17      game_over_text = [(26, 31, 1, 16, 17, 3, "Your quest is over"),
    1.18 -                          (31, 4, 29, 17, 1, "Press  SPACE")]
    1.19 +                          (31, 2, 29, 17, 1, "Press SPACE/FIRE")]
    1.20      
    1.21      game_over_data = encode_text(game_over_text)
    1.22      data += game_over_data
    1.23 @@ -315,7 +317,7 @@
    1.24      initial_row_offsets           = row_indices + 0x10
    1.25      
    1.26      # Store the in-game text data and other routines above the working data.
    1.27 -    # This is done in the loader.
    1.28 +    # The generated file is loaded in the game loader.
    1.29      title_data_address = initial_row_offsets + 0x10
    1.30      
    1.31      in_game_data_labels, in_game_data_details, title_data_routines = \
     2.1 --- a/code.oph	Sat Oct 11 01:36:11 2014 +0200
     2.2 +++ b/code.oph	Sun Oct 12 00:12:18 2014 +0200
     2.3 @@ -31,20 +31,7 @@
     2.4                              ; calls will appear.
     2.5  
     2.6      jsr print_title_text
     2.7 -
     2.8 -    ; Wait for the SPACE key or fire button to be pressed.
     2.9 -    main_start_wait_loop:
    2.10 -
    2.11 -        jsr read_joystick_fire
    2.12 -
    2.13 -        lda #1
    2.14 -        bcs main_init
    2.15 -
    2.16 -        main_start_wait_loop_key_check:
    2.17 -
    2.18 -        ldx #157            ; (SPACE)
    2.19 -        jsr check_key
    2.20 -        bne main_start_wait_loop
    2.21 +    jsr wait_for_space_or_fire
    2.22  
    2.23      lda #0
    2.24  
    2.25 @@ -249,8 +236,7 @@
    2.26  
    2.27      jsr print_game_over_text
    2.28  
    2.29 -    lda #157        ; (SPACE)
    2.30 -    jsr wait_for_key
    2.31 +    jsr wait_for_space_or_fire
    2.32  
    2.33      jmp main
    2.34  
    2.35 @@ -453,7 +439,6 @@
    2.36      lda $77
    2.37      adc #0
    2.38      sta $77
    2.39 -    clc
    2.40  
    2.41      rts
    2.42  
     3.1 --- a/ending.oph	Sat Oct 11 01:36:11 2014 +0200
     3.2 +++ b/ending.oph	Sun Oct 12 00:12:18 2014 +0200
     3.3 @@ -31,34 +31,42 @@
     3.4          bne game_completed_text_loop
     3.5  
     3.6      ldx #0
     3.7 +    stx $75
     3.8      game_completed_copy_loop:
     3.9  
    3.10 +        lda #4                          ; Draw from column 4 to column 35.
    3.11 +        sta $74
    3.12 +        jsr read_screen_address_bank1   ; $72,$73=address
    3.13 +
    3.14 +        lda $73
    3.15 +        sec
    3.16 +        sbc #$0a    ; Subtract 8 rows ($a00) from the address.
    3.17 +        sta $73
    3.18 +        clc
    3.19 +
    3.20 +        lda $72     ; Use $70,$71 for the source address.
    3.21 +        sta $70
    3.22 +        lda $73
    3.23 +        adc #$28    ; Find the corresponding bank 2 address.
    3.24 +        sta $71     ; This addition will not cause the carry flag to be set.
    3.25 +
    3.26          ; Traverse each column in the row
    3.27  
    3.28          ldy #0
    3.29          game_completed_column_loop:
    3.30  
    3.31 -            lda #4                          ; Draw from column 4 to column 35,
    3.32 +            lda #4                          ; Draw from column 4 to column 35.
    3.33              sta $74
    3.34 -            jsr read_screen_address_bank1   ; $72,$73=address
    3.35 -
    3.36 -            lda $73
    3.37 -            sec
    3.38 -            sbc #$0a    ; Subtract 8 rows ($a00) from the address.
    3.39 -            sta $73
    3.40 -            clc
    3.41 -
    3.42 -            lda $72     ; Use $70,$71 for the source address.
    3.43 -            sta $70
    3.44 -            lda $73
    3.45 -            adc #$28    ; Find the corresponding bank 2 address.
    3.46 -            sta $71     ; This addition will not cause the carry flag to be set.
    3.47  
    3.48              game_completed_copy_inner_loop:
    3.49  
    3.50                  lda ($70),y
    3.51                  sta ($72),y
    3.52  
    3.53 +                ;sty $75
    3.54 +                ;jsr gc_plot_roll
    3.55 +                ;ldy $75
    3.56 +
    3.57                  jsr next_cell   ; Reuse a plotting routine to increase $72,$73
    3.58                                  ; by 8 and $74 by 1.
    3.59  
    3.60 @@ -68,19 +76,25 @@
    3.61                  lda $71
    3.62                  adc #0
    3.63                  sta $71
    3.64 -                clc
    3.65  
    3.66                  lda $74
    3.67                  cmp #36
    3.68                  bne game_completed_copy_inner_loop
    3.69  
    3.70 -            iny
    3.71 -            cpy #8
    3.72 -            bne game_completed_column_loop
    3.73 +            ;iny
    3.74 +            ;cpy #8
    3.75 +            ;bne game_completed_column_loop
    3.76  
    3.77 +        clc
    3.78 +        inc $75                     ; Increment the vertical counter.
    3.79 +        lda $75                     ; If at the bottom of the display area
    3.80 +        cmp #96                     ; then break out of the loop.
    3.81 +        beq game_completed_wait
    3.82 +
    3.83 +        and #$07                        ; Update the row counter (X) every
    3.84 +        bne game_completed_copy_loop    ; eight pixels.
    3.85          inx
    3.86 -        cpx #12
    3.87 -        bne game_completed_copy_loop
    3.88 +        jmp game_completed_copy_loop
    3.89  
    3.90      game_completed_wait:
    3.91  
     4.1 --- a/loader.oph	Sat Oct 11 01:36:11 2014 +0200
     4.2 +++ b/loader.oph	Sun Oct 12 00:12:18 2014 +0200
     4.3 @@ -320,7 +320,6 @@
     4.4          lda $71
     4.5          adc #0
     4.6          sta $71
     4.7 -        clc
     4.8  
     4.9          jmp plot8x24_y0_loop
    4.10  
    4.11 @@ -350,7 +349,6 @@
    4.12      lda #>player_left1
    4.13      adc #0
    4.14      sta $71
    4.15 -    clc
    4.16  
    4.17      lda #$a0
    4.18      sta $72
    4.19 @@ -367,7 +365,6 @@
    4.20      lda $71
    4.21      adc #0
    4.22      sta $71
    4.23 -    clc
    4.24  
    4.25      lda $72
    4.26      adc #$70                        ; plot 7 characters to the right
     5.1 --- a/monsters.oph	Sat Oct 11 01:36:11 2014 +0200
     5.2 +++ b/monsters.oph	Sun Oct 12 00:12:18 2014 +0200
     5.3 @@ -120,7 +120,6 @@
     5.4      lda #>monster_row_address
     5.5      adc #0
     5.6      sta $77
     5.7 -    clc
     5.8  
     5.9      rts
    5.10  
    5.11 @@ -254,7 +253,6 @@
    5.12      lda #0
    5.13      adc #0
    5.14      sta $73
    5.15 -    clc
    5.16  
    5.17      iny
    5.18      lda ($86),y                 ; y offset
     6.1 --- a/plotting.oph	Sat Oct 11 01:36:11 2014 +0200
     6.2 +++ b/plotting.oph	Sun Oct 12 00:12:18 2014 +0200
     6.3 @@ -44,7 +44,6 @@
     6.4      lda #0
     6.5      adc #0
     6.6      sta $73
     6.7 -    clc
     6.8      rts
     6.9  
    6.10  read_screen_address_bank2:  ; X=row, A=column offset
    6.11 @@ -81,7 +80,6 @@
    6.12      adc #0
    6.13      sta $71                     ; S1 ($70,$71)
    6.14  
    6.15 -    clc
    6.16      rts
    6.17  
    6.18  read_and_mask_visible_sprite:
    6.19 @@ -110,7 +108,6 @@
    6.20      lda #left_sprites_high
    6.21      adc #0
    6.22      sta $71                     ; S2 ($70,$71)
    6.23 -    clc
    6.24  
    6.25      rts
    6.26  
    6.27 @@ -132,7 +129,6 @@
    6.28      lda #rotated_sprites_high
    6.29      adc #0
    6.30      sta $71                 ; S1 ($70,$71)
    6.31 -    clc
    6.32  
    6.33      rts
    6.34  
    6.35 @@ -154,7 +150,6 @@
    6.36      lda #right_sprites_high
    6.37      adc #0
    6.38      sta $81                     ; S2 ($80,$81)
    6.39 -    clc
    6.40  
    6.41      rts
    6.42  
    6.43 @@ -230,7 +225,6 @@
    6.44              lda #0
    6.45              adc #0
    6.46              sta $8d
    6.47 -            clc
    6.48  
    6.49              lda $72
    6.50              adc $8c
    6.51 @@ -248,7 +242,6 @@
    6.52              lda $77
    6.53              adc #0
    6.54              sta $77
    6.55 -            clc
    6.56  
    6.57              bcc plot_bank1r_offset_loop
    6.58  
    6.59 @@ -352,7 +345,6 @@
    6.60              lda #0
    6.61              adc #0
    6.62              sta $8d
    6.63 -            clc
    6.64  
    6.65              lda $72
    6.66              adc $8c
    6.67 @@ -374,7 +366,6 @@
    6.68              lda $77
    6.69              adc #0
    6.70              sta $77
    6.71 -            clc
    6.72  
    6.73              bcc plot_bank1l_offset_loop
    6.74  
    6.75 @@ -460,7 +451,6 @@
    6.76          lda $73
    6.77          adc #0
    6.78          sta $73
    6.79 -        clc
    6.80  
    6.81          plot_bank2r_row_loop_skip_leading:
    6.82          clc
    6.83 @@ -499,7 +489,6 @@
    6.84              lda #0
    6.85              adc #0
    6.86              sta $8d
    6.87 -            clc
    6.88  
    6.89              lda $72
    6.90              adc $8c
    6.91 @@ -518,7 +507,6 @@
    6.92              lda $77
    6.93              adc #0
    6.94              sta $77
    6.95 -            clc
    6.96  
    6.97              lda $78                         ; Read the current type and the
    6.98              jsr read_right_sprite_address   ; corresponding right edge sprite.
    6.99 @@ -536,7 +524,6 @@
   6.100              lda $73
   6.101              adc #0
   6.102              sta $73
   6.103 -            clc
   6.104  
   6.105              inc $74
   6.106  
   6.107 @@ -621,7 +608,6 @@
   6.108                  lda $73
   6.109                  adc #0
   6.110                  sta $73
   6.111 -                clc
   6.112  
   6.113                  bcc plot_bank2l_offset_loop ; Jump to the loop so that the span
   6.114                                              ; can be plotted.
   6.115 @@ -716,7 +702,6 @@
   6.116              lda #0
   6.117              adc #0
   6.118              sta $8d
   6.119 -            clc
   6.120  
   6.121              lda $72
   6.122              adc $8c
   6.123 @@ -747,7 +732,6 @@
   6.124              lda $73
   6.125              adc #0
   6.126              sta $73
   6.127 -            clc
   6.128  
   6.129              lda $76                 ; Add 2 to I.
   6.130              adc #2
   6.131 @@ -755,7 +739,6 @@
   6.132              lda $77
   6.133              adc #0
   6.134              sta $77
   6.135 -            clc
   6.136  
   6.137              jmp plot_bank2l_offset_loop
   6.138  
   6.139 @@ -856,7 +839,6 @@
   6.140              lda $77
   6.141              adc #0
   6.142              sta $77
   6.143 -            clc
   6.144  
   6.145              bcc initial_plot_bank1_span_loop
   6.146  
   6.147 @@ -921,7 +903,6 @@
   6.148              lda $73
   6.149              adc #0
   6.150              sta $73
   6.151 -            clc
   6.152  
   6.153              inc $74         ; one tile filled on the screen
   6.154  
   6.155 @@ -949,7 +930,6 @@
   6.156              lda $77
   6.157              adc #0
   6.158              sta $77
   6.159 -            clc
   6.160  
   6.161              bcc initial_plot_bank2_span_loop
   6.162  
   6.163 @@ -1016,7 +996,6 @@
   6.164      lda $73
   6.165      adc #0
   6.166      sta $73
   6.167 -    clc
   6.168  
   6.169      inc $74         ; one tile filled on the screen
   6.170      rts
   6.171 @@ -1044,7 +1023,6 @@
   6.172      lda bank1_char_rows_high,x
   6.173      adc #0
   6.174      sta $73
   6.175 -    clc
   6.176  
   6.177      jmp plot_char_bank
   6.178  
   6.179 @@ -1060,7 +1038,6 @@
   6.180      lda bank2_char_rows_high,x
   6.181      adc #0
   6.182      sta $73
   6.183 -    clc
   6.184  
   6.185      ; fall through
   6.186  
   6.187 @@ -1153,7 +1130,6 @@
   6.188      lda $73
   6.189      adc #0
   6.190      sta $73
   6.191 -    clc
   6.192  
   6.193      ldy $8c                     ; Start reading from the first offset.
   6.194      lda #1
   6.195 @@ -1237,7 +1213,6 @@
   6.196          lda $71
   6.197          adc #0
   6.198          sta $71
   6.199 -        clc
   6.200  
   6.201          bcc plot8x24_y0_loop
   6.202  
   6.203 @@ -1322,7 +1297,6 @@
   6.204          lda $71
   6.205          adc #0
   6.206          sta $71
   6.207 -        clc
   6.208  
   6.209          lda $72         ; update the destination pointer to point to the next
   6.210          adc #8          ; space
   6.211 @@ -1330,7 +1304,6 @@
   6.212          lda $73
   6.213          adc #0
   6.214          sta $73
   6.215 -        clc
   6.216  
   6.217          bcc plot8x24_y1_loop
   6.218  
   6.219 @@ -1371,7 +1344,6 @@
   6.220      lda #top_panel_objects_bank1_high
   6.221      adc #0
   6.222      sta $73
   6.223 -    clc
   6.224  
   6.225      jmp plot_tile_bank
   6.226  
   6.227 @@ -1382,7 +1354,6 @@
   6.228      lda #top_panel_objects_bank2_high
   6.229      adc #0
   6.230      sta $73
   6.231 -    clc
   6.232  
   6.233      jmp plot_tile_bank
   6.234  
   6.235 @@ -1426,7 +1397,6 @@
   6.236      lda #$00
   6.237      adc #0
   6.238      sta $8d
   6.239 -    clc
   6.240  
   6.241      plot_life_after_row_check:
   6.242  
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/routines/disable_sound.oph	Sun Oct 12 00:12:18 2014 +0200
     7.3 @@ -0,0 +1,20 @@
     7.4 +; Copyright (C) 2014 David Boddie <david@boddie.org.uk>
     7.5 +;
     7.6 +; This program is free software: you can redistribute it and/or modify
     7.7 +; it under the terms of the GNU General Public License as published by
     7.8 +; the Free Software Foundation, either version 3 of the License, or
     7.9 +; (at your option) any later version.
    7.10 +;
    7.11 +; This program is distributed in the hope that it will be useful,
    7.12 +; but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.13 +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.14 +; GNU General Public License for more details.
    7.15 +;
    7.16 +; You should have received a copy of the GNU General Public License
    7.17 +; along with this program.  If not, see <http://www.gnu.org/licenses/>.
    7.18 +
    7.19 +; disable_sound:  ; X=1 (disable); X=0 (enable)
    7.20 +
    7.21 +    lda #210
    7.22 +    ldy #0
    7.23 +    jmp $fff4   ; optimise away the rts
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/routines/wait_for_space_or_fire.oph	Sun Oct 12 00:12:18 2014 +0200
     8.3 @@ -0,0 +1,33 @@
     8.4 +; Copyright (C) 2014 David Boddie <david@boddie.org.uk>
     8.5 +;
     8.6 +; This program is free software: you can redistribute it and/or modify
     8.7 +; it under the terms of the GNU General Public License as published by
     8.8 +; the Free Software Foundation, either version 3 of the License, or
     8.9 +; (at your option) any later version.
    8.10 +;
    8.11 +; This program is distributed in the hope that it will be useful,
    8.12 +; but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.13 +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.14 +; GNU General Public License for more details.
    8.15 +;
    8.16 +; You should have received a copy of the GNU General Public License
    8.17 +; along with this program.  If not, see <http://www.gnu.org/licenses/>.
    8.18 +
    8.19 +; wait_for_space_or_fire:
    8.20 +
    8.21 +    ; Wait for the SPACE key or fire button to be pressed.
    8.22 +    wait_for_space_or_fire_loop:
    8.23 +
    8.24 +        jsr read_joystick_fire
    8.25 +
    8.26 +        lda #1
    8.27 +        bcs wait_for_space_or_fire_exit
    8.28 +
    8.29 +        ldx #157            ; (SPACE)
    8.30 +        jsr check_key
    8.31 +        bne wait_for_space_or_fire_loop
    8.32 +
    8.33 +    wait_for_space_or_fire_exit:
    8.34 +
    8.35 +    clc
    8.36 +    rts
     9.1 --- a/sound.oph	Sat Oct 11 01:36:11 2014 +0200
     9.2 +++ b/sound.oph	Sun Oct 12 00:12:18 2014 +0200
     9.3 @@ -37,9 +37,3 @@
     9.4      jsr $fff1
     9.5  
     9.6      rts
     9.7 -
     9.8 -disable_sound:  ; X=1 (disable); X=0 (enable)
     9.9 -
    9.10 -    lda #210
    9.11 -    ldy #0
    9.12 -    jmp $fff4   ; optimise away the rts