junglejourney
changeset 31:78f826e6e5a5
Introduced a plotting buffer that records which characters need to
be unplotted and plotted. All the operations in the buffer are then
performed in sequence to minimise flicker and drawing artifacts.
Reduced the number of characters on screen to 6.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sat Aug 20 04:34:14 2011 +0200 |
| parents | 3efa4d121a4f |
| children | a0d2f1c1ecdd |
| files | build.py mapcode.oph |
| diffstat | 2 files changed, 183 insertions(+), 27 deletions(-) [+] |
line diff
1.1 --- a/build.py Fri Aug 19 02:38:05 2011 +0200 1.2 +++ b/build.py Sat Aug 20 04:34:14 2011 +0200 1.3 @@ -49,7 +49,7 @@ 1.4 # Planned memory map 1.5 # 1900 CODE (map) 1.6 # 1x00 space 1.7 - # 3300 character table (0x3C/6 = 10 entries) 1.8 + # 3300 character table (0x24/6 = 6 entries) 1.9 # n type (0 missing, 1 player, 2 projectile, 3 explosion, 1.10 # 4 and higher enemy - bits 3,4,5 are enemy type) 1.11 # n+1 counter/direction (player/enemy: bits 1,2 are direction, 1.12 @@ -66,7 +66,7 @@ 1.13 # second character is always the player's weapon 1.14 # new characters are added after these 1.15 # 1.16 - # 333C objects/treasure table (0xB4/5 = 36 entries) 1.17 + # 3324 objects/treasure table (0xB4/5 = 36 entries) 1.18 # n type 1.19 # n+1 i map offset 1.20 # n+2 j map offset 1.21 @@ -96,7 +96,15 @@ 1.22 # 1.23 # 4*2*0x30 + 4*0x30 + 4*2*0x10 + 4*0x10 + 5*4*2*0x40 + 4*0x40 + 4*0x40 + 4*0x40 + 4*0x40 + 2*0x40 + 2*0x40 + 0x3400 1.24 # 1.25 - # 45C0 space 1.26 + # 4600 space 1.27 + # 4700 plot buffer (alternate unplot/plot entries terminating in 255) 1.28 + # n,n+1 address 1.29 + # n+2,n+3 source address 1.30 + # n+4,n+5 destination address 1.31 + # 1.32 + # 4700 and every 12 bytes is unplot entries 1.33 + # 4706 and every 12 bytes is plot entries 1.34 + # 1.35 # 5300 SPRITES (map) 1.36 # 5780 space 1.37 # 579c room data (generated)
2.1 --- a/mapcode.oph Fri Aug 19 02:38:05 2011 +0200 2.2 +++ b/mapcode.oph Sat Aug 20 04:34:14 2011 +0200 2.3 @@ -638,7 +638,8 @@ 2.4 cpy #32 2.5 bpl plotloop8x24_y0_2 2.6 2.7 - rts 2.8 + clc 2.9 + jmp plot_buffer_loop_next 2.10 2.11 ; Sprite data stored in memory: 00 04 08 0c 10 14 18 1c 20 24 28 2c 2.12 ; 2.13 @@ -738,7 +739,8 @@ 2.14 dex 2.15 bpl plotloop8x24_y1_loop 2.16 2.17 - rts 2.18 + clc 2.19 + jmp plot_buffer_loop_next 2.20 2.21 plot16x16_y0: ; $70,$71=source address 2.22 ; $72,$73=destination address 2.23 @@ -771,7 +773,7 @@ 2.24 bpl plotloop16x16_y0_1 2.25 clc 2.26 2.27 - rts 2.28 + jmp plot_buffer_loop_next 2.29 2.30 ; Sprite data stored in memory: 00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c 2.31 ; 2.32 @@ -881,7 +883,7 @@ 2.33 2.34 plotloop16x16_y1_exit: 2.35 clc 2.36 - rts 2.37 + jmp plot_buffer_loop_next 2.38 2.39 plot8x8_y0: ; $70,$71=source address 2.40 ; $72,$73=destination address 2.41 @@ -894,7 +896,7 @@ 2.42 bpl plotloop8x8_y0_0 2.43 clc 2.44 2.45 - rts 2.46 + jmp plot_buffer_loop_next 2.47 2.48 ; Sprite data stored in memory: 00 04 2.49 ; 2.50 @@ -957,7 +959,7 @@ 2.51 plot8x8_y1_exit: 2.52 clc 2.53 2.54 - rts 2.55 + jmp plot_buffer_loop_next 2.56 2.57 2.58 check_key: ; x=key code 2.59 @@ -1115,17 +1117,26 @@ 2.60 2.61 ; Use the dy value to determine which plotting routine to use. 2.62 2.63 + ldy #0 2.64 lda $76 2.65 and #1 2.66 bne plot_characters_plot_8x24_1 2.67 2.68 - jsr plot8x24_y0 2.69 - jmp plot_characters_next 2.70 + lda #<plot8x24_y0 2.71 + sta ($84),y 2.72 + iny 2.73 + lda #>plot8x24_y0 2.74 + sta ($84),y 2.75 + jmp plot_characters_stored 2.76 2.77 plot_characters_plot_8x24_1: 2.78 clc 2.79 - jsr plot8x24_y1 2.80 - jmp plot_characters_next 2.81 + lda #<plot8x24_y1 2.82 + sta ($84),y 2.83 + iny 2.84 + lda #>plot8x24_y1 2.85 + sta ($84),y 2.86 + jmp plot_characters_stored 2.87 2.88 2.89 plot_characters_loop_not_player: 2.90 @@ -1136,17 +1147,26 @@ 2.91 2.92 ; Use the dy value to determine which plotting routine to use. 2.93 2.94 + ldy #0 2.95 lda $76 2.96 and #1 2.97 bne plot_characters_plot_8x8_1 2.98 2.99 - jsr plot8x8_y0 2.100 - jmp plot_characters_next 2.101 + lda #<plot8x8_y0 2.102 + sta ($84),y 2.103 + iny 2.104 + lda #>plot8x8_y0 2.105 + sta ($84),y 2.106 + jmp plot_characters_stored 2.107 2.108 plot_characters_plot_8x8_1: 2.109 clc 2.110 - jsr plot8x8_y1 2.111 - jmp plot_characters_next 2.112 + lda #<plot8x8_y1 2.113 + sta ($84),y 2.114 + iny 2.115 + lda #>plot8x8_y1 2.116 + sta ($84),y 2.117 + jmp plot_characters_stored 2.118 2.119 2.120 plot_characters_loop_not_projectile: 2.121 @@ -1193,19 +1213,47 @@ 2.122 2.123 ; Use the dy value to determine which plotting routine to use. 2.124 2.125 + ldy #0 2.126 lda $76 2.127 and #1 2.128 bne plot_characters_plot_16x16_1 2.129 2.130 - jsr plot16x16_y0 2.131 - jmp plot_characters_next 2.132 + lda #<plot16x16_y0 2.133 + sta ($84),y 2.134 + iny 2.135 + lda #>plot16x16_y0 2.136 + sta ($84),y 2.137 + jmp plot_characters_stored 2.138 2.139 plot_characters_plot_16x16_1: 2.140 clc 2.141 - jsr plot16x16_y1 2.142 - jmp plot_characters_next 2.143 + lda #<plot16x16_y1 2.144 + sta ($84),y 2.145 + iny 2.146 + lda #>plot16x16_y1 2.147 + sta ($84),y 2.148 2.149 2.150 + plot_characters_stored: 2.151 + 2.152 + iny 2.153 + lda $70 2.154 + sta ($84),y 2.155 + iny 2.156 + lda $71 2.157 + sta ($84),y 2.158 + iny 2.159 + lda $72 2.160 + sta ($84),y 2.161 + iny 2.162 + lda $73 2.163 + sta ($84),y 2.164 + 2.165 + clc 2.166 + lda $84 2.167 + adc #12 2.168 + sta $84 2.169 + 2.170 plot_characters_loop_not_enemy: 2.171 2.172 plot_characters_next: 2.173 @@ -1215,16 +1263,99 @@ 2.174 lda $74 2.175 adc #6 2.176 2.177 - cmp #$3c 2.178 + cmp #$24 2.179 bpl plot_characters_exit 2.180 sta $74 2.181 jmp plot_characters_loop 2.182 2.183 plot_characters_exit: 2.184 + lda #255 2.185 + ldy #0 2.186 + sta ($84),y 2.187 clc 2.188 rts 2.189 2.190 -; Note that the room offsets reflect that the room is 2.191 +reset_plot_buffer: 2.192 + lda #$06 ; reset the index into the plot buffer 2.193 + sta $84 2.194 + lda #$47 2.195 + sta $85 2.196 + rts 2.197 + 2.198 +reset_unplot_buffer: 2.199 + lda #$00 ; reset the index into the plot buffer 2.200 + sta $84 2.201 + lda #$47 2.202 + sta $85 2.203 + rts 2.204 + 2.205 +plot_buffer: 2.206 + 2.207 + lda #$00 2.208 + sta $84 2.209 + lda #$47 2.210 + sta $85 2.211 + 2.212 + lda #6 2.213 + sta $88 2.214 + 2.215 + plot_buffer_loop: 2.216 + 2.217 + ldy #0 2.218 + lda ($84),y 2.219 + cmp #255 2.220 + beq plot_buffer_loop_skip 2.221 + 2.222 + clc 2.223 + sta $86 2.224 + 2.225 + iny 2.226 + lda ($84),y 2.227 + sta $87 2.228 + 2.229 + iny 2.230 + lda ($84),y 2.231 + sta $70 2.232 + 2.233 + iny 2.234 + lda ($84),y 2.235 + sta $71 2.236 + 2.237 + iny 2.238 + lda ($84),y 2.239 + sta $72 2.240 + 2.241 + iny 2.242 + lda ($84),y 2.243 + sta $73 2.244 + 2.245 + jmp ($86) ; returns to plot_buffer_loop_next 2.246 + 2.247 + plot_buffer_loop_skip: 2.248 + 2.249 + lda $88 2.250 + cmp #12 2.251 + beq plot_buffer_exit ; both unplot and plot lists have terminated 2.252 + 2.253 + lda #12 2.254 + sta $88 2.255 + lda $84 2.256 + adc #6 2.257 + sta $84 2.258 + jmp plot_buffer_loop 2.259 + 2.260 + plot_buffer_loop_next: 2.261 + clc 2.262 + 2.263 + lda $84 2.264 + adc $88 2.265 + sta $84 2.266 + jmp plot_buffer_loop 2.267 + 2.268 + plot_buffer_exit: 2.269 + clc 2.270 + rts 2.271 + 2.272 room_row_offsets_low: .byte $9c,$a6,$b0,$ba,$c4,$ce,$d8,$e2,$ec,$f6 2.273 2.274 animate_player_left: 2.275 @@ -1727,7 +1858,7 @@ 2.276 lda $74 2.277 adc #6 2.278 2.279 - cmp #$3c 2.280 + cmp #$24 2.281 bpl move_characters_exit 2.282 sta $74 2.283 jmp move_characters_loop 2.284 @@ -1747,7 +1878,7 @@ 2.285 txa 2.286 adc #6 2.287 tax 2.288 - cpx #$3c 2.289 + cpx #$24 2.290 bmi clear_character_loop 2.291 2.292 rts 2.293 @@ -1976,20 +2107,37 @@ 2.294 sta $79 2.295 jsr plot_room 2.296 jsr clear_characters 2.297 + 2.298 + jsr reset_unplot_buffer 2.299 + lda #255 ; terminate the unplot list by default because the 2.300 + ldy #0 ; initial plotting of the buffer only plots characters 2.301 + sta ($84),y 2.302 + jsr reset_plot_buffer 2.303 jsr plot_characters 2.304 + jsr plot_buffer 2.305 2.306 lda #63 2.307 sta $33ff 2.308 2.309 room_loop: 2.310 - lda #19 2.311 - jsr $fff4 2.312 + lda #$00 ; reset the index into the plot buffer 2.313 + sta $84 2.314 + lda #$47 2.315 + sta $85 2.316 + 2.317 + jsr reset_unplot_buffer 2.318 jsr plot_characters ; unplot 2.319 jsr move_characters 2.320 jsr move_player 2.321 bcs after_room_loop 2.322 2.323 + jsr reset_plot_buffer 2.324 jsr plot_characters ; plot 2.325 + 2.326 + lda #19 2.327 + jsr $fff4 2.328 + jsr plot_buffer 2.329 + 2.330 ldx #157 2.331 jsr check_key 2.332 cpy #255
