| Dun Darach | Routines | 
| Prev: 9FE6 | Up: Map | 
| 
 
 | |||||||||||||||||||
| 
Both N/S and E/W paths can be tested.
 
Coordinates should be switched to match the axis and vector for the paths required.
 | |||||||||||||||||||
| Path_FindByCoord | A017 | LD (TempAl),BC | |||||||||||||||||
| A01B | LD HL,$FFFC | ||||||||||||||||||
| A01E | ADD HL,DE | ||||||||||||||||||
| A01F | EX DE,HL | ||||||||||||||||||
| Path_FindByCoord_0 | A020 | LD L,(IX+$00) | Get axis of path. | ||||||||||||||||
| A023 | LD H,(IX+$01) | ||||||||||||||||||
| A026 | AND A | Get difference to coord. | |||||||||||||||||
| A027 | SBC HL,DE | ||||||||||||||||||
| A029 | JR NC,Path_FindByCoord_2 | ||||||||||||||||||
| 
Next path.
 | |||||||||||||||||||
| Path_FindByCoord_1 | A02B | LD BC,$000C | Move onto next road | ||||||||||||||||
| A02E | ADD IX,BC | ||||||||||||||||||
| A030 | JR Path_FindByCoord_0 | ||||||||||||||||||
| Path_FindByCoord_2 | A032 | LD BC,$0009 | Check value is within margin | ||||||||||||||||
| A035 | SBC HL,BC | ||||||||||||||||||
| A037 | JR C,Path_FindByCoord_3 | ||||||||||||||||||
| 
Path not found.
 | |||||||||||||||||||
| A039 | SCF | IF greater than margin, just end. | |||||||||||||||||
| A03A | RET | ||||||||||||||||||
| Path_FindByCoord_3 | A03B | LD BC,(TempAl) | |||||||||||||||||
| A03F | LD L,(IX+$02) | Get end A of road. | |||||||||||||||||
| A042 | LD H,(IX+$03) | ||||||||||||||||||
| A045 | SCF | Difference | |||||||||||||||||
| A046 | SBC HL,BC | ||||||||||||||||||
| A048 | JR NC,Path_FindByCoord_1 | ||||||||||||||||||
| A04A | LD L,(IX+$04) | Get end B of road. | |||||||||||||||||
| A04D | LD H,(IX+$05) | ||||||||||||||||||
| A050 | AND A | Get difference | |||||||||||||||||
| A051 | SBC HL,BC | ||||||||||||||||||
| A053 | JR C,Path_FindByCoord_1 | ||||||||||||||||||
| 
Path found.
 | |||||||||||||||||||
| A055 | LD A,(_a19e) | Simply return with the result. | |||||||||||||||||
| A058 | AND A | ||||||||||||||||||
| A059 | RET NZ | ||||||||||||||||||
| 
Search through table.
 | |||||||||||||||||||
| A05A | PUSH IX | ||||||||||||||||||
| A05C | POP DE | ||||||||||||||||||
| A05D | LD HL,$B137 | ||||||||||||||||||
| A060 | LD B,$0C | Loop | |||||||||||||||||
| A062 | LD C,$00 | Number of matches. | |||||||||||||||||
| 
_
 | |||||||||||||||||||
| Path_FindByCoord_4 | A064 | LD A,E | |||||||||||||||||
| A065 | CP (HL) | ||||||||||||||||||
| A066 | INC HL | ||||||||||||||||||
| A067 | JR NZ,Path_FindByCoord_5 | ||||||||||||||||||
| A069 | LD A,D | ||||||||||||||||||
| A06A | CP (HL) | ||||||||||||||||||
| A06B | JR NZ,Path_FindByCoord_5 | ||||||||||||||||||
| A06D | INC C | Found, increase match counter. | |||||||||||||||||
| Path_FindByCoord_5 | A06E | INC HL | |||||||||||||||||
| A06F | DJNZ Path_FindByCoord_4 | ||||||||||||||||||
| A071 | LD A,C | See if two or more have been found. | |||||||||||||||||
| A072 | CP $02 | ||||||||||||||||||
| A074 | CCF | If the result if less, return carry to indicate failed to find path. | |||||||||||||||||
| A075 | RET | ||||||||||||||||||
| DistanceA | A076 | DEFW $0029 | |||||||||||||||||
| DistanceB | A078 | DEFW $0029 | |||||||||||||||||
| Prev: 9FE6 | Up: Map |