| Ant Attack | Routines |
| Prev: 8E0B | Up: Map | Next: 8E80 |
|
Used by the routine at PLAY_SCRIPT.
Every message the machine code shows and every sound it makes is a script in SCRIPTS: the Dth record there, counting the $FF that ends each. The first byte is a stream to print to (2, the upper screen); then, until $FF:
$80-$FF: a sound -- bits 0-3 a note from TONES, $0F meaning noise, and bits 4-6 one less than how many times. $7D: the next byte is an attribute to fill the play area with. $7E: the next byte is the low byte of the address of a two-byte number, in the variables, to print. Anything else is printed, control codes and all.
|
||||||||
| RUN_SCRIPT | 8E0D | LD IY,ERR_NR | Find the Dth $FF from SCRIPTS... | |||||
| 8E11 | LD HL,SCRIPTS | |||||||
| 8E14 | LD BC,$0800 | |||||||
| 8E17 | LD A,$FF | |||||||
| RUN_SCRIPT_0 | 8E19 | CPIR | ...or give up after 2K. | |||||
| 8E1B | RET PO | |||||||
| 8E1C | DEC D | |||||||
| 8E1D | JR NZ,RUN_SCRIPT_0 | |||||||
| 8E1F | PUSH HL | IX = the script. | ||||||
| 8E20 | POP IX | |||||||
| 8E22 | LD A,(IX+$00) | Stream 1 or 2, or nothing. | ||||||
| 8E25 | INC IX | |||||||
| 8E27 | DEC A | |||||||
| 8E28 | CP $02 | |||||||
| 8E2A | RET NC | |||||||
| 8E2B | INC A | |||||||
| 8E2C | CALL $1601 | |||||||
| RUN_SCRIPT_1 | 8E2F | LD A,(IX+$00) | The next byte; $FF ends. | |||||
| 8E32 | INC IX | |||||||
| 8E34 | CP $FF | |||||||
| 8E36 | RET Z | |||||||
| 8E37 | AND A | A sound? | ||||||
| 8E38 | JP P,RUN_SCRIPT_4 | |||||||
| 8E3B | LD B,A | D = how many times. | ||||||
| 8E3C | AND $70 | |||||||
| 8E3E | RLCA | |||||||
| 8E3F | RLCA | |||||||
| 8E40 | RLCA | |||||||
| 8E41 | RLCA | |||||||
| 8E42 | INC A | |||||||
| 8E43 | LD D,A | |||||||
| 8E44 | LD A,B | E = the note; $0F is noise. | ||||||
| 8E45 | AND $0F | |||||||
| 8E47 | CP $0F | |||||||
| 8E49 | JR Z,RUN_SCRIPT_3 | |||||||
| RUN_SCRIPT_2 | 8E4B | PUSH AF | Play the note D times. | |||||
| 8E4C | CALL TONE | |||||||
| 8E4F | POP AF | |||||||
| 8E50 | DEC D | |||||||
| 8E51 | JR NZ,RUN_SCRIPT_2 | |||||||
| 8E53 | JR RUN_SCRIPT_1 | |||||||
| RUN_SCRIPT_3 | 8E55 | LD B,$00 | Or the noise. | |||||
| 8E57 | CALL NOISE | |||||||
| 8E5A | DEC D | |||||||
| 8E5B | JR NZ,RUN_SCRIPT_3 | |||||||
| 8E5D | JR RUN_SCRIPT_1 | |||||||
| RUN_SCRIPT_4 | 8E5F | CP $7E | $7E: a number. | |||||
| 8E61 | JR Z,RUN_SCRIPT_6 | |||||||
| 8E63 | CP $7D | $7D: a colour. | ||||||
| 8E65 | JR Z,RUN_SCRIPT_5 | |||||||
| 8E67 | RST $10 | Print anything else. | ||||||
| 8E68 | JR RUN_SCRIPT_1 | |||||||
| RUN_SCRIPT_5 | 8E6A | LD A,(IX+$00) | Fill the play area with the colour. | |||||
| 8E6D | INC IX | |||||||
| 8E6F | CALL FILL_PLAY_ATTRIBUTES | |||||||
| 8E72 | JR RUN_SCRIPT_1 | |||||||
| RUN_SCRIPT_6 | 8E74 | LD L,(IX+$00) | Print the number whose address has the next byte as its low byte and $B4 as its high. | |||||
| 8E77 | INC IX | |||||||
| 8E79 | LD H,$B4 | |||||||
| 8E7B | CALL $1A28 | |||||||
| 8E7E | JR RUN_SCRIPT_1 | |||||||
| Prev: 8E0B | Up: Map | Next: 8E80 |