]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
Fix POP AF test (from blargg's CPU tests)
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Wed, 21 May 2008 20:12:51 +0000 (16:12 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Wed, 21 May 2008 20:12:51 +0000 (16:12 -0400)
auxboot.c
core/insn_pop_reg.v
flashboot.asm [new file with mode: 0644]
flashdiag.asm [new file with mode: 0644]
flashprog.asm [new file with mode: 0644]
fpgaboot.asm

index c5ce3af4fc15860b1235ed1b5d75ecc884039e0c..2024bfe0d1a57b61d0a0f47007953e568e03aa3f 100644 (file)
--- a/auxboot.c
+++ b/auxboot.c
@@ -13,11 +13,8 @@ void main()
 {
   char buf[259];
   int sz;
-  buf[0] = 0x1B;
-  buf[1] = 'A';
-  buf[2] = buf[3] = buf[4] = 0;
-  dowrite(buf, 5);
+  buf[0] = '\e';
   buf[1] = 'P';
-  read(0, buf+2, 127);
-  dowrite(buf, 129);
+  read(0, buf+2, 256);
+  dowrite(buf, 257);
 }
\ No newline at end of file
index 55d12ece5331ceb8f0e4e82918c3ab4029ce2c08..dbe601c363888955dfb45d2b27a741ec0c48a138 100644 (file)
@@ -19,7 +19,7 @@
                0:      begin end
                1:      begin
                                case (opcode[5:4])
-                               `INSN_stack_AF: `_F <= rdata;
+                               `INSN_stack_AF: `_F <= rdata & 8'hF0;
                                `INSN_stack_BC: `_C <= rdata;
                                `INSN_stack_DE: `_E <= rdata;
                                `INSN_stack_HL: `_L <= rdata;
diff --git a/flashboot.asm b/flashboot.asm
new file mode 100644 (file)
index 0000000..3987ac3
--- /dev/null
@@ -0,0 +1,80 @@
+       SECTION "wee",HOME[$0]
+       ld sp, $CFFF
+
+       ld hl, loading+$D800
+       call puts+$D800
+
+       ld a, $FF       ; Put the thing in read array mode.
+       ld [$FF65], a
+
+       xor a
+       ld d, a
+       ld e, a
+       
+loop:  ld a, $04
+       cp d
+       jr z,done
+       
+       xor c
+ifl:   ld a, d                 ; Set up for the flash read.
+       ld [$FF60], a
+       ld a, e
+       ld [$FF61], a
+       ld a, c
+       ld [$FF62], a
+       ld a, [$FF65]
+       ld b, a
+       ld a, d                 ; Set up for the flash read.
+       ld [$FF60], a
+       ld a, e
+       ld [$FF61], a
+       ld a, c
+       ld [$FF62], a
+       ld a, b
+       ld [$FF63], a
+       inc c
+       jr nz, ifl
+       
+       ld a, $2E       ;.
+       call putc+$D800
+       
+       inc de
+       jr loop
+done:  
+       ld hl, booting+$D800
+       call puts+$D800
+       
+       xor a
+       ld h, a
+       ld l, a
+       ld [hl], $01    ; Select the GB boot rom
+
+       rst $00         ; Boot
+
+putc:
+       push bc
+       ld c, $53
+       push af
+.waitport:
+       ld a,[c]
+       and $01
+       jr nz,.waitport
+       pop af
+       ld [$FF52],a
+       pop bc
+       ret
+
+loading:
+       db "Loading...",0
+booting:
+       db $0D,$0A,"Booting...",$0D,$0A,0
+
+puts:
+       ld a, [hli]
+       cp $00
+       ret z
+       call putc+$D800
+       jr puts
+
+       section "a", HOME[$FF]
+       nop
diff --git a/flashdiag.asm b/flashdiag.asm
new file mode 100644 (file)
index 0000000..2d0738c
--- /dev/null
@@ -0,0 +1,65 @@
+       SECTION "wee",HOME[$0]
+       ld sp, $CFFF
+       ld hl, $FF60
+       ld a, $FF
+       ld [hli], a
+       ld [hli], a
+       ld [hli], a
+       ld a, $90       ; device info
+       ld [$FF65], a
+       
+       call rn+$FF80
+       
+       ld a, [$FF65]   ; 0000
+       call puthex + $FF80
+       
+       call rn+$FF80
+       
+       ld a, [$FF65]   ; 0000
+       call puthex + $FF80
+       
+       call rn+$FF80
+       
+       jp $0000
+
+puthex:
+       push af
+       swap a
+       and $0F
+       ld hl, hexdig+$FF80
+       add l
+       ld l, a
+       ld a, [hl]
+       call putc+$FF80
+       pop af
+       and $0F
+       ld hl, hexdig+$FF80
+       add l
+       ld l, a
+       ld a, [hl]
+       call putc+$FF80
+       ret
+
+hexdig:
+       db "0123456789ABCDEF"
+
+putc:
+       ld c, $53
+       push af
+.waitport:
+       ld a,[c]
+       and $01
+       jr nz,.waitport
+       pop af
+       ld [$FF52],a
+       ret
+
+rn:
+       ld a, 13
+       call putc+$FF80
+       ld a, 10
+       jr putc
+
+
+       section "a", HOME[$7E]
+       nop
diff --git a/flashprog.asm b/flashprog.asm
new file mode 100644 (file)
index 0000000..c0f74da
--- /dev/null
@@ -0,0 +1,151 @@
+       SECTION "wee",HOME[$0]
+       ld hl, $D000
+       ld sp, hl
+       
+       xor a
+       ld [$FF60], a
+       ld [$FF61], a
+       ld [$FF62], a
+       
+       ld a, $50       ; Clear SR
+       ld [$FF65], a
+       
+       call unlock+$D800
+       xor a
+       ld d, a
+       ld e, a
+       call erase+$D800
+       
+       xor a
+       ld d, a
+       ld e, a
+       
+loop:  ld a, $04
+       cp d
+       jr z,done
+       
+       xor a
+       ld c, a                 ; Count
+
+ifl:   call program+$D800
+       xor a
+       cp c
+       jr nz, ifl
+ifldone:
+
+       ld a, $70
+       ld [$FF65], a
+       ld a, [$FF65]           ; Load from the status register
+       call puthex+$D800
+               
+;      ld a, $2E       ;.
+;      call putc+$D800
+       
+       inc de
+       jr loop
+done:  
+       rst $00
+
+putc:
+       push af
+.wport:
+       ld a,[$FF53]
+       and $01
+       jr nz,.wport
+       pop af
+       ld [$FF52],a
+       ret
+
+puthex:
+       push hl
+       ld hl, hexdig+$D800
+       push hl
+       push af
+       swap a
+       and $0F
+       add l
+       ld l, a
+       ld a, [hl]
+       call putc+$D800
+       pop af
+       and $0F
+       pop hl
+       add l
+       ld l, a
+       ld a, [hl]
+       pop hl
+       jr putc
+
+hexdig:
+       db "0123456789ABCDEF"
+       
+unlock:
+       ld a, $55
+       call putc+$D800
+       ld a, $60       ; Unlock the device
+       ld [$FF65], a
+       ld a, $D0
+       ld [$FF65], a
+       call waitrdy+$D800
+       ld a, [$FF65]
+       call puthex+$D800
+       ret
+
+erase:
+       ld a, $45
+       call putc+$D800
+       ld a, d
+       ld [$FF60], a
+       ld a, e
+       ld [$FF61], a
+       xor a
+       ld [$FF62], a
+       ld a, $20       ; Unlock the device
+       ld [$FF65], a
+       ld a, $D0
+       ld [$FF65], a
+       call waitrdy+$D800
+       ld a, [$FF65]
+       call puthex+$D800
+       ret
+
+; need to save d, e, and c
+program:
+       ld a, d
+       ld [$FF60], a
+       ld a, e
+       ld [$FF61], a
+       ld a, c
+       ld [$FF62], a
+       ld a, $40
+       ld [$FF65], a
+       ld a, d
+       ld [$FF60], a
+       ld a, e
+       ld [$FF61], a
+       ld a, c
+       ld [$FF62], a
+       ld a, [$FF63]
+       ld b, a
+       ld a, d
+       ld [$FF60], a
+       ld a, e
+       ld [$FF61], a
+       ld a, c
+       ld [$FF62], a
+       ld a, b
+       ld [$FF65], a
+       call waitrdy+$D800
+       inc c
+       ret
+
+waitrdy:
+       ld a, $70       ; Wait status register.
+       ld [$FF65], a
+.wrl:  ld a, [$FF65]   ; Wait for bit 7 to come back on again.
+       bit 7,a
+       jr z, .wrl
+       ret
+
+       section "a", HOME[$FF]
+       nop
index 6cb96137856398593e4cec4c97a98f8c8cdfe95b..dfb4ec9e68f7bd6ed70911ca59ae12fe51f2c91e 100644 (file)
@@ -107,8 +107,8 @@ bootcmd:
        jr putc
 
 .prog:
-       ld hl, $FF80
-       ld c, $7F
+       ld hl, $D800
+       ld c, $00
 .pl:   dec c
        jp z, .progboot
        call getc
@@ -117,7 +117,7 @@ bootcmd:
 .progboot:
        ld a, $50       ;P
        call putc
-       jp $FF80
+       jp $D800
        
        SECTION "a", HOME[$100]
        nop     ; Make sure we don't overflow.
This page took 0.036837 seconds and 4 git commands to generate.