Prev: 65323 Up: Map Next: 65372
65326: Calculate new co-ordinates using relative offsets
Used by the routines at LINE_ROUTINE, FILL_ROUTINE and PERFORM_SHADE.
Input
C new X co-ordinate
B new Y co-ordinate
CALC_RELATIVE_OFFSETS 65326 CALL GET_OFFSETS Get offsets required
65329 LD BC,(23677) Get current co-ordinates
65333 LD A,C A=current X co-ordinate
65334 BIT 6,(IX+0) Should this be a negative X offset?
65338 JR Z,CALC_RELATIVE_OFFSETS_0 If not, jump to adding X offset
65340 SUB E Subtract X offset from current X co-ord
65341 JP CALC_RELATIVE_OFFSETS_1 Skip over adding X offset
CALC_RELATIVE_OFFSETS_0 65344 ADD A,E Add X offset to current X co-ord
This entry point is used by the routine at 65323.
CALC_RELATIVE_OFFSETS_1 65345 LD C,A C=new X co-ordinate
65346 LD A,B A=current Y co-ordinate
65347 BIT 7,(IX+0) Should there be a negative Y offset?
65351 JR Z,CALC_RELATIVE_OFFSETS_2 If not, skip to adding Y offset
65353 SUB D Subtract Y offset from current Y co-ord
65354 JR NC,CALC_RELATIVE_OFFSETS_4 Is this less than 0? If not, set new Y co-ord and exit
65356 SUB 80 If so, adjust Y co-ord to wrap around screen
65358 JP CALC_RELATIVE_OFFSETS_4 Set new Y co-ord and exit
CALC_RELATIVE_OFFSETS_2 65361 ADD A,D Add Y-offset to current Y co-ord
65362 JR C,CALC_RELATIVE_OFFSETS_3 Does this exceed 255? If so, skip to subtracting 176.
65364 CP 176 Does this exceed 176?
65366 JR C,CALC_RELATIVE_OFFSETS_4 If not, no adjustment needed
CALC_RELATIVE_OFFSETS_3 65368 SUB 176 If new co-ord is offscreen, subtract 176
This entry point is used by the routine at CALC_RELATIVE_OFFSETS_0.
CALC_RELATIVE_OFFSETS_4 65370 LD B,A B=new Y co-ordinate
65371 RET
Prev: 65323 Up: Map Next: 65372