diff options
-rw-r--r-- | defender.ca65 | 449 | ||||
-rw-r--r-- | defender.info | 75 |
2 files changed, 324 insertions, 200 deletions
diff --git a/defender.ca65 b/defender.ca65 index ea33929..087c7bf 100644 --- a/defender.ca65 +++ b/defender.ca65 @@ -1,5 +1,5 @@ ; da65 V2.16 - Git 6de78c5 -; Created: 2017-09-22 16:02:17 +; Created: 2017-09-22 19:39:56 ; Input file: defender.rom ; Page: 1 @@ -88,6 +88,7 @@ plosion_x := $0505 plosion_y := $0506 plosion_x_start := $0507 plosion_y_start := $0508 +leading_zero_flag:= $0510 ; bit 7 clear = skip leading zeroes in print_number. set = print leading zeroes ('01' instead of '1' cursor_line := $0512 ; cursor_x times 9, scanline where next char prints (range XXX) cur_line := $0513 ; current line of glyph being drawn, used by print_letter and draw_glyph last_line := $0514 ; last line of glyph being drawn, used by print_letter and draw_glyph @@ -280,13 +281,17 @@ title_screen_idle: jsr clear_screen ; 807F 20 A1 B8 .. jsr draw_scanner_border_and_planet ; 8082 20 B1 9F .. lda game_type ; 8085 A5 E1 .. - beq L808F ; 8087 F0 06 .. + beq tsi_text ; 8087 F0 06 .. jsr draw_p1_lives_and_bombs ; 8089 20 B0 86 .. jsr draw_p2_lives_and_bombs ; 808C 20 80 87 .. -L808F: jsr draw_title_text ; 808F 20 59 82 Y. -L8092: jsr show_game_type ; 8092 20 1F 81 .. -L8095: lda draw_ok_flag ; 8095 A5 AB .. - bpl L8095 ; 8097 10 FC .. +; play & fade the drone while we wait for the user to press select or start +tsi_text: + jsr draw_title_text ; 808F 20 59 82 Y. +tsi_show_gt: + jsr show_game_type ; 8092 20 1F 81 .. +tsi_wait_to_draw: + lda draw_ok_flag ; 8095 A5 AB .. + bpl tsi_wait_to_draw ; 8097 10 FC .. clc ; 8099 18 . ; rotate colors update_title_colors: @@ -294,7 +299,7 @@ update_title_colors: adc #$10 ; 809D 69 10 i. sta COLOR0 ; 809F 8D C4 02 ... lda drone_volume ; 80A2 A5 BD .. - beq title_fx_ok ; 80A4 F0 11 .. + beq tsi_check_start ; 80A4 F0 11 .. ; alter the drone sound's pitch update_title_sfx: sec ; 80A6 38 8 @@ -307,22 +312,23 @@ update_title_sfx: ora #$A0 ; 80AF 09 A0 .. sta AUDC3 ; 80B1 8D 05 D2 ... sta AUDC4 ; 80B4 8D 07 D2 ... -title_fx_ok: +tsi_check_start: lda #$FF ; 80B7 A9 FF .. sta pause_flag ; 80B9 85 AF .. - jsr check_consol ; 80BB 20 A0 BA .. + jsr read_consol ; 80BB 20 A0 BA .. lda start_flag ; 80BE A5 BE .. bmi start_game ; 80C0 30 3E 0> lda select_flag ; 80C2 A5 B0 .. - bpl L8092 ; 80C4 10 CC .. + bpl tsi_show_gt ; 80C4 10 CC .. lda #$03 ; 80C6 A9 03 .. -L80C8: pha ; 80C8 48 H +tsi_delay: + pha ; 80C8 48 H lda #$FF ; 80C9 A9 FF .. jsr delay_loop ; 80CB 20 74 88 t. pla ; 80CE 68 h sec ; 80CF 38 8 sbc #$01 ; 80D0 E9 01 .. - bne L80C8 ; 80D2 D0 F4 .. + bne tsi_delay ; 80D2 D0 F4 .. lda #$00 ; 80D4 A9 00 .. sta select_flag ; 80D6 85 B0 .. sta ATRACT ; 80D8 85 4D .M @@ -385,12 +391,14 @@ show_game_type: lda #$00 ; 8136 A9 00 .. sta cursor_x ; 8138 8D 39 14 .9. ldy #$00 ; 813B A0 00 .. -L813D: lda (tmp_ptr),y ; 813D B1 E7 .. - beq L8147 ; 813F F0 06 .. +sgt_nextchar: + lda (tmp_ptr),y ; 813D B1 E7 .. + beq sgt_done ; 813F F0 06 .. jsr printchar ; 8141 20 2E 97 .. iny ; 8144 C8 . - bne L813D ; 8145 D0 F6 .. -L8147: rts ; 8147 60 ` + bne sgt_nextchar ; 8145 D0 F6 .. +sgt_done: + rts ; 8147 60 ` ; ---------------------------------------------------------------------------- ; the strings these point to are 37 characters long, null-terminated, ASCII with high bit set (this game was ported from the Apple II, where ASCII normally has the high bit set) @@ -571,7 +579,7 @@ game_on:jsr init_drone ; 8369 20 79 8D lda #$FF ; 83C0 A9 FF .. sta $F4 ; 83C2 85 F4 .. lsr $F7 ; 83C4 46 F7 F. - jmp L845B ; 83C6 4C 5B 84 L[. + jmp clear_enemy_explosions ; 83C6 4C 5B 84 L[. ; ---------------------------------------------------------------------------- ; notice the check against $64? that's why we get stuck on level 99 over & over again @@ -602,12 +610,13 @@ nl_drone: jsr clear_scanner_draw_planet_and_humans; 83F0 20 5E 9E ^. jsr draw_scanner_border_and_planet ; 83F3 20 B1 9F .. lda #$10 ; 83F6 A9 10 .. -L83F8: pha ; 83F8 48 H - jsr draw_starfield ; 83F9 20 32 A8 2. +nl_next_stars: + pha ; 83F8 48 H + jsr animate_starfield ; 83F9 20 32 A8 2. pla ; 83FC 68 h sec ; 83FD 38 8 sbc #$01 ; 83FE E9 01 .. - bne L83F8 ; 8400 D0 F6 .. + bne nl_next_stars ; 8400 D0 F6 .. jsr print_end_level_msg ; 8402 20 42 96 B. jsr draw_scores ; 8405 20 42 94 B. inc lives ; 8408 E6 9E .. @@ -615,13 +624,14 @@ L83F8: pha ; 83F8 48 dec lives ; 840D C6 9E .. jsr draw_p2_lives_and_bombs ; 840F 20 80 87 .. lda #$1E ; 8412 A9 1E .. -L8414: pha ; 8414 48 H +nl_delay: + pha ; 8414 48 H lda #$FF ; 8415 A9 FF .. jsr delay_loop ; 8417 20 74 88 t. pla ; 841A 68 h sec ; 841B 38 8 sbc #$01 ; 841C E9 01 .. - bne L8414 ; 841E D0 F4 .. + bne nl_delay ; 841E D0 F4 .. lda lives ; 8420 A5 9E .. bne level_cleared ; 8422 D0 03 .. jmp out_of_lives ; 8424 4C 0E B7 L.. @@ -654,24 +664,30 @@ dont_repopulate: sta $98 ; 8450 85 98 .. sta $A6 ; 8452 85 A6 .. bit $F7 ; 8454 24 F7 $. - bpl L845B ; 8456 10 03 .. + bpl clear_enemy_explosions ; 8456 10 03 .. jmp LB6D1 ; 8458 4C D1 B6 L.. ; ---------------------------------------------------------------------------- -L845B: ldy #$00 ; 845B A0 00 .. +clear_enemy_explosions: + ldy #$00 ; 845B A0 00 .. lda #$00 ; 845D A9 00 .. -L845F: sta enemy_explosion_table,y ; 845F 99 2B 05 .+. +cex_loop: + sta enemy_explosion_table,y ; 845F 99 2B 05 .+. iny ; 8462 C8 . - bpl L845F ; 8463 10 FA .. -L8465: jsr clear_screen ; 8465 20 A1 B8 .. + bpl cex_loop ; 8463 10 FA .. +; clean up game state, show prompt if in 2p mode +prep_next_level: + jsr clear_screen ; 8465 20 A1 B8 .. lda #$00 ; 8468 A9 00 .. sta $A4 ; 846A 85 A4 .. lda TRIG0 ; 846C AD 10 D0 ... ldy current_player ; 846F A4 F1 .. cpy #$02 ; 8471 C0 02 .. - bne L8478 ; 8473 D0 03 .. + bne pnl_store_trig ; 8473 D0 03 .. lda TRIG1 ; 8475 AD 11 D0 ... -L8478: sta trigger ; 8478 85 A3 .. +; store either TRIG0 or TRIG1 +pnl_store_trig: + sta trigger ; 8478 85 A3 .. lda #$00 ; 847A A9 00 .. sta ship_delta ; 847C 85 D5 .. sta select_flag ; 847E 85 B0 .. @@ -688,10 +704,11 @@ L8478: sta trigger ; 8478 85 A3 sta ship_y_pos ; 8494 85 C4 .. ldy #$00 ; 8496 A0 00 .. lda #$00 ; 8498 A9 00 .. -L849A: sta player_shots_y,y ; 849A 99 1A 05 ... +pnl_clear_player_shots: + sta player_shots_y,y ; 849A 99 1A 05 ... iny ; 849D C8 . cpy #$10 ; 849E C0 10 .. - bcc L849A ; 84A0 90 F8 .. + bcc pnl_clear_player_shots ; 84A0 90 F8 .. jsr init_drone ; 84A2 20 79 8D y. lda #$7E ; 84A5 A9 7E .~ sta COLOR2 ; 84A7 8D C6 02 ... @@ -743,31 +760,37 @@ psd_loop: prompt_done: lda #$00 ; 84FF A9 00 .. sta ATRACT ; 8501 85 4D .M -L8503: jsr check_consol ; 8503 20 A0 BA .. +; handle start/select keys during gameplay (ignore if not paused) +check_consol: + jsr read_consol ; 8503 20 A0 BA .. bit select_flag ; 8506 24 B0 $. - bpl L8511 ; 8508 10 07 .. + bpl cc_chk_start ; 8508 10 07 .. bit pause_flag ; 850A 24 AF $. - bpl L852A ; 850C 10 1C .. + bpl check_paused ; 850C 10 1C .. jmp init_title_screen ; 850E 4C 31 80 L1. ; ---------------------------------------------------------------------------- -L8511: bit start_flag ; 8511 24 BE $. - bpl L852A ; 8513 10 15 .. +cc_chk_start: + bit start_flag ; 8511 24 BE $. + bpl check_paused ; 8513 10 15 .. bit pause_flag ; 8515 24 AF $. - bpl L852A ; 8517 10 11 .. + bpl check_paused ; 8517 10 11 .. jmp game_on ; 8519 4C 69 83 Li. ; ---------------------------------------------------------------------------- -L851C: lda game_type ; 851C A5 E1 .. - bne L852A ; 851E D0 0A .. - jsr L895C ; 8520 20 5C 89 \. +; in demo mode, pressing any key returns to the title screen +cc_chk_keyboard: + lda game_type ; 851C A5 E1 .. + bne check_paused ; 851E D0 0A .. + jsr draw_demo_text ; 8520 20 5C 89 \. lda last_kbcode ; 8523 A5 E0 .. - beq L852A ; 8525 F0 03 .. + beq check_paused ; 8525 F0 03 .. jmp init_title_screen ; 8527 4C 31 80 L1. ; ---------------------------------------------------------------------------- -L852A: bit pause_flag ; 852A 24 AF $. - bmi L8503 ; 852C 30 D5 0. +check_paused: + bit pause_flag ; 852A 24 AF $. + bmi check_consol ; 852C 30 D5 0. inc $D4 ; 852E E6 D4 .. lda $D4 ; 8530 A5 D4 .. and #$3F ; 8532 29 3F )? @@ -775,13 +798,16 @@ L852A: bit pause_flag ; 852A 24 AF jsr clear_scanner_draw_planet_and_humans; 8536 20 5E 9E ^. jsr smartbomb_check ; 8539 20 8A 8B .. jsr LAC18 ; 853C 20 18 AC .. -L853F: bit draw_ok_flag ; 853F 24 AB $. - bpl L853F ; 8541 10 FC .. +wait_draw_ok: + bit draw_ok_flag ; 853F 24 AB $. + bpl wait_draw_ok ; 8541 10 FC .. jsr LA4CC ; 8543 20 CC A4 .. inc level_jiffies_lo ; 8546 E6 87 .. - bne L854C ; 8548 D0 02 .. + bne check_spawn ; 8548 D0 02 .. inc level_jiffies_hi ; 854A E6 F6 .. -L854C: lda level_jiffies_lo ; 854C A5 87 .. +; see if it's time to spawn a lander wave or a baiter yet +check_spawn: + lda level_jiffies_lo ; 854C A5 87 .. and #$3F ; 854E 29 3F )? bne L8558 ; 8550 D0 06 .. jsr spawn_lander_wave ; 8552 20 98 AE .. @@ -802,7 +828,7 @@ L8558: lda $D4 ; 8558 A5 D4 lda level_jiffies_lo ; 8573 A5 87 .. and #$08 ; 8575 29 08 ). bne L857F ; 8577 D0 06 .. - jsr flash_score ; 8579 20 BC 93 .. + jsr clear_score ; 8579 20 BC 93 .. jmp L8582 ; 857C 4C 82 85 L.. ; ---------------------------------------------------------------------------- @@ -810,7 +836,7 @@ L857F: jsr draw_scores ; 857F 20 42 94 L8582: lda $D4 ; 8582 A5 D4 .. and #$07 ; 8584 29 07 ). bne L858B ; 8586 D0 03 .. - jsr draw_starfield ; 8588 20 32 A8 2. + jsr animate_starfield ; 8588 20 32 A8 2. L858B: lda $D4 ; 858B A5 D4 .. clc ; 858D 18 . adc #$B3 ; 858E 69 B3 i. @@ -831,7 +857,7 @@ L85AA: jsr update_player_shots ; 85AA 20 17 9A lda $D4 ; 85B0 A5 D4 .. and #$07 ; 85B2 29 07 ). beq L85B9 ; 85B4 F0 03 .. - jmp L851C ; 85B6 4C 1C 85 L.. + jmp cc_chk_keyboard ; 85B6 4C 1C 85 L.. ; ---------------------------------------------------------------------------- L85B9: jsr erase_scanner_ship ; 85B9 20 0C A2 .. @@ -881,7 +907,7 @@ L8603: clc ; 8603 18 jsr draw_ship ; 8610 20 A1 B5 .. jsr ship_exhaust ; 8613 20 86 99 .. jsr draw_scanner_ship ; 8616 20 93 A1 .. - jmp L851C ; 8619 4C 1C 85 L.. + jmp cc_chk_keyboard ; 8619 4C 1C 85 L.. ; ---------------------------------------------------------------------------- ; TRIG0 or 1 depending on which player is playing @@ -1261,7 +1287,7 @@ hyperspace_pressed: lda #$10 ; 8897 A9 10 .. hsp_loop: pha ; 8899 48 H - jsr draw_starfield ; 889A 20 32 A8 2. + jsr animate_starfield ; 889A 20 32 A8 2. pla ; 889D 68 h sec ; 889E 38 8 sbc #$01 ; 889F E9 01 .. @@ -1296,96 +1322,108 @@ demo_logic: sta ship_delta ; 88C6 85 D5 .. lda ship_move_delay ; 88C8 A5 93 .. and #$03 ; 88CA 29 03 ). - beq L88D1 ; 88CC F0 03 .. + beq dl_check_move ; 88CC F0 03 .. jsr inertia_logic ; 88CE 20 81 86 .. -L88D1: inc ship_move_delay ; 88D1 E6 93 .. +; is it time to move the ship? +dl_check_move: + inc ship_move_delay ; 88D1 E6 93 .. lda ship_move_delay ; 88D3 A5 93 .. and #$03 ; 88D5 29 03 ). - beq L892B ; 88D7 F0 52 .R + beq dl_check_hyper ; 88D7 F0 52 .R lda #$00 ; 88D9 A9 00 .. sta $98 ; 88DB 85 98 .. -L88DD: ldy $98 ; 88DD A4 98 .. +dl_vert_move: + ldy $98 ; 88DD A4 98 .. lda sprite_list,y ; 88DF B9 EB 0A ... - bne L88F0 ; 88E2 D0 0C .. -L88E4: lda $98 ; 88E4 A5 98 .. + bne dl_vert_delta ; 88E2 D0 0C .. +dl_vm_next: + lda $98 ; 88E4 A5 98 .. clc ; 88E6 18 . adc #$04 ; 88E7 69 04 i. sta $98 ; 88E9 85 98 .. - bpl L88DD ; 88EB 10 F0 .. + bpl dl_vert_move ; 88EB 10 F0 .. jmp L8603 ; 88ED 4C 03 86 L.. ; ---------------------------------------------------------------------------- -L88F0: lda sprite_list+3,y ; 88F0 B9 EE 0A ... +; move the ship up or down, towards the sprite we're considering. actual movement ends up as the sum of all the calls here +dl_vert_delta: + lda sprite_list+3,y ; 88F0 B9 EE 0A ... and #$07 ; 88F3 29 07 ). - beq L88E4 ; 88F5 F0 ED .. + beq dl_vm_next ; 88F5 F0 ED .. cmp #$03 ; 88F7 C9 03 .. - beq L88E4 ; 88F9 F0 E9 .. + beq dl_vm_next ; 88F9 F0 E9 .. cmp #$07 ; 88FB C9 07 .. - beq L88E4 ; 88FD F0 E5 .. + beq dl_vm_next ; 88FD F0 E5 .. lda sprite_list,y ; 88FF B9 EB 0A ... cmp ship_y_pos ; 8902 C5 C4 .. ror a ; 8904 6A j eor #$FF ; 8905 49 FF I. sta $F3 ; 8907 85 F3 .. bit $F3 ; 8909 24 F3 $. - bpl L891C ; 890B 10 0F .. + bpl dl_down ; 890B 10 0F .. dec ship_y_pos ; 890D C6 C4 .. lda ship_y_pos ; 890F A5 C4 .. cmp #$20 ; 8911 C9 20 . - bcs L8959 ; 8913 B0 44 .D + bcs dl_done ; 8913 B0 44 .D lda #$20 ; 8915 A9 20 . sta ship_y_pos ; 8917 85 C4 .. jmp L8603 ; 8919 4C 03 86 L.. ; ---------------------------------------------------------------------------- -L891C: inc ship_y_pos ; 891C E6 C4 .. +; move the ship down +dl_down:inc ship_y_pos ; 891C E6 C4 .. lda ship_y_pos ; 891E A5 C4 .. cmp #$A0 ; 8920 C9 A0 .. - bcc L8959 ; 8922 90 35 .5 + bcc dl_done ; 8922 90 35 .5 lda #$A0 ; 8924 A9 A0 .. sta ship_y_pos ; 8926 85 C4 .. jmp L8603 ; 8928 4C 03 86 L.. ; ---------------------------------------------------------------------------- -L892B: lda level_jiffies_lo ; 892B A5 87 .. - beq L894C ; 892D F0 1D .. +dl_check_hyper: + lda level_jiffies_lo ; 892B A5 87 .. + beq dl_hyperspace ; 892D F0 1D .. lda enemy_count ; 892F A5 9C .. cmp #$08 ; 8931 C9 08 .. - bcs L8952 ; 8933 B0 1D .. + bcs dl_smartbomb ; 8933 B0 1D .. lda RANDOM ; 8935 AD 0A D2 ... and #$07 ; 8938 29 07 ). - bne L8959 ; 893A D0 1D .. + bne dl_done ; 893A D0 1D .. bit planet_dead_flag ; 893C 24 A0 $. - bmi L8946 ; 893E 30 06 0. + bmi dl_trigger ; 893E 30 06 0. lda ship_y_pos ; 8940 A5 C4 .. cmp #$90 ; 8942 C9 90 .. - bcs L8959 ; 8944 B0 13 .. -L8946: jsr handle_trigger ; 8946 20 D0 99 .. - jmp L8959 ; 8949 4C 59 89 LY. + bcs dl_done ; 8944 B0 13 .. +dl_trigger: + jsr handle_trigger ; 8946 20 D0 99 .. + jmp dl_done ; 8949 4C 59 89 LY. ; ---------------------------------------------------------------------------- -L894C: sec ; 894C 38 8 +dl_hyperspace: + sec ; 894C 38 8 ror hyperspace_flag ; 894D 66 AE f. - jmp L8959 ; 894F 4C 59 89 LY. + jmp dl_done ; 894F 4C 59 89 LY. ; ---------------------------------------------------------------------------- -L8952: sec ; 8952 38 8 +dl_smartbomb: + sec ; 8952 38 8 ror spacebar_flag ; 8953 66 AC f. lda #$00 ; 8955 A9 00 .. sta enemy_count ; 8957 85 9C .. -L8959: jmp L8603 ; 8959 4C 03 86 L.. +dl_done:jmp L8603 ; 8959 4C 03 86 L.. ; ---------------------------------------------------------------------------- -L895C: lda $D4 ; 895C A5 D4 .. +; draw the text for DEFENDER c 1982 ATARI, during the demo game +draw_demo_text: + lda $D4 ; 895C A5 D4 .. and #$3F ; 895E 29 3F )? - beq draw_demo_text ; 8960 F0 01 .. + beq ddt_draw ; 8960 F0 01 .. rts ; 8962 60 ` ; ---------------------------------------------------------------------------- -; draw the text for DEFENDER c 1982 ATARI, during the demo game -draw_demo_text: +ddt_draw: lda draw_ok_flag ; 8963 A5 AB .. - bpl L895C ; 8965 10 F5 .. + bpl draw_demo_text ; 8965 10 F5 .. lda #$01 ; 8967 A9 01 .. sta cursor_x ; 8969 8D 39 14 .9. lda #$14 ; 896C A9 14 .. @@ -1398,12 +1436,14 @@ draw_demo_text: lda L89B5,y ; 8979 B9 B5 89 ... sta glyph_color_mask ; 897C 85 EE .. ldy #$00 ; 897E A0 00 .. -L8980: lda demo_text,y ; 8980 B9 8F 89 ... - beq L898B ; 8983 F0 06 .. +ddt_nextchar: + lda demo_text,y ; 8980 B9 8F 89 ... + beq ddt_done ; 8983 F0 06 .. jsr printchar ; 8985 20 2E 97 .. iny ; 8988 C8 . - bne L8980 ; 8989 D0 F5 .. -L898B: pla ; 898B 68 h + bne ddt_nextchar ; 8989 D0 F5 .. +ddt_done: + pla ; 898B 68 h sta glyph_color_mask ; 898C 85 EE .. rts ; 898E 60 ` @@ -1420,17 +1460,19 @@ L89B5: .byte $FF,$AA,$FF,$55 ; 89B5 FF AA FF 55 ; save game state to p1_sav_* area save_p1_state: ldx #$00 ; 89B9 A2 00 .. -L89BB: cpx #$80 ; 89BB E0 80 .. - bcs L89CB ; 89BD B0 0C .. +sp1_loop: + cpx #$80 ; 89BB E0 80 .. + bcs sp1_skip ; 89BD B0 0C .. lda sprite_list,x ; 89BF BD EB 0A ... sta p1_sav_sprite_list,x ; 89C2 9D 00 16 ... lda sprite_list+128,x ; 89C5 BD 6B 0B .k. sta p1_sav_sprite_list+128,x ; 89C8 9D 80 16 ... -L89CB: lda actor_list,x ; 89CB BD 6B 0C .k. +sp1_skip: + lda actor_list,x ; 89CB BD 6B 0C .k. sta $1700,x ; 89CE 9D 00 17 ... inx ; 89D1 E8 . cpx #$C0 ; 89D2 E0 C0 .. - bcc L89BB ; 89D4 90 E5 .. + bcc sp1_loop ; 89D4 90 E5 .. lda score ; 89D6 AD 2F 14 ./. sta p1_sav_score ; 89D9 8D C0 17 ... lda score+1 ; 89DC AD 30 14 .0. @@ -1457,17 +1499,19 @@ L89CB: lda actor_list,x ; 89CB BD 6B 0C ; save game state to p2_sav_* area save_p2_state: ldx #$00 ; 8A0D A2 00 .. -L8A0F: cpx #$80 ; 8A0F E0 80 .. - bcs L8A1F ; 8A11 B0 0C .. +sp2_loop: + cpx #$80 ; 8A0F E0 80 .. + bcs sp2_skip ; 8A11 B0 0C .. lda sprite_list,x ; 8A13 BD EB 0A ... sta p2_sav_sprite_list,x ; 8A16 9D 00 18 ... lda sprite_list+128,x ; 8A19 BD 6B 0B .k. sta p2_sav_sprite_list+128,x ; 8A1C 9D 80 18 ... -L8A1F: lda actor_list,x ; 8A1F BD 6B 0C .k. +sp2_skip: + lda actor_list,x ; 8A1F BD 6B 0C .k. sta $1900,x ; 8A22 9D 00 19 ... inx ; 8A25 E8 . cpx #$C0 ; 8A26 E0 C0 .. - bcc L8A0F ; 8A28 90 E5 .. + bcc sp2_loop ; 8A28 90 E5 .. lda score ; 8A2A AD 2F 14 ./. sta p2_sav_score ; 8A2D 8D C0 19 ... lda score+1 ; 8A30 AD 30 14 .0. @@ -1494,17 +1538,19 @@ L8A1F: lda actor_list,x ; 8A1F BD 6B 0C ; restore game state from p1_sav_* area load_p1_state: ldx #$00 ; 8A61 A2 00 .. -L8A63: cpx #$80 ; 8A63 E0 80 .. - bcs L8A73 ; 8A65 B0 0C .. +lp1_loop: + cpx #$80 ; 8A63 E0 80 .. + bcs lp1_skip ; 8A65 B0 0C .. lda p1_sav_sprite_list,x ; 8A67 BD 00 16 ... sta sprite_list,x ; 8A6A 9D EB 0A ... lda p1_sav_sprite_list+128,x ; 8A6D BD 80 16 ... sta sprite_list+128,x ; 8A70 9D 6B 0B .k. -L8A73: lda $1700,x ; 8A73 BD 00 17 ... +lp1_skip: + lda $1700,x ; 8A73 BD 00 17 ... sta actor_list,x ; 8A76 9D 6B 0C .k. inx ; 8A79 E8 . cpx #$C0 ; 8A7A E0 C0 .. - bcc L8A63 ; 8A7C 90 E5 .. + bcc lp1_loop ; 8A7C 90 E5 .. lda p1_sav_score ; 8A7E AD C0 17 ... sta score ; 8A81 8D 2F 14 ./. lda p1_sav_score+1 ; 8A84 AD C1 17 ... @@ -1531,17 +1577,19 @@ L8A73: lda $1700,x ; 8A73 BD 00 17 ; restore game state from p2_sav_* area load_p2_state: ldx #$00 ; 8AB5 A2 00 .. -L8AB7: cpx #$80 ; 8AB7 E0 80 .. - bcs L8AC7 ; 8AB9 B0 0C .. +lp2_loop: + cpx #$80 ; 8AB7 E0 80 .. + bcs lp2_skip ; 8AB9 B0 0C .. lda p2_sav_sprite_list,x ; 8ABB BD 00 18 ... sta sprite_list,x ; 8ABE 9D EB 0A ... lda p2_sav_sprite_list+128,x ; 8AC1 BD 80 18 ... sta sprite_list+128,x ; 8AC4 9D 6B 0B .k. -L8AC7: lda $1900,x ; 8AC7 BD 00 19 ... +lp2_skip: + lda $1900,x ; 8AC7 BD 00 19 ... sta actor_list,x ; 8ACA 9D 6B 0C .k. inx ; 8ACD E8 . cpx #$C0 ; 8ACE E0 C0 .. - bcc L8AB7 ; 8AD0 90 E5 .. + bcc lp2_loop ; 8AD0 90 E5 .. lda p2_sav_score ; 8AD2 AD C0 19 ... sta score ; 8AD5 8D 2F 14 ./. lda p2_sav_score+1 ; 8AD8 AD C1 19 ... @@ -1572,12 +1620,14 @@ print_p1_text: lda #$0A ; 8B0E A9 0A .. sta cursor_y ; 8B10 8D 3A 14 .:. ldy #$00 ; 8B13 A0 00 .. -L8B15: lda player_one_text,y ; 8B15 B9 21 8B .!. - beq L8B20 ; 8B18 F0 06 .. +pp1_next: + lda player_one_text,y ; 8B15 B9 21 8B .!. + beq pp1_done ; 8B18 F0 06 .. jsr printchar ; 8B1A 20 2E 97 .. iny ; 8B1D C8 . - bne L8B15 ; 8B1E D0 F5 .. -L8B20: rts ; 8B20 60 ` + bne pp1_next ; 8B1E D0 F5 .. +pp1_done: + rts ; 8B20 60 ` ; ---------------------------------------------------------------------------- ; ' P L A Y E R O N E' @@ -1594,12 +1644,14 @@ print_p2_text: lda #$0A ; 8B43 A9 0A .. sta cursor_y ; 8B45 8D 3A 14 .:. ldy #$00 ; 8B48 A0 00 .. -L8B4A: lda player_two_text,y ; 8B4A B9 56 8B .V. - beq L8B55 ; 8B4D F0 06 .. +pp2_next: + lda player_two_text,y ; 8B4A B9 56 8B .V. + beq pp2_done ; 8B4D F0 06 .. jsr printchar ; 8B4F 20 2E 97 .. iny ; 8B52 C8 . - bne L8B4A ; 8B53 D0 F5 .. -L8B55: rts ; 8B55 60 ` + bne pp2_next ; 8B53 D0 F5 .. +pp2_done: + rts ; 8B55 60 ` ; ---------------------------------------------------------------------------- ; ' P L A Y E R T W O' @@ -1616,11 +1668,12 @@ clear_prompt_text: lda #$0A ; 8B78 A9 0A .. sta cursor_y ; 8B7A 8D 3A 14 .:. ldy #$00 ; 8B7D A0 00 .. -L8B7F: lda #$A0 ; 8B7F A9 A0 .. +cpt_next_char: + lda #$A0 ; 8B7F A9 A0 .. jsr printchar ; 8B81 20 2E 97 .. iny ; 8B84 C8 . cpy #$28 ; 8B85 C0 28 .( - bcc L8B7F ; 8B87 90 F6 .. + bcc cpt_next_char ; 8B87 90 F6 .. rts ; 8B89 60 ` ; ---------------------------------------------------------------------------- @@ -1773,7 +1826,7 @@ L8C7C: pha ; 8C7C 48 lda $E6 ; 8C86 A5 E6 .. beq L8C9B ; 8C88 F0 11 .. L8C8A: pha ; 8C8A 48 H - jsr L8D0C ; 8C8B 20 0C 8D .. + jsr get_spawn_pos ; 8C8B 20 0C 8D .. lda #$06 ; 8C8E A9 06 .. sta current_sprite ; 8C90 85 F9 .. jsr add_to_sprite_list ; 8C92 20 A5 A4 .. @@ -1847,14 +1900,16 @@ get_random: rts ; 8D0B 60 ` ; ---------------------------------------------------------------------------- -L8D0C: jsr get_random ; 8D0C 20 F2 8C .. +; pick a random, valid spot +get_spawn_pos: + jsr get_random ; 8D0C 20 F2 8C .. and #$FE ; 8D0F 29 FE ). sta $DD ; 8D11 85 DD .. lda random_seed+1 ; 8D13 A5 C7 .. and #$01 ; 8D15 29 01 ). sta $DE ; 8D17 85 DE .. eor $92 ; 8D19 45 92 E. - beq L8D0C ; 8D1B F0 EF .. + beq get_spawn_pos ; 8D1B F0 EF .. jsr get_random ; 8D1D 20 F2 8C .. and #$1F ; 8D20 29 1F ). adc #$30 ; 8D22 69 30 i0 @@ -2320,68 +2375,73 @@ snd_planet_explode: .byte $1D,$8F,$1E,$8F,$1F,$8F,$20,$8F ; 93B2 1D 8F 1E 8F 1F 8F 20 8F ...... . .byte $20,$80 ; 93BA 20 80 . ; ---------------------------------------------------------------------------- -; flash the score of the current player -flash_score: +; print 7 spaces over the current player's score. used to flash the score of the current player +clear_score: lda #$01 ; 93BC A9 01 .. sta cursor_x ; 93BE 8D 39 14 .9. lda players ; 93C1 A5 E2 .. cmp #$01 ; 93C3 C9 01 .. - beq L93D2 ; 93C5 F0 0B .. + beq fs_set_y ; 93C5 F0 0B .. lda current_player ; 93C7 A5 F1 .. cmp #$01 ; 93C9 C9 01 .. - beq L93D2 ; 93CB F0 05 .. + beq fs_set_y ; 93CB F0 05 .. lda #$20 ; 93CD A9 20 . sta cursor_x ; 93CF 8D 39 14 .9. -L93D2: lda #$02 ; 93D2 A9 02 .. +fs_set_y: + lda #$02 ; 93D2 A9 02 .. sta cursor_y ; 93D4 8D 3A 14 .:. ldy #$07 ; 93D7 A0 07 .. -L93D9: lda #$A0 ; 93D9 A9 A0 .. +fs_next_char: + lda #$A0 ; 93D9 A9 A0 .. jsr printchar ; 93DB 20 2E 97 .. dey ; 93DE 88 . - bne L93D9 ; 93DF D0 F8 .. -L93E1: rts ; 93E1 60 ` + bne fs_next_char ; 93DF D0 F8 .. +fs_done:rts ; 93E1 60 ` ; ---------------------------------------------------------------------------- -L93E2: lda #$01 ; 93E2 A9 01 .. +; draw current player's score in 2p mode. does nothing in 1p mode! +draw_score_2p: + lda #$01 ; 93E2 A9 01 .. sta cursor_x ; 93E4 8D 39 14 .9. lda players ; 93E7 A5 E2 .. cmp #$01 ; 93E9 C9 01 .. - beq L93E1 ; 93EB F0 F4 .. + beq fs_done ; 93EB F0 F4 .. lda current_player ; 93ED A5 F1 .. cmp #$01 ; 93EF C9 01 .. - bne L93F8 ; 93F1 D0 05 .. + bne ds2_ok ; 93F1 D0 05 .. lda #$20 ; 93F3 A9 20 . sta cursor_x ; 93F5 8D 39 14 .9. -L93F8: lda #$02 ; 93F8 A9 02 .. +ds2_ok: lda #$02 ; 93F8 A9 02 .. sta cursor_y ; 93FA 8D 3A 14 .:. lda #$FF ; 93FD A9 FF .. sta glyph_color_mask ; 93FF 85 EE .. - lsr $0510 ; 9401 4E 10 05 N.. + lsr leading_zero_flag ; 9401 4E 10 05 N.. lda current_player ; 9404 A5 F1 .. cmp #$01 ; 9406 C9 01 .. - beq L9426 ; 9408 F0 1C .. + beq ds2p_p1 ; 9408 F0 1C .. lda p1_sav_score+3 ; 940A AD C3 17 ... - jsr draw_2_score_digits ; 940D 20 83 94 .. + jsr print_number ; 940D 20 83 94 .. lda p1_sav_score+2 ; 9410 AD C2 17 ... - jsr draw_2_score_digits ; 9413 20 83 94 .. + jsr print_number ; 9413 20 83 94 .. lda p1_sav_score+1 ; 9416 AD C1 17 ... - jsr draw_2_score_digits ; 9419 20 83 94 .. + jsr print_number ; 9419 20 83 94 .. sec ; 941C 38 8 - ror $0510 ; 941D 6E 10 05 n.. + ror leading_zero_flag ; 941D 6E 10 05 n.. lda p1_sav_score ; 9420 AD C0 17 ... - jmp draw_2_score_digits ; 9423 4C 83 94 L.. + jmp print_number ; 9423 4C 83 94 L.. ; ---------------------------------------------------------------------------- -L9426: lda p2_sav_score+3 ; 9426 AD C3 19 ... - jsr draw_2_score_digits ; 9429 20 83 94 .. +; draw player 1's score since he's the current player +ds2p_p1:lda p2_sav_score+3 ; 9426 AD C3 19 ... + jsr print_number ; 9429 20 83 94 .. lda p2_sav_score+2 ; 942C AD C2 19 ... - jsr draw_2_score_digits ; 942F 20 83 94 .. + jsr print_number ; 942F 20 83 94 .. lda p2_sav_score+1 ; 9432 AD C1 19 ... - jsr draw_2_score_digits ; 9435 20 83 94 .. + jsr print_number ; 9435 20 83 94 .. sec ; 9438 38 8 - ror $0510 ; 9439 6E 10 05 n.. + ror leading_zero_flag ; 9439 6E 10 05 n.. lda p2_sav_score ; 943C AD C0 19 ... - jmp draw_2_score_digits ; 943F 4C 83 94 L.. + jmp print_number ; 943F 4C 83 94 L.. ; ---------------------------------------------------------------------------- ; draw score digits in the HUDs for both players (but not lives nor smartbombs) @@ -2390,57 +2450,60 @@ draw_scores: sta cursor_x ; 9444 8D 39 14 .9. lda players ; 9447 A5 E2 .. cmp #$01 ; 9449 C9 01 .. - beq L9458 ; 944B F0 0B .. + beq dsc_ok ; 944B F0 0B .. lda current_player ; 944D A5 F1 .. cmp #$01 ; 944F C9 01 .. - beq L9458 ; 9451 F0 05 .. + beq dsc_ok ; 9451 F0 05 .. lda #$20 ; 9453 A9 20 . sta cursor_x ; 9455 8D 39 14 .9. -L9458: lda #$02 ; 9458 A9 02 .. +dsc_ok: lda #$02 ; 9458 A9 02 .. sta cursor_y ; 945A 8D 3A 14 .:. lda #$FF ; 945D A9 FF .. sta glyph_color_mask ; 945F 85 EE .. - lsr $0510 ; 9461 4E 10 05 N.. + lsr leading_zero_flag ; 9461 4E 10 05 N.. lda score+3 ; 9464 AD 32 14 .2. - jsr draw_2_score_digits ; 9467 20 83 94 .. + jsr print_number ; 9467 20 83 94 .. lda score+2 ; 946A AD 31 14 .1. - jsr draw_2_score_digits ; 946D 20 83 94 .. + jsr print_number ; 946D 20 83 94 .. lda score+1 ; 9470 AD 30 14 .0. - jsr draw_2_score_digits ; 9473 20 83 94 .. + jsr print_number ; 9473 20 83 94 .. sec ; 9476 38 8 - ror $0510 ; 9477 6E 10 05 n.. + ror leading_zero_flag ; 9477 6E 10 05 n.. lda score ; 947A AD 2F 14 ./. - jsr draw_2_score_digits ; 947D 20 83 94 .. - jmp L93E2 ; 9480 4C E2 93 L.. + jsr print_number ; 947D 20 83 94 .. + jmp draw_score_2p ; 9480 4C E2 93 L.. ; ---------------------------------------------------------------------------- -; called 4 times for the 4 bytes of score. does division by 10. -draw_2_score_digits: +; print number in A, at current cursor pos. range 0-99 (0-$63). does division by 10. suppress leading zeroes if leading_zero_flag is clear. +print_number: sta $0517 ; 9483 8D 17 05 ... ldy #$01 ; 9486 A0 01 .. -L9488: lda #$00 ; 9488 A9 00 .. +pn_div10: + lda #$00 ; 9488 A9 00 .. sta $0518 ; 948A 8D 18 05 ... -L948D: sec ; 948D 38 8 +pn_div10_loop: + sec ; 948D 38 8 lda $0517 ; 948E AD 17 05 ... sbc power_10_table,y ; 9491 F9 07 95 ... - bcc L949E ; 9494 90 08 .. + bcc pn_div10_ok ; 9494 90 08 .. sta $0517 ; 9496 8D 17 05 ... inc $0518 ; 9499 EE 18 05 ... - bne L948D ; 949C D0 EF .. -L949E: lda $0518 ; 949E AD 18 05 ... + bne pn_div10_loop ; 949C D0 EF .. +pn_div10_ok: + lda $0518 ; 949E AD 18 05 ... asl a ; 94A1 0A . asl a ; 94A2 0A . asl a ; 94A3 0A . sta glyph_offset ; 94A4 8D 16 05 ... - bit $0510 ; 94A7 2C 10 05 ,.. - bmi L94B5 ; 94AA 30 09 0. + bit leading_zero_flag ; 94A7 2C 10 05 ,.. + bmi pn_draw ; 94AA 30 09 0. lda glyph_offset ; 94AC AD 16 05 ... - beq L94B8 ; 94AF F0 07 .. + beq pn_skip ; 94AF F0 07 .. sec ; 94B1 38 8 - ror $0510 ; 94B2 6E 10 05 n.. -L94B5: jsr draw_glyph ; 94B5 20 BC 94 .. -L94B8: dey ; 94B8 88 . - bpl L9488 ; 94B9 10 CD .. + ror leading_zero_flag ; 94B2 6E 10 05 n.. +pn_draw:jsr draw_glyph ; 94B5 20 BC 94 .. +pn_skip:dey ; 94B8 88 . + bpl pn_div10 ; 94B9 10 CD .. rts ; 94BB 60 ` ; ---------------------------------------------------------------------------- @@ -2480,7 +2543,7 @@ dg_next_line: rts ; 9506 60 ` ; ---------------------------------------------------------------------------- -; 1, 10, 100 aka 10*0, 10*1, 10*2. used by draw_2_score_digits. last byte appears to never get read. +; 1, 10, 100 aka 10*0, 10*1, 10*2. used by print_number. last byte appears to never get read. power_10_table: .byte $01,$0A,$64 ; 9507 01 0A 64 ..d ; 13 4x8 glyphs, 0 thru 9, space, left & right halves of copyright symbol. 2bpp, but only one color used (11). really 3x8 as rightmost column is blank (for spacing) in all glyphs. height is the full 8 (no blanks for spacing). @@ -2542,8 +2605,8 @@ aw_loop:lda attack_wave_text,y ; 9652 B9 D6 96 bne aw_loop ; 965B D0 F5 .. print_level: lda level ; 965D A5 9A .. - lsr $0510 ; 965F 4E 10 05 N.. - jsr draw_2_score_digits ; 9662 20 83 94 .. + lsr leading_zero_flag ; 965F 4E 10 05 N.. + jsr print_number ; 9662 20 83 94 .. ldy #$00 ; 9665 A0 00 .. completed_loop: lda completed_text,y ; 9667 B9 EE 96 ... @@ -2559,14 +2622,14 @@ clamp_bonus: lda #$05 ; 9678 A9 05 .. ; print 1st digit of bonus multiplier (range 1-5) print_bonus_mult: - lsr $0510 ; 967A 4E 10 05 N.. - jsr draw_2_score_digits ; 967D 20 83 94 .. + lsr leading_zero_flag ; 967A 4E 10 05 N.. + jsr print_number ; 967D 20 83 94 .. sec ; 9680 38 8 - ror $0510 ; 9681 6E 10 05 n.. + ror leading_zero_flag ; 9681 6E 10 05 n.. ; print 00 after the 1-digit multiplier print_bonus_00: lda #$00 ; 9684 A9 00 .. - jsr draw_2_score_digits ; 9686 20 83 94 .. + jsr print_number ; 9686 20 83 94 .. lda #$22 ; 9689 A9 22 ." sta sprite_x ; 968B 85 E3 .. lda #$90 ; 968D A9 90 .. @@ -2798,7 +2861,7 @@ animate_explosion: jsr animate_splosion ; 9834 20 95 98 .. inc $0501 ; 9837 EE 01 05 ... jsr animate_splosion ; 983A 20 95 98 .. -L983D: dec $0501 ; 983D CE 01 05 ... +ae_loop:dec $0501 ; 983D CE 01 05 ... jsr animate_splosion ; 9840 20 95 98 .. inc $0501 ; 9843 EE 01 05 ... inc $0501 ; 9846 EE 01 05 ... @@ -2810,7 +2873,7 @@ L983D: dec $0501 ; 983D CE 01 05 sta COLOR2 ; 9854 8D C6 02 ... lda $0501 ; 9857 AD 01 05 ... cmp #$10 ; 985A C9 10 .. - bcc L983D ; 985C 90 DF .. + bcc ae_loop ; 985C 90 DF .. jsr animate_splosion ; 985E 20 95 98 .. dec $0500 ; 9861 CE 00 05 ... jsr animate_splosion ; 9864 20 95 98 .. @@ -2823,14 +2886,14 @@ animate_implosion: jsr animate_splosion ; 986C 20 95 98 .. dec $0501 ; 986F CE 01 05 ... jsr animate_splosion ; 9872 20 95 98 .. -L9875: inc $0501 ; 9875 EE 01 05 ... +ai_loop:inc $0501 ; 9875 EE 01 05 ... jsr animate_splosion ; 9878 20 95 98 .. dec $0501 ; 987B CE 01 05 ... dec $0501 ; 987E CE 01 05 ... jsr animate_splosion ; 9881 20 95 98 .. lda $0501 ; 9884 AD 01 05 ... cmp #$01 ; 9887 C9 01 .. - bcs L9875 ; 9889 B0 EA .. + bcs ai_loop ; 9889 B0 EA .. jsr animate_splosion ; 988B 20 95 98 .. inc $0501 ; 988E EE 01 05 ... jsr animate_splosion ; 9891 20 95 98 .. @@ -4558,7 +4621,7 @@ LA509: lda planet_dead_flag ; A509 A5 A0 ror planet_dead_flag ; A518 66 A0 f. pla ; A51A 68 h pla ; A51B 68 h - jmp L8465 ; A51C 4C 65 84 Le. + jmp prep_next_level ; A51C 4C 65 84 Le. ; ---------------------------------------------------------------------------- LA51F: rts ; A51F 60 ` @@ -4976,7 +5039,7 @@ LA819: jsr get_random ; A819 20 F2 8C ; ---------------------------------------------------------------------------- ; XXX don't know how this works yet -draw_starfield: +animate_starfield: jsr get_random ; A832 20 F2 8C .. lda $95 ; A835 A5 95 .. clc ; A837 18 . @@ -5759,7 +5822,7 @@ spawn_bombers: beq spawn_pods ; AE65 F0 16 .. spb_loop: pha ; AE67 48 H - jsr L8D0C ; AE68 20 0C 8D .. + jsr get_spawn_pos ; AE68 20 0C 8D .. lda random_seed ; AE6B A5 C6 .. and #$08 ; AE6D 29 08 ). clc ; AE6F 18 . @@ -5775,7 +5838,7 @@ spawn_pods: beq spawn_landers ; AE80 F0 11 .. spp_loop: pha ; AE82 48 H - jsr L8D0C ; AE83 20 0C 8D .. + jsr get_spawn_pos ; AE83 20 0C 8D .. lda #$05 ; AE86 A9 05 .. sta current_sprite ; AE88 85 F9 .. jsr spawn_sprite ; AE8A 20 ED AB .. @@ -5791,31 +5854,31 @@ spawn_lander_wave: lda landers_to_spawn ; AE98 A5 9B .. beq lis_done ; AE9A F0 49 .I jsr play_materialize ; AE9C 20 32 8E 2. - jsr L8D0C ; AE9F 20 0C 8D .. + jsr get_spawn_pos ; AE9F 20 0C 8D .. lda #$01 ; AEA2 A9 01 .. sta current_sprite ; AEA4 85 F9 .. jsr spawn_sprite ; AEA6 20 ED AB .. dec landers_to_spawn ; AEA9 C6 9B .. beq lis_done ; AEAB F0 38 .8 - jsr L8D0C ; AEAD 20 0C 8D .. + jsr get_spawn_pos ; AEAD 20 0C 8D .. lda #$01 ; AEB0 A9 01 .. sta current_sprite ; AEB2 85 F9 .. jsr spawn_sprite ; AEB4 20 ED AB .. dec landers_to_spawn ; AEB7 C6 9B .. beq lis_done ; AEB9 F0 2A .* - jsr L8D0C ; AEBB 20 0C 8D .. + jsr get_spawn_pos ; AEBB 20 0C 8D .. lda #$01 ; AEBE A9 01 .. sta current_sprite ; AEC0 85 F9 .. jsr spawn_sprite ; AEC2 20 ED AB .. dec landers_to_spawn ; AEC5 C6 9B .. beq lis_done ; AEC7 F0 1C .. - jsr L8D0C ; AEC9 20 0C 8D .. + jsr get_spawn_pos ; AEC9 20 0C 8D .. lda #$01 ; AECC A9 01 .. sta current_sprite ; AECE 85 F9 .. jsr spawn_sprite ; AED0 20 ED AB .. dec landers_to_spawn ; AED3 C6 9B .. beq lis_done ; AED5 F0 0E .. - jsr L8D0C ; AED7 20 0C 8D .. + jsr get_spawn_pos ; AED7 20 0C 8D .. lda #$01 ; AEDA A9 01 .. sta current_sprite ; AEDC 85 F9 .. jsr spawn_sprite ; AEDE 20 ED AB .. @@ -6627,7 +6690,7 @@ LB472: lda animation_counter ; B472 A5 85 ; copy protection, causes game to crash next time the player gets killed. called from several places in the code. ram_self_destruct_1: lda #$02 ; B47F A9 02 .. - sta L983D ; B481 8D 3D 98 .=. + sta ae_loop ; B481 8D 3D 98 .=. rts ; B484 60 ` ; ---------------------------------------------------------------------------- @@ -6988,7 +7051,7 @@ LB6F8: lda lives ; B6F8 A5 9E LB705: lda current_player ; B705 A5 F1 .. eor #$03 ; B707 49 03 I. sta current_player ; B709 85 F1 .. -LB70B: jmp L845B ; B70B 4C 5B 84 L[. +LB70B: jmp clear_enemy_explosions ; B70B 4C 5B 84 L[. ; ---------------------------------------------------------------------------- out_of_lives: @@ -7023,7 +7086,7 @@ LB732: jsr print_game_over ; B732 20 1E B8 bne LB6E3 ; B74C D0 95 .. LB74E: lda p2_sav_lives ; B74E AD C6 19 ... bne LB6E3 ; B751 D0 90 .. -LB753: jsr check_consol ; B753 20 A0 BA .. +LB753: jsr read_consol ; B753 20 A0 BA .. sec ; B756 38 8 ror pause_flag ; B757 66 AF f. bit start_flag ; B759 24 BE $. @@ -7081,7 +7144,7 @@ LB79B: ldy $9F ; B79B A4 9F ; ---------------------------------------------------------------------------- LB7AA: lda #$01 ; B7AA A9 01 .. sta sprite_list+3,y ; B7AC 99 EE 0A ... -LB7AF: jsr L8D0C ; B7AF 20 0C 8D .. +LB7AF: jsr get_spawn_pos ; B7AF 20 0C 8D .. lda sprite_list+3,y ; B7B2 B9 EE 0A ... sta current_sprite ; B7B5 85 F9 .. jsr spawn_sprite ; B7B7 20 ED AB .. @@ -7506,8 +7569,8 @@ vkeybd_finish: rti ; BA9F 40 @ ; ---------------------------------------------------------------------------- -; see if start or select are pressed -check_consol: +; see if start or select are pressed, set flags +read_consol: lda #$08 ; BAA0 A9 08 .. sta CONSOL ; BAA2 8D 1F D0 ... lda CONSOL ; BAA5 AD 1F D0 ... @@ -7651,7 +7714,7 @@ baiter_check: bcs bc_done ; BB8B B0 15 .. ; yes, spawn it bc_spawn: - jsr L8D0C ; BB8D 20 0C 8D .. + jsr get_spawn_pos ; BB8D 20 0C 8D .. lda $91 ; BB90 A5 91 .. sta $DD ; BB92 85 DD .. lda $92 ; BB94 A5 92 .. diff --git a/defender.info b/defender.info index 58b2e95..519fadb 100644 --- a/defender.info +++ b/defender.info @@ -12,8 +12,13 @@ label { name "rtclok_ok"; addr $800b; }; label { name "init_work_ram"; addr $a268; }; label { name "start_game"; addr $8100; comment "..."; }; label { name "show_game_type"; addr $811f; comment "draw the text for e.g. ONE PLAYER EASY"; }; +label { name "sgt_nextchar"; addr $813d; }; +label { name "sgt_done"; addr $8147; }; label { name "draw_title_text"; addr $8259; comment "draw the text for DEFENDER/SELECT GAME AND PRESS THE START BUTTON"; }; -label { name "draw_demo_text"; addr $8963; comment "draw the text for DEFENDER c 1982 ATARI, during the demo game"; }; +label { name "draw_demo_text"; addr $895c; comment "draw the text for DEFENDER c 1982 ATARI, during the demo game"; }; +label { name "ddt_draw"; addr $8963; }; +label { name "ddt_nextchar"; addr $8980; }; +label { name "ddt_done"; addr $898b; }; label { name "dtt_lo"; addr $8267; comment "lda #<title_text"; }; label { name "dtt_hi"; addr $826b; comment "lda #>title_text"; }; label { name "dtt_loop"; addr $8271; }; @@ -21,7 +26,7 @@ label { name "dtt_color"; addr $8279; comment "multicolor support. bytes with $F label { name "dtt_print"; addr $8288; }; label { name "dtt_inc_ptr"; addr $828b; }; label { name "dtt_done"; addr $8294; }; -label { name "check_consol"; addr $baa0; comment "see if start or select are pressed"; }; +label { name "read_consol"; addr $baa0; comment "see if start or select are pressed, set flags"; }; label { name "start_pressed"; addr $bac6; comment "user pressed start key, ignore if game is playing & not paused"; }; label { name "consol_done"; addr $bab4; comment "several code paths jump here instead of doing their own RTS"; }; label { name "ignore_start"; addr $bad1; comment "don't handle start key while game is playing & not paused"; }; @@ -50,8 +55,12 @@ label { name "level_ok"; addr $83d7; comment "ramp up the speed on odd-numbered label { name "set_game_type"; addr $80e6; }; label { name "update_title_colors"; addr $809a; comment "rotate colors"; }; label { name "update_title_sfx"; addr $80a6; comment "alter the drone sound's pitch"; }; -label { name "title_fx_ok"; addr $80b7; }; +label { name "tsi_show_gt"; addr $8092; }; +label { name "tsi_wait_to_draw"; addr $8095; }; +label { name "tsi_delay"; addr $80c8; }; +label { name "tsi_check_start"; addr $80b7; }; label { name "title_screen_idle"; addr $8078; comment "play & fade the drone while we wait for the user to press select or start"; }; +label { name "tsi_text"; addr $808f; comment "play & fade the drone while we wait for the user to press select or start"; }; label { name "init_title_screen"; addr $8031; }; label { name "init_drone"; addr $8d79; comment "start the drone sound you hear at the title screen & when starting/ending a level. Also silence channel 2 (the engine noise). In BASIC this would be: SOUND 1,0,0,0:SOUND 2,255,10,15:SOUND 3,254,10,15"; }; label { name "game_on"; addr $8369; comment "called when start button is pressed from title screen or pause mode"; }; @@ -99,12 +108,14 @@ label { name "hsp_loop"; addr $8899; }; label { name "hsp_check_demo"; addr $88ae; comment "don't ever kill the 'player' in demo mode (game_type==0)"; }; label { name "check_hyperspace_fatal"; addr $88b2; comment "kill player if RANDOM >= $AA (in other words, 33% of the time!)"; }; label { name "hsp_done"; addr $88bc; }; -label { name "draw_starfield"; addr $a832; comment "XXX don't know how this works yet"; }; +label { name "animate_starfield"; addr $a832; comment "XXX don't know how this works yet"; }; label { name "hyperspace_implosion"; addr $97e7; comment "looks like the ship explosion, but in reverse"; }; label { name "ship_explosion"; addr $97d9; comment "particles"; }; label { name "init_splosion"; addr $97f7; comment "calculate (ex|im)plosion particles for the player ship"; }; label { name "animate_explosion"; addr $9830; }; +label { name "ae_loop"; addr $983d; }; label { name "animate_implosion"; addr $9868; }; +label { name "ai_loop"; addr $9875; }; label { name "animate_splosion"; addr $9895; comment "called multiple times by animate_(im|ex)plosion. uses particles set up by init_splosion"; }; label { name "as_done"; addr $9961; }; label { name "is_loop"; addr $97f9; }; @@ -113,8 +124,20 @@ label { name "draw_scanner_border_and_planet"; addr $9fb1; comment "XXX don't kn label { name "add_cursprite_points"; addr $a7ae; comment "add points to score based on what kind of enemy we killed. does not include points for rescued humans nor end-of-level bonus."; }; label { name "add_points"; addr $a7b2; comment "this entry point takes a sprite type in A, used for end-of-level bonus (and...?)"; }; label { name "draw_scores"; addr $9442; comment "draw score digits in the HUDs for both players (but not lives nor smartbombs)"; }; -label { name "draw_2_score_digits"; addr $9483; comment "called 4 times for the 4 bytes of score. does division by 10."; }; -label { name "flash_score"; addr $93bc; comment "flash the score of the current player"; }; +label { name "dsc_ok"; addr $9458; }; +label { name "draw_score_2p"; addr $93e2; comment "draw current player's score in 2p mode. does nothing in 1p mode!"; }; +label { name "ds2p_p1"; addr $9426; comment "draw player 1's score since he's the current player"; }; +label { name "ds2_ok"; addr $93f8; }; +label { name "print_number"; addr $9483; comment "print number in A, at current cursor pos. range 0-99 (0-$63). does division by 10. suppress leading zeroes if leading_zero_flag is clear."; }; +label { name "pn_div10"; addr $9488; }; +label { name "pn_div10_loop"; addr $948d; }; +label { name "pn_draw"; addr $94b5; }; +label { name "pn_skip"; addr $94b8; }; +label { name "pn_div10_ok"; addr $949e; }; +label { name "clear_score"; addr $93bc; comment "print 7 spaces over the current player's score. used to flash the score of the current player"; }; +label { name "fs_set_y"; addr $93d2; }; +label { name "fs_next_char"; addr $93d9; }; +label { name "fs_done"; addr $93e1; }; label { name "copy_code_to_ram"; addr $a291; comment "copy is done because the code is self-modifying"; }; label { name "clr_ram_sprites_loop"; addr $a2aa; }; label { name "crsl_ok"; addr $a2b4; }; @@ -155,9 +178,22 @@ label { name "sbf_loop"; addr $9c0f; }; label { name "spawn_sprite"; addr $abed; comment "XXX does this apply to humanoids too?"; }; label { name "nl_wtf"; addr $83cb; comment "this branch should never be taken (means level was $FF, but it's clamped to $63 below)"; }; label { name "nl_drone"; addr $83ea; }; +label { name "nl_next_stars"; addr $83f8; }; +label { name "nl_delay"; addr $8414; }; label { name "level_cleared"; addr $8427; comment "decide whether or not to resurrect dead humans"; }; label { name "dont_repopulate"; addr $843f; }; label { name "div_5_loop"; addr $842c; }; +label { name "clear_enemy_explosions"; addr $845b; }; +label { name "cex_loop"; addr $845f; }; +label { name "prep_next_level"; addr $8465; comment "clean up game state, show prompt if in 2p mode"; }; +label { name "pnl_store_trig"; addr $8478; comment "store either TRIG0 or TRIG1"; }; +label { name "pnl_clear_player_shots"; addr $849a; }; +label { name "check_consol"; addr $8503; comment "handle start/select keys during gameplay (ignore if not paused)"; }; +label { name "cc_chk_start"; addr $8511; }; +label { name "cc_chk_keyboard"; addr $851c; comment "in demo mode, pressing any key returns to the title screen"; }; +label { name "check_paused"; addr $852a; }; +label { name "wait_draw_ok"; addr $853f; }; +label { name "check_spawn"; addr $854c; comment "see if it's time to spawn a lander wave or a baiter yet"; }; label { name "draw_p1_lives_and_bombs"; addr $86b0; comment "update HUD"; }; label { name "draw_p2_lives_and_bombs"; addr $8780; comment "update HUD"; }; label { name "move_ship"; addr $85c9; comment "only in non-demo game"; }; @@ -201,6 +237,16 @@ label { name "no_vert_move"; addr $ad98; comment "ship not moving up or down XXX label { name "move_up"; addr $ad90; comment "XXX how does this work?"; }; label { name "move_down"; addr $ad94; comment "XXX how does this work?"; }; label { name "demo_logic"; addr $88bd; comment "animate the demo-game ship"; }; +label { name "dl_hyperspace"; addr $894c; }; +label { name "dl_smartbomb"; addr $8952; }; +label { name "dl_done"; addr $8959; }; +label { name "dl_down"; addr $891c; comment "move the ship down"; }; +label { name "dl_vert_delta"; addr $88f0; comment "move the ship up or down, towards the sprite we're considering. actual movement ends up as the sum of all the calls here"; }; +label { name "dl_vert_move"; addr $88dd; }; +label { name "dl_vm_next"; addr $88e4; }; +label { name "dl_trigger"; addr $8946; }; +label { name "dl_check_move"; addr $88d1; comment "is it time to move the ship?"; }; +label { name "dl_check_hyper"; addr $892b; }; label { name "printchar"; addr $972e; comment "print the DSCII text character in the A reg"; }; label { name "pch_done"; addr $9757; }; label { name "print_copyright"; addr $9758; comment "print copyright symbol ($c0). it's double-wide, so 2 glyphs"; }; @@ -223,6 +269,14 @@ label { name "ab_next_sprite"; addr $9698; }; label { name "calc_bonus_index"; addr $96c7; comment "A = 7 + (level < 6 ? level : 5); // index into score_points_table"; }; label { name "cbi_add7"; addr $96cf; comment "add 7 because that's where the bonus amounts start, in score_points_table"; }; label { name "save_p1_state"; addr $89b9; comment "save game state to p1_sav_* area"; }; +label { name "sp1_loop"; addr $89bb; }; +label { name "sp1_skip"; addr $89cb; }; +label { name "sp2_loop"; addr $8a0f; }; +label { name "sp2_skip"; addr $8a1f; }; +label { name "lp1_loop"; addr $8a63; }; +label { name "lp1_skip"; addr $8a73; }; +label { name "lp2_loop"; addr $8ab7; }; +label { name "lp2_skip"; addr $8ac7; }; label { name "save_p2_state"; addr $8a0d; comment "save game state to p2_sav_* area"; }; label { name "load_p1_state"; addr $8a61; comment "restore game state from p1_sav_* area"; }; label { name "load_p2_state"; addr $8ab5; comment "restore game state from p2_sav_* area"; }; @@ -233,8 +287,13 @@ label { name "delay_loop"; addr $8874; comment "takes delay time in A. only ever label { name "dl_wait"; addr $8876; }; label { name "prompt_done"; addr $84ff; comment "either the prompt screen is finished, or we were in single-player mode & didn't need it"; }; label { name "print_p1_text"; addr $8b09; comment "print PLAYER ONE"; }; +label { name "pp1_next"; addr $8b15; }; +label { name "pp1_done"; addr $8b20; }; label { name "print_p2_text"; addr $8b3e; comment "print PLAYER TWO"; }; +label { name "pp2_next"; addr $8b4a; }; +label { name "pp2_done"; addr $8b55; }; label { name "clear_prompt_text"; addr $8b73; comment "print 40 spaces over the PLAYER (ONE|TWO) message"; }; +label { name "cpt_next_char"; addr $8b7f; }; # not sure 'spawn' is quite the right word here label { name "spawn_humanoid"; addr $aee6; comment "'spawn' not the right word. this does all the logic for humanoids (falling, hitting the ground)"; }; label { name "spawn_lander"; addr $b08e; }; @@ -251,6 +310,7 @@ label { name "baiter_check"; addr $bb7b; comment "decide whether to spawn a bait label { name "bc_done"; addr $bba2; }; label { name "bc_spawn"; addr $bb8d; comment "yes, spawn it"; }; label { name "get_random"; addr $8cf2; comment "variant of an LFSR. could have just use 'lda RANDOM', this is likely an artifact of Baker's Apple II heritage. Returns 'random' number in A."; }; +label { name "get_spawn_pos"; addr $8d0c; comment "pick a random, valid spot"; }; label { name "detonate_smartbomb"; addr $8bac; }; label { name "smartbomb_kill_stuff"; addr $8bd0; comment "kill every enemy on the screen"; }; label { name "kill_next"; addr $8bbd; }; @@ -334,6 +394,7 @@ label { name "screen_ptr"; addr $c0; size 2; comment "pointer to screen memory, # non-zp data addresses label { name "enemy_explosion_table"; addr $052b; size 128; comment "4 bytes per entry, 32 entries"; }; label { name "splosion_particles"; addr $0400; size 256; comment "page full of random garbage, generated by init_splosion, used/altered by animate_plosion"; }; +label { name "leading_zero_flag"; addr $0510; comment "bit 7 clear = skip leading zeroes in print_number. set = print leading zeroes ('01' instead of '1'"; }; label { name "plosion_x_start"; addr $0507; }; label { name "plosion_y_start"; addr $0508; }; label { name "plosion_x"; addr $0505; }; @@ -437,7 +498,7 @@ range { name "gttxt_2p_normal"; start $820f; end $8233; type bytetable; comment range { name "gttxt_2p_hard"; start $8234; end $8258; type bytetable; comment "' T W O P L A Y E R H A R D '"; }; range { name "title_text"; start $8295; end $8328; type bytetable; comment "cF, c5 are color codes. 'cF D E F E N D E RnlnlnlnlnlnlcF S E L E C T G A M E A N D P R E S Snlnl T H E S T A R T B U T T O Nnlnlnlnlc5 c) 1 9 8 2 A T A R I'"; }; range { name "table_8329"; start $8329; end $8368; type bytetable; comment "is this used at all?"; }; -range { name "power_10_table"; start $9507; end $9509; type bytetable; comment "1, 10, 100 aka 10*0, 10*1, 10*2. used by draw_2_score_digits. last byte appears to never get read."; }; +range { name "power_10_table"; start $9507; end $9509; type bytetable; comment "1, 10, 100 aka 10*0, 10*1, 10*2. used by print_number. last byte appears to never get read."; }; range { name "font"; start $950a; end $9641; type bytetable; comment "13 4x8 glyphs, 0 thru 9, space, left & right halves of copyright symbol. 2bpp, but only one color used (11). really 3x8 as rightmost column is blank (for spacing) in all glyphs. height is the full 8 (no blanks for spacing)."; }; label { name "font_letters"; addr $9572; comment "uppercase, 26 4x8 glyphs but no blank column for spacing (full 4x8). also J Q Z glyphs are graphics of some kind."; }; range { name "demo_text"; start $898f; end $89b8; type bytetable; comment "' D E F E N D E R c 1982 A T A R I '"; }; |