junglejourney

changeset 105:5a0c9fedd2c2

Added basic sounds. Added a title logo and a completion image.
author David Boddie <david@boddie.org.uk>
date Sun Sep 04 01:38:57 2011 +0200
parents b9003a1a35e9
children ec9b8b735e5b
files build.py mapcode.oph tools/makesprites.py
diffstat 3 files changed, 366 insertions(+), 25 deletions(-) [+]
line diff
     1.1 --- a/build.py	Sun Sep 04 01:37:55 2011 +0200
     1.2 +++ b/build.py	Sun Sep 04 01:38:57 2011 +0200
     1.3 @@ -47,6 +47,7 @@
     1.4      out_uef_file = sys.argv[1]
     1.5      
     1.6      # Memory map
     1.7 +    # 1780 title screen
     1.8      # 1F00 CODE
     1.9      # 3?00 space
    1.10      # 3D00 character table (0x24/6 = 6 entries + 1 special entry)
    1.11 @@ -154,8 +155,15 @@
    1.12      data = makesprites.read_sprites(makesprites.chars)
    1.13      files.append(("CHARS", 0x3400, 0x3400, data))
    1.14  
    1.15 +    data = makesprites.read_sprites([makesprites.title])
    1.16 +    data += makesprites.encode(makesprites.read_sprites([makesprites.completed]))
    1.17 +    files.append(("TITLE", 0x5A80, 0x5A80, data))
    1.18 +
    1.19      u = UEFfile.UEFfile(creator = 'build.py '+version)
    1.20      u.minor = 6
    1.21 +    
    1.22 +    # Insert a gap at the start of the tape.
    1.23 +    #u.chunks.append((0x112, "\x01\x00\x00\x00"))
    1.24      u.import_files(0, files)
    1.25      
    1.26      # Write the new UEF file.
     2.1 --- a/mapcode.oph	Sun Sep 04 01:37:55 2011 +0200
     2.2 +++ b/mapcode.oph	Sun Sep 04 01:38:57 2011 +0200
     2.3 @@ -3394,6 +3394,10 @@
     2.4  
     2.5      jsr plot_character
     2.6  
     2.7 +    ; Play a sound.
     2.8 +    ldx #0
     2.9 +    jsr play_sound
    2.10 +
    2.11      move_projectile_no_enemy_collision:
    2.12  
    2.13      lda $3d07       ; type 2 projectiles pass through everything
    2.14 @@ -3512,7 +3516,10 @@
    2.15      ; Check collisions with the player.
    2.16  
    2.17      jsr player_collide
    2.18 -    bcc move_characters_exit
    2.19 +    bcs move_characters_collisions
    2.20 +    jmp move_characters_exit
    2.21 +
    2.22 +    move_characters_collisions:
    2.23      clc
    2.24  
    2.25      ldy #0
    2.26 @@ -3553,13 +3560,19 @@
    2.27      sta $70
    2.28      jsr add_strength
    2.29      clc
    2.30 +
    2.31 +    ldx #2
    2.32 +    jsr play_sound
    2.33 +
    2.34      rts
    2.35  
    2.36      move_characters_not_health:
    2.37      cmp #5
    2.38      bmi move_characters_not_treasure
    2.39  
    2.40 -    ; Do nothing here. We have already increased the player's score.
    2.41 +    ldx #2
    2.42 +    jsr play_sound
    2.43 +
    2.44      clc
    2.45      rts
    2.46  
    2.47 @@ -3572,6 +3585,10 @@
    2.48      ora #$01
    2.49      sta $3df0
    2.50      clc
    2.51 +
    2.52 +    ldx #3
    2.53 +    jsr play_sound
    2.54 +
    2.55      rts
    2.56  
    2.57      move_characters_not_key:
    2.58 @@ -3580,6 +3597,10 @@
    2.59      asl
    2.60      sta $3df9
    2.61      clc
    2.62 +
    2.63 +    ldx #2
    2.64 +    jsr play_sound
    2.65 +
    2.66      rts
    2.67  
    2.68      move_character_destroy_enemy:
    2.69 @@ -3600,6 +3621,9 @@
    2.70  
    2.71      ; Reduce the player's strength.
    2.72  
    2.73 +    ldx #1
    2.74 +    jsr play_sound
    2.75 +
    2.76      lda #1
    2.77      sta $70
    2.78      jmp reduce_strength ; optimise away the rts
    2.79 @@ -4091,8 +4115,148 @@
    2.80      jsr set_palette
    2.81      rts
    2.82  
    2.83 +sounds_low:  .byte <explosion_sound, <damage_sound, <item_sound, <key_sound
    2.84 +sounds_high: .byte >explosion_sound, >damage_sound, >item_sound, >key_sound
    2.85 +
    2.86 +explosion_sound: .byte 1,0, 1,0, 60,0, 2,0
    2.87 +damage_sound:    .byte 1,0, 2,0, 40,0, 4,0
    2.88 +item_sound:      .byte 1,0, 3,0, 80,0, 8,0
    2.89 +key_sound:       .byte 1,0, 3,0, 150,0, 8,0
    2.90 +
    2.91 +play_sound:     ; X=sound number
    2.92 +
    2.93 +    lda sounds_high,x
    2.94 +    tay
    2.95 +    lda sounds_low,x
    2.96 +    tax
    2.97 +    lda #7
    2.98 +    jsr $fff1
    2.99 +
   2.100 +    rts
   2.101 +
   2.102 +copy_title:
   2.103 +
   2.104 +    ldx #7
   2.105 +    ldy #127
   2.106 +
   2.107 +    copy_title_loop1:
   2.108 +
   2.109 +        copy_title_loop2:
   2.110 +
   2.111 +            lda ($70),y
   2.112 +            sta ($72),y
   2.113 +            dey
   2.114 +            cpy #255
   2.115 +            bne copy_title_loop2
   2.116 +
   2.117 +        dec $71
   2.118 +        dec $73
   2.119 +        dex
   2.120 +        bpl copy_title_loop1
   2.121 +
   2.122 +    rts
   2.123 +
   2.124 +copy_title_down:
   2.125 +
   2.126 +    lda #$80
   2.127 +    sta $70
   2.128 +    lda #$61
   2.129 +    sta $71
   2.130 +
   2.131 +    lda #$80
   2.132 +    sta $72
   2.133 +    lda #$1e
   2.134 +    sta $73
   2.135 +
   2.136 +    jmp copy_title  ; optimise away the rts
   2.137 +
   2.138 +copy_title_up:
   2.139 +
   2.140 +    lda #$80
   2.141 +    sta $70
   2.142 +    lda #$1e
   2.143 +    sta $71
   2.144 +
   2.145 +    lda #$80
   2.146 +    sta $72
   2.147 +    lda #$61
   2.148 +    sta $73
   2.149 +
   2.150 +    jmp copy_title  ; optimise away the rts
   2.151 +
   2.152 +move_completed_screen_down:
   2.153 +
   2.154 +    lda #$00
   2.155 +    sta $70
   2.156 +    lda #$62
   2.157 +    sta $71
   2.158 +
   2.159 +    lda #$00
   2.160 +    sta $72
   2.161 +    lda #$10
   2.162 +    sta $73
   2.163 +
   2.164 +    move_completed_screen_loop:
   2.165 +
   2.166 +        ldy #1
   2.167 +        lda ($70),y
   2.168 +        asl
   2.169 +        asl
   2.170 +        asl
   2.171 +        asl
   2.172 +        dey
   2.173 +        ora ($70),y
   2.174 +        sta ($72),y
   2.175 +
   2.176 +        lda #0
   2.177 +        sta ($70),y
   2.178 +        iny
   2.179 +        sta ($70),y
   2.180 +
   2.181 +        clc
   2.182 +        lda $70
   2.183 +        adc #2
   2.184 +        sta $70
   2.185 +        lda $71
   2.186 +        adc #0
   2.187 +        sta $71
   2.188 +        clc
   2.189 +        
   2.190 +        lda $72
   2.191 +        adc #1
   2.192 +        sta $72
   2.193 +        lda $73
   2.194 +        adc #0
   2.195 +        sta $73
   2.196 +        clc
   2.197 +
   2.198 +        lda $72
   2.199 +        cmp #$80
   2.200 +        bne move_completed_screen_loop
   2.201 +
   2.202 +        lda $73
   2.203 +        cmp #$17
   2.204 +        bne move_completed_screen_loop
   2.205 +
   2.206 +    rts
   2.207 +
   2.208 +copy_completed_screen_up:
   2.209 +
   2.210 +    lda #$00
   2.211 +    sta $70
   2.212 +    lda #$17
   2.213 +    sta $71
   2.214 +
   2.215 +    lda #$00
   2.216 +    sta $72
   2.217 +    lda #$69
   2.218 +    sta $73
   2.219 +
   2.220 +    jmp copy_title  ; optimise away the rts
   2.221 +
   2.222  sprites_file_name: .byte "SPRITES", 13
   2.223  chars_file_name: .byte "CHARS", 13
   2.224 +title_file_name: .byte "TITLE", 13
   2.225  
   2.226  sprites_block: .byte <sprites_file_name, >sprites_file_name
   2.227                 .byte 0, $53, 0, 0
   2.228 @@ -4106,17 +4270,16 @@
   2.229                 .byte $80, $12, 0, 0
   2.230                 .byte $80, $50, 0, 0
   2.231  
   2.232 +title_block: .byte <title_file_name, >title_file_name
   2.233 +               .byte $80, $5a, 0, 0
   2.234 +               .byte $80, $5a, 0, 0
   2.235 +               .byte $80, $16, 0, 0
   2.236 +               .byte $00, $71, 0, 0
   2.237 +
   2.238 +init_load_window_vdu_bytes: .byte 28,0,29,19,24
   2.239 +init_clear_window_vdu_bytes: .byte 28,0,31,19,0
   2.240 +
   2.241  init:
   2.242 -    lda #255
   2.243 -    ldx #<sprites_block
   2.244 -    ldy #>sprites_block
   2.245 -    jsr $ffdd
   2.246 -
   2.247 -    lda #255
   2.248 -    ldx #<chars_block
   2.249 -    ldy #>chars_block
   2.250 -    jsr $ffdd
   2.251 -
   2.252      lda #22         ; MODE 5
   2.253      jsr $ffee
   2.254      lda #5
   2.255 @@ -4133,14 +4296,109 @@
   2.256          dex
   2.257          bpl cursor_loop
   2.258  
   2.259 +    jsr set_hidden_palette
   2.260 +
   2.261 +    ldx #0
   2.262 +    init_load_window_loop:
   2.263 +
   2.264 +        lda init_load_window_vdu_bytes,x
   2.265 +        jsr $ffee
   2.266 +        inx
   2.267 +        cpx #5
   2.268 +        bne init_load_window_loop
   2.269 +
   2.270 +    lda #255
   2.271 +    ldx #<title_block
   2.272 +    ldy #>title_block
   2.273 +    jsr $ffdd
   2.274 +
   2.275 +    lda #255
   2.276 +    ldx #<sprites_block
   2.277 +    ldy #>sprites_block
   2.278 +    jsr $ffdd
   2.279 +
   2.280 +    lda #255
   2.281 +    ldx #<chars_block
   2.282 +    ldy #>chars_block
   2.283 +    jsr $ffdd
   2.284 +
   2.285 +    ; Copy the title screen to a lower address in memory.
   2.286 +    jsr copy_title_down
   2.287 +
   2.288 +    ; Move the completed screen down in memory, decoding it.
   2.289 +    jsr move_completed_screen_down
   2.290 +
   2.291 +    lda #12     ; clear the text window
   2.292 +    jsr $ffee
   2.293 +
   2.294 +    lda #26     ; unset the text window
   2.295 +    jsr $ffee
   2.296 +
   2.297 +    ; Define ENVELOPEs.
   2.298 +    lda #0
   2.299 +    sta $70
   2.300 +    define_envelopes_loop:
   2.301 +
   2.302 +        lda $70
   2.303 +        tax
   2.304 +        lda envelopes_high,x
   2.305 +        tay
   2.306 +        lda envelopes_low,x
   2.307 +        tax
   2.308 +        lda #8
   2.309 +        jsr $fff1
   2.310 +
   2.311 +        inc $70
   2.312 +        lda $70
   2.313 +        cmp #1
   2.314 +        bne define_envelopes_loop
   2.315 +
   2.316      rts
   2.317  
   2.318 -title_vdu_bytes:    .byte 12, 17,2, 31,4,27, "Press SPACE", 31,7,28, "to play"
   2.319 -title_vdu_bytes1:   .byte 17,3, 31,1,30, "     (c) 2011     "
   2.320 -title_vdu_bytes2:   .byte 17,3, 31,1,30, "   David Boddie"
   2.321 +envelopes_low:  .byte <explosion_envelope, <damage_envelope, <item_envelope
   2.322 +envelopes_high: .byte >explosion_envelope, >damage_envelope, >item_envelope
   2.323 +
   2.324 +explosion_envelope: .byte 1,1,252,0,0,10,0,0,126,0,0,130,126,126
   2.325 +damage_envelope:    .byte 2,4,8,0,248,2,0,2,126,0,0,130,126,126
   2.326 +item_envelope:      .byte 3,2,2,254,1,4,4,2,126,0,0,130,126,126
   2.327 +
   2.328 +title_vdu_bytes:    .byte 17,2, 31,4,27, "Press SPACE", 31,7,28, "to play"
   2.329 +title_vdu_bytes1:   .byte 17,3, 31,1,30, "Copyright (c) 2011"
   2.330 +title_vdu_bytes2:   .byte 17,3, 31,1,30, "   David Boddie   "
   2.331  title_vdu_bytes3:   .byte 17,1, 31,1,30, "for Retro Software"
   2.332 -
   2.333 -show_title:
   2.334 +title_vdu_bytes4:   .byte 17,3, 31,1,30, "GNU GPL 3 or later"
   2.335 +
   2.336 +set_standard_palette:
   2.337 +
   2.338 +    lda #1
   2.339 +    sta $70
   2.340 +    lda #1
   2.341 +    sta $71
   2.342 +    jsr set_palette
   2.343 +
   2.344 +    jmp set_core_palette    ; optimise away the rts
   2.345 +
   2.346 +set_complete_palette:
   2.347 +
   2.348 +    lda #1
   2.349 +    sta $70
   2.350 +    lda #4
   2.351 +    sta $71
   2.352 +    jsr set_palette
   2.353 +
   2.354 +    jmp set_core_palette    ; optimise away the rts
   2.355 +
   2.356 +set_hidden_palette:
   2.357 +
   2.358 +    lda #1
   2.359 +    sta $70
   2.360 +    lda #0
   2.361 +    sta $71
   2.362 +    jsr set_palette
   2.363 +
   2.364 +    ; Run on into the next routine.
   2.365 +
   2.366 +set_core_palette:
   2.367  
   2.368      lda #2
   2.369      sta $70
   2.370 @@ -4154,6 +4412,12 @@
   2.371      sta $71
   2.372      jsr set_palette
   2.373  
   2.374 +    rts
   2.375 +
   2.376 +show_title:
   2.377 +
   2.378 +    jsr set_standard_palette
   2.379 +
   2.380      ldx #0
   2.381      write_title_text_loop:
   2.382          lda title_vdu_bytes,x
   2.383 @@ -4162,6 +4426,9 @@
   2.384          cpx #27
   2.385          bmi write_title_text_loop
   2.386  
   2.387 +    ; Show the title.
   2.388 +    jsr copy_title_up
   2.389 +
   2.390      lda #0
   2.391      sta $72
   2.392  
   2.393 @@ -4175,13 +4442,13 @@
   2.394          ldy #22
   2.395          show_title_wait_message_loop:
   2.396  
   2.397 -            lda title_vdu_bytes1, x
   2.398 +            lda title_vdu_bytes1,x
   2.399              jsr $ffee
   2.400              inx
   2.401              dey
   2.402              bpl show_title_wait_message_loop
   2.403  
   2.404 -        cpx #69
   2.405 +        cpx #92
   2.406          beq show_title_wait_reset_offset
   2.407  
   2.408          txa
   2.409 @@ -4200,10 +4467,8 @@
   2.410          beq show_title_wait_loop
   2.411  
   2.412          show_title_wait_loop_no_update:
   2.413 -        lda #129
   2.414          ldx #157
   2.415 -        ldy #255
   2.416 -        jsr $fff4
   2.417 +        jsr check_key
   2.418          cpy #255
   2.419          bne show_title_wait_inner_loop
   2.420  
   2.421 @@ -4423,6 +4688,10 @@
   2.422          cpx #25
   2.423          bne end_of_level_text_loop2
   2.424  
   2.425 +    lda $3dfa
   2.426 +    cmp #3
   2.427 +    bpl show_end_of_level_screen_exit
   2.428 +
   2.429      lda #192    ; initialise delay counter
   2.430      sta $3df5
   2.431  
   2.432 @@ -4434,6 +4703,7 @@
   2.433          dec $3df5
   2.434          bne show_end_of_level_delay_loop2
   2.435  
   2.436 +    show_end_of_level_screen_exit:
   2.437      rts
   2.438  
   2.439  level_bonus_vdu_bytes: .byte 5,6,31, 1,17  ; reversed
   2.440 @@ -4477,8 +4747,53 @@
   2.441      clc
   2.442      rts
   2.443  
   2.444 +complete_game_vdu_bytes1: .byte 12
   2.445 +complete_game_vdu_bytes2: .byte 17,3, 31,2,20, "Congratulations!"
   2.446 +complete_game_vdu_bytes3: .byte 17,2, 31,1,22, "Now journey onward"
   2.447 +complete_game_vdu_bytes4: .byte 17,2, 31,1,24, "to a new adventure"
   2.448 +complete_game_vdu_bytes5: .byte 17,1, 31,4,27, "Press SPACE", 31,7,28, "to exit"
   2.449 +
   2.450  show_complete_game:
   2.451  
   2.452 +    ldx #0
   2.453 +    show_complete_game_vdu_loop:
   2.454 +
   2.455 +        lda complete_game_vdu_bytes1,x
   2.456 +        jsr $ffee
   2.457 +        inx
   2.458 +        cpx #68
   2.459 +        bne show_complete_game_vdu_loop
   2.460 +
   2.461 +    jsr copy_completed_screen_up
   2.462 +
   2.463 +    jsr set_complete_palette
   2.464 +
   2.465 +    lda #255
   2.466 +    sta $3df5
   2.467 +
   2.468 +    show_complete_game_delay_loop:
   2.469 +
   2.470 +        lda #19
   2.471 +        jsr $fff4
   2.472 +
   2.473 +        dec $3df5
   2.474 +        bne show_complete_game_no_message
   2.475 +
   2.476 +        ldx #0
   2.477 +        show_complete_game_message_loop:
   2.478 +
   2.479 +            lda complete_game_vdu_bytes5,x
   2.480 +            jsr $ffee
   2.481 +            inx
   2.482 +            cpx #26
   2.483 +            bne show_complete_game_message_loop
   2.484 +
   2.485 +        show_complete_game_no_message:
   2.486 +        ldx #157
   2.487 +        jsr check_key
   2.488 +        cpy #255
   2.489 +        bne show_complete_game_delay_loop
   2.490 +
   2.491      rts
   2.492  
   2.493  status_vdu_bytes: .byte 31,2,0, 17,3, "Score", 31,11,0, 17,2, "Strength", 17,1
   2.494 @@ -4504,7 +4819,7 @@
   2.495          bmi write_status_text_loop
   2.496  
   2.497      ; Set the level.
   2.498 -    lda #0
   2.499 +    lda #3
   2.500      sta $3dfa
   2.501  
   2.502      ; Set the score.
   2.503 @@ -4779,11 +5094,16 @@
   2.504  
   2.505              game_over:
   2.506              jsr show_game_over
   2.507 -            jmp main_loop
   2.508 +            jmp main_loop_play_again
   2.509  
   2.510              complete_game:
   2.511 +            jsr show_end_of_level_screen
   2.512              jsr show_complete_game
   2.513 -            jmp main_loop
   2.514 +            jmp main_loop_play_again
   2.515 +
   2.516 +        main_loop_play_again:
   2.517 +        lda #12
   2.518 +        jsr $ffee
   2.519  
   2.520          jmp main_loop
   2.521  
     3.1 --- a/tools/makesprites.py	Sun Sep 04 01:37:55 2011 +0200
     3.2 +++ b/tools/makesprites.py	Sun Sep 04 01:38:57 2011 +0200
     3.3 @@ -157,6 +157,9 @@
     3.4           read_xpm("images/finalexitr.xpm", [(".", "0"), ("#", "1"), ("+", "2"), ("@", "3")]),
     3.5           ]
     3.6  
     3.7 +title = read_xpm("images/title-screen.xpm")
     3.8 +
     3.9 +completed = read_xpm("images/complete-screen.xpm", [(".", "0"), ("@", "1"), ("+", "2"), ("#", "3")])
    3.10  
    3.11  def read_sprite(lines):
    3.12  
    3.13 @@ -248,3 +251,13 @@
    3.14          data += read_sprite(lines)
    3.15      
    3.16      return data
    3.17 +
    3.18 +def encode(data):
    3.19 +
    3.20 +    new_data = ""
    3.21 +    for c in data:
    3.22 +    
    3.23 +        i = ord(c)
    3.24 +        new_data += chr(i & 0x0f) + chr((i & 0xf0) >> 4)
    3.25 +    
    3.26 +    return new_data