![]() |
Routines |
| Prev: 929C | Up: Map | Next: 92EE |
|
Used by the routine at update_missile.
Called by update_missile when the missile has no target. The type is first tested for a free record by INC A, so the SUB $14 after it leaves the type less $13, the same index as type_points's. Goes through the first seven records at object_records and picks, of those drawn this pass, the one whose type is worth most in missile_target_values, putting its record number in the high nibble of the missile's +$17 (the low nibble is cleared with it). None found: +$17 stays $F0. The best value so far is kept in scratch_count.
|
||||||||
| find_missile_target | 92B4 | LD IY,object_records | Seven records; best value 0 | |||||
| 92B8 | LD B,$07 | |||||||
| 92BA | XOR A | |||||||
| 92BB | LD (scratch_count),A | |||||||
| find_missile_target_0 | 92BE | BIT 7,(IY+$10) | Drawn this pass, and in use | |||||
| 92C2 | JR Z,find_missile_target_1 | |||||||
| 92C4 | LD A,(IY+$00) | |||||||
| 92C7 | INC A | |||||||
| 92C8 | JR Z,find_missile_target_1 | |||||||
| 92CA | SUB $14 | Its value, by the type less $13 (the INC A above); not more than the best: skip | ||||||
| 92CC | LD HL,missile_target_values | |||||||
| 92CF | CALL add_a_to_hl | |||||||
| 92D2 | LD A,(scratch_count) | |||||||
| 92D5 | CP (HL) | |||||||
| 92D6 | JR NC,find_missile_target_1 | |||||||
| 92D8 | LD A,(HL) | The best so far | ||||||
| 92D9 | LD (scratch_count),A | |||||||
| 92DC | LD A,B | Its record number, in the high nibble of +$17 | ||||||
| 92DD | XOR $07 | |||||||
| 92DF | ADD A,A | |||||||
| 92E0 | ADD A,A | |||||||
| 92E1 | ADD A,A | |||||||
| 92E2 | ADD A,A | |||||||
| 92E3 | LD (IX+$17),A | |||||||
| find_missile_target_1 | 92E6 | LD DE,$0018 | Next record | |||||
| 92E9 | ADD IY,DE | |||||||
| 92EB | DJNZ find_missile_target_0 | |||||||
| 92ED | RET | |||||||
| Prev: 929C | Up: Map | Next: 92EE |