Jet Set Willy: Routine at 38622

| Routines

38622: Play an intro message sound effect

Used by the routine at 34762.
Input
A | Value between 50 and 81
38622 | LD E,A | Save the value of A in E for later retrieval
38623 | LD C,254 | We will output to port 254
38625 | LD D,A | Copy A into D; bits 0-2 of D determine the initial border colour
38626 | RES 4,D | Reset bit 4 of D (initial speaker state)
38628 | RES 3,D | Reset bit 3 of D (initial MIC state)
38630 | LD B,E | Initialise B (delay counter for the inner loop)
38631 | CP B | Is it time to flip the MIC and speaker and make the border black?
38632 | JR NZ,38636 | Jump if not
38634 | LD D,24 | Set bits 3 (MIC) and 4 (speaker) of D, and reset bits 0-2 (black border)
38636 | OUT (C),D | Set the MIC state, speaker state and border colour
38638 | DJNZ 38631 | Jump back until the inner loop is finished
38640 | DEC A | Is the outer loop finished too?
38641 | JR NZ,38625 | Jump back if not
38643 | RET |