Routines
| Prev: D2F2 | Up: Map | Next: D33C |
D305: Add up a byte of the things in thing A (the work of $D2ED/$D2F2)
|
||||||||||||||||
| D305 | PUSH IX | Save IX on the stack | ||||||||||||||
| D307 | LD IX,$8B6F | Start at the first thing | ||||||||||||||
| D30B | CALL $D21C | Call the routine "Step to the next thing's record (D206), keeping A" (D21C) - Next thing; Z at the end | ||||||||||||||
| D30E | JR Z,$D334 | If the zero flag is set, skip ahead to D334 | ||||||||||||||
| D310 | CP (IY+$01) | Compare A with the holder byte (+1) of the thing record at IY - Is it in A? | ||||||||||||||
| D313 | JR NZ,$D30B | If A differs from the holder byte (+1) of the thing record at IY, go back to D30B | ||||||||||||||
| D315 | PUSH AF | Save AF on the stack | ||||||||||||||
| D316 | SUB A | Clear A to zero - B = 0: weights (+3), all the way down; B <> 0: sizes (+2), this level only | ||||||||||||||
| D317 | CP B | Compare A with B | ||||||||||||||
| D318 | LD A,C | Copy C into A | ||||||||||||||
| D319 | JR Z,$D324 | If A equals B, skip ahead to D324 | ||||||||||||||
| D31B | ADD A,(IY+$02) | Add the size byte (+2) of the thing record at IY to A - Add its size; over 127 gives $FF | ||||||||||||||
| D31E | JP PE,$D337 | If the parity/overflow flag is set, skip ahead to D337 | ||||||||||||||
| D321 | LD C,A | Copy A into C | ||||||||||||||
| D322 | JR $D331 | Skip ahead to D331 | ||||||||||||||
| D324 | ADD A,(IY+$03) | Add the weight byte (+3) of the thing record at IY to A - Add its weight; over 127 gives $FF | ||||||||||||||
| D327 | JP PE,$D337 | If the parity/overflow flag is set, skip ahead to D337 | ||||||||||||||
| D32A | LD C,A | Copy A into C | ||||||||||||||
| D32B | LD A,(IX+$00) | Read the number byte (+0) of the thing record at IX into A - and the weight of what it holds | ||||||||||||||
| D32E | CALL $D305 | Call the routine "Add up a byte of the things in thing A (the work of..." (D305) | ||||||||||||||
| D331 | POP AF | Restore AF from the stack | ||||||||||||||
| D332 | JR $D30B | Go back to D30B | ||||||||||||||
| D334 | POP IX | Restore IX from the stack | ||||||||||||||
| D336 | RET | Return to the caller | ||||||||||||||
| D337 | POP AF | Restore AF from the stack - Overflow: C = $FF | ||||||||||||||
| D338 | LD C,$FF | Load C with $FF | ||||||||||||||
| D33A | JR $D334 | Go back to D334 | ||||||||||||||
| Prev: D2F2 | Up: Map | Next: D33C |