![]() |
Routines |
| Prev: 36275 | Up: Map | Next: 36472 |
|
||||||||||||||||||
| 36327 | LD A,C | Load room number into A | ||||||||||||||||
| 36328 | LD HL,25440 | Point HL at start of table of current characters' locations (i.e. Gimbal, Thor etc.) | ||||||||||||||||
| 36331 | LD DE,25307 | Point DE at table of characters' slots in their current rooms | ||||||||||||||||
| 36334 | LD IX,36472 | Point IX at 36472 list of occupied slots... | ||||||||||||||||
| 36338 | LD (IX+0),0 | ...and set three bytes there to zeroes... | ||||||||||||||||
| 36342 | LD (IX+1),0 | ... | ||||||||||||||||
| 36346 | LD (IX+2),0 | ... | ||||||||||||||||
| 36350 | PUSH BC | Store BC | ||||||||||||||||
| 36351 | LD B,8 | Load B with 8 | ||||||||||||||||
| 36353 | CP (HL) | Compare a character's current screen number with room number passed to this routine (in A)... | ||||||||||||||||
| 36354 | JR NZ,36364 | ...and if they're not the same then skip ahead to 36364 (move onto next character, if applicable) | ||||||||||||||||
| 36356 | EX AF,AF' | Swap registers | ||||||||||||||||
| 36357 | LD A,(DE) | Load character's slot (i.e. order of arrival in the room) into A | ||||||||||||||||
| 36358 | LD (IX+0),A | Copy slot into table at 36472 | ||||||||||||||||
| 36361 | INC IX | Advance IX to next entry in this table | ||||||||||||||||
| 36363 | EX AF,AF' | Exchange registers | ||||||||||||||||
| 36364 | INC HL | Advance HL by three bytes (i.e. skip over x- and y-coordinates to get to screen number of next character)... | ||||||||||||||||
| 36365 | INC HL | ... | ||||||||||||||||
| 36366 | INC HL | ... | ||||||||||||||||
| 36367 | INC DE | Advance DE by one byte to get slot of next character | ||||||||||||||||
| 36368 | DJNZ 36353 | Loop back if previous character was not the last | ||||||||||||||||
| 36370 | POP BC | Restore BC | ||||||||||||||||
| 36371 | LD IX,36472 | Point IX at list of occupied slots | ||||||||||||||||
| 36375 | LD A,1 | If one of the characters in room C has a slot of 1... | ||||||||||||||||
| 36377 | CP (IX+0) | ...then jump ahead to 36394... | ||||||||||||||||
| 36380 | JR Z,36394 | ... | ||||||||||||||||
| 36382 | CP (IX+1) | ... | ||||||||||||||||
| 36385 | JR Z,36394 | ... | ||||||||||||||||
| 36387 | CP (IX+2) | ... | ||||||||||||||||
| 36390 | JR Z,36394 | ... | ||||||||||||||||
| 36392 | JR 36435 | ...else jump to 36435 | ||||||||||||||||
| 36394 | LD A,2 | If one of the characters in room C has a slot of 2... | ||||||||||||||||
| 36396 | CP (IX+0) | ...then jump ahead to 36413... | ||||||||||||||||
| 36399 | JR Z,36413 | ... | ||||||||||||||||
| 36401 | CP (IX+1) | ... | ||||||||||||||||
| 36404 | JR Z,36413 | ... | ||||||||||||||||
| 36406 | CP (IX+2) | ... | ||||||||||||||||
| 36409 | JR Z,36413 | ... | ||||||||||||||||
| 36411 | JR 36435 | ...else jump to 36435 | ||||||||||||||||
| 36413 | LD A,3 | If one of the characters in room C has a slot of 3... | ||||||||||||||||
| 36415 | CP (IX+0) | ...then jump ahead to 36432... | ||||||||||||||||
| 36418 | JR Z,36432 | ... | ||||||||||||||||
| 36420 | CP (IX+1) | ... | ||||||||||||||||
| 36423 | JR Z,36432 | ... | ||||||||||||||||
| 36425 | CP (IX+2) | ... | ||||||||||||||||
| 36428 | JR Z,36432 | ... | ||||||||||||||||
| 36430 | JR 36435 | ...else jump to 36435 | ||||||||||||||||
| 36432 | LD A,4 | Return with A=4... | ||||||||||||||||
| 36434 | RET | ... | ||||||||||||||||
| 36435 | LD E,A | Load highest slot among characters plus one in room into E | ||||||||||||||||
| 36436 | PUSH DE | Store DE (E=lowest empty slot) | ||||||||||||||||
| 36437 | PUSH BC | Store BC (B=character index, C=room number) | ||||||||||||||||
| 36438 | DEC A | Decrease A to get index of lowest empty slot... | ||||||||||||||||
| 36439 | ADD A,A | ...double it... | ||||||||||||||||
| 36440 | LD E,A | ...and load into DE... | ||||||||||||||||
| 36441 | LD D,0 | ... | ||||||||||||||||
| 36443 | LD B,0 | Set B to zero | ||||||||||||||||
| 36445 | PUSH BC | Copy BC into HL... | ||||||||||||||||
| 36446 | POP HL | ...so that HL contains room number passed to this routine initially | ||||||||||||||||
| 36447 | ADD HL,HL | Double room number... | ||||||||||||||||
| 36448 | ADD HL,BC | ...add room number again (now three times)... | ||||||||||||||||
| 36449 | ADD HL,HL | ...and double again to get six times original room number in HL | ||||||||||||||||
| 36450 | LD BC,53938 | Point BC at table of coordinates of character positions in rooms | ||||||||||||||||
| 36453 | ADD HL,BC | Add to six times room number into HL | ||||||||||||||||
| 36454 | ADD HL,DE | Add to this double (slot - 1) from DE | ||||||||||||||||
| 36455 | LD C,(HL) | Load x- and y-coordinates into BC | ||||||||||||||||
| 36456 | INC HL | ... | ||||||||||||||||
| 36457 | LD B,(HL) | ... | ||||||||||||||||
| 36458 | EXX | Exchange all registers | ||||||||||||||||
| 36459 | POP BC | Restore BC (B=character index, C=room number) | ||||||||||||||||
| 36460 | LD HL,25307 | Point HL at table of characters' slots in their current rooms | ||||||||||||||||
| 36463 | LD D,0 | Load input character index into DE... | ||||||||||||||||
| 36465 | LD E,B | ... | ||||||||||||||||
| 36466 | ADD HL,DE | Add as offset to HL | ||||||||||||||||
| 36467 | POP DE | Restore DE (E=lowest empty slot) | ||||||||||||||||
| 36468 | LD (HL),E | Set this character's slot to be lowest empty slot in this room | ||||||||||||||||
| 36469 | LD A,E | Set A to slot number just filled | ||||||||||||||||
| 36470 | EXX | Exchange all registers | ||||||||||||||||
| 36471 | RET | Return | ||||||||||||||||
| Prev: 36275 | Up: Map | Next: 36472 |