B | Number of game characters to consider |
D | Row of play area (0-20) |
E | Column of play area (0-191) |
H | Number of first character to consider |
24576 | 2E01 | LD L,1 | (HL)=x-coordinate of character |
24578 | 7B | LD A,E | A=column of play area (0-191) |
24579 | 96 | SUB (HL) | |
24580 | FE03 | CP 3 | Game characters are three character squares wide |
24582 | 3044 | JR NC,24652 | Jump if no part of this game character is in this column |
24584 | 2D | DEC L | (HL)=animatory state of game character |
24585 | CB7E | BIT 7,(HL) | Is the character facing left? |
24587 | 2803 | JR Z,24592 | Jump if so |
24589 | 2F | CPL | |
24590 | C603 | ADD A,3 | |
24592 | 87 | ADD A,A | Now C=0 if the back of the character is in this column, 4 if it's the middle, and 8 if it's the front |
24593 | 87 | ADD A,A | |
24594 | 4F | LD C,A | |
24595 | 2E02 | LD L,2 | (HL)=y-coordinate of game character |
24597 | 7A | LD A,D | A=row of play area (0-20) |
24598 | 96 | SUB (HL) | |
24599 | FE04 | CP 4 | Game characters are 4 character squares tall |
24601 | 3031 | JR NC,24652 | Jump if no part of this game character is in this row |
24603 | 81 | ADD A,C | 0≤A≤11 (character square of game character at this row and column, where 0=bottom back, 4=bottom middle, 8=bottom front, 11=top front) |
24604 | C6D7 | ADD A,215 | 215≤A≤226 |
24606 | D9 | EXX | |
24607 | 67 | LD H,A | |
24608 | D9 | EXX | |
24609 | 2E00 | LD L,0 | |
24611 | 7E | LD A,(HL) | A=animatory state of game character |
24612 | F680 | OR 128 | 128≤A≤255 |
24614 | D9 | EXX | |
24615 | 6F | LD L,A | 128≤L≤255 (215≤H≤226) |
24616 | 7E | LD A,(HL) | A=game character UDG reference (73-255) |
24617 | A7 | AND A | |
24618 | 281F | JR Z,24651 | Jump if this is the "null" UDG (a blank square) |
24620 | 5F | LD E,A | E=UDG reference (73-255) |
24621 | 7D | LD A,L | A=(normalised) animatory state (128-255) |
24622 | FED0 | CP 208 | 208=animatory state of MR WACKER, first teacher |
24624 | D9 | EXX | |
24625 | 7E | LD A,(HL) | A=animatory state (0-255) |
24626 | D9 | EXX | |
24627 | 16B7 | LD D,183 | Point to graphic data at page 183 onwards |
24629 | 3802 | JR C,24633 | Jump unless dealing with animatory states 208-255 (teachers, ALBERT, and water from pistol) |
24631 | 16C7 | LD D,199 | Point to graphic data at page 199 onwards |
24633 | 2170E1 | LD HL,57712 | Point HL at the UDG buffer |
24636 | 07 | RLCA | |
24637 | 3811 | JR C,24656 | Jump if character is facing right |
24639 | EB | EX DE,HL | |
24640 | 1A | LD A,(DE) | A=byte already in UDG buffer |
24641 | B6 | OR (HL) | OR with the game character UDG byte |
24642 | 24 | INC H | |
24643 | A6 | AND (HL) | AND with the outline mask for this game character UDG byte |
24644 | 24 | INC H | Point to the next UDG byte |
24645 | 12 | LD (DE),A | Place the resultant byte back in the UDG buffer |
24646 | 1C | INC E | |
24647 | CB5B | BIT 3,E | |
24649 | 28F5 | JR Z,24640 | Jump back unless all 8 bytes have been done |
24651 | D9 | EXX | |
24652 | 24 | INC H | Next game character |
24653 | 10B1 | DJNZ 24576 | Jump back until all characters done |
24655 | C9 | RET | |
24656 | 06B6 | LD B,182 | Page 182 (46592 to 46847) contains mirror images of 0-255 |
24658 | 1A | LD A,(DE) | A=game character UDG byte |
24659 | 4F | LD C,A | |
24660 | 0A | LD A,(BC) | A=mirror image of this game character UDG byte |
24661 | B6 | OR (HL) | OR on what's already in the UDG buffer |
24662 | 77 | LD (HL),A | Put the result so far back in the UDG buffer |
24663 | 14 | INC D | |
24664 | 1A | LD A,(DE) | A=outline mask for this game character UDG byte |
24665 | 4F | LD C,A | |
24666 | 0A | LD A,(BC) | Mirror it |
24667 | A6 | AND (HL) | AND it with what's in the UDG buffer |
24668 | 77 | LD (HL),A | Place the result in the UDG buffer |
24669 | 14 | INC D | Next game character UDG byte |
24670 | 2C | INC L | Next byte of UDG buffer |
24671 | CB5D | BIT 3,L | |
24673 | 28EF | JR Z,24658 | Jump back unless all 8 bytes have been done |
24675 | 18E6 | JR 24651 |