]> Joshua Wise's Git repositories - fpgaboy.git/blame - fpgaboot.asm
Fix the UART, and set it to 19k2 for more stable operation. Make the downloader a...
[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
bf3f2c5f
JW
101.dl: dec c
102 jr z, .done
103 call getc
298e8085 104 ld [$FF63], A
bf3f2c5f
JW
105 jr .dl
106.done: ld A, $44 ;D
107 jr putc
108
298e8085
JW
109.prog:
110 ld hl, $FF80
111 ld c, $7F
112.pl: dec c
bf3f2c5f 113 jp z, .progboot
298e8085
JW
114 call getc
115 ld [hli], a
116 jr .pl
bf3f2c5f
JW
117.progboot:
118 ld a, $50 ;P
119 call putc
120 jp $FF80
298e8085 121
49c326da
JW
122 SECTION "a", HOME[$100]
123 nop ; Make sure we don't overflow.
124
This page took 0.038344 seconds and 4 git commands to generate.