Chase H.Q. | Routines |
Prev: BB69 | Up: Map | Next: BDC1 |
Used by the routines at load_stage, attract_mode, main_loop, run_pregame_screen, escape_scene and page_in_stage_128k.
|
||||
draw_screen | BC3E | LD HL,$4811 | Point HL at screen pixel (136,64). This is positioned halfway across so we can PUSH to the screen via SP. | |
BC41 | EXX | |||
BC42 | LD HL,$F001 | Point HL' at backbuffer + 1 byte. | ||
BC45 | LD ($BDBE),SP | Self modify SP restore instruction | ||
A sequence that transfers 16 bytes
|
||||
draw_screen_0 | BC49 | LD SP,HL | Point SP at the back buffer | |
BC4A | POP AF | Pull in 16 bytes from the back buffer (order: AF' DE BC AF' DE' BC' IX IY), incrementing SP | ||
BC4B | EX AF,AF' | |||
BC4C | POP DE | |||
BC4D | POP BC | |||
BC4E | EXX | |||
BC4F | POP AF | |||
BC50 | POP DE | |||
BC51 | POP BC | |||
BC52 | POP IX | |||
BC54 | POP IY | |||
BC56 | LD SP,HL | Point SP at screen | ||
BC57 | PUSH IY | Push out 16 bytes to the screen (reversing the order), decrementing SP | ||
BC59 | PUSH IX | |||
BC5B | PUSH BC | |||
BC5C | PUSH DE | |||
BC5D | PUSH AF | |||
BC5E | INC H | Advance screen pointer | ||
BC5F | EXX | Continue pushing | ||
BC60 | PUSH BC | |||
BC61 | PUSH DE | |||
BC62 | EX AF,AF' | |||
BC63 | PUSH AF | |||
BC64 | INC H | Advance back buffer pointer | ||
BC65 | LD SP,HL | Transfer another 16 bytes (128 pixels) | ||
BC66 | POP AF | |||
BC67 | EX AF,AF' | |||
BC68 | POP DE | |||
BC69 | POP BC | |||
BC6A | EXX | |||
BC6B | POP AF | |||
BC6C | POP DE | |||
BC6D | POP BC | |||
BC6E | POP IX | |||
BC70 | POP IY | |||
BC72 | LD SP,HL | |||
BC73 | PUSH IY | |||
BC75 | PUSH IX | |||
BC77 | PUSH BC | |||
BC78 | PUSH DE | |||
BC79 | PUSH AF | |||
BC7A | INC H | |||
BC7B | EXX | |||
BC7C | PUSH BC | |||
BC7D | PUSH DE | |||
BC7E | EX AF,AF' | |||
BC7F | PUSH AF | |||
BC80 | INC H | |||
BC81 | LD SP,HL | Transfer another 16 bytes (128 pixels) | ||
BC82 | POP AF | |||
BC83 | EX AF,AF' | |||
BC84 | POP DE | |||
BC85 | POP BC | |||
BC86 | EXX | |||
BC87 | POP AF | |||
BC88 | POP DE | |||
BC89 | POP BC | |||
BC8A | POP IX | |||
BC8C | POP IY | |||
BC8E | LD SP,HL | |||
BC8F | PUSH IY | |||
BC91 | PUSH IX | |||
BC93 | PUSH BC | |||
BC94 | PUSH DE | |||
BC95 | PUSH AF | |||
BC96 | INC H | |||
BC97 | EXX | |||
BC98 | PUSH BC | |||
BC99 | PUSH DE | |||
BC9A | EX AF,AF' | |||
BC9B | PUSH AF | |||
BC9C | INC H | |||
BC9D | LD SP,HL | Transfer another 16 bytes (128 pixels) | ||
BC9E | POP AF | |||
BC9F | EX AF,AF' | |||
BCA0 | POP DE | |||
BCA1 | POP BC | |||
BCA2 | EXX | |||
BCA3 | POP AF | |||
BCA4 | POP DE | |||
BCA5 | POP BC | |||
BCA6 | POP IX | |||
BCA8 | POP IY | |||
BCAA | LD SP,HL | |||
BCAB | PUSH IY | |||
BCAD | PUSH IX | |||
BCAF | PUSH BC | |||
BCB0 | PUSH DE | |||
BCB1 | PUSH AF | |||
BCB2 | INC H | |||
BCB3 | EXX | |||
BCB4 | PUSH BC | |||
BCB5 | PUSH DE | |||
BCB6 | EX AF,AF' | |||
BCB7 | PUSH AF | |||
BCB8 | INC H | |||
BCB9 | BIT 2,H | is the back buffer row a multiple of 4? | ||
BCBB | JP NZ,draw_screen_0 | loop if so | ||
BCBE | LD DE,$F810 | Advance back buffer pointer (backwards) by a half row? | ||
BCC1 | ADD HL,DE | |||
BCC2 | EXX | |||
BCC3 | LD DE,$F80E | Advance screen pointer (backwards) by half a row? | ||
BCC6 | ADD HL,DE | |||
BCC7 | EXX | |||
This is a similar sequence but only moves 14 bytes (not using IY)
|
||||
draw_screen_1 | BCC8 | LD SP,HL | Point SP at the back buffer | |
BCC9 | POP AF | Pull in 16 bytes from the back buffer (order: AF' DE BC AF' DE' BC' IX), incrementing SP | ||
BCCA | EX AF,AF' | |||
BCCB | POP DE | |||
BCCC | POP BC | |||
BCCD | EXX | |||
BCCE | POP AF | |||
BCCF | POP DE | |||
BCD0 | POP BC | |||
BCD1 | POP IX | |||
BCD3 | LD SP,HL | |||
BCD4 | PUSH IX | |||
BCD6 | PUSH BC | |||
BCD7 | PUSH DE | |||
BCD8 | PUSH AF | |||
BCD9 | INC H | |||
BCDA | EXX | |||
BCDB | PUSH BC | |||
BCDC | PUSH DE | |||
BCDD | EX AF,AF' | |||
BCDE | PUSH AF | |||
BCDF | INC H | |||
BCE0 | LD SP,HL | Transfer another 14 bytes (112 pixels) | ||
BCE1 | POP AF | |||
BCE2 | EX AF,AF' | |||
BCE3 | POP DE | |||
BCE4 | POP BC | |||
BCE5 | EXX | |||
BCE6 | POP AF | |||
BCE7 | POP DE | |||
BCE8 | POP BC | |||
BCE9 | POP IX | |||
BCEB | LD SP,HL | |||
BCEC | PUSH IX | |||
BCEE | PUSH BC | |||
BCEF | PUSH DE | |||
BCF0 | PUSH AF | |||
BCF1 | INC H | |||
BCF2 | EXX | |||
BCF3 | PUSH BC | |||
BCF4 | PUSH DE | |||
BCF5 | EX AF,AF' | |||
BCF6 | PUSH AF | |||
BCF7 | INC H | |||
BCF8 | LD SP,HL | Transfer another 14 bytes (112 pixels) | ||
BCF9 | POP AF | |||
BCFA | EX AF,AF' | |||
BCFB | POP DE | |||
BCFC | POP BC | |||
BCFD | EXX | |||
BCFE | POP AF | |||
BCFF | POP DE | |||
BD00 | POP BC | |||
BD01 | POP IX | |||
BD03 | LD SP,HL | |||
BD04 | PUSH IX | |||
BD06 | PUSH BC | |||
BD07 | PUSH DE | |||
BD08 | PUSH AF | |||
BD09 | INC H | |||
BD0A | EXX | |||
BD0B | PUSH BC | |||
BD0C | PUSH DE | |||
BD0D | EX AF,AF' | |||
BD0E | PUSH AF | |||
BD0F | INC H | |||
BD10 | LD SP,HL | Transfer another 14 bytes (112 pixels) | ||
BD11 | POP AF | |||
BD12 | EX AF,AF' | |||
BD13 | POP DE | |||
BD14 | POP BC | |||
BD15 | EXX | |||
BD16 | POP AF | |||
BD17 | POP DE | |||
BD18 | POP BC | |||
BD19 | POP IX | |||
BD1B | LD SP,HL | |||
BD1C | PUSH IX | |||
BD1E | PUSH BC | |||
BD1F | PUSH DE | |||
BD20 | PUSH AF | |||
BD21 | INC H | |||
BD22 | EXX | |||
BD23 | PUSH BC | |||
BD24 | PUSH DE | |||
BD25 | EX AF,AF' | |||
BD26 | PUSH AF | |||
BD27 | INC H | |||
BD28 | BIT 2,H | Is the back buffer row multiple of 4? | ||
BD2A | JP NZ,draw_screen_1 | |||
BD2D | BIT 3,H | Is the back buffer row multiple of 8? | ||
BD2F | JR NZ,draw_screen_bd4d | |||
BD31 | LD H,$F0 | L -= $F0, H = $F0 | ||
BD33 | LD A,L | |||
BD34 | SUB H | |||
BD35 | LD L,A | |||
BD36 | JP NC,draw_screen_attributes | L >= $F0 | ||
BD39 | JP PE,draw_screen_bd45 | PE = parity even | ||
BD3C | EXX | |||
BD3D | LD DE,$F812 | Increment the screen address | ||
BD40 | ADD HL,DE | |||
BD41 | EXX | |||
BD42 | JP draw_screen_0 | |||
draw_screen_bd45 | BD45 | EXX | ||
BD46 | LD HL,$5011 | Point HL at screen pixel (136,128). | ||
BD49 | EXX | |||
BD4A | JP draw_screen_0 | Copy more | ||
draw_screen_bd4d | BD4D | EXX | ||
BD4E | LD DE,$F812 | |||
BD51 | ADD HL,DE | Which one are we modifying here? | ||
BD52 | EXX | |||
BD53 | LD A,L | |||
BD54 | SUB $10 | Ditto, which? | ||
BD56 | LD L,A | |||
BD57 | JP draw_screen_0 | |||
draw_screen_attributes | BD5A | LD A,($A220) | Don't update the attributes if the level intro screen is being shown | |
BD5D | AND A | |||
BD5E | JR NZ,draw_screen_exit | |||
BD60 | LD HL,$E34C | |||
BD63 | LD A,(HL) | Seems to be related to the horizon level | ||
BD64 | INC L | |||
BD65 | LD E,(HL) | |||
BD66 | LD (HL),A | |||
BD67 | LD A,E | |||
BD68 | OR A | Jump to exit check if both are zero | ||
BD69 | JR Z,draw_screen_4 | |||
BD6B | ADD A,A | E = A * 4 | ||
BD6C | ADD A,A | |||
BD6D | LD E,A | |||
BD6E | SBC A,A | A = $FF if carry set, zero otherwise | ||
BD6F | LD D,A | D = A | ||
BD70 | LD HL,($A186) | Fetch the address of the first line of ground attributes (+ 31) | ||
BD73 | LD BC,$6868 | Set the sky colour screen attributes (always black over bright cyan) | ||
BD76 | JR Z,draw_screen_2 | If A was zero then jump (Z => sky, NZ => ground) | ||
BD78 | LD BC,($5CF4) | Load the ground colour screen attributes (varies per level) | ||
BD7C | ADD HL,DE | Point SP at the screen attributes (DE = $FFE0 = -32) | ||
draw_screen_2 | BD7D | LD SP,HL | ||
BD7E | PUSH BC | Fill 30 bytes - length of attribute line minus the two blank edges | ||
BD7F | PUSH BC | |||
BD80 | PUSH BC | |||
BD81 | PUSH BC | |||
BD82 | PUSH BC | |||
BD83 | PUSH BC | |||
BD84 | PUSH BC | |||
BD85 | PUSH BC | |||
BD86 | PUSH BC | |||
BD87 | PUSH BC | |||
BD88 | PUSH BC | |||
BD89 | PUSH BC | |||
BD8A | PUSH BC | |||
BD8B | PUSH BC | |||
BD8C | PUSH BC | |||
BD8D | JR NZ,draw_screen_3 | |||
BD8F | ADD HL,DE | Move to next line of attributes | ||
draw_screen_3 | BD90 | LD ($A186),HL | Save the address of the first line of ground attributes (+ 31) | |
draw_screen_4 | BD93 | LD A,($A22E) | Exit if sighted_flag is zero (flashing lights / smash mode) | |
BD96 | AND A | |||
BD97 | JR Z,draw_screen_exit | |||
BD99 | LD A,($A230) | Jump if perp_caught_stage >= 3 (when car stops) | ||
BD9C | CP $03 | |||
BD9E | JR NC,draw_screen_exit | |||
Set the smash meter attributes
|
||||
BDA0 | LD HL,$5962 | Screen attribute (2,11) | ||
BDA3 | LD DE,$0020 | = 32 | ||
BDA6 | LD C,$50 | Black over bright red | ||
BDA8 | LD (HL),C | Set two attrs | ||
BDA9 | ADD HL,DE | |||
BDAA | LD (HL),C | |||
BDAB | ADD HL,DE | |||
BDAC | LD C,$58 | Black over bright magenta | ||
BDAE | LD (HL),C | Set two attrs | ||
BDAF | ADD HL,DE | |||
BDB0 | LD (HL),C | |||
BDB1 | ADD HL,DE | |||
BDB2 | LD C,$60 | Black over bright green | ||
BDB4 | LD (HL),C | Set two attrs | ||
BDB5 | ADD HL,DE | |||
BDB6 | LD (HL),C | |||
BDB7 | ADD HL,DE | |||
BDB8 | LD C,$78 | Black over bright white | ||
BDBA | LD (HL),C | Set two attrs | ||
BDBB | ADD HL,DE | |||
BDBC | LD (HL),C | |||
draw_screen_exit | BDBD | LD SP,$0000 | Restore SP (self modified at start of routine) | |
BDC0 | RET | Return |
Prev: BB69 | Up: Map | Next: BDC1 |