junglejourney
changeset 30:3efa4d121a4f
Renamed an incorrectly named routine.
Added support for emerging enemies.
Added sprites for emerging enemies.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Fri Aug 19 02:38:05 2011 +0200 |
| parents | 98510cf24d1f |
| children | 78f826e6e5a5 |
| files | build.py images/emerge1.xpm images/emerge2.xpm images/emerge3.xpm images/emerge4.xpm makesprites.py mapcode.oph |
| diffstat | 7 files changed, 322 insertions(+), 28 deletions(-) [+] |
line diff
1.1 --- a/build.py Wed Aug 17 01:26:50 2011 +0200 1.2 +++ b/build.py Fri Aug 19 02:38:05 2011 +0200 1.3 @@ -52,7 +52,11 @@ 1.4 # 3300 character table (0x3C/6 = 10 entries) 1.5 # n type (0 missing, 1 player, 2 projectile, 3 explosion, 1.6 # 4 and higher enemy - bits 3,4,5 are enemy type) 1.7 - # n+1 counter/direction (bits 1,2 are direction, bit 0 is animation) 1.8 + # n+1 counter/direction (player/enemy: bits 1,2 are direction, 1.9 + # bit 0 is animation) 1.10 + # (emerging, explosion: bits 4,5,6 are enemy type for emerging, 1.11 + # bit 3 is type 0=emerge,1=explode, 1.12 + # bits 0,1,2 are animation with bit 0 a delay bit) 1.13 # n+2 y room offset (0-10) 1.14 # n+3 dy (0-5) 1.15 # n+4 x room offset (0-10) 1.16 @@ -75,12 +79,14 @@ 1.17 # 33F6 score (four bytes) 1.18 # 33FA level 1.19 # 33FB palette workspace (enough for one 5 byte palette entry) 1.20 + # 33FE and 33FF are also enemy generation counter when in a room 1.21 # 1.22 # 3400 CHARS (character sprites) 1.23 # 4 * 2 * 0x30 (player movement) 1.24 # 4 * 0x30 (player demise) 1.25 # 4 * 2 * 0x10 (projectile) 1.26 - # 5 * 4 * 2 * 0x40 (enemies) 36C0 1.27 + # 4 * 0x10 (projectile explode) 1.28 + # 5 * 4 * 2 * 0x40 (enemies) 3700 1.29 # 4 * 0x40 (enemy appear) 1.30 # 4 * 0x40 (enemy demise) 1.31 # 4 * 0x40 (weapons) 1.32 @@ -88,7 +94,7 @@ 1.33 # 2 * 0x40 (exit) 1.34 # 2 * 0x40 (final exit) 1.35 # 1.36 - # 4*2*0x30 + 4*0x30 + 4*2*0x10 + 5*4*2*0x40 + 4*0x40 + 4*0x40 + 4*0x40 + 4*0x40 + 2*0x40 + 2*0x40 + 0x3400 1.37 + # 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.38 # 1.39 # 45C0 space 1.40 # 5300 SPRITES (map)
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/images/emerge1.xpm Fri Aug 19 02:38:05 2011 +0200 2.3 @@ -0,0 +1,24 @@ 2.4 +/* XPM */ 2.5 +static char * emerge1_xpm[] = { 2.6 +"16 16 5 1", 2.7 +" c None", 2.8 +". c #000000", 2.9 +"+ c #FF0000", 2.10 +"@ c #FFFF00", 2.11 +"# c #008000", 2.12 +"................", 2.13 +".+..............", 2.14 +"..+.........+...", 2.15 +".......+.....+..", 2.16 +"......+.........", 2.17 +"................", 2.18 +".........@......", 2.19 +"...#......@.....", 2.20 +"..#.............", 2.21 +"................", 2.22 +"................", 2.23 +"............+...", 2.24 +"...+.......+....", 2.25 +"....+..+........", 2.26 +"........+.......", 2.27 +"................"};
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/images/emerge2.xpm Fri Aug 19 02:38:05 2011 +0200 3.3 @@ -0,0 +1,24 @@ 3.4 +/* XPM */ 3.5 +static char * emerge2_xpm[] = { 3.6 +"16 16 5 1", 3.7 +" c None", 3.8 +". c #000000", 3.9 +"+ c #FF0000", 3.10 +"@ c #008000", 3.11 +"# c #FFFF00", 3.12 +"................", 3.13 +".+.....+........", 3.14 +"..+...+.....+...", 3.15 +"..+....+.....+..", 3.16 +"...+..+.....+...", 3.17 +"...........+....", 3.18 +"...@@....#..+...", 3.19 +"..@.@.....#.....", 3.20 +"..@@......#.....", 3.21 +".........#...+..", 3.22 +"............+...", 3.23 +".+......+...+...", 3.24 +"..++...+...+....", 3.25 +"....+..+........", 3.26 +"........+.......", 3.27 +"................"};
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/images/emerge3.xpm Fri Aug 19 02:38:05 2011 +0200 4.3 @@ -0,0 +1,24 @@ 4.4 +/* XPM */ 4.5 +static char * emerge3_xpm[] = { 4.6 +"16 16 5 1", 4.7 +" c None", 4.8 +". c #000000", 4.9 +"+ c #FF0000", 4.10 +"@ c #008000", 4.11 +"# c #FFFF00", 4.12 +"................", 4.13 +".......++.......", 4.14 +"..+...+..+..+...", 4.15 +"..+..+.......+..", 4.16 +"...++.......+...", 4.17 +"........+..+....", 4.18 +"...+...+....+...", 4.19 +"..@.@........+..", 4.20 +"...+...#..#...+.", 4.21 +"........##...+..", 4.22 +"..++........+...", 4.23 +".+......++......", 4.24 +"..+....+..+.....", 4.25 +".....#.......+..", 4.26 +"....#.......+...", 4.27 +"................"};
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/images/emerge4.xpm Fri Aug 19 02:38:05 2011 +0200 5.3 @@ -0,0 +1,23 @@ 5.4 +/* XPM */ 5.5 +static char * emerge4_xpm[] = { 5.6 +"16 16 4 1", 5.7 +" c None", 5.8 +". c #000000", 5.9 +"+ c #FF0000", 5.10 +"@ c #FFFF00", 5.11 +"................", 5.12 +".......++..+....", 5.13 +"..+...+..++.+...", 5.14 +"..+..+.......+..", 5.15 +"...++.......+...", 5.16 +"........+..+....", 5.17 +"...+...+....+...", 5.18 +"..+.+.+......+..", 5.19 +"...+.+.@..@...+.", 5.20 +"........+@...+..", 5.21 +"..++........+...", 5.22 +".+..+...++...+..", 5.23 +"..+..+.+..+...+.", 5.24 +".....@....+..+..", 5.25 +"....+......++...", 5.26 +"................"};
6.1 --- a/makesprites.py Wed Aug 17 01:26:50 2011 +0200 6.2 +++ b/makesprites.py Fri Aug 19 02:38:05 2011 +0200 6.3 @@ -76,6 +76,11 @@ 6.4 read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.5 read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.6 read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.7 + # placeholder projectile explode sprites 6.8 + read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.9 + read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.10 + read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.11 + read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.12 6.13 read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.14 read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.15 @@ -127,10 +132,10 @@ 6.16 read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.17 6.18 # placeholder enemy appear 6.19 - read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.20 - read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.21 - read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.22 - read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]), 6.23 + read_xpm("images/emerge1.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]), 6.24 + read_xpm("images/emerge2.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]), 6.25 + read_xpm("images/emerge3.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]), 6.26 + read_xpm("images/emerge4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]), 6.27 6.28 # placeholder enemy demise 6.29 read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
7.1 --- a/mapcode.oph Wed Aug 17 01:26:50 2011 +0200 7.2 +++ b/mapcode.oph Fri Aug 19 02:38:05 2011 +0200 7.3 @@ -26,7 +26,7 @@ 7.4 clc 7.5 rts 7.6 7.7 -div9: ; A = value 7.8 +mod9: ; A = value 7.9 divide_loop: 7.10 cmp #9 7.11 bcc after_divide_loop ; bmi should work here, I think, but it doesn't 7.12 @@ -43,7 +43,7 @@ 7.13 next_value: ; no argument 7.14 jsr unlimited_values 7.15 lda $7d 7.16 - jsr div9 7.17 + jsr mod9 7.18 and #7 ; (next value % 9) & 7 7.19 tax 7.20 lda tile_values_map,x 7.21 @@ -1024,8 +1024,11 @@ 7.22 screen_columns_high: .byte $00,$00,$00,$00,$00,$00,$00,$00,$01,$01 7.23 screen_subcolumns_low: .byte $00,$08,$10,$18 7.24 7.25 -enemy_direction_chars_low: .byte $c0,$00,$40,$80,$c0,$00,$40,$80 7.26 -enemy_direction_chars_high: .byte $36,$37,$37,$37,$37,$38,$38,$38 7.27 +enemy_direction_chars_low: .byte $00,$40,$80,$c0,$00,$40,$80,$c0 7.28 +enemy_direction_chars_high: .byte $37,$37,$37,$37,$38,$38,$38,$38 7.29 + 7.30 +emerge_explode_chars_low: .byte $00,$40,$80,$c0,$00,$40,$80,$c0 7.31 +emerge_explode_chars_high: .byte $41,$41,$41,$41,$42,$42,$42,$42 7.32 7.33 plot_characters: 7.34 7.35 @@ -1150,8 +1153,20 @@ 7.36 cmp #3 7.37 bne plot_characters_loop_not_explosion 7.38 7.39 - ; Plot 16x16 sprites (explosions) 7.40 + ; Plot 16x16 sprites (emerging, explosions) 7.41 7.42 + ; Select the sprites to use. 7.43 + 7.44 + lda $80 ; remove the least significant bit, used to delay 7.45 + lsr ; the animation 7.46 + and #7 ; only keep the bits required to find the correct sprite 7.47 + tax 7.48 + lda emerge_explode_chars_low,x 7.49 + sta $70 7.50 + lda emerge_explode_chars_high,x 7.51 + sta $71 7.52 + 7.53 + jmp plot_characters_16x16 7.54 7.55 plot_characters_loop_not_explosion: 7.56 cmp #4 7.57 @@ -1161,9 +1176,9 @@ 7.58 7.59 ; Select the set of sprites to use. 7.60 7.61 - and #248 7.62 + and #$38 7.63 lsr 7.64 - lsr ; bits 3,4,5 >> 2 7.65 + lsr ; bits 3,4,5 >> 2 -> bits 1,2,3 7.66 clc 7.67 sta $71 ; 0x00, 0x02, 0x04, 0x06, 0x08 7.68 7.69 @@ -1174,6 +1189,8 @@ 7.70 adc $71 7.71 sta $71 7.72 7.73 + plot_characters_16x16: 7.74 + 7.75 ; Use the dy value to determine which plotting routine to use. 7.76 7.77 lda $76 7.78 @@ -1190,7 +1207,6 @@ 7.79 7.80 7.81 plot_characters_loop_not_enemy: 7.82 - clc 7.83 7.84 plot_characters_next: 7.85 clc 7.86 @@ -1572,6 +1588,170 @@ 7.87 clc 7.88 rts 7.89 7.90 +emerge_type: ; returns A=type 7.91 + jsr unlimited_values 7.92 + lda $7d 7.93 + and #$70 7.94 + cmp #$40 7.95 + bmi exit_emerge_type 7.96 + 7.97 + lda #$40 7.98 + 7.99 + exit_emerge_type: 7.100 + clc 7.101 + rts 7.102 + 7.103 +emerge_position: ; returns A=position 7.104 + jsr unlimited_values 7.105 + lda $7d 7.106 + and #7 7.107 + adc #1 7.108 + clc 7.109 + rts 7.110 + 7.111 +move_characters: 7.112 + 7.113 + dec $33ff 7.114 + 7.115 + lda #$0c 7.116 + sta $74 7.117 + lda #$33 7.118 + sta $75 7.119 + 7.120 + move_characters_loop: 7.121 + 7.122 + ldy #0 7.123 + lda ($74),y 7.124 + cmp #0 7.125 + bne move_characters_read_character 7.126 + 7.127 + ; See if it is time to generate a new enemy. 7.128 + lda $33ff 7.129 + cmp #0 7.130 + bne move_characters_next 7.131 + 7.132 + lda #63 7.133 + sta $33ff 7.134 + 7.135 + jsr emerge_position ; obtain a y position 7.136 + tax 7.137 + jsr emerge_position ; obtain an x position 7.138 + sta $80 ; temporary 7.139 + tay 7.140 + 7.141 + lda room_row_offsets_low,x 7.142 + sta $70 7.143 + lda #$57 7.144 + sta $71 7.145 + lda ($70),y ; load the tile 7.146 + 7.147 + cmp #0 7.148 + bne move_characters_next 7.149 + 7.150 + ; There is a space in the room, so add an emerging enemy. 7.151 + 7.152 + ldy #0 7.153 + lda #3 7.154 + sta ($74),y 7.155 + 7.156 + jsr emerge_type ; obtain an enemy type 7.157 + iny 7.158 + sta ($74),y 7.159 + 7.160 + txa 7.161 + iny 7.162 + sta ($74),y ; store the y position 7.163 + lda #1 7.164 + iny 7.165 + sta ($74),y ; store the dy offset 7.166 + 7.167 + lda $80 7.168 + iny 7.169 + sta ($74),y ; store the x position 7.170 + lda #0 7.171 + iny 7.172 + sta ($74),y ; store the dx offset 7.173 + 7.174 + jmp move_characters_next 7.175 + 7.176 + move_characters_read_character: 7.177 + clc 7.178 + 7.179 + cmp #3 7.180 + bne move_characters_next 7.181 + 7.182 + iny 7.183 + lda ($74),y ; direction/animation 7.184 + tax 7.185 + adc #1 7.186 + and #7 7.187 + sta $80 7.188 + bne move_characters_explosion_not_finished 7.189 + 7.190 + dey 7.191 + 7.192 + txa 7.193 + and #8 7.194 + bne move_characters_remove_character 7.195 + 7.196 + ; For emerges, convert into an enemy. 7.197 + txa 7.198 + and #$70 ; only keep bits 4,5,6 7.199 + lsr ; bits 4,5,6 -> 3,4,5 7.200 + ora #4 ; make this an enemy 7.201 + 7.202 + sta ($74),y ; update the type 7.203 + iny 7.204 + lda #0 ; prepare the direction and animation offset 7.205 + 7.206 + jmp move_characters_update_character 7.207 + 7.208 + move_characters_remove_character: 7.209 + 7.210 + ; For explosions, just write 0 into the character array. 7.211 + lda #0 7.212 + jmp move_characters_update_character 7.213 + 7.214 + move_characters_explosion_not_finished: 7.215 + txa 7.216 + and #$f8 7.217 + ora $80 7.218 + 7.219 + move_characters_update_character: 7.220 + sta ($74),y 7.221 + 7.222 + move_characters_next: 7.223 + clc 7.224 + 7.225 + ; Examine the next character. 7.226 + lda $74 7.227 + adc #6 7.228 + 7.229 + cmp #$3c 7.230 + bpl move_characters_exit 7.231 + sta $74 7.232 + jmp move_characters_loop 7.233 + 7.234 + move_characters_exit: 7.235 + clc 7.236 + rts 7.237 + 7.238 +clear_characters: 7.239 + 7.240 + ; Clear the character table. 7.241 + 7.242 + ldx #6 7.243 + clear_character_loop: 7.244 + lda #0 7.245 + sta $3300,x 7.246 + txa 7.247 + adc #6 7.248 + tax 7.249 + cpx #$3c 7.250 + bmi clear_character_loop 7.251 + 7.252 + rts 7.253 + 7.254 set_palette: 7.255 ; $70=logical colour 7.256 ; $71=physical colour 7.257 @@ -1620,8 +1800,8 @@ 7.258 chars_block: .byte <chars_file_name, >chars_file_name 7.259 .byte $00, $34, 0, 0 7.260 .byte $00, $34, 0, 0 7.261 - .byte $c0, $11, 0, 0 7.262 - .byte $c0, $45, 0, 0 7.263 + .byte $00, $12, 0, 0 7.264 + .byte $00, $46, 0, 0 7.265 7.266 init: 7.267 lda #255 7.268 @@ -1680,17 +1860,7 @@ 7.269 sta $33f1 7.270 sta $33f3 7.271 7.272 - ; Clear the character table and set player position. 7.273 - 7.274 - ldx #0 7.275 - clear_character_loop: 7.276 - lda #0 7.277 - sta $3300,x 7.278 - txa 7.279 - adc #6 7.280 - tax 7.281 - cpx #$f0 7.282 - bmi clear_character_loop 7.283 + ; Set the player position. 7.284 7.285 lda #1 ; player 7.286 sta $3300 7.287 @@ -1705,6 +1875,19 @@ 7.288 lda #0 ; dx=0 7.289 sta $3305 7.290 7.291 +; lda #$3 ; explode/emerge 7.292 +; sta $330c 7.293 +; lda #0 ; emerge (first frame) 7.294 +; sta $330d 7.295 +; lda #3 ; y=3 7.296 +; sta $330e 7.297 +; lda #1 ; dy=1 7.298 +; sta $330f 7.299 +; lda #3 ; x=3 7.300 +; sta $3310 7.301 +; lda #0 ; dx=0 7.302 +; sta $3311 7.303 +; 7.304 ; lda #$4 ; enemy (0) 7.305 ; sta $330c 7.306 ; lda #0 ; left up (first frame) 7.307 @@ -1792,12 +1975,17 @@ 7.308 lda $33f3 7.309 sta $79 7.310 jsr plot_room 7.311 + jsr clear_characters 7.312 jsr plot_characters 7.313 7.314 + lda #63 7.315 + sta $33ff 7.316 + 7.317 room_loop: 7.318 lda #19 7.319 jsr $fff4 7.320 jsr plot_characters ; unplot 7.321 + jsr move_characters 7.322 jsr move_player 7.323 bcs after_room_loop 7.324
