forked from gardners/c65gs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethertest.a65
103 lines (82 loc) · 1.72 KB
/
ethertest.a65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
; Ethernet controller test program for the C65GS
; Include C64 BASIC program load header
.word $0801
.org $0801
.scope
.word _next, 10 ; Next line and current line number
.byte $97, "2,0:", $9e, " 2014", $AA, "65",0 ; POKE 2,0 : SYS 2014+65
_next: .word 0
iter1: .byte 0
.checkpc 2079
.advance 2079
programentrypoint:
; Enable C65GS io
lda #$47
sta $d02f
lda #$53
sta $D02f
; Map ethernet registers at $6000 - $7FFF
; Ethernet controller really lives $FFDE000 - $FFDEFFF, so select $FF megabyte section for MAP LO
lda #$ff
ldx #$0f
ldy #$00
ldz #$00
map
eom
; now enable mapping of $DE000-$DFFFF at $6000
; MAPs are offset based, so we need to subtract $6000 from the target address
; $DE000 - $6000 = $D8000
lda #$80
ldx #$8d
ldy #$00
ldz #$00
map
eom
; Ethernet registers should now be visible from $6000 - $6FFF
; read buffer will be at $6800 - $6FFF
; make sure ethernet transceiver is on and not generating IRQs
; (we will poll it).
; also make sure that we acknowledge the last received packet so that the
; ethernet controller knows it can receive.
lda $d6e1
lsr
and #$02
ora #$01
sta $d6e1
lda #$17
sta $d018
packetloop:
lda $d6e1
and #$20
beq packetloop
; clear eth RX signal, and leave ethernet tranceiver on
; and make last used RX buffer visible
lda $d6e1
and #$04
lsr
ora #$01
sta $d6e1
; to clear the screen
lda #$93
jsr $ffd2
; Show contents of latest packet
ldx #$00
loop1: lda $6800,x
sta $0428,x
lda $6900,x
sta $0528,x
lda $6a00,x
sta $0628,x
lda $6ac8,x
sta $0700,x
inx
bne loop1
; Print length of packet
lda $6801
ldx $6800
jsr $BDCD
lda #$20
jsr $FFD2
jmp packetloop
.scend
.outfile "ethertest.prg"