+ SECTION "wee",HOME[$0]
+outlp: ; Read a packet out if one is waiting.
+ ld a, [$FF69]
+ ld h, a
+ call puthex+$D800
+ ld a, [$FF69]
+ ld l, a
+ call puthex+$D800
+rxlp: ld a, h
+ or l
+ jr z, tx
+ dec hl
+ ld a, [$FF69]
+ call puthex+$D800
+ jr rxlp
+tx: ld a, 13
+ call putc+$D800
+ ld a, 10
+ call putc+$D800
+ ld a, [$FF51]
+ ld [$D800+diqing], a
+ ld a, $0
+ ld [$FF69], a
+ ld a, $60
+ ld c, a
+ ld hl, $D800+bleep
+ ld [$FF69], a
+lp: ld a, [hli]
+ ld [$FF69], a
+ dec c
+ jr nz, lp
+ ld hl, $0000
+dl1: dec hl
+ ld a, [$FF68]
+ ld [$FF51], a
+ ld a, h
+ or l
+ jr nz, dl1
+ jr outlp
+bleep: db $FF, $FF, $FF, $FF, $FF, $FF
+ db $00, $12, $34, $56, $78, $90
+ db $08, $00
+
+ db $45, $00, $00, $2E, $00, $00, $00, $00, $80, $11
+ db $26, $bd
+ db $0A, $00, $00, $02
+ db $0A, $00, $00, $01
+
+ db $04, $00, $04, $00, $00, $1A, $00, $00
+
+diqing: db $01, $02, $03, $04, $05, $06, $07, $08
+
+putc:
+ push af
+.waitport:
+ ld a,[$FF53]
+ and $01
+ jr nz,.waitport
+ pop af
+ ld [$FF52],a
+ ret
+
+puthex: ; Put two hex nibbles to the serial console.
+ push bc
+ push hl
+ push af
+ swap a
+ and $0F
+ ld hl,hex+$D800
+ ld b,0
+ ld c,a
+ add hl,bc
+ ld a, [hl]
+ call putc+$D800
+ pop af
+ and $0F
+ ld hl,hex+$D800
+ ld c,a
+ add hl,bc
+ ld a, [hl]
+ call putc+$D800
+ pop hl
+ pop bc
+ ret
+hex: db "0123456789ABCDEF"
+
+ section "anus", HOME[$100]
+ nop