![]() |
Routines |
A | Character's new animatory state |
D | Character's new y-coordinate (155-169) |
E | Character's new x-coordinate (0-95) |
H | Character number (152-172) |
25008 | LD L,96 | Point to byte 96 of the character's buffer |
25010 | LD (HL),A | Set the new animatory state |
25011 | LD B,A | Store the animatory state in B for later |
25012 | INC L | L=97 |
25013 | LD (HL),D | Set the new y-coordinate |
25014 | INC L | L=98 |
25015 | LD (HL),E | Set the new x-coordinate |
25016 | LD A,(32512) | A=column at far left of screen (0-64) |
25019 | SUB 3 | Is the far left of the skool in view? |
25021 | JR C,25025 | Jump if so |
25023 | CP E | Is the character off-screen to the left? |
25024 | RET NC | Return if so (SRB does not need updating) |
25025 | ADD A,34 | |
25027 | CP E | Is the character off-screen to the right? |
25028 | RET C | Return if so (SRB does not need updating) |
25029 | SUB 32 | |
25031 | CPL | A=256-(32512) |
25032 | ADD A,E | A=character's x-coordinate minus (32512): -2<=A<=31 |
25033 | PUSH HL | Save the character number |
25034 | LD L,B | L=character's animatory state |
25035 | LD H,173 | Character UDG references are stored in pages 173-184 |
25037 | BIT 7,A | Is the left column of the character sprite on-screen? |
25039 | JR Z,25051 | Jump if so |
25041 | LD H,177 | Pages 177-180 store UDG references for the middle column of sprites |
25043 | INC A | -1<=A<=0 |
25044 | BIT 7,A | Is the middle column of the character sprite on-screen at the left? |
25046 | JR Z,25051 | Jump if so |
25048 | INC A | A=0 |
25049 | LD H,181 | Pages 181-184 store UDG references for the right column of sprites |
25051 | RLCA | Set the instruction at 27015 to SET n,(HL) where n is the appropriate bit of the SRB byte that needs to be set |
25052 | RLCA | |
25053 | RLCA | |
25054 | LD E,A | |
25055 | AND 56 | |
25057 | ADD A,198 | |
25059 | LD (27016),A | |
25062 | LD A,E | A=8c (c=0-31: leftmost column of screen covered by sprite) |
25063 | RLCA | |
25064 | RLCA | |
25065 | AND 3 | A=INT(c/8) |
25067 | LD E,A | E=INT(c/8) |
25068 | LD A,D | A=character's y-coordinate (155-169) |
25069 | SUB 149 | 5<=A<=20 |
25071 | ADD A,A | |
25072 | ADD A,A | A=4*(D-149) |
25073 | ADD A,E | A=4*(D-149)+INT(c/8) |
25074 | LD E,A | E=12+4*(D-152)+INT(c/8) |
25075 | LD D,127 | Now HL points to the relevant byte of the SRB (32524-32607), and DE points to the base address of the character UDG references |
25077 | EX DE,HL | |
25078 | CALL 27008 | Update the SRB for one column of the character's sprite |
25081 | JR NZ,25104 | Jump if we just updated the SRB for the right column of the sprite |
25083 | SUB 16 | Point HL back to the relevant byte of the SRB (32524-32607) |
25085 | LD L,A | |
25086 | LD A,(27016) | Change the instruction at 27015 from SET n,(HL) to SET n+1,(HL) |
25089 | ADD A,8 | |
25091 | LD (27016),A | |
25094 | JR NC,25078 | Jump back unless 27015 was previously SET 7,(HL) |
25096 | INC L | Move to the next byte of the SRB |
25097 | LD A,L | The zero flag will be set now if we "wrapped around" to the left side of the screen, i.e. the next column of the character sprite is off-screen to the right |
25098 | AND 3 | |
25100 | LD A,198 | This will change the instruction at 27015 to SET 0,(HL) |
25102 | JR NZ,25091 | Jump back to consider the remaining on-screen columns of the character sprite |
25104 | POP HL | Restore the character number (152-172) to H |
25105 | RET |