![]() |
Routines |
| Prev: A11A | Up: Map | Next: A18A |
|
Used by the routines at InitialiseCharacterDataStructure, LinkCharacterWhenFlagged, ProcessTextTokenStream, ReadPointerFirstDisplay, RecordResultCharacterScript, DispatchCharacterScript, CDBF, AllocateMemoryAndStoreCharacter and StoreResultHighByte.
Grows the workspace at 9FE3 by the size asked for, plus a three-byte header, and returns the new block.
|
||||
| AllocateMemory | A11C | PUSH IY | Add 03 to the total. | |
| A11E | PUSH HL | |||
| A11F | PUSH DE | |||
| A120 | PUSH BC | |||
| A121 | ADD A,$03 | |||
| A123 | LD C,A | |||
| A124 | LD B,$00 | Start the free-space search and read the list at 9FE3. | ||
| A126 | LD HL,($9FE3) | |||
| A129 | LD IY,$9FE3 | Point IY at the free-space list (9FE3). | ||
| AllocateMemory_Loop | A12D | LD A,L | Jump ahead to AllocateMemory_TestBitCountLink if the pointer is 0000. | |
| A12E | OR H | |||
| A12F | JR Z,AllocateMemory_TestBitCountLink | |||
| A131 | LD E,(HL) | Jump ahead to AllocateMemory_Next when the high byte of this free block is set. | ||
| A132 | INC HL | |||
| A133 | LD D,(HL) | |||
| A134 | INC HL | |||
| A135 | LD A,D | |||
| A136 | AND A | |||
| A137 | JR NZ,AllocateMemory_Next | |||
| A139 | LD A,E | Jump ahead to AllocateMemory_NextBlock if the first value is below the second. | ||
| A13A | CP C | |||
| A13B | JR C,AllocateMemory_NextBlock | |||
| AllocateMemory_Next | A13D | BIT 0,B | Jump ahead to AllocateMemory_KeepAllocationRemember if bit 0 is clear. | |
| A13F | JR Z,AllocateMemory_KeepAllocationRemember | |||
| A141 | PUSH HL | Read the pointer saved ahead of this record. | ||
| A142 | LD L,(IX-$02) | |||
| A145 | LD H,(IX-$01) | |||
| A148 | AND A | Compare HL with DE. | ||
| A149 | SBC HL,DE | |||
| A14B | POP HL | Restore HL from the stack. | ||
| A14C | JR C,AllocateMemory_NextBlock | Jump ahead to AllocateMemory_NextBlock if HL was below DE. | ||
| AllocateMemory_KeepAllocationRemember | A14E | PUSH HL | Copy the allocation into IX and remember the caller's index. | |
| A14F | POP IX | |||
| A151 | LD ($A11A),IY | |||
| A155 | SET 0,B | Set the mark on this character. | ||
| AllocateMemory_NextBlock | A157 | PUSH HL | Follow the next free block and repeat from AllocateMemory_Loop. | |
| A158 | POP IY | |||
| A15A | LD E,(HL) | |||
| A15B | INC HL | |||
| A15C | LD D,(HL) | |||
| A15D | EX DE,HL | |||
| A15E | JR AllocateMemory_Loop | |||
|
See whether bit 0 of the count is set, then read the link stored ahead of this record, then clear the high byte of the count.
|
||||
| AllocateMemory_TestBitCountLink | A160 | BIT 0,B | Jump ahead to StoreThatByteLinkAhead_JoinStep if bit 0 is clear. | |
| A162 | JR Z,StoreThatByteLinkAhead_JoinStep | |||
| A164 | LD L,(IX-$02) | Read the pointer saved ahead of this record and count 00. | ||
| A167 | LD H,(IX-$01) | |||
| A16A | LD B,$00 | |||
| A16C | AND A | Clear the carry before subtracting the block length from the free space. | ||
| A16D | SBC HL,BC | Measure the pointer against the count. | ||
| A16F | LD A,H | Read the high byte of the pointer. | ||
| A170 | AND A | Clear the carry so a zero high byte means only a few bytes of free space remain. | ||
| A171 | JR NZ,StoreThatByteLinkAhead | Jump to StoreThatByteLinkAhead when the free space still has a high byte. | ||
| A173 | LD A,L | Go to StoreThatByteLinkAhead if at least four bytes of free space remain. | ||
| A174 | CP $04 | |||
| A176 | JR NC,StoreThatByteLinkAhead | |||
| A178 | LD IY,($A11A) | Bring the saved index back from A11A and read the character id. | ||
| A17C | LD A,(IX+$00) | |||
| A17F | LD (IY+$00),A | Store the character id. | ||
| A182 | LD A,(IX+$01) | Jump ahead to StoreThatByteLinkAhead_TestBytePreviousMemory to step to the next character record. | ||
| A185 | LD (IY+$01),A | |||
| A188 | JR StoreThatByteLinkAhead_TestBytePreviousMemory | |||
| Prev: A11A | Up: Map | Next: A18A |