]>
Commit | Line | Data |
---|---|---|
1 | SECTION "wee",HOME[$0] | |
2 | ; this all needs to be PIC! | |
3 | st: | |
4 | ld sp, $CFFF | |
5 | xor a | |
6 | ld hl, $FF60 | |
7 | ld [hli], a | |
8 | ld [hli], a | |
9 | ld [hli], a | |
10 | nak: | |
11 | ld a, $15 ; NAK | |
12 | call putc+$FF80 | |
13 | ||
14 | .ack: call getc+$FF80 | |
15 | cp $01 ;SOH | |
16 | jr z,.soh | |
17 | cp $04 ;EOT | |
18 | jr z, .eot | |
19 | cp $18 ;CAN | |
20 | jr z, .rst | |
21 | jr .donak | |
22 | ||
23 | .eot: | |
24 | ld A, $06 ; Ack the EOT | |
25 | call putc+$FF80 | |
26 | .rst: rst $00 | |
27 | ||
28 | .soh: call getc+$FF80 ; blk | |
29 | call getc+$FF80 ; iblk | |
30 | xor a | |
31 | ld b, a | |
32 | ld l, a | |
33 | ld h, $C0 | |
34 | .lp: call getc+$FF80 | |
35 | ld [hli], a | |
36 | add b | |
37 | ld b, a | |
38 | bit 7, l | |
39 | jr z, .lp | |
40 | .cksm: call getc+$FF80 | |
41 | cp b | |
42 | jr nz, .donak | |
43 | ld hl, $C000 | |
44 | .lp2: jr z, .doack | |
45 | ld a, [hli] | |
46 | ld [$FF63], A | |
47 | bit 7, l | |
48 | jr z,.lp2 | |
49 | .doack: ld A, $06 | |
50 | call putc+$FF80 | |
51 | jr .ack | |
52 | .donak: call getc+$FF80 ; Wait until the line clears, and then once | |
53 | jr .donak ; that happens, getc will cause a NAK. | |
54 | ||
55 | getc: | |
56 | xor d | |
57 | xor e | |
58 | .dgetc: | |
59 | dec de | |
60 | xor a | |
61 | cp d | |
62 | jr z, .timeout | |
63 | ld a, [$FF53] | |
64 | and $02 | |
65 | jr z, .dgetc | |
66 | ld a, [$FF52] | |
67 | ret | |
68 | .timeout: | |
69 | ld hl, $D000 | |
70 | ld a, [hl] | |
71 | inc a | |
72 | ld [hl], a | |
73 | ld [$FF51], a | |
74 | jr nak | |
75 | ||
76 | putc: | |
77 | ld c, $53 | |
78 | push af | |
79 | .waitport: | |
80 | ld a,[c] | |
81 | and $01 | |
82 | jr nz,.waitport | |
83 | pop af | |
84 | ld [$FF52],a | |
85 | ret | |
86 | ||
87 | section "a", HOME[$7F] | |
88 | nop |