| Technician Ted | Routines |
| Prev: 8277 | Up: Map | Next: 8341 |
|
Used by the routine at 8277.
|
||||||||
| 82D4 | LD E,(HL) | Put the on-screen address in DE | ||||||
| 82D5 | INC HL | |||||||
| 82D6 | LD D,(HL) | |||||||
| 82D7 | INC HL | |||||||
| 82D8 | LD C,(HL) | Put the frame counter in BC | ||||||
| 82D9 | INC HL | |||||||
| 82DA | LD B,$00 | |||||||
| 82DC | LD A,C | |||||||
| 82DD | BIT 0,(HL) | Are we going left or right? | ||||||
| 82DF | JR Z,$82E8 | Jump forward if we're going left | ||||||
| 82E1 | ADD A,$20 | Get the next frame to the right | ||||||
| 82E3 | LD C,A | |||||||
| 82E4 | LD A,E | |||||||
| 82E5 | ADC A,B | |||||||
| 82E6 | JR $82EF | |||||||
| 82E8 | SUB $20 | Get the next frame to the left | ||||||
| 82EA | LD C,A | |||||||
| 82EB | LD A,E | |||||||
| 82EC | SBC A,B | |||||||
| 82ED | LD B,$01 | |||||||
| 82EF | LD E,A | Store the next frame | ||||||
| 82F0 | CPL | Flip all the bits, but only keep the bottom 5 | ||||||
| 82F1 | AND $1F | |||||||
| 82F3 | JR NZ,$82FD | Move on if we don't need to change direction | ||||||
|
A sprite needs changing direction. Don't get the next frame counter, position and direction, but instead just reuse these values and go the other way.
|
||||||||
| 82F5 | LD (HL),B | Current direction | ||||||
| 82F6 | DEC HL | |||||||
| 82F7 | LD C,(HL) | Current position | ||||||
| 82F8 | DEC HL | |||||||
| 82F9 | DEC HL | |||||||
| 82FA | LD E,(HL) | Current frame counter | ||||||
| 82FB | JR $8305 | |||||||
|
Otherwise, get the next set of values to animate with
|
||||||||
| 82FD | LD B,(HL) | Next direction | ||||||
| 82FE | DEC HL | |||||||
| 82FF | LD (HL),C | Next position | ||||||
| 8300 | DEC HL | |||||||
| 8301 | DEC HL | |||||||
| 8302 | LD (HL),E | Next frame counter | ||||||
| 8303 | CP $00 | |||||||
|
Put the sprite on screen
|
||||||||
| 8305 | LD HL,$8077 | Base address of sprites | ||||||
| 8308 | ADD HL,BC | Add 100 for right-facing, otherwise 0 | ||||||
| 8309 | EX DE,HL | Swap this with the screen offset to write to | ||||||
| 830A | LD C,$01 | Repeat this twice for 16 lines | ||||||
| 830C | LD B,$08 | Writing 8 lines at a time | ||||||
| 830E | LD A,(DE) | Get the first half of the line | ||||||
| 830F | LD (HL),A | Put it on screen | ||||||
| 8310 | INC L | Move onto next half on screen | ||||||
| 8311 | INC DE | Move onto next half in sprite buffer | ||||||
| 8312 | LD A,(DE) | Get the second half of the line | ||||||
| 8313 | LD (HL),A | Put it on screen | ||||||
| 8314 | DEC L | Move back to left half on screen | ||||||
| 8315 | INC DE | Move to next line in sprite buffer | ||||||
| 8316 | INC H | Move onto next line on screen | ||||||
| 8317 | DJNZ $830E | Loop round to write the next line | ||||||
| 8319 | DEC C | Done the second half yet? | ||||||
| 831A | LD BC,$F820 | Point to second half of sprite | ||||||
| 831D | ADD HL,BC | |||||||
| 831E | JR Z,$830C | Loop back if second half not yet done | ||||||
|
At this point we are done with all animation and need to resync the tape signal
|
||||||||
| 8320 | POP BC | Restore flags | ||||||
| 8321 | POP DE | |||||||
| 8322 | EXX | |||||||
| 8323 | LD B,$B0 | Timing constant | ||||||
| 8325 | CALL $8362 | Get a edge change from tape | ||||||
| 8328 | LD A,$16 | Loop round again | ||||||
| 832A | DEC A | |||||||
| 832B | JR NZ,$832A | |||||||
| 832D | CALL C,$8362 | If we got an edge change, there shouldn't be another one within this time frame | ||||||
| 8330 | JP NC,$0000 | If there was an edge change, the tape is out of sync. Reset. | ||||||
| 8333 | LD B,$02 | Wait for a bit | ||||||
| 8335 | DJNZ $8335 | |||||||
| 8337 | EXX | Increment the animation change flag to compensate for drawing | ||||||
| 8338 | INC C | |||||||
| 8339 | INC C | |||||||
| 833A | INC DE | Is anything else queued? | ||||||
| 833B | LD A,(DE) | |||||||
| 833C | AND A | |||||||
| 833D | JP NZ,$8277 | Jump back if so | ||||||
| 8340 | RET | Otherwise all done | ||||||
| Prev: 8277 | Up: Map | Next: 8341 |