8 SECTION "config", HOME[$0]
9 myMAC: db $12, $34, $56, $78, $9A, $00
10 myIP: db $0A, $00, $00, $02
11 myMask: db $FF, $00, $00, $00
12 myGW: db $0A, $00, $00, $01
14 SECTION "boot", HOME[$100]
19 db $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83 ;<<< no $00,$c3,$50,$01
20 db $00,$0C,$00,$0D,$00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6
21 db $DD,$DD,$D9,$99,$BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F
22 db $BB,$B9,$33,$3E ; Standard Nintendo DO NOT CHANGE...
24 db "GB Ethernet " ; Cart name 16bytes
25 db $00,$00,$00 ; Not used
26 db $00 ; Cart type ROM Only
29 db $cf,$08 ; Maker ID Matthew Johnson
31 db $87 ; Complement check (Important)
32 db $ff,$ff ; Cheksum, fix this if you are going to
37 PUTSIL "Ethernet test ROM"
38 .lp: xor a ; Reset state machines
40 ld a, [ETH_STATUS] ; Load current status
48 ld bc, bssend - bssstart
73 PUTSI "getpacket: Got "
76 PUTSIL " byte packet from hardware."
83 PUTSI "ether_input: Packet to "
113 ; Verify the destination MAC.
124 ; Done? Then it was to us!
126 .notus: ; Was it to broadcast?
136 .us: PUTSIL "ether_input: It's to us!"
137 ; Which protocol does it belong to?
141 add hl, bc ; Skip source and dest MAC.
153 PUTSIL "ether_input: Not addressed to us and not broadcast."
157 PUTSIL "ether_input: Unknown protocol; dropping"
161 PUTSIL "ether_input: ARP packet"
165 PUTSIL "ether_input: IP packet"
170 ; First, verify that this is an ARP packet that we can handle.
190 PUTSIL "arp_input: Unknown protocol hardware or request"
193 db $00, $01, $08, $00, $06, $04, $00
196 PUTSIL "arp_input.req: Request"
197 ; Is it asking about us?
200 ld c, $10 ; SHA + SPA + THA
211 PUTSIL "arp_input.req: Aimed at us."
212 pop hl ; Now synthesize a response packet.
219 ld hl, 10 ; SHA + SPA
220 add hl, de ; Now DE points at SHA, and HL points at THA
227 pop hl ; HL now points at SHA
235 ld de, myIP ; HL now points at SPA
243 ld e, l ; HL now points at THA
245 add hl, de ; HL has now been backed up to the start of the ethernet header.
247 ld e, l ; DE now points at the dest
249 add hl, de ; HL now points at the source
256 ld hl, myMAC ; DE now points at the source
264 add hl, de ; HL now points at the start of the packet -- should be C000!
266 ld c, 64 ; Minimum size packet; avoid transmitting a runt
268 PUTSIL "arp_input.req: sent response!"
271 PUTSIL "arp_input.req: Not aimed at us; ignoring."
276 PUTSIL "arp_input.resp: Response"
287 PUTSIL "ip_input: not ipv4 -- fuck off"
330 PUTSIL "ip_input: checksum fail -- bailing"
334 PUTSIL "ip_input: checksum good"
341 PUTSI "ip_input: this packet is from 0x"
363 PUTSIL "ip_input: wheeeeeeeeeeeeeeee"
373 ; make hl point at beginning of data
379 ; ok, pass it off to something else
395 PUTSIL "ip_input: this packet is not to our IP address. Bailing."
400 PUTSIL "icmp_input: too lazy to parse -- fuck off"
404 PUTSIL "udp_input: too lazy to parse -- fuck off"
408 ld a, [ETH_STATUS] ; Wait for the port to become available.
423 SECTION "ethdata", BSS
426 arptable DS ARP_ENTRIES * ARP_ENTRY_SIZE