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