--- /dev/null
+#include <stdio.h>
+
+void dowrite(char *s, int len)
+{
+ int i;
+ for (i=0; i<len; i++)
+ {
+ write(1, s+i, 1);
+ }
+}
+
+void main()
+{
+ char buf[259];
+ int sz;
+ dowrite("\x1B" "A\x00\x00\x00...", 8);
+ fprintf(stderr, "Address sent\n");
+ while ((sz = read(0, buf+3, 128)) > 0)
+ {
+ buf[0] = 0x1B;
+ buf[1] = 'D';
+ buf[2] = sz - 1;
+ dowrite(buf, sz + 3);
+ dowrite(".", 1);
+ fprintf(stderr, "Data sent\n");
+ usleep(100000);
+ }
+}
\ No newline at end of file
- section "end",HOME[1024]
- nop
-
SECTION "a",HOME[$00]
start: jp main
section "tmro",HOME[$50]
jp tmro
+ SECTION "b",HOME[$100]
+boot: jr main ; $0100
+ nop ; $0102
+ nop ; $0103
+ ;Nintendo Logo ; $0104
+ DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
+ DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
+ DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
+ ;$0134
+ DB $00,$E7,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00
+ ;$0144
+ DB $00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00
+
main:
ld a, $FF
ld c, $51
--- /dev/null
+ SECTION "wee",HOME[$0]
+ ; this all needs to be PIC!
+st:
+ ld sp, $CFFF
+ xor a
+ ld hl, $FF60
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+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 .donak
+
+.eot:
+ ld A, $06 ; Ack the EOT
+ call putc+$FF80
+.rst: rst $00
+
+.soh: call getc+$FF80 ; blk
+ call getc+$FF80 ; iblk
+ xor a
+ ld b, a
+ ld l, a
+ ld h, $C0
+.lp: call getc+$FF80
+ ld [hli], a
+ add b
+ ld b, a
+ bit 7, l
+ jr z, .lp
+.cksm: call getc+$FF80
+ cp b
+ jr nz, .donak
+ ld hl, $C000
+.lp2: jr z, .doack
+ ld a, [hli]
+ ld [$FF63], A
+ bit 7, l
+ jr z,.lp2
+.doack: ld A, $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
+.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, $D000
+ ld a, [hl]
+ inc a
+ ld [hl], a
+ ld [$FF51], a
+ 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[$7F]
+ nop
\ No newline at end of file