SECTION "boot", HOME[$0]
- ld a, $AA
+boot: ld a, $AA
ld [$FF51], A ; Poke the LEDs
+
+ ld sp, $FFFE
+
+ ld hl, signon
+ call puts
; Write a little bit to the RAM
- ld H, $01
- ld L, $00
- ld A, $00
+ ld hl, $0104
+ xor a
ld [HLI], A
ld [HLI], A
ld [HLI], A
ld [HLI], A
ld [HLI], A
- ld a, $55
- ld [$FF51], A ; Poke the LEDs
-
ld A, $FF
ld [HLI], A
ld [HLI], A
ld [HLI], A
ld [HLI], A
- ld H, $00
- ld L, $00
- ld [HL], $01 ; Select the GB boot rom
- rst $00 ; Boot
+ ld c, $51
+.wait: ld a, [c]
+ cp $00
+ jr nz, .wait
+
+ ld h, a
+ ld l, a
+ ld [hl], $01 ; Select the GB boot rom
+
+ ld a, $55
+ ld [c], a
+
+ ld hl, booting
+ call puts
+
+ rst $00 ; Boot
+
+putc:
+ ld c, $53
+ push af
+.waitport:
+ ld a,[c]
+ cp $00
+ jr nz,.waitport
+ pop af
+ ld [$FF52],a
+ ret
+
+puts:
+ ld a, [hli]
+ cp $00
+ ret z
+ call putc
+ jr puts
+
+signon:
+ db $0D,$0A,$1B,"[1mFPGABoy Boot ROM",$1B,"[0m",$0D,$0A,0
+booting:
+ db "Booting...",$0D,$0A,0
+
+
SECTION "a", HOME[$100]
nop ; Make sure we don't overflow.
\ No newline at end of file