Prev: 860F Up: Map Next: 86F6
865A: Draw the pre-game screen
The pre-game screen ("CHASE H.Q. MONITORING SYSTEM") is drawn by following the commands stored at pregame_data. Possible commands are "plot tile" (single or up to 30 repetitions), "set background colour", "set address", "draw horizontally", "draw vertically" or "stop". The tiles are the 45 8x8 pixel tiles that live at pregame_tiles.
Once the tiles are drawn the strings at pre_game_messages are drawn by calling print_message.
Used by the routine at run_pregame_screen.
draw_pregame 865A LD HL,$77D8 Address of pre-game screen data
dp_get_command 865D LD A,(HL) Read a command byte
865E AND A Set flags
865F JP Z,dp_print_strings Zero is the "Stop" command so jump to rendering messages
8662 INC HL Advance to next command byte
8663 CP $D0 Jump if < $D0 (either "Repeat" or "Plot tile")
8665 JR C,dp_repeat_or_plot_tile
8667 CP $E0 Jump if < $D0..$DF ("Set background colour")
8669 JR C,dp_set_bg_colour
866B CP $F0 Jump if >= $F0 ("Set address")
866D JR NC,dp_set_address
$E1 is "Draw horizontally". $E2 is "Draw vertically".
dp_set_direction 866F SUB $E0 Self modify dp_direction with (A - $E0)
8671 LD ($86C9),A
8674 JR dp_get_command Loop dp_get_command
$D0..$DF is "Set background colour".
dp_set_bg_colour 8676 SUB $D0 Self modify 86C2 with (A - $D0) << 3
8678 RLCA
8679 RLCA
867A RLCA
867B LD ($86C3),A
867E JR dp_get_command Loop dp_get_command
$F0..$FF is "Set address".
dp_set_address 8680 LD D,A Load new backbuffer address into DE
8681 LD E,(HL)
8682 INC HL
8683 JR dp_get_command Loop dp_get_command
$00..$CF could be either "Repeat" or "Plot tile".
dp_repeat_or_plot_tile 8685 CP $1F Command bytes >= $1F emit single tiles
8687 LD B,$01 Set count to 1 irrespective
8689 JR NC,dp_do_plot Jump if so
Plot multiple tiles.
868B LD B,A Command bytes <= $1E emit repeated tiles
868C LD A,(HL) Read tile index
868D INC HL Advance to next command
dp_do_plot 868E PUSH HL Preserve command pointer
868F SUB $1F Turn command byte into a tile index
8691 RLCA Multiply by 8 - size of tile. Carry flag is updated
8692 RLCA
8693 RLA
8694 PUSH BC Preserve count
8695 LD C,A Expand tile offset into BC
8696 LD B,$00
8698 RL B Add in carry flag
869A LD HL,$78A7 HL = &pregame_tiles[A]
869D ADD HL,BC
869E POP BC Restore count
869F EX DE,HL DE becomes tile ptr, HL becomes backbuffer ptr
dp_line_loop 86A0 PUSH BC Count
86A1 PUSH DE Tile ptr
86A2 PUSH HL Backbuffer ptr
Plot a tile.
86A3 LD B,$08 8 rows per tile
dp_tile_loop 86A5 LD A,(DE) Copy a row of tile pixels to the screen
86A6 LD (HL),A
86A7 INC DE Move to next tile row
86A8 INC H Move to next scanline
86A9 DJNZ dp_tile_loop Loop dp_tile_loop
86AB POP BC Pop backbuffer ptr
Seems to be building an attribute address?
86AC LD A,B Get bit 3 of Y
86AD RLA
86AE RLA
86AF AND $20
86B1 LD D,A
86B2 LD A,C Add to X bits
86B3 AND $1F
86B5 ADD A,D
86B6 LD E,A
86B7 LD A,C Get bits 4..6 of Y. Bit 6 goes to carry
86B8 AND $E0
86BA ADD A,A
86BB LD D,$59 Select second third of attributes
86BD JR NC,dp_attrs
86BF INC D Otherwise select final third of attributes
dp_attrs 86C0 ADD A,E DE is now the attribute byte address
86C1 LD E,A
86C2 LD A,$00 Load <self modified> attribute value, as set by the $Dx commands
86C4 AND A Set attribute byte if non-zero
86C5 JR Z,dp_direction
86C7 LD (DE),A
dp_direction 86C8 LD A,$00 Load <self modified - 1> direction value, as set by the $Ex commands
86CA DEC A
86CB JR Z,dp_direction_horizontal Jump if horizontal
dp_direction_vertical 86CD LD A,H Get bits 0..3 of Y
86CE AND $0F
86D0 JR NZ,dp_nextone Jump to dp_nextone if non-zero
H is incremented by 1 earlier. So if it was 0b11111111 it's now 0b00000000 so make it 0b11110000. Does this happen in any other case?
86D2 LD A,H H -= 16
86D3 SUB $10
86D5 LD H,A
86D6 LD A,L Increment bits 4..6 of Y (visually downwards by 16?)
86D7 ADD A,$20
86D9 LD L,A
86DA JR dp_nextone Jump to dp_nextone
dp_direction_horizontal 86DC LD H,B Move one character to the right
86DD LD L,C
86DE INC L
dp_nextone 86DF POP DE Restore tile ptr
86E0 POP BC Restore count
86E1 DJNZ dp_line_loop Loop dp_line_loop while B > 0
86E3 EX DE,HL DE = Back buffer ptr
86E4 POP HL Restore command pointer
86E5 JP dp_get_command Loop dp_get_command
dp_print_strings 86E8 LD B,$04 Four messages to print
86EA LD HL,$7798 Address of pre_game_messages
dp_print_string 86ED LD A,$04 Flags TBD
86EF DEC HL HL--
86F0 CALL print_message Call print_message
86F3 DJNZ dp_print_string Loop to dp_print_string while B > 0
86F5 RET Return
Prev: 860F Up: Map Next: 86F6