| Technician Ted | Routines | 
| Prev: B5E6 | Up: Map | Next: B6F5 | 
| 
Used by the routine at AE77.
 
 | ||||||||
| B5FA | LD DE,$A000 | Attributes 1 | ||||||
| 
This entry point is used by the routine at AE77.
 | ||||||||
| B5FD | LD A,(IX+$00) | Get next command | ||||||
| B600 | INC IX | Move forward ready for the next one | ||||||
| B602 | CP $10 | Set carry flag if this command sets bits 0-3 | ||||||
| B604 | RRA | Put direction in carry flag | ||||||
| B605 | LD C,A | Store the remainder of the bits in C | ||||||
| B606 | LD A,$01 | Offset $01 for left / right | ||||||
| B608 | JR NC,$B60C | Move forward if left / right | ||||||
| B60A | LD A,$20 | Offset $20 for up / down | ||||||
| B60C | LD H,$00 | Store for offset in HL later | ||||||
| B60E | SRL C | Get positive / negative movement flag | ||||||
| B610 | JR NC,$B615 | Move forward if positive | ||||||
| B612 | NEG | Moving negative distance (left or up), convert to negative value | ||||||
| B614 | DEC H | Start from previous line | ||||||
| B615 | LD L,A | Put offset in L | ||||||
| B616 | LD ($A445),HL | Store this | ||||||
| B619 | LD A,C | Get bits 2-7 in A | ||||||
| B61A | SRL A | Get MOVE or DRAW command | ||||||
| B61C | JR NC,$B670 | Jump forward if MOVE | ||||||
| 
Draw the current UDG here
 | ||||||||
| B61E | SRL A | |||||||
| B620 | LD C,A | |||||||
| B621 | EX AF,AF' | |||||||
| B622 | LD A,($A444) | |||||||
| B625 | INC A | |||||||
| B626 | JR NZ,$B633 | |||||||
| B628 | LD HL,($A455) | |||||||
| B62B | LD A,(HL) | |||||||
| B62C | ADD A,C | |||||||
| B62D | LD (HL),A | |||||||
| B62E | INC HL | |||||||
| B62F | LD A,($A443) | |||||||
| B632 | LD (HL),A | |||||||
| B633 | EX AF,AF' | |||||||
| B634 | EX AF,AF' | |||||||
| B635 | LD C,D | |||||||
| B636 | LD A,D | |||||||
| B637 | RLCA | |||||||
| B638 | RLCA | |||||||
| B639 | RLCA | |||||||
| B63A | AND $08 | |||||||
| B63C | LD HL,$A45C | |||||||
| B63F | ADD A,(HL) | |||||||
| B640 | LD D,A | |||||||
| B641 | LD A,($A444) | |||||||
| B644 | INC A | |||||||
| B645 | JR NZ,$B655 | |||||||
| B647 | LD A,($A445) | |||||||
| B64A | RLA | |||||||
| B64B | JR NC,$B655 | |||||||
| B64D | LD HL,($A455) | |||||||
| B650 | INC HL | |||||||
| B651 | INC HL | |||||||
| B652 | LD (HL),E | |||||||
| B653 | INC HL | |||||||
| B654 | LD (HL),D | |||||||
| 
Copy the UDG data onto screen
 | ||||||||
| B655 | LD HL,($A441) | Get current UDG | ||||||
| B658 | LD B,$08 | 8 lines | ||||||
| B65A | LD A,(HL) | Get next line | ||||||
| B65B | LD (DE),A | Set it | ||||||
| B65C | INC HL | Next line in data | ||||||
| B65D | INC D | Next line on screen | ||||||
| B65E | DJNZ $B65A | Loop back if more to do | ||||||
| 
Put the attribute on screen
 | ||||||||
| B660 | LD D,C | Point DE to the attributes buffer | ||||||
| B661 | LD A,($A443) | Get current attribute | ||||||
| B664 | LD (DE),A | Set it on screen | ||||||
| B665 | LD HL,($A445) | Get current size and direction | ||||||
| B668 | ADD HL,DE | Set it to here and put it in HL | ||||||
| B669 | EX DE,HL | |||||||
| B66A | EX AF,AF' | Restore A | ||||||
| B66B | DEC A | Loop back to next iteration | ||||||
| B66C | JR NZ,$B634 | |||||||
| B66E | JR $B6A0 | |||||||
| 
Move in the direction specified
 | ||||||||
| B670 | SRL A | Put bit 3 in the carry flag. A now contains direction to move in | ||||||
| B672 | LD B,A | Put the remainder in B | ||||||
| B673 | EX AF,AF' | Remember flags | ||||||
| B674 | LD HL,($A445) | Get offset | ||||||
| B677 | EX DE,HL | Convert to an offset inside the attribute buffer | ||||||
| B678 | ADD HL,DE | |||||||
| B679 | DJNZ $B678 | Keep moving while there is more to do | ||||||
| B67B | EX DE,HL | Remember current location in DE | ||||||
| B67C | LD A,($A444) | |||||||
| B67F | INC A | |||||||
| B680 | JR NZ,$B69F | |||||||
| B682 | LD HL,($A455) | |||||||
| B685 | LD A,(HL) | |||||||
| B686 | AND A | |||||||
| B687 | JR Z,$B692 | |||||||
| B689 | INC HL | |||||||
| B68A | INC HL | |||||||
| B68B | INC HL | |||||||
| B68C | INC HL | |||||||
| B68D | LD (HL),$00 | |||||||
| B68F | LD ($A455),HL | |||||||
| B692 | INC HL | |||||||
| B693 | INC HL | |||||||
| B694 | LD A,D | |||||||
| B695 | RLCA | |||||||
| B696 | RLCA | |||||||
| B697 | RLCA | |||||||
| B698 | AND $08 | |||||||
| B69A | ADD A,$80 | |||||||
| B69C | LD (HL),E | |||||||
| B69D | INC HL | |||||||
| B69E | LD (HL),A | |||||||
| B69F | EX AF,AF' | Restore carry flag | ||||||
| B6A0 | JP NC,$B5FD | Jump back if not changing sprite | ||||||
| 
Change the current UDG, or end logic
 | ||||||||
| B6A3 | LD L,(IX+$00) | Put UDG ID in L | ||||||
| B6A6 | INC IX | Move to next entry in the room data | ||||||
| B6A8 | BIT 0,L | Is there an attribute change? | ||||||
| B6AA | JR Z,$B6B6 | Move forward if not | ||||||
| B6AC | LD A,(IX+$00) | Get the attribute | ||||||
| B6AF | INC IX | Move to next entry in the room data | ||||||
| B6B1 | LD ($A443),A | Set this as the current attribute | ||||||
| B6B4 | RES 0,L | Turn off the attribute flag | ||||||
| B6B6 | LD A,L | Restore in A | ||||||
| B6B7 | CP $FE | Is this an "end of data" command? | ||||||
| B6B9 | JR NZ,$B6D2 | No, so move forward and select the UDG | ||||||
| B6BB | LD A,($A444) | |||||||
| B6BE | INC A | |||||||
| B6BF | RET NZ | |||||||
| B6C0 | LD HL,($A455) | |||||||
| B6C3 | LD A,(HL) | |||||||
| B6C4 | AND A | |||||||
| B6C5 | JR Z,$B6CD | |||||||
| B6C7 | INC HL | |||||||
| B6C8 | INC HL | |||||||
| B6C9 | INC HL | |||||||
| B6CA | INC HL | |||||||
| B6CB | LD (HL),$00 | |||||||
| B6CD | INC HL | |||||||
| B6CE | LD ($A455),HL | |||||||
| B6D1 | RET | |||||||
| 
Set a new current UDG
 | ||||||||
| B6D2 | LD H,$00 | Convert UDG number (in L) to an offset | ||||||
| B6D4 | ADD HL,HL | |||||||
| B6D5 | ADD HL,HL | |||||||
| B6D6 | LD BC,($A423) | Add this to the base pointer for static UDGs | ||||||
| B6DA | ADD HL,BC | |||||||
| B6DB | LD ($A441),HL | Set this as the current value | ||||||
| B6DE | LD HL,$A462 | Get the flags for this room | ||||||
| B6E1 | SRL (HL) | Extract out the next bit | ||||||
| B6E3 | JP NC,$B5FD | If the bit is not set, this UDG should be printed | ||||||
| B6E6 | LD HL,$5000 | Select main screen. This will be overwritten by the main } room drawing process, and hence the UDG will not be displayed | ||||||
| B6E9 | LD ($A441),HL | |||||||
| B6EC | LD A,($A402) | Select new current attribute | ||||||
| B6EF | LD ($A443),A | |||||||
| B6F2 | JP $B5FD | Back to parsing | ||||||
| Prev: B5E6 | Up: Map | Next: B6F5 |