|  | Routines | 
| Prev: 9D71 | Up: Map | Next: 9F0C | 
| 
Used by the routine at 947A.
 | ||||
| 9E02 | LD A,($A05F) | Return if atoms are not flushing on teleporting | ||
| 9E05 | OR A | |||
| 9E06 | RET Z | |||
| 9E07 | LD IY,$9F14 | Set IY to the address for the Rex atoms data buffer during teleporting | ||
| 9E0B | LD B,$14 | Set BC to the number of 'Rex atoms' (20) | ||
| 
This entry point is used by the routine at 9E52.
 | ||||
| 9E0D | PUSH BC | Save BC | ||
| 9E0E | LD A,(IY+$00) | If atom is not configured jump to iniciatise atom data | ||
| 9E11 | OR A | |||
| 9E12 | JP Z,$9E8A | |||
| 9E15 | LD A,($A0B6) | Set A093 the x-position of the atom, based on x-offset of atom and x-position of Rex | ||
| 9E18 | ADD A,(IY+$01) | |||
| 9E1B | LD ($A093),A | |||
| 9E1E | AND $07 | Set A the graphic data for atom based on bit2-0 x-position of atom | ||
| 9E20 | LD E,A | |||
| 9E21 | LD D,$00 | |||
| 9E23 | LD HL,$9F0C | |||
| 9E26 | ADD HL,DE | |||
| 9E27 | LD A,(HL) | |||
| 9E28 | PUSH AF | Save AF | ||
| 9E29 | LD A,(IY+$02) | Computes into HL the address into room graphic data of the atom | ||
| 9E2C | LD L,A | |||
| 9E2D | LD H,$00 | |||
| 9E2F | ADD HL,HL | |||
| 9E30 | ADD HL,HL | |||
| 9E31 | ADD HL,HL | |||
| 9E32 | ADD HL,HL | |||
| 9E33 | ADD HL,HL | |||
| 9E34 | LD A,($A093) | |||
| 9E37 | SRL A | |||
| 9E39 | SRL A | |||
| 9E3B | SRL A | |||
| 9E3D | LD E,A | |||
| 9E3E | LD D,$00 | |||
| 9E40 | ADD HL,DE | |||
| 9E41 | LD DE,$EAFF | |||
| 9E44 | ADD HL,DE | |||
| 9E45 | POP AF | Restore AF | ||
| 9E46 | OR (HL) | Put the graphic data atom in this location | ||
| 9E47 | LD (HL),A | |||
| 9E48 | LD A,($A062) | if teleporting Rex at game begin jump to update atom position | ||
| 9E4B | OR A | |||
| 9E4C | JP Z,$9ED7 | |||
| 9E4F | JP $9EF4 | Jump to update atom position | ||
| 
Process another atom
 | ||||
| 9E52 | LD DE,$0003 | Point IY to the next atom into Rex atom data table | ||
| 9E55 | ADD IY,DE | |||
| 9E57 | POP BC | Restore BC | ||
| 9E58 | DJNZ $9E0D | Jump back until all atoms has been processed | ||
| 
All atoms processed
 | ||||
| 9E5A | LD A,($A062) | Jump forward if Rex is teleporing on init game | ||
| 9E5D | OR A | |||
| 9E5E | JP Z,$9E6D | |||
| 9E61 | LD A,($A0B7) | Decrement y-position of Rex if y-position less than 24 | ||
| 9E64 | DEC A | |||
| 9E65 | CP $18 | |||
| 9E67 | JP C,$9E6D | |||
| 9E6A | LD ($A0B7),A | |||
| 9E6D | LD A,($A061) | Decrement teleporting loop counter | ||
| 9E70 | DEC A | |||
| 9E71 | LD ($A061),A | |||
| 9E74 | OR A | Return if loop counter is not zero | ||
| 9E75 | RET NZ | |||
| 
Loop counter for teleporting finished
 | ||||
| 9E76 | LD A,$01 | Set Rex visible | ||
| 9E78 | LD ($A05D),A | |||
| 9E7B | XOR A | Finish teleporting | ||
| 9E7C | LD ($A05F),A | |||
| 9E7F | LD ($A060),A | |||
| 9E82 | LD A,($A055) | Jump to resume game after Rex is dead | ||
| 9E85 | OR A | |||
| 9E86 | JP NZ,$9C76 | |||
| 9E89 | RET | |||
| 
Initialise data for Rex atoms during teleporting
 | ||||
| 9E8A | LD A,($A062) | Jump forward if teleporting Rex after dead | ||
| 9E8D | OR A | |||
| 9E8E | JP NZ,$9EB2 | |||
| 
Rex is teleporting on game begin
 | ||||
| 9E91 | LD A,($A061) | If teleporting loop counter < 50 jump to process next atom | ||
| 9E94 | CP $32 | |||
| 9E96 | JP C,$9E52 | |||
| 9E99 | CALL $A388 | Set A a random number between 4 and 19 | ||
| 9E9C | AND $0F | |||
| 9E9E | ADD A,$04 | |||
| 9EA0 | LD (IY+$00),A | Set this number as y-delta into data buffer for atom y-position variation | ||
| 9EA3 | CALL $A388 | Set A a random number between 0 and 15 | ||
| 9EA6 | AND $0F | |||
| 9EA8 | LD (IY+$01),A | Set this number as x-offset into the teleporting data buffer | ||
| 9EAB | LD (IY+$02),$00 | Set 0 as y-position of Rex atoms into the teleporting data buffer | ||
| 9EAF | JP $9E52 | Jump to process next atom | ||
| 
Rex is teleporting after dead
 | ||||
| 9EB2 | LD A,($A061) | If teleporting loop counter < 50 jump to process next atom | ||
| 9EB5 | CP $32 | |||
| 9EB7 | JP C,$9E52 | |||
| 9EBA | CALL $A388 | Set A a random number between 4 and 19 | ||
| 9EBD | AND $0F | |||
| 9EBF | ADD A,$04 | |||
| 9EC1 | LD (IY+$00),A | Set this number as y-delta into data buffer for atom y-position variation | ||
| 9EC4 | CALL $A388 | Set A a random number between 0 and 15 | ||
| 9EC7 | AND $0F | |||
| 9EC9 | LD (IY+$01),A | Set this number as x-offset into the teleporting data buffer | ||
| 9ECC | LD A,($A0B7) | Set the y-position of Rex minus 4 the y-position for Rex atoms during teleporting | ||
| 9ECF | SUB $04 | |||
| 9ED1 | LD (IY+$02),A | |||
| 9ED4 | JP $9E52 | Jump to process next atom | ||
| 
Update data for the atom when teleporting Rex at game begin
 | ||||
| 9ED7 | LD A,(IY+$02) | Set A the y-position of atom | ||
| 9EDA | ADD A,(IY+$00) | Add to A the y-offset of atom | ||
| 9EDD | LD HL,$A0B7 | Compare atom y-position with Rex y-position | ||
| 9EE0 | CP (HL) | |||
| 9EE1 | JP C,$9EEE | Jump forward if Rex y-position is greater than y-position of atom | ||
| 9EE4 | LD (IY+$00),$00 | Reset y-offset | ||
| 9EE8 | CALL $9D0F | Set Rex visible | ||
| 9EEB | JP $9E52 | Jump to process next atom | ||
| 9EEE | LD (IY+$02),A | Set the new y-position for the atom | ||
| 9EF1 | JP $9E52 | Jump to process next atom | ||
| 
Update data for the atom when teleporting Rex afer dead
 | ||||
| 9EF4 | LD A,(IY+$02) | Set A the y-position of atom | ||
| 9EF7 | SUB (IY+$00) | substract to A the y-offset of atom | ||
| 9EFA | CP $DF | Jump forward if atom y-position greater than 32 | ||
| 9EFC | JP C,$9F06 | |||
| 9EFF | LD (IY+$00),$00 | Reset y-offset | ||
| 9F03 | JP $9E52 | Jump to process next atom | ||
| 9F06 | LD (IY+$02),A | Set the new y-position for the atom | ||
| 9F09 | JP $9E52 | Jump to process next atom | ||
| Prev: 9D71 | Up: Map | Next: 9F0C |