Prev: C00C Up: Map Next: C16A
C06E: Prepare and display a new high-score entry
Reached from check_high_score when the new score beats or ties the table row whose address was pushed there. Shifts the rows below the insertion point down by one (33 bytes each; row 1 needs no shift), writes the score digits, stage code and retry-attempt number into the row, runs a highlight/flash display, then drops into the joystick-driven name-entry loop at name_entry_frame.
Used by the routine at check_high_score.
insert_high_score_entry C06E LD A,C A = row counter (1..10, from check_high_score)
C06F EX AF,AF' Bank the row counter
C070 LD A,C A = row counter again
C071 DEC A
C072 JR Z,ihe_write_row Row 1 (bottom of the table) -> nothing below to shift
ihe_shift_rows C074 LD DE,$C54A DE -> one past the last table row (shift destination)
C077 LD HL,$C529 HL -> last table row (shift source)
insert_high_score_entry_0 C07A LD BC,$001A Shift 26 bytes of the row down into the row below
C07D LDDR
C07F LD C,$07 then step both pointers back the rest of the 33-byte row stride without copying -- the trailing 7 bytes of each row (2 padding bytes + the row's own 5-char rank suffix, e.g. "2ND " -- see the data at C3AF) are static labels, not player data, so they are simply left untouched by the shift
C081 AND A
C082 SBC HL,BC
C084 EX DE,HL
C085 SBC HL,BC
C087 EX DE,HL
C088 DEC A One row done
C089 JR NZ,insert_high_score_entry_0 Loop up through the rows above the insertion point
ihe_write_row C08B POP DE DE -> the row being inserted (address pushed by check_high_score)
C08C LD HL,$C55F HL -> formatted score digit string
C08F LD BC,$0008 Write the 8 score digits into the row
C092 LDIR
C094 INC DE DE += 4
C095 INC DE
C096 INC DE
C097 INC DE
C098 LD A,($8007) A = wanted_stage_number
C09B LD C,A C = stage_number * 3 -- index into a 3-byte-per-stage table
C09C ADD A,A
C09D ADD A,C
C09E LD C,A
C09F LD HL,$C564 HL -> stage code/name table (3 bytes/stage)
C0A2 ADD HL,BC HL -> this stage's entry
C0A3 LD C,$03 Write the 3-byte stage code into the row
C0A5 LDIR
C0A7 EX DE,HL HL -> row (DE no longer needed for the copy)
C0A8 LD C,$05 HL += 5
C0AA ADD HL,BC
C0AB LD A,($8006) A = retry_count (0/1/2)
C0AE ADD A,$31 A = ASCII '1'..'3'
C0B0 LD (HL),A Write the attempt-number digit into the row
C0B1 LD C,$03 HL += 3
C0B3 ADD HL,BC
C0B4 LD ($C59C),HL Remember this position
C0B7 LD (HL),$2E Write two static full stops ("..")
C0B9 INC HL
C0BA LD (HL),$2E
C0BC INC HL
C0BD LD (HL),$AE A third full stop with bit 7 set, terminating the row's 3-character name field (see C3AF) with placeholder text before the player's initials overwrite it
C0BF EX AF,AF' Restore the row counter (banked at $C06F)
C0C0 LD ($C2F8),A Save the row counter
C0C3 LD B,A B = row counter
Address = $C401 + (10 - row_counter) * 33: locates this row's entry in a 33-byte-per-row table (each row's screen address then its text), stored as the operand of $C155 so the entry loop blinks the new entry's row. The multiply is done as (10-row)*32 (5x ADD A,A, overflow captured in D via RL D) plus one more (10-row) added back in (ADD A,C) -- i.e. x*32 + x = x*33.
C0C4 NEG
C0C6 ADD A,$0A
C0C8 LD C,A
C0C9 ADD A,A
C0CA ADD A,A
C0CB ADD A,A
C0CC ADD A,A
C0CD ADD A,A
C0CE LD D,$00
C0D0 RL D
C0D2 ADD A,C
C0D3 LD E,A
C0D4 LD HL,$C401
C0D7 ADD HL,DE
C0D8 LD ($C156),HL Patch the operand of $C155 LD HL,$C422
Intro scroll length = $A0 - clamp(7 - row_counter, 0..7) * 16 frames, stored as the countdown operand at $C13D: 160 frames for ranks 1-4, 16 fewer per rank below that, so the new entry's row stops on the bottom line of the table.
C0DB LD A,$07
C0DD SUB B
C0DE JR NC,insert_high_score_entry_1
C0E0 XOR A
insert_high_score_entry_1 C0E1 ADD A,A
C0E2 ADD A,A
C0E3 ADD A,A
C0E4 ADD A,A
C0E5 LD C,A
C0E6 LD A,$A0
C0E8 SUB C
C0E9 LD ($C13D),A Seed the intro countdown at ihe_flash_loop
C0EC CALL clear_playfield_and_attrs See clear_playfield_and_attrs
Set the table attributes. clear_playfield_and_attrs leaves HL=$57FF and DE=$5800, so this fills $5A00 onwards with $47 (bright white on black) for 512 bytes, running past the attributes into $5B00-$5BFF. Rows 15 and 23 are then set to black on black, so the table rows are hidden as they scroll in and out of the band between them.
C0EF INC L
C0F0 LD H,$5A
C0F2 INC E
C0F3 LD D,H
C0F4 LD (HL),$47
C0F6 LD BC,$01FF
C0F9 LDIR
C0FB LD HL,$59E0
C0FE LD DE,$5AE0
C101 XOR A
C102 LD B,$20
insert_high_score_entry_2 C104 LD (HL),A Zero attribute rows 15 ($59E0) and 23 ($5AE0) in lockstep
C105 LD (DE),A
C106 INC E
C107 INC L
C108 DJNZ insert_high_score_entry_2
C10A LD DE,$C401
C10D LD HL,$C54B
C110 LD A,$0A A = 10 (rows)
insert_high_score_entry_3 C112 LDI Copy 2 bytes per row from the table at $C54B into the row-offset table at $C401 (31-byte stride)
C114 LDI
C116 EX DE,HL
C117 LD BC,$001F
C11A ADD HL,BC
C11B EX DE,HL
C11C DEC A
C11D JR NZ,insert_high_score_entry_3
C11F LD HL,$C3AF HL -> C3AF data block
C122 CALL print_string Common routine outside this bank
C125 CALL setup_im2_interrupt_table See setup_im2_interrupt_table
C128 LD A,$03
C12A CALL titlescr_start_tune See titlescr_start_tune, called with A=3
C12D EI
C12E HALT Wait for the next interrupt
C12F XOR A
C130 LD ($C2F2),A Clear a flag/self-modified byte at $C2F2
ihe_flash_loop C133 CALL titlescr_music See titlescr_music
C136 CALL scroll_score_rows See scroll_score_rows
C139 CALL name_entry_input See name_entry_input
C13C LD A,$A0 Count down the intro: the operand is seeded at $C0E9 and rewritten here each pass, so the scroll runs for that many frames before name entry proper begins
C13E DEC A
C13F LD ($C13D),A
C142 JR NZ,ihe_flash_loop
C144 LD A,$C9 $C9 = RET opcode
C146 LD ($C2F2),A Self-modify $C2F2 to RET, ending the entry loop
ihe_entry_loop C149 CALL name_entry_frame Handle one frame of name entry (see name_entry_frame)
C14C CALL name_entry_input See name_entry_input
C14F CALL titlescr_music See titlescr_music
C152 JP ihe_entry_loop Loop -- exits via a side effect inside a callee
This entry point is used by the routine at name_entry_input.
name_entry_frame C155 LD HL,$C422 HL -> the new entry's row-address slot (operand set at
C158 LD E,(HL) $C0D8); DE = that row's current screen address
C159 INC HL
C15A LD D,(HL)
C15B INC HL
C15C EXX Swap in DE (bank what was the caller's shadow set)
C15D PUSH HL Preserve the caller's shadow BC/DE/HL on the stack, in case redraw_name_frame uses EXX itself
C15E PUSH DE
C15F PUSH BC
C160 EXX Swap back -- main regs include DE (the loaded state)
C161 CALL redraw_name_frame See redraw_name_frame (joystick/letter-selection update)
C164 EXX Swap to the (now current) shadow set
C165 POP BC Restore the caller's shadow BC/DE/HL
C166 POP DE
C167 POP HL
C168 EXX Swap back to the main set
C169 RET
Prev: C00C Up: Map Next: C16A