castleraider

changeset 341:245eb88d1ec8 tip

Finished the proof of concept ending sequence. Moved a routine into the working area to save space. Removed redundant CLC instructions. Added a working area size check to the build script.
author David Boddie <david@boddie.org.uk>
date Mon Oct 13 01:13:04 2014 +0200
parents cfd396bc7d4f
children
files build.py ending.oph plotting.oph routines/clear_bank.oph routines/next_cell.oph scrolling.oph
diffstat 6 files changed, 64 insertions(+), 44 deletions(-) [+]
line diff
     1.1 --- a/build.py	Sun Oct 12 23:46:28 2014 +0200
     1.2 +++ b/build.py	Mon Oct 13 01:13:04 2014 +0200
     1.3 @@ -108,7 +108,8 @@
     1.4      "read_joystick_axis",
     1.5      "read_joystick_fire",
     1.6      "disable_sound",
     1.7 -    "wait_for_space_or_fire"
     1.8 +    "wait_for_space_or_fire",
     1.9 +    "next_cell"
    1.10      ]
    1.11  
    1.12  def encode_in_game_data_and_routines(in_game_data_address):
    1.13 @@ -763,7 +764,14 @@
    1.14      # Calculate the amount of working space used.
    1.15      # 0xcfb is the start of a block of memory used for palette operations.
    1.16      
    1.17 -    print "Working data area runs from 0b00 to %04x (%i bytes free)" % (working_end, 0xcfb - working_end)
    1.18 +    working_free = 0xcfb - working_end
    1.19 +    print "Working data area runs from 0b00 to %04x" % working_end,
    1.20 +    if working_free < 0:
    1.21 +        print
    1.22 +        sys.stderr.write("Working data area overruns following data by %i bytes.\n" % -working_free)
    1.23 +        sys.exit(1)
    1.24 +    else:
    1.25 +        print "(%i bytes free)" % working_free
    1.26      print
    1.27      
    1.28      # Calculate the amount of memory used for each file.
    1.29 @@ -775,7 +783,7 @@
    1.30          sys.stderr.write("CODE overruns following data by %i bytes.\n" % (code_finish - data_start))
    1.31          sys.exit(1)
    1.32      else:
    1.33 -        print " (%i bytes free)" % (data_start - code_finish)
    1.34 +        print "(%i bytes free)" % (data_start - code_finish)
    1.35      
    1.36      levels_finish = levels_address + len(level_data)
    1.37      print "LEVELS  runs from %04x to %04x" % (levels_address, levels_finish),
    1.38 @@ -784,7 +792,7 @@
    1.39          sys.stderr.write("LEVELS overruns following data by %i bytes.\n" % (levels_finish - sprite_area_address))
    1.40          sys.exit(1)
    1.41      else:
    1.42 -        print " (%i bytes free)" % (sprite_area_address - levels_finish)
    1.43 +        print "(%i bytes free)" % (sprite_area_address - levels_finish)
    1.44      
    1.45      char_area_finish = sprite_area_address + len(sprite_data) + len(char_data)
    1.46      print "SPRITES runs from %04x to %04x" % (sprite_area_address, char_area_finish)
     2.1 --- a/ending.oph	Sun Oct 12 23:46:28 2014 +0200
     2.2 +++ b/ending.oph	Mon Oct 13 01:13:04 2014 +0200
     2.3 @@ -52,6 +52,7 @@
     2.4          sta $77     ; This addition will not cause the carry flag to be set.
     2.5  
     2.6          stx $7a
     2.7 +        jsr vsync
     2.8          jsr plot_roll
     2.9          ldx $7a
    2.10  
    2.11 @@ -81,24 +82,34 @@
    2.12      sta $7b     ; Define an end value for the index.
    2.13  
    2.14      ldy #0
    2.15 -    ldx $75     ; Use the row offset as an index.
    2.16 +    sty $7c     ; Maintain an index into a source translation table.
    2.17 +    ldx $75     ; Use the row offset as an index into source and destination
    2.18 +                ; address look-up tables.
    2.19  
    2.20      plot_roll_loop:
    2.21  
    2.22 -        lda $78
    2.23 -        adc roll_row_offsets_low,x
    2.24 +        lda $78                     ; Find the address of the start of the
    2.25 +        adc roll_row_offsets_low,x  ; pixel row to plot.
    2.26          sta $72
    2.27          lda $79
    2.28          adc roll_row_offsets_high,x
    2.29          sta $73
    2.30  
    2.31 -        lda $76
    2.32 -        adc roll_row_offsets_low,x
    2.33 +        stx $7d                 ; Save the current pixel row.
    2.34 +        ldx $7c                 ; Load the pixel row offset in the roll.
    2.35 +        lda roll_row_source_offsets,x   ; Load the pixel row displacement.
    2.36 +        adc $7d                         ; Add it to the current pixel row.
    2.37 +        tax                     ; Use it to reference a source pixel row.
    2.38 +
    2.39 +        lda $76                     ; Find the address of the start of the
    2.40 +        adc roll_row_offsets_low,x  ; source pixel row.
    2.41          sta $70
    2.42          lda $77
    2.43          adc roll_row_offsets_high,x
    2.44          sta $71
    2.45  
    2.46 +        ldx $7d                 ; Restore the current pixel row.
    2.47 +
    2.48          lda #4                  ; Draw from column 4 to column 35.
    2.49          sta $74
    2.50  
    2.51 @@ -121,6 +132,7 @@
    2.52              cmp #36
    2.53              bne plot_roll_pixel_row_loop
    2.54  
    2.55 +        inc $7c
    2.56          inx
    2.57          cpx $7b
    2.58          bne plot_roll_loop
    2.59 @@ -131,12 +143,14 @@
    2.60      rts
    2.61  
    2.62  completed_text: .byte 17,131, 28,2,16,17,5, 12
    2.63 -                .byte 17,1, 10, " Well done!"
    2.64 +                .byte 17,1
    2.65 +                .byte 10,    "  Well done!"
    2.66 +                .byte 13,10,10, " You escaped!"
    2.67  completed_text_end:
    2.68  
    2.69  .alias completed_text_length [completed_text_end - completed_text]
    2.70  
    2.71 -roll_row_offsets_low:   .byte 0,1,2,3,4,5,6,7,$40,$41,$42,$43,$44,$45,$46
    2.72 -roll_row_offsets_high:  .byte 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1
    2.73 +roll_row_offsets_low:   .byte 0,1,2,3,4,5,6,7,$40,$41,$42,$43,$44,$45,$46,$47,$80,$81,$82
    2.74 +roll_row_offsets_high:  .byte 0,0,0,0,0,0,0,0,$01,$01,$01,$01,$01,$01,$01,$01,$02,$02,$02
    2.75  
    2.76 -roll_row_source_offsets: .byte 0,7,6,5,4,3,2,1
    2.77 +roll_row_source_offsets: .byte 0,11,10,8,6,4,2,1
     3.1 --- a/plotting.oph	Sun Oct 12 23:46:28 2014 +0200
     3.2 +++ b/plotting.oph	Mon Oct 13 01:13:04 2014 +0200
     3.3 @@ -31,7 +31,6 @@
     3.4      lda $73
     3.5      adc bank1_rows_high,x
     3.6      sta $73                 ; x ($72,$73)
     3.7 -    clc
     3.8  
     3.9      rts
    3.10  
    3.11 @@ -57,7 +56,6 @@
    3.12      lda $73
    3.13      adc bank2_rows_high,x
    3.14      sta $73                 ; x ($72,$73)
    3.15 -    clc
    3.16  
    3.17      rts
    3.18  
    3.19 @@ -232,7 +230,6 @@
    3.20              lda $73
    3.21              adc $8d
    3.22              sta $73             ; x ($72,$73)
    3.23 -            clc
    3.24  
    3.25              lda $76             ; Add 2 to I.
    3.26              adc #2
    3.27 @@ -305,7 +302,6 @@
    3.28              sta $72                 ; row, R, to get x.
    3.29              lda bank1_rows_high,x
    3.30              sta $73                 ; x ($72,$73)
    3.31 -            clc
    3.32  
    3.33              lda $72     ; The leading tile would be plotted off the left hand
    3.34              sec         ; side of the screen.
    3.35 @@ -352,7 +348,6 @@
    3.36              lda $73
    3.37              adc $8d
    3.38              sta $73             ; x ($72,$73)
    3.39 -            clc
    3.40  
    3.41              ldy #0
    3.42              lda ($76),y             ; Load the type number, t,
    3.43 @@ -441,7 +436,7 @@
    3.44          cmp #40
    3.45          bcc plot_bank2r_row_on_screen
    3.46  
    3.47 -        jmp plot_bank2r_offset_endloop   ; break if the screen edge is reached
    3.48 +        bcs plot_bank2r_offset_endloop   ; break if the screen edge is reached
    3.49  
    3.50          plot_bank2r_row_on_screen:
    3.51  
    3.52 @@ -496,7 +491,6 @@
    3.53              lda $73
    3.54              adc $8d
    3.55              sta $73                 ; x ($72,$73)
    3.56 -            clc
    3.57  
    3.58              plot_bank2r_offset_next:
    3.59              clc
    3.60 @@ -638,7 +632,6 @@
    3.61              sta $72                 ; row, R, to get x.
    3.62              lda bank2_rows_high,x
    3.63              sta $73                 ; x ($72,$73)
    3.64 -            clc
    3.65  
    3.66              lda $72     ; The merged tile would be plotted off the left hand
    3.67              sec         ; side of the screen.
    3.68 @@ -709,7 +702,6 @@
    3.69              lda $73
    3.70              adc $8d
    3.71              sta $73                 ; x ($72,$73)
    3.72 -            clc
    3.73  
    3.74              ldy #0
    3.75              lda ($76),y                 ; Load the type number, t,
    3.76 @@ -740,7 +732,7 @@
    3.77              adc #0
    3.78              sta $77
    3.79  
    3.80 -            jmp plot_bank2l_offset_loop
    3.81 +            bcc plot_bank2l_offset_loop
    3.82  
    3.83          plot_bank2l_offset_endloop:
    3.84          clc
    3.85 @@ -988,18 +980,6 @@
    3.86      initial_plot_bank_tile_loop_span_endloop1:
    3.87      jmp initial_plot_bank1_span_endloop
    3.88  
    3.89 -next_cell:
    3.90 -
    3.91 -    lda $72
    3.92 -    adc #8
    3.93 -    sta $72
    3.94 -    lda $73
    3.95 -    adc #0
    3.96 -    sta $73
    3.97 -
    3.98 -    inc $74         ; one tile filled on the screen
    3.99 -    rts
   3.100 -
   3.101  player_sprites_low:  .byte <player_left1, <player_left2, <player_right1, <player_right2
   3.102  player_sprites_high: .byte >player_left1, >player_left2, >player_right1, >player_right2
   3.103  player_y_offset:     .byte 0, 4
   3.104 @@ -1024,7 +1004,7 @@
   3.105      adc #0
   3.106      sta $73
   3.107  
   3.108 -    jmp plot_char_bank
   3.109 +    bcc plot_char_bank
   3.110  
   3.111  plot_char_bank2:
   3.112  
   3.113 @@ -1086,7 +1066,6 @@
   3.114      lda $73
   3.115      adc bank2_char_rows_high,x  ; y position (high)
   3.116      sta $73
   3.117 -    clc
   3.118  
   3.119      plot_monster_both_banks:
   3.120  
   3.121 @@ -1170,7 +1149,6 @@
   3.122          lda $73
   3.123          adc #$01
   3.124          sta $73
   3.125 -        clc
   3.126  
   3.127          lda $8c
   3.128          adc #4
   3.129 @@ -1205,7 +1183,6 @@
   3.130          lda $73
   3.131          adc #$01
   3.132          sta $73
   3.133 -        clc
   3.134  
   3.135          lda $70
   3.136          adc #16
   3.137 @@ -1265,7 +1242,6 @@
   3.138          lda $73
   3.139          adc #$01
   3.140          sta $73
   3.141 -        clc
   3.142  
   3.143          ldx #0
   3.144          plot8x24_y1_lower_loop_outer:
   3.145 @@ -1411,7 +1387,6 @@
   3.146      lda $8d
   3.147      adc #top_panel_lives_bank1_high
   3.148      sta $73
   3.149 -    clc
   3.150  
   3.151      jsr plot_life_sprite
   3.152  
   3.153 @@ -1421,7 +1396,6 @@
   3.154      lda $8d
   3.155      adc #top_panel_lives_bank2_high
   3.156      sta $73
   3.157 -    clc
   3.158  
   3.159      ; Fall through into the plotting routine.
   3.160  
     4.1 --- a/routines/clear_bank.oph	Sun Oct 12 23:46:28 2014 +0200
     4.2 +++ b/routines/clear_bank.oph	Mon Oct 13 01:13:04 2014 +0200
     4.3 @@ -30,7 +30,6 @@
     4.4          lda $71
     4.5          adc #0
     4.6          sta $71
     4.7 -        clc
     4.8  
     4.9          cmp $72
    4.10          bne clear_bank_loop
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/routines/next_cell.oph	Mon Oct 13 01:13:04 2014 +0200
     5.3 @@ -0,0 +1,26 @@
     5.4 +; Copyright (C) 2014 David Boddie <david@boddie.org.uk>
     5.5 +;
     5.6 +; This program is free software: you can redistribute it and/or modify
     5.7 +; it under the terms of the GNU General Public License as published by
     5.8 +; the Free Software Foundation, either version 3 of the License, or
     5.9 +; (at your option) any later version.
    5.10 +;
    5.11 +; This program is distributed in the hope that it will be useful,
    5.12 +; but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.13 +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.14 +; GNU General Public License for more details.
    5.15 +;
    5.16 +; You should have received a copy of the GNU General Public License
    5.17 +; along with this program.  If not, see <http://www.gnu.org/licenses/>.
    5.18 +
    5.19 +; next_cell:
    5.20 +
    5.21 +    lda $72
    5.22 +    adc #8
    5.23 +    sta $72
    5.24 +    lda $73
    5.25 +    adc #0
    5.26 +    sta $73
    5.27 +
    5.28 +    inc $74         ; one tile filled on the screen
    5.29 +    rts
     6.1 --- a/scrolling.oph	Sun Oct 12 23:46:28 2014 +0200
     6.2 +++ b/scrolling.oph	Mon Oct 13 01:13:04 2014 +0200
     6.3 @@ -74,7 +74,6 @@
     6.4          lda $77
     6.5          adc #0
     6.6          sta $77
     6.7 -        clc
     6.8          bcc init_scrolling_monster_loop
     6.9  
    6.10      init_scrolling_monster_next: