castleraider
changeset 293:0511bde814c4
Memory saving optimisations.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sun Mar 30 23:39:32 2014 +0200 |
| parents | 256c97f5d8fe |
| children | f8a3753a9c53 |
| files | plotting.oph sound.oph |
| diffstat | 2 files changed, 30 insertions(+), 35 deletions(-) [+] |
line diff
1.1 --- a/plotting.oph Sun Mar 30 23:06:08 2014 +0200 1.2 +++ b/plotting.oph Sun Mar 30 23:39:32 2014 +0200 1.3 @@ -63,14 +63,7 @@ 1.4 read_screen_address_bank1: ; X=row, A=column offset 1.5 ; sets $72,$73 1.6 1.7 - asl ; Multiply o by 8 1.8 - asl 1.9 - asl 1.10 - sta $72 1.11 - lda #0 1.12 - adc #0 1.13 - sta $73 1.14 - clc 1.15 + jsr read_screen_address_low 1.16 1.17 lda $72 1.18 adc banks_rows_low,x ; Add to the screen start address for the 1.19 @@ -82,8 +75,7 @@ 1.20 1.21 rts 1.22 1.23 -read_screen_address_bank2: ; X=row, A=column offset 1.24 - ; sets $72,$73=screen address 1.25 +read_screen_address_low: 1.26 1.27 asl ; Multiply o by 8 1.28 asl 1.29 @@ -93,6 +85,12 @@ 1.30 adc #0 1.31 sta $73 1.32 clc 1.33 + rts 1.34 + 1.35 +read_screen_address_bank2: ; X=row, A=column offset 1.36 + ; sets $72,$73=screen address 1.37 + 1.38 + jsr read_screen_address_low 1.39 1.40 lda $72 1.41 adc banks_rows_low,x ; Add to the screen start address for the 1.42 @@ -110,13 +108,9 @@ 1.43 cmp #$10 1.44 bcc read_sprite_address_next 1.45 1.46 - jsr read_visible_sprite ; check whether the sprite is visible 1.47 - ; (it represents a special tile) 1.48 - 1.49 - and #$1f 1.50 + jsr read_and_mask_visible_sprite 1.51 1.52 read_sprite_address_next: ; a regular tile 1.53 - clc 1.54 1.55 asl 1.56 asl 1.57 @@ -130,18 +124,23 @@ 1.58 clc 1.59 rts 1.60 1.61 +read_and_mask_visible_sprite: 1.62 + 1.63 + jsr read_visible_sprite ; check whether the sprite is visible 1.64 + ; (it represents a special tile) 1.65 + and #$1f 1.66 + clc 1.67 + rts 1.68 + 1.69 read_left_sprite_address: ; A=tile number 1.70 ; sets $70,$71=sprite address 1.71 1.72 cmp #$10 1.73 bcc read_left_sprite_address_next 1.74 1.75 - jsr read_visible_sprite ; check whether the sprite is visible 1.76 - ; (it represents a special tile) 1.77 - and #$1f 1.78 + jsr read_and_mask_visible_sprite 1.79 1.80 read_left_sprite_address_next: ; a regular tile 1.81 - clc 1.82 1.83 asl 1.84 asl 1.85 @@ -161,12 +160,9 @@ 1.86 cmp #$10 1.87 bcc read_rotated_sprite_address_next 1.88 1.89 - jsr read_visible_sprite ; check whether the sprite is visible 1.90 - ; (it represents a special tile) 1.91 - and #$1f 1.92 + jsr read_and_mask_visible_sprite 1.93 1.94 read_rotated_sprite_address_next: ; a regular tile 1.95 - clc 1.96 1.97 asl 1.98 asl 1.99 @@ -186,12 +182,9 @@ 1.100 cmp #$10 1.101 bcc read_right_sprite_address_next 1.102 1.103 - jsr read_visible_sprite ; check whether the sprite is visible 1.104 - ; (it represents a special tile) 1.105 - and #$1f 1.106 + jsr read_and_mask_visible_sprite 1.107 1.108 read_right_sprite_address_next: ; a regular tile 1.109 - clc 1.110 1.111 asl 1.112 asl
2.1 --- a/sound.oph Sun Mar 30 23:06:08 2014 +0200 2.2 +++ b/sound.oph Sun Mar 30 23:39:32 2014 +0200 2.3 @@ -13,11 +13,7 @@ 2.4 ; You should have received a copy of the GNU General Public License 2.5 ; along with this program. If not, see <http://www.gnu.org/licenses/>. 2.6 2.7 -sounds_low: .byte <demise_sound, <item_sound, <jump_sound, <step_sound 2.8 - .byte <door_sound, <portal_sound 2.9 -sounds_high: .byte >demise_sound, >item_sound, >jump_sound, >step_sound 2.10 - .byte >door_sound, >portal_sound 2.11 - 2.12 +sounds: 2.13 demise_sound: .byte 1,0, 1,0, 160,0, 6,0 ; 6 * 50ms 2.14 item_sound: .byte $13,0, 2,0, 160,0, 4,0 ; 4 * 50ms 2.15 jump_sound: .byte $13,0, 3,0, 50,0, 2,0 ; 2 * 50ms 2.16 @@ -27,10 +23,16 @@ 2.17 2.18 play_sound: ; X=sound number 2.19 2.20 - lda sounds_high,x 2.21 + txa 2.22 + asl 2.23 + asl 2.24 + asl 2.25 + adc #<sounds 2.26 + tax 2.27 + lda #0 2.28 + adc #>sounds 2.29 tay 2.30 - lda sounds_low,x 2.31 - tax 2.32 + clc 2.33 lda #7 2.34 jsr $fff1 2.35
