SECTION "wee",HOME[\$0] ; this all needs to be PIC! ; xor a ; ld hl, \$FF60 ; ld [hli], a ; ld [hli], a ; ld [hli], a st: ld sp, \$CFFF nak: ld a, \$15 ; NAK call putc+\$FF80 .ack: call getc+\$FF80 ; cp \$01 ;SOH ; jr z,.soh cp \$04 ;EOT jr z, .eot cp \$18 ;CAN jr z, .rst jr nak .eot: ld A, \$06 ; Ack the EOT call putc+\$FF80 .rst: rst \$00 .soh: call getc+\$FF80 ; blk call getc+\$FF80 ; iblk ld b, \$00 ld hl, \$C000 .lp: bit 7, l jr nz, .cksm call getc+\$FF80 ld [hli], a add b ld b, a jr .lp .cksm: call getc+\$FF80 cp b jr nz, .donak ld hl, \$C000 .lp2: ld a, [hli] ld [\$FF63], A bit 7, l jr z,.lp2 .doack: ld A, \$06 ; 06 call putc+\$FF80 jr .ack .donak: call getc+\$FF80 ; Wait until the line clears, and then once jr .donak ; that happens, getc will cause a NAK. getc: xor d ;xor e ; Possibly not needed? .dgetc: dec de xor a cp d jr z, .timeout ld a, [\$FF53] and \$02 jr z, .dgetc ld a, [\$FF52] ret .timeout: ld hl, \$D010 ld a, [hl] inc a ld [hl], a ld [\$FF51], a pop hl jr nak putc: ld c, \$53 push af .waitport: ld a,[c] and \$01 jr nz,.waitport pop af ld [\$FF52],a ret section "a", HOME[\$7E] nop