X-Git-Url: http://git.joshuawise.com/fpgaboy.git/blobdiff_plain/1eefdc8e89a69963b1c1a084fe4ecec844997293..HEAD:/fpgaboot.asm diff --git a/fpgaboot.asm b/fpgaboot.asm index 4a1089f..dfb4ec9 100644 --- a/fpgaboot.asm +++ b/fpgaboot.asm @@ -7,34 +7,22 @@ boot: ld a, $AA ld hl, signon call puts - ; Write a little bit to the RAM - ld hl, $0104 - xor a - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A +.wait: ld a, [$FF53] + and $02 + jr z, .nodata + ld a, [$FF52] + ld [$FF51], a - ld A, $FF - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - ld [HLI], A - - ld c, $51 - -.wait: ld a, [c] + cp $1B ; Escape + jp z, .cbc + ld [$FF52], a +.cbc: call z, bootcmd + +.nodata: ld a, [$FF51] cp $00 jr nz, .wait +doboot: xor a ld h, a ld l, a ld [hl], $01 ; Select the GB boot rom @@ -47,12 +35,17 @@ boot: ld a, $AA rst $00 ; Boot +signon: + db $0D,$0A,$1B,"[1mFPGABoy Boot ROM",$1B,"[0m",$0D,$0A,0 +booting: + db "Booting...",$0D,$0A,0 + putc: ld c, $53 push af .waitport: ld a,[c] - cp $00 + and $01 jr nz,.waitport pop af ld [$FF52],a @@ -65,12 +58,67 @@ puts: call putc jr puts -signon: - db $0D,$0A,$1B,"[1mFPGABoy Boot ROM",$1B,"[0m",$0D,$0A,0 -booting: - db "Booting...",$0D,$0A,0 +getc: + ld a, [$FF53] + and $02 + jr z, getc + ld a, [$FF52] + ret +bootcmd: + call getc + cp $56 ;V + jr z,.version + cp $41 ;A + jr z,.addr + cp $44 ;D + jr z,.data + cp $50 ;P + jr z,.prog + cp $42 ;B + jr z,doboot + cp $1B + jr z,bootcmd ; If you keep yelling, you're bound to get the thing's attention. + ld a, $3f ;? + jr putc +.version: + ld hl, .verstr + jr puts +.verstr: + db "V1.00",0 +.addr: + call getc + ld [$FF60], A + call getc + ld [$FF61], A + call getc + ld [$FF62], A + ld A, $41 ;A + jr putc +.data: + call getc ; byte count + ld c, a +.dl: dec c + jr z, .done + call getc + ld [$FF63], A + jr .dl +.done: ld A, $44 ;D + jr putc +.prog: + ld hl, $D800 + ld c, $00 +.pl: dec c + jp z, .progboot + call getc + ld [hli], a + jr .pl +.progboot: + ld a, $50 ;P + call putc + jp $D800 + SECTION "a", HOME[$100] nop ; Make sure we don't overflow. \ No newline at end of file