| Routines

21920: Count down from 9 to 0

Continues from the routine at 33204. Counts down from 9 to 0, giving the user a chance to set the input method and change the characters' names before the game starts.
Input
BC | 256
DE | 33024
HL | 23296
21920 | LDIR | Copy 256 bytes from 23296 to 33024
21922 | LD H,88 | INK 1: PAPER 1
21924 | LD B,3
21926 | LD D,H
21927 | INC E
21928 | LD (HL),9
21930 | LDIR
21932 | LD HL,23611 | Reset bit 5 at 23611, ready for future keypresses
21935 | RES 5,(HL)
21937 | EXX | Point HL' at the last byte of the graphic data for the digit '9' in the ROM
21938 | LD HL,15823
21941 | EXX
21942 | LD DE,1084 | Wait approximately one second
21945 | DJNZ 21945
21947 | DEC DE
21948 | LD A,D
21949 | OR E
21950 | JR NZ,21945
21952 | LD HL,23020 | 23020 is the attribute file address where the bottom row of 'big pixels' will be drawn
21955 | LD DE,65496 | DE=-40
21958 | LD C,8 | There are 8 pixel rows per countdown digit
21960 | EXX |
21961 | BIT 7,L | Set the zero flag when HL' hits 15743
21963 | LD A,(HL) | Pick up a digit pixel row byte
21964 | DEC HL | Move HL' to the next pixel row up
21965 | EXX |
21966 | JP Z,21737 | Start the game if we've already printed '0'
21969 | LD B,8 | There are 8 bits per pixel row
21971 | LD (HL),9 | INK 1: PAPER 1 (blue) for a reset pixel
21973 | RLCA | Is this a reset pixel?
21974 | JR NC,21978 | Jump if so
21976 | LD (HL),36 | INK 4: PAPER 4 (green) for a set pixel
21978 | INC HL | Move HL along to the next attribute file address
21979 | DJNZ 21971 | Jump back until all 8 'big pixels' have been drawn
21981 | ADD HL,DE | Move HL back 8 spaces and up one row of the attribute file
21982 | DEC C | Next pixel row
21983 | JR NZ,21960 | Jump back until all 8 pixel rows have been drawn
21985 | CALL 29012 | Make a ticking sound effect
21988 | LD HL,23611 |
21991 | BIT 5,(HL) | Reset the zero flag if a key was pressed
21993 | RES 5,(HL) | Reset bit 5 at 23611, ready for future keypresses
21995 | JP NZ,21425 | Jump if a key was pressed
21998 | JR 21942 | Wait roughly one second, then print the next digit