Cut 1 at an onboard bootloader
[fpgaboy.git] / fpgaboot.asm
CommitLineData
49c326da 1 SECTION "boot", HOME[$0]
1eefdc8e 2boot: ld a, $AA
49c326da 3 ld [$FF51], A ; Poke the LEDs
1eefdc8e
JW
4
5 ld sp, $FFFE
6
7 ld hl, signon
8 call puts
49c326da 9
298e8085
JW
10.wait: ld a, [$FF53]
11 and $02
12 jr z, .nodata
13 ld a, [$FF52]
14 ld [$FF51], a
49c326da 15
298e8085
JW
16 cp $1B ; Escape
17 jp z, .cbc
18 ld [$FF52], a
19.cbc: call z, bootcmd
20
21.nodata: ld a, [$FF51]
1eefdc8e
JW
22 cp $00
23 jr nz, .wait
24
298e8085 25doboot: xor a
1eefdc8e
JW
26 ld h, a
27 ld l, a
28 ld [hl], $01 ; Select the GB boot rom
29
30 ld a, $55
31 ld [c], a
32
33 ld hl, booting
34 call puts
35
36 rst $00 ; Boot
37
298e8085
JW
38signon:
39 db $0D,$0A,$1B,"[1mFPGABoy Boot ROM",$1B,"[0m",$0D,$0A,0
40booting:
41 db "Booting...",$0D,$0A,0
42
1eefdc8e
JW
43putc:
44 ld c, $53
45 push af
46.waitport:
47 ld a,[c]
298e8085 48 and $01
1eefdc8e
JW
49 jr nz,.waitport
50 pop af
51 ld [$FF52],a
52 ret
53
54puts:
55 ld a, [hli]
56 cp $00
57 ret z
58 call putc
59 jr puts
60
298e8085
JW
61getc:
62 ld a, [$FF53]
63 and $02
64 jr z, getc
65 ld a, [$FF52]
66 ret
1eefdc8e 67
298e8085
JW
68bootcmd:
69 call getc
70 cp $56 ;V
71 jr z,.version
72 cp $41 ;A
73 jr z,.addr
74 cp $44 ;D
75 jr z,.data
76 cp $50 ;P
77 jr z,.prog
78 cp $42 ;B
79 jr z,doboot
80 cp $1B
81 jr z,bootcmd ; If you keep yelling, you're bound to get the thing's attention.
82 ld a, $3f ;?
83 jr putc
84.version:
85 ld hl, .verstr
86 jr puts
87.verstr:
88 db "V1.00",0
89.addr:
90 call getc
91 ld [$FF60], A
92 call getc
93 ld [$FF61], A
94 call getc
95 ld [$FF62], A
96 ld A, $41 ;A
97 jr putc
98.data:
99 call getc ; byte count
100 ld c, a
101.dl: call getc
102 ld [$FF63], A
103 dec c
104 jp nz, .dl
105 ld A, $44 ;D
106 ret
107.prog:
108 ld hl, $FF80
109 ld c, $7F
110.pl: dec c
111 jp z, $FF80
112 call getc
113 ld [hli], a
114 jr .pl
115
49c326da
JW
116 SECTION "a", HOME[$100]
117 nop ; Make sure we don't overflow.
118
This page took 0.030808 seconds and 4 git commands to generate.