![]() |
Routines |
Prev: 24993 | Up: Map |
Used by many routines. Sets the new animatory state and location of a character, and updates the screen refresh buffer (SRB) accordingly.
|
||||||||||||||||
25008 | LD L,96 | Point HL at byte 96 of the character's buffer | ||||||||||||||
25010 | LD (HL),A | Set the new animatory state | ||||||||||||||
25011 | LD B,A | Store the new 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 | ||||||||||||||
This entry point is used by the routine at 25108.
|
||||||||||||||||
25016 | LD A,(32512) | A=leftmost column of the skool on-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 | A=character's screen x-coordinate: -2<=A<=31 | ||||||||||||||
25031 | CPL | |||||||||||||||
25032 | ADD A,E | |||||||||||||||
25033 | PUSH HL | Save the character number | ||||||||||||||
25034 | LD L,B | L=character's new animatory state | ||||||||||||||
25035 | LD H,173 | Pages 173-176 store UDG references for the left column of the sprites | ||||||||||||||
25037 | BIT 7,A | Is the left column of the 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 the sprites | ||||||||||||||
25043 | INC A | -1<=A<=0 | ||||||||||||||
25044 | BIT 7,A | Is the middle column of the 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 the sprites | ||||||||||||||
At this point, A holds the leftmost column of the screen (0-31) occupied by the character's sprite, and H holds the page number (173, 177, 181) corresponding to the leftmost column of the sprite that appears on-screen.
|
||||||||||||||||
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 the screen occupied by the 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 | A=4*(D-149) | ||||||||||||||
25072 | ADD A,A | |||||||||||||||
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, and DE points to the base address of the sprite 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 | ||||||||||||||
25085 | LD L,A | |||||||||||||||
25086 | LD A,(27016) | Prepare to change the instruction at 27015 from SET n,(HL) to SET n+1,(HL) | ||||||||||||||
25089 | ADD A,8 | |||||||||||||||
25091 | LD (27016),A | Change the instruction at 27015 from SET n,(HL) to SET n+1,(HL) or SET 0,(HL) | ||||||||||||||
25094 | JR NC,25078 | Jump back unless the instruction at 27015 should be changed to SET 0,(HL) now | ||||||||||||||
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 sprite | ||||||||||||||
25104 | POP HL | Restore the character number (152-172) to H | ||||||||||||||
25105 | RET |
Prev: 24993 | Up: Map |