]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
Add a ROM, and go up to 8k of RAM
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Wed, 2 Apr 2008 09:08:08 +0000 (05:08 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Wed, 2 Apr 2008 09:08:08 +0000 (05:08 -0400)
FPGABoy.ise
System.v
rom.asm [new file with mode: 0644]
rom.hex

index f5e4846968d62f15f873fc0119d7e4ab80c6f52c..06b8ca4b0d1efd142d6cffefedce33343bab4605 100644 (file)
Binary files a/FPGABoy.ise and b/FPGABoy.ise differ
index dec02b8bfadc766aa96bc76aa6130be9ca82936c..996ec1092c1973a86f85b9ba24e5099ac301f31c 100644 (file)
--- a/System.v
+++ b/System.v
@@ -22,7 +22,7 @@ module InternalRAM(
        input wr, rd);
        
        // synthesis attribute ram_style of reg is block
-       reg [7:0] ram [2047:0];
+       reg [7:0] ram [8191:0];
        
        wire decode = address[15:13] == 3'b110;
        reg [7:0] odata;
@@ -34,8 +34,8 @@ module InternalRAM(
                if (decode)
                begin
                        if (wr)
-                               ram[address[10:0]] <= data;
-                       odata <= ram[address[10:0]];
+                               ram[address[12:0]] <= data;
+                       odata <= ram[address[12:0]];
                end
        end
 endmodule
diff --git a/rom.asm b/rom.asm
new file mode 100644 (file)
index 0000000..2ede41c
--- /dev/null
+++ b/rom.asm
@@ -0,0 +1,139 @@
+       SECTION "a",HOME
+main:
+       ld c, $51
+       ld a, $FF
+       ld [c],a
+       ld sp,$DFFF
+
+       ld hl,text
+       call puts
+       
+       call memtest
+       call waitsw
+       jp main
+
+text:
+       db $1B,"[1mFPGABoy Diagnostic ROM",$1B,"[0m",$0D,$0A,0
+
+memtest:
+       ld hl,memteststr
+       call puts
+       
+       ld hl, $C000
+.wr:
+       ld a,h
+       xor l
+       ld [hli],a
+       ld a, $DF
+       cp h
+       jp nz, .wr
+       ld a, $80
+       cp l
+       jp nz, .wr
+
+       ld hl, $C000
+.rd:
+       ld a,h
+       xor l
+       ld b,a
+       ld a, [hli]
+       cp b
+       jp nz, .memfail
+       
+       ld a, $DF
+       cp h
+       jp nz, .rd
+       ld a, $80
+       cp l
+       jp nz, .rd
+       
+       ld hl, testokstr
+       call puts
+       ret
+.memfail:
+       @ decrement hl the easy way
+       ld a,[hld]
+       push hl
+       ld hl, failatstr
+       call puts
+       pop hl
+       ld a, h
+       call puthex
+       ld a, l
+       call puthex
+       ld a, $0A
+       call putc
+       ld a, $0D
+       call putc
+       ret
+
+memteststr:
+       db "Testing memory from $C000 to $DF80...",0
+testokstr:
+       db " OK!",$0D,$0A,0
+failatstr:
+       db " Test failed at $",0
+puthex:
+       push af
+       rra
+       rra
+       rra
+       rra
+       ld b,$0F
+       and b
+       ld b,$30
+       add b
+       call putc
+       pop af
+       ld b,$0F
+       and b
+       ld b,$30
+       add b
+       call putc
+       ret
+
+waitsw:
+       ld hl,waitswstr
+       call puts
+       
+       ld c, $51
+       ld a, $00
+       ld [c],a
+       
+       ld c, $51
+       ld b, $0
+.loop1:
+       ld a,[c]
+       cp b
+       jp z,.loop1
+.loop2:
+       ld a,[c]
+       cp b
+       jp nz,.loop2
+       ret
+
+waitswstr:
+       db "Diagnostic ROM complete; flip switches to nonzero and then to zero to reset.",$0D,$0A,0
+
+putc:
+       push af
+       ld b, 0
+       ld c, $50
+.waitport:
+       ld a,[c]
+       cp b
+       jp nz,.waitport
+       pop af
+       ld [c],a
+       ret
+
+puts:
+       ld a, [hli]
+       ld b, $00
+       cp b
+       jp z, .done
+       call putc
+       jp puts
+.done:
+       ret
+
diff --git a/rom.hex b/rom.hex
index a37d956eab31f36740224981acec1861442a29d3..d31cc375e954456f79b4243dddfd27480810e7a7 100644 (file)
--- a/rom.hex
+++ b/rom.hex
+0e
+51
+3e
+ff
+e2
 31
 ff
 df
 21
-16
-00
-0e
-50
-06
-00
-2a
-b8
-ca
+17
 00
+cd
+58
+01
+cd
+38
 00
-e2
 cd
-23
+e2
 00
 c3
-0a
 00
-48
-65
-6c
-6c
+00
+1b
+5b
+31
+6d
+46
+50
+47
+41
+42
 6f
-2c
+79
 20
-5a
-38
-30
-21
+44
+69
+61
+67
+6e
+6f
+73
+74
+69
+63
 20
+52
+4f
+4d
+1b
+5b
+30
+6d
+0d
+0a
 00
-f2
-b8
-c2
-23
-00
-c9
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
-00
+21
+8a
 00
+cd
+58
+01
+21
 00
+c0
+7c
+ad
+22
+3e
+df
+bc
+c2
+41
 00
+3e
+80
+bd
+c2
+41
 00
+21
 00
+c0
+7c
+ad
+47
+2a
+b8
+c2
+6e
 00
+3e
+df
+bc
+c2
+53
 00
+3e
+80
+bd
+c2
+53
 00
+21
+b0
 00
+cd
+58
+01
+c9
+3a
+e5
+21
+b7
 00
+cd
+58
+01
+e1
+7c
+cd
+c9
 00
+7d
+cd
+c9
 00
+3e
+0a
+cd
+4b
+01
+3e
+0d
+cd
+4b
+01
+c9
+54
+65
+73
+74
+69
+6e
+67
+20
+6d
+65
+6d
+6f
+72
+79
+20
+66
+72
+6f
+6d
+20
+24
+43
+30
+30
+30
+20
+74
+6f
+20
+24
+44
+46
+38
+30
+2e
+2e
+2e
 00
+20
+4f
+4b
+21
+0d
+0a
 00
+20
+54
+65
+73
+74
+20
+66
+61
+69
+6c
+65
+64
+20
+61
+74
+20
+24
 00
+f5
+1f
+1f
+1f
+1f
+06
+0f
+a0
+06
+30
+80
+cd
+4b
+01
+f1
+06
+0f
+a0
+06
+30
+80
+cd
+4b
+01
+c9
+21
+fc
 00
+cd
+58
+01
+0e
+51
+3e
 00
+e2
+0e
+51
+06
 00
+f2
+b8
+ca
+f1
 00
+f2
+b8
+c2
+f6
 00
+c9
+44
+69
+61
+67
+6e
+6f
+73
+74
+69
+63
+20
+52
+4f
+4d
+20
+63
+6f
+6d
+70
+6c
+65
+74
+65
+3b
+20
+66
+6c
+69
+70
+20
+73
+77
+69
+74
+63
+68
+65
+73
+20
+74
+6f
+20
+6e
+6f
+6e
+7a
+65
+72
+6f
+20
+61
+6e
+64
+20
+74
+68
+65
+6e
+20
+74
+6f
+20
+7a
+65
+72
+6f
+20
+74
+6f
+20
+72
+65
+73
+65
+74
+2e
+0d
+0a
 00
+f5
+06
 00
+0e
+50
+f2
+b8
+c2
+50
+01
+f1
+e2
+c9
+2a
+06
 00
+b8
+ca
+65
+01
+cd
+4b
+01
+c3
+58
+01
+c9
 00
 00
 00
This page took 0.049202 seconds and 4 git commands to generate.