mirror of
https://github.com/MiSTer-devel/Gameboy_MiSTer.git
synced 2026-04-26 03:04:36 +00:00
Merge pull request #46 from brNX/master
Baked in open source bootstrap roms and GB Fast boot added (back again)
This commit is contained in:
1
BootROMs/README.md
Normal file
1
BootROMs/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Open Source DMG and CGB boot Roms from [https://github.com/LIJI32/SameBoy/](https://github.com/LIJI32/SameBoy/)
|
||||
BIN
BootROMs/SameBoyLogo.png
Normal file
BIN
BootROMs/SameBoyLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 468 B |
2
BootROMs/agb_boot.asm
Normal file
2
BootROMs/agb_boot.asm
Normal file
@@ -0,0 +1,2 @@
|
||||
AGB EQU 1
|
||||
include "cgb_boot.asm"
|
||||
BIN
BootROMs/agb_boot.bin
Normal file
BIN
BootROMs/agb_boot.bin
Normal file
Binary file not shown.
1188
BootROMs/cgb_boot.asm
Normal file
1188
BootROMs/cgb_boot.asm
Normal file
File diff suppressed because it is too large
Load Diff
BIN
BootROMs/cgb_boot.bin
Normal file
BIN
BootROMs/cgb_boot.bin
Normal file
Binary file not shown.
107
BootROMs/cgb_boot.mif
Normal file
107
BootROMs/cgb_boot.mif
Normal file
@@ -0,0 +1,107 @@
|
||||
-- http://srecord.sourceforge.net/
|
||||
--
|
||||
-- Generated automatically by srec_cat -o --mif
|
||||
--
|
||||
DEPTH = 2304;
|
||||
WIDTH = 8;
|
||||
ADDRESS_RADIX = HEX;
|
||||
DATA_RADIX = HEX;
|
||||
CONTENT BEGIN
|
||||
0000: 31 FE FF 21 00 80 CD EF 05 3E 02 0E 70 E2 26 D0 AF CD EF 05 E2 E0 C1 E0;
|
||||
0018: 80 26 FE 0E A0 22 0D 20 FC 3E 80 E0 26 E0 11 3E F3 E0 12 E0 25 3E 77 E0;
|
||||
0030: 24 CD 8F 08 3E FC E0 47 11 04 01 21 10 80 1A 47 CD BA 05 13 7B FE 34 20;
|
||||
0048: F5 CD 54 06 3E 01 E0 4F AF 21 00 80 CD EF 05 CD 18 06 06 03 21 C2 98 16;
|
||||
0060: 03 3E 08 0E 10 F5 3E 01 E0 4F 36 08 AF E0 4F F1 22 82 0D 20 F0 D6 2F D5;
|
||||
0078: 11 10 00 19 D1 05 20 E3 15 28 0A 15 3E 38 2E A7 01 07 01 18 D8 11 A2 05;
|
||||
0090: 0E 08 21 81 FF AF 2F 22 22 1A 13 22 1A 13 22 AF 22 22 22 22 0D 20 EF 21;
|
||||
00A8: 81 FF CD 65 06 3E 91 E0 40 CD 76 06 06 2D CD DE 05 3E 83 CD E8 05 06 05;
|
||||
00C0: CD DE 05 3E C1 CD E8 05 3E 1E E0 C2 CD E3 07 CD D2 05 21 C2 FF 35 20 F4;
|
||||
00D8: CD 9F 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E0 50 00 00 00 00 00 00 00 00;
|
||||
0108: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
0138: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
0168: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
0198: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
01B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
01C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
01F8: 00 00 00 00 00 00 00 00 00 88 16 36 D1 DB F2 3C 8C 92 3D 5C 58 C9 3E 70;
|
||||
0210: 1D 59 69 19 35 A8 14 AA 75 95 99 34 6F 15 FF 97 4B 90 17 10 39 F7 F6 A2;
|
||||
0228: 49 4E C3 68 E0 8B F0 CE 0C 29 E8 B7 86 9A 52 01 9D 71 9C BD 5D 6D 67 3F;
|
||||
0240: 6B B3 46 28 A5 C6 D3 27 61 18 66 6A BF 0D F4 B3 46 28 A5 C6 D3 27 61 18;
|
||||
0258: 66 6A BF 0D F4 B3 00 04 05 23 22 03 1F 0F 0A 05 13 24 87 25 1E 2C 15 20;
|
||||
0270: 1F 14 05 21 0D 0E 05 1D 05 12 09 03 02 1A 19 19 29 2A 1A 2D 2A 2D 24 26;
|
||||
0288: 1A 2A 1E 29 22 22 05 2A 06 05 21 19 2A 2A 28 02 10 19 2A 2A 05 00 27 24;
|
||||
02A0: 16 19 06 20 0C 24 0B 27 12 27 18 1F 32 11 2E 06 1B 00 2F 29 29 00 00 13;
|
||||
02B8: 22 17 12 1D 42 45 46 41 41 52 42 45 4B 45 4B 20 52 2D 55 52 41 52 20 49;
|
||||
02D0: 4E 41 49 4C 49 43 45 20 52 20 20 E8 90 90 90 A0 A0 A0 C0 C0 C0 48 48 48;
|
||||
02E8: 00 00 00 D8 D8 D8 28 28 28 60 60 60 D0 D0 D0 80 40 40 20 E0 E0 20 10 10;
|
||||
0300: 18 20 20 20 E8 E8 E0 20 E0 10 88 10 80 80 40 20 20 38 20 20 90 20 20 A0;
|
||||
0318: 98 98 48 1E 1E 58 88 88 10 20 20 10 20 20 18 E0 E0 00 18 18 00 00 00 08;
|
||||
0330: 90 B0 90 A0 B0 A0 C0 B0 C0 80 B0 40 88 20 68 DE 00 70 DE 20 78 98 B0 48;
|
||||
0348: 80 E0 50 20 B8 E0 88 B0 10 20 00 10 20 E0 18 E0 18 00 18 E0 20 A8 E0 20;
|
||||
0360: 18 E0 00 C8 18 E0 00 E0 40 20 18 E0 E0 18 30 20 E0 E8 F0 F0 F0 F8 F8 F8;
|
||||
0378: E0 20 08 00 00 10 FF 7F BF 32 D0 00 00 00 9F 63 79 42 B0 15 CB 04 FF 7F;
|
||||
0390: 31 6E 4A 45 00 00 FF 7F EF 1B 00 02 00 00 FF 7F 1F 42 F2 1C 00 00 FF 7F;
|
||||
03A8: 94 52 4A 29 00 00 FF 7F FF 03 2F 01 00 00 FF 7F EF 03 D6 01 00 00 FF 7F;
|
||||
03C0: B5 42 C8 3D 00 00 74 7E FF 03 80 01 00 00 FF 67 AC 77 13 1A 6B 2D D6 7E;
|
||||
03D8: FF 4B 75 21 00 00 FF 53 5F 4A 52 7E 00 00 FF 4F D2 7E 4C 3A E0 1C ED 03;
|
||||
03F0: FF 7F 5F 25 00 00 6A 03 1F 02 FF 03 FF 7F FF 7F DF 01 12 01 00 00 1F 23;
|
||||
0408: 5F 03 F2 00 09 00 FF 7F EA 03 1F 01 00 00 9F 29 1A 00 0C 00 00 00 FF 7F;
|
||||
0420: 7F 02 1F 00 00 00 FF 7F E0 03 06 02 20 01 FF 7F EB 7E 1F 00 00 7C FF 7F;
|
||||
0438: FF 3F 00 7E 1F 00 FF 7F FF 03 1F 00 00 00 FF 03 1F 00 0C 00 00 00 FF 7F;
|
||||
0450: 3F 03 93 01 00 00 00 00 00 42 7F 03 FF 7F FF 7F 8C 7E 00 7C 00 00 FF 7F;
|
||||
0468: EF 1B 80 61 00 00 FF 7F EA 7F 5F 7D 00 00 78 47 90 32 87 1D 61 08 01 30;
|
||||
0480: 05 08 00 28 2B 03 06 07 1C 31 33 34 35 36 3C 42 B9 A5 B9 A5 42 3C 30 00;
|
||||
0498: 58 01 03 07 0F 1F 3E 3C 7C 78 46 7C 7F 3F 1F 0F 03 00 31 3F FF 51 C0 00;
|
||||
04B0: 20 0F 20 1F 32 03 07 FF 41 F8 00 32 80 E0 F0 31 30 00 4B 01 E1 E3 E7 C7;
|
||||
04C8: CF DF DE FE 7C 78 00 21 07 0F 21 1F 3F 45 7B FB F3 F1 E1 FF 90 00 20 80;
|
||||
04E0: 20 81 30 C1 41 C3 E3 50 F7 21 FF 7F 40 00 21 F0 F8 20 FC 20 FE 21 FF CF;
|
||||
04F8: 20 C7 51 C2 80 60 00 26 03 07 0F 1F 3F 7F FF 45 EF CF 8F 0F 1F 1E 21 3E;
|
||||
0510: 3C 40 00 20 CF 32 DF 9F 9E 41 BE 3F 31 7C 78 31 7F FF 40 00 30 FF 41 FE;
|
||||
0528: 00 40 F8 40 00 20 F8 20 F0 60 00 50 01 50 03 50 07 30 0F 40 00 40 FF 20;
|
||||
0540: E3 20 E7 40 FF 21 C3 83 21 87 FF 52 FE FC 00 23 80 C0 C3 C7 35 CF 8F 9F;
|
||||
0558: 1E 9E DE 20 DF 53 8F 87 03 00 22 1F 7F FF 83 F0 C0 80 00 31 C3 FF 41 FE;
|
||||
0570: 00 56 E1 F9 FC FE 7E 1F 0F 58 1F 1E 3E 7C F8 F0 E0 C0 00 21 E0 F0 24 F8;
|
||||
0588: 78 3D 3F 1F 30 0F 41 1F 1E 21 3E 3C 40 00 D9 0F 1E 3C 78 F8 F0 E0 C0 80;
|
||||
05A0: 00 00 FF 7F 4F 77 C7 22 9F 03 7D 01 1D 24 38 6D 02 71 FF 7F BF 32 D0 00;
|
||||
05B8: 00 00 CD BD 05 3E 04 0E 00 CB 20 F5 CB 11 F1 CB 11 3D 20 F5 79 22 23 22;
|
||||
05D0: 23 C9 E5 21 0F FF CB 86 CB 46 28 FC E1 C9 CD E3 07 CD D2 05 05 20 F7 C9;
|
||||
05E8: E0 13 3E 87 E0 14 C9 22 CB 6C 28 FB C9 CD F8 05 1A A1 47 1C 1C 1A 1D 1D;
|
||||
0600: A1 CB 37 B0 CB 41 28 02 CB 37 23 22 CB 31 C9 CD 12 06 CD F5 05 1C 7B C9;
|
||||
0618: 11 96 04 21 80 80 1A 13 47 E6 0F 28 08 4F 1A 22 23 13 0D 20 F9 CB 30 78;
|
||||
0630: E6 0F 28 0A 4F 1A 13 22 23 0D 20 FB 18 E0 11 04 01 0E F0 CD 0F 06 C6 16;
|
||||
0648: 5F CD 0F 06 D6 16 5F FE 1C 20 EE 23 11 8E 04 0E 08 1A 13 22 23 0D 20 F9;
|
||||
0660: C9 0E 6A 18 06 16 40 1E 00 0E 68 3E 80 B3 E2 0C 2A E2 15 20 FB C9 3E 01;
|
||||
0678: E0 4F 16 1A 06 02 CD DE 05 21 C0 98 0E 03 7E FE 0F 28 05 34 E6 07 28 03;
|
||||
0690: 23 18 F3 7D F6 1F 6F 23 0D 20 EB 15 20 DE C9 06 20 0E 20 21 81 FF C5 CD;
|
||||
06A8: 9D 07 C1 0D 20 F8 CD D2 05 CD D2 05 21 81 FF CD 65 06 05 20 E4 CD D2 07;
|
||||
06C0: AF E0 4F 2F E0 00 CD D2 07 11 56 FF 2E 0D FA 43 01 CB 7F CC F2 06 CB 7F;
|
||||
06D8: E0 4C F0 80 47 28 05 F0 C1 A7 20 06 AF 4F 3E 11 61 C9 CD F2 06 E0 4C 3E;
|
||||
06F0: 01 C9 3E 01 E0 6C CD 20 07 CB 7F C4 74 08 E6 7F;
|
||||
0700: 47 F0 C1 A7 28 0A 21 7D 04 4F 06 00 09 7E 18 01 78 CD D2 05 CD 6D 07 3E;
|
||||
0718: 04 16 00 1E 08 2E 7C C9 21 4B 01 7E FE 33 28 05 3D 20 40 18 0C 2E 44 2A;
|
||||
0730: FE 30 20 37 7E FE 31 20 32 2E 34 0E 10 AF 86 2C 0D 20 FB 47 21 00 02 7D;
|
||||
0748: D6 5E C8 2A B8 20 F8 7D D6 41 38 0E E5 7D C6 7A 6F 7E E1 4F FA 37 01 B9;
|
||||
0760: 20 E5 7D C6 5D 6F 78 E0 80 7E C9 AF C9 47 80 80 21 D9 02 06 00 4F 09 1E;
|
||||
0778: 00 2A E5 21 7E 03 06 00 4F 09 16 08 CD 61 06 E1 CB 5B 20 04 1E 08 18 E9;
|
||||
0790: 2A 21 7E 03 06 00 4F 09 16 08 C3 67 06 2A 5F 3A 57 01 21 04 7B E6 1F FE;
|
||||
07A8: 1F 20 02 CB 81 7B E6 E0 FE E0 20 09 7A E6 03 FE 03 20 02 CB A9 7A E6 7C;
|
||||
07C0: FE 7C 20 02 CB 90 E5 62 6B 09 54 5D E1 7B 22 7A 22 C9 21 51 FF 3E 88 22;
|
||||
07D8: AF 22 3E 98 22 3E A0 22 36 12 C9 3E 20 E0 00 F0 00 2F E6 0F C8 C5 0E 00;
|
||||
07F0: 0C 1F 30 FC 3E 10 E0 00 F0 00 2F 17 17 E6 0C 81 47 F0 C1 4F 78 E0 C1 B9;
|
||||
0808: C1 C8 F5 E5 C5 D5 21 7D 04 4F 06 00 09 7E 47 80 80 21 DB 02 06 00 4F 09;
|
||||
0820: 7E 21 7F 03 06 00 4F 09 3A FE 7F 20 02 23 23 F5 2A E5 21 81 FF CD 69 08;
|
||||
0838: E1 E0 83 2A E5 21 82 FF CD 69 08 E1 E0 84 F1 28 02 23 23 2A E0 BB 2A E0;
|
||||
0850: BC 2A E0 85 7E E0 86 CD D2 05 21 81 FF CD 65 06 3E 1E E0 C2 D1 C1 E1 F1;
|
||||
0868: C9 11 08 00 0E 08 77 19 0D 20 FB C9 F5 CD D2 05 3E 19 EA 10 99 21 2F 99;
|
||||
0880: 0E 0C 3D 28 08 32 0D 20 F9 2E 0F 18 F5 F1 C9 21 30 FF AF 0E 10 22 2F 0D;
|
||||
0898: 20 FB C9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
08B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
08C8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
08E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00;
|
||||
08F8: 00 00 00 00 00 00 00 00;
|
||||
END;
|
||||
2
BootROMs/cgb_boot_fast.asm
Normal file
2
BootROMs/cgb_boot_fast.asm
Normal file
@@ -0,0 +1,2 @@
|
||||
FAST EQU 1
|
||||
include "cgb_boot.asm"
|
||||
153
BootROMs/dmg_boot.asm
Normal file
153
BootROMs/dmg_boot.asm
Normal file
@@ -0,0 +1,153 @@
|
||||
; SameBoy DMG bootstrap ROM
|
||||
; Todo: use friendly names for HW registers instead of magic numbers
|
||||
SECTION "BootCode", ROM0[$0]
|
||||
Start:
|
||||
; Init stack pointer
|
||||
ld sp, $fffe
|
||||
|
||||
; Clear memory VRAM
|
||||
ld hl, $8000
|
||||
|
||||
.clearVRAMLoop
|
||||
ldi [hl], a
|
||||
bit 5, h
|
||||
jr z, .clearVRAMLoop
|
||||
|
||||
; Init Audio
|
||||
ld a, $80
|
||||
ldh [$26], a
|
||||
ldh [$11], a
|
||||
ld a, $f3
|
||||
ldh [$12], a
|
||||
ldh [$25], a
|
||||
ld a, $77
|
||||
ldh [$24], a
|
||||
|
||||
; Init BG palette
|
||||
ld a, $fc
|
||||
ldh [$47], a
|
||||
|
||||
; Load logo from ROM.
|
||||
; A nibble represents a 4-pixels line, 2 bytes represent a 4x4 tile, scaled to 8x8.
|
||||
; Tiles are ordered left to right, top to bottom.
|
||||
ld de, $104 ; Logo start
|
||||
ld hl, $8010 ; This is where we load the tiles in VRAM
|
||||
|
||||
.loadLogoLoop
|
||||
ld a, [de] ; Read 2 rows
|
||||
ld b, a
|
||||
call DoubleBitsAndWriteRow
|
||||
call DoubleBitsAndWriteRow
|
||||
inc de
|
||||
ld a, e
|
||||
xor $34 ; End of logo
|
||||
jr nz, .loadLogoLoop
|
||||
|
||||
; Load trademark symbol
|
||||
ld de, TrademarkSymbol
|
||||
ld c,$08
|
||||
.loadTrademarkSymbolLoop:
|
||||
ld a,[de]
|
||||
inc de
|
||||
ldi [hl],a
|
||||
inc hl
|
||||
dec c
|
||||
jr nz, .loadTrademarkSymbolLoop
|
||||
|
||||
; Set up tilemap
|
||||
ld a,$19 ; Trademark symbol
|
||||
ld [$9910], a ; ... put in the superscript position
|
||||
ld hl,$992f ; Bottom right corner of the logo
|
||||
ld c,$c ; Tiles in a logo row
|
||||
.tilemapLoop
|
||||
dec a
|
||||
jr z, .tilemapDone
|
||||
ldd [hl], a
|
||||
dec c
|
||||
jr nz, .tilemapLoop
|
||||
ld l,$0f ; Jump to top row
|
||||
jr .tilemapLoop
|
||||
.tilemapDone
|
||||
|
||||
; Turn on LCD
|
||||
ld a, $91
|
||||
ldh [$40], a
|
||||
|
||||
; Wait ~0.75 seconds
|
||||
ld b, 45
|
||||
call WaitBFrames
|
||||
|
||||
; Play first sound
|
||||
ld a, $83
|
||||
call PlaySound
|
||||
ld b, 5
|
||||
call WaitBFrames
|
||||
; Play second sound
|
||||
ld a, $c1
|
||||
call PlaySound
|
||||
|
||||
; Wait ~1.15 seconds
|
||||
ld b, 70
|
||||
call WaitBFrames
|
||||
|
||||
; Set registers to match the original DMG boot
|
||||
ld hl, $01B0
|
||||
push hl
|
||||
pop af
|
||||
ld hl, $014D
|
||||
ld bc, $0013
|
||||
ld de, $00D8
|
||||
|
||||
; Boot the game
|
||||
jp BootGame
|
||||
|
||||
|
||||
DoubleBitsAndWriteRow:
|
||||
; Double the most significant 4 bits, b is shifted by 4
|
||||
ld a, 4
|
||||
ld c, 0
|
||||
.doubleCurrentBit
|
||||
sla b
|
||||
push af
|
||||
rl c
|
||||
pop af
|
||||
rl c
|
||||
dec a
|
||||
jr nz, .doubleCurrentBit
|
||||
ld a, c
|
||||
; Write as two rows
|
||||
ldi [hl], a
|
||||
inc hl
|
||||
ldi [hl], a
|
||||
inc hl
|
||||
ret
|
||||
|
||||
WaitFrame:
|
||||
push hl
|
||||
ld hl, $FF0F
|
||||
res 0, [hl]
|
||||
.wait
|
||||
bit 0, [hl]
|
||||
jr z, .wait
|
||||
pop hl
|
||||
ret
|
||||
|
||||
WaitBFrames:
|
||||
call WaitFrame
|
||||
dec b
|
||||
jr nz, WaitBFrames
|
||||
ret
|
||||
|
||||
PlaySound:
|
||||
ldh [$13], a
|
||||
ld a, $87
|
||||
ldh [$14], a
|
||||
ret
|
||||
|
||||
|
||||
TrademarkSymbol:
|
||||
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
|
||||
|
||||
SECTION "BootGame", ROM0[$fe]
|
||||
BootGame:
|
||||
ldh [$50], a
|
||||
BIN
BootROMs/dmg_boot.bin
Normal file
BIN
BootROMs/dmg_boot.bin
Normal file
Binary file not shown.
256
BootROMs/dmg_boot.mem
Normal file
256
BootROMs/dmg_boot.mem
Normal file
@@ -0,0 +1,256 @@
|
||||
31
|
||||
FE
|
||||
FF
|
||||
21
|
||||
00
|
||||
80
|
||||
22
|
||||
CB
|
||||
6C
|
||||
28
|
||||
FB
|
||||
3E
|
||||
80
|
||||
E0
|
||||
26
|
||||
E0
|
||||
11
|
||||
3E
|
||||
F3
|
||||
E0
|
||||
12
|
||||
E0
|
||||
25
|
||||
3E
|
||||
77
|
||||
E0
|
||||
24
|
||||
3E
|
||||
FC
|
||||
E0
|
||||
47
|
||||
11
|
||||
04
|
||||
01
|
||||
21
|
||||
10
|
||||
80
|
||||
1A
|
||||
47
|
||||
CD
|
||||
82
|
||||
00
|
||||
CD
|
||||
82
|
||||
00
|
||||
13
|
||||
7B
|
||||
EE
|
||||
34
|
||||
20
|
||||
F2
|
||||
11
|
||||
B1
|
||||
00
|
||||
0E
|
||||
08
|
||||
1A
|
||||
13
|
||||
22
|
||||
23
|
||||
0D
|
||||
20
|
||||
F9
|
||||
3E
|
||||
19
|
||||
EA
|
||||
10
|
||||
99
|
||||
21
|
||||
2F
|
||||
99
|
||||
0E
|
||||
0C
|
||||
3D
|
||||
28
|
||||
08
|
||||
32
|
||||
0D
|
||||
20
|
||||
F9
|
||||
2E
|
||||
0F
|
||||
18
|
||||
F5
|
||||
3E
|
||||
91
|
||||
E0
|
||||
40
|
||||
06
|
||||
2D
|
||||
CD
|
||||
A3
|
||||
00
|
||||
3E
|
||||
83
|
||||
CD
|
||||
AA
|
||||
00
|
||||
06
|
||||
05
|
||||
CD
|
||||
A3
|
||||
00
|
||||
3E
|
||||
C1
|
||||
CD
|
||||
AA
|
||||
00
|
||||
06
|
||||
46
|
||||
CD
|
||||
A3
|
||||
00
|
||||
21
|
||||
B0
|
||||
01
|
||||
E5
|
||||
F1
|
||||
21
|
||||
4D
|
||||
01
|
||||
01
|
||||
13
|
||||
00
|
||||
11
|
||||
D8
|
||||
00
|
||||
C3
|
||||
FE
|
||||
00
|
||||
3E
|
||||
04
|
||||
0E
|
||||
00
|
||||
CB
|
||||
20
|
||||
F5
|
||||
CB
|
||||
11
|
||||
F1
|
||||
CB
|
||||
11
|
||||
3D
|
||||
20
|
||||
F5
|
||||
79
|
||||
22
|
||||
23
|
||||
22
|
||||
23
|
||||
C9
|
||||
E5
|
||||
21
|
||||
0F
|
||||
FF
|
||||
CB
|
||||
86
|
||||
CB
|
||||
46
|
||||
28
|
||||
FC
|
||||
E1
|
||||
C9
|
||||
CD
|
||||
97
|
||||
00
|
||||
05
|
||||
20
|
||||
FA
|
||||
C9
|
||||
E0
|
||||
13
|
||||
3E
|
||||
87
|
||||
E0
|
||||
14
|
||||
C9
|
||||
3C
|
||||
42
|
||||
B9
|
||||
A5
|
||||
B9
|
||||
A5
|
||||
42
|
||||
3C
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
E0
|
||||
50
|
||||
62
BootROMs/logo-compress.c
Normal file
62
BootROMs/logo-compress.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
void pair(size_t count, uint8_t byte)
|
||||
{
|
||||
static size_t unique_count = 0;
|
||||
static uint8_t unique_data[15];
|
||||
if (count == 1) {
|
||||
unique_data[unique_count++] = byte;
|
||||
assert(unique_count <= 15);
|
||||
}
|
||||
else {
|
||||
assert(count <= 15);
|
||||
uint8_t control = (count << 4) | unique_count;
|
||||
putchar(control);
|
||||
|
||||
for (size_t i = 0; i < unique_count; i++) {
|
||||
putchar(unique_data[i]);
|
||||
}
|
||||
|
||||
if (count != 0) {
|
||||
putchar(byte);
|
||||
}
|
||||
else {
|
||||
assert(control == 0);
|
||||
}
|
||||
|
||||
unique_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
size_t count = 1;
|
||||
uint8_t byte = getchar();
|
||||
int new;
|
||||
size_t position = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
_setmode(0,_O_BINARY);
|
||||
_setmode(1,_O_BINARY);
|
||||
#endif
|
||||
|
||||
while ((new = getchar()) != EOF) {
|
||||
if (byte == new) {
|
||||
count++;
|
||||
}
|
||||
else {
|
||||
pair(count, byte);
|
||||
byte = new;
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
pair(count, byte);
|
||||
pair(0, 0);
|
||||
}
|
||||
2
BootROMs/sgb2_boot.asm
Normal file
2
BootROMs/sgb2_boot.asm
Normal file
@@ -0,0 +1,2 @@
|
||||
SGB2 EQU 1
|
||||
include "sgb_boot.asm"
|
||||
BIN
BootROMs/sgb2_boot.bin
Normal file
BIN
BootROMs/sgb2_boot.bin
Normal file
Binary file not shown.
213
BootROMs/sgb_boot.asm
Normal file
213
BootROMs/sgb_boot.asm
Normal file
@@ -0,0 +1,213 @@
|
||||
; SameBoy SGB bootstrap ROM
|
||||
; Todo: use friendly names for HW registers instead of magic numbers
|
||||
SECTION "BootCode", ROM0[$0]
|
||||
Start:
|
||||
; Init stack pointer
|
||||
ld sp, $fffe
|
||||
|
||||
; Clear memory VRAM
|
||||
ld hl, $8000
|
||||
|
||||
.clearVRAMLoop
|
||||
ldi [hl], a
|
||||
bit 5, h
|
||||
jr z, .clearVRAMLoop
|
||||
|
||||
; Init Audio
|
||||
ld a, $80
|
||||
ldh [$26], a
|
||||
ldh [$11], a
|
||||
ld a, $f3
|
||||
ldh [$12], a
|
||||
ldh [$25], a
|
||||
ld a, $77
|
||||
ldh [$24], a
|
||||
|
||||
; Init BG palette to white
|
||||
ld a, $0
|
||||
ldh [$47], a
|
||||
|
||||
; Load logo from ROM.
|
||||
; A nibble represents a 4-pixels line, 2 bytes represent a 4x4 tile, scaled to 8x8.
|
||||
; Tiles are ordered left to right, top to bottom.
|
||||
ld de, $104 ; Logo start
|
||||
ld hl, $8010 ; This is where we load the tiles in VRAM
|
||||
|
||||
.loadLogoLoop
|
||||
ld a, [de] ; Read 2 rows
|
||||
ld b, a
|
||||
call DoubleBitsAndWriteRow
|
||||
call DoubleBitsAndWriteRow
|
||||
inc de
|
||||
ld a, e
|
||||
xor $34 ; End of logo
|
||||
jr nz, .loadLogoLoop
|
||||
|
||||
; Load trademark symbol
|
||||
ld de, TrademarkSymbol
|
||||
ld c,$08
|
||||
.loadTrademarkSymbolLoop:
|
||||
ld a,[de]
|
||||
inc de
|
||||
ldi [hl],a
|
||||
inc hl
|
||||
dec c
|
||||
jr nz, .loadTrademarkSymbolLoop
|
||||
|
||||
; Set up tilemap
|
||||
ld a,$19 ; Trademark symbol
|
||||
ld [$9910], a ; ... put in the superscript position
|
||||
ld hl,$992f ; Bottom right corner of the logo
|
||||
ld c,$c ; Tiles in a logo row
|
||||
.tilemapLoop
|
||||
dec a
|
||||
jr z, .tilemapDone
|
||||
ldd [hl], a
|
||||
dec c
|
||||
jr nz, .tilemapLoop
|
||||
ld l,$0f ; Jump to top row
|
||||
jr .tilemapLoop
|
||||
.tilemapDone
|
||||
|
||||
; Turn on LCD
|
||||
ld a, $91
|
||||
ldh [$40], a
|
||||
|
||||
ld a, $f1 ; Packet magic, increases by 2 for every packet
|
||||
ldh [$80], a
|
||||
ld hl, $104 ; Header start
|
||||
|
||||
xor a
|
||||
ld c, a ; JOYP
|
||||
|
||||
.sendCommand
|
||||
xor a
|
||||
ld [c], a
|
||||
ld a, $30
|
||||
ld [c], a
|
||||
|
||||
ldh a, [$80]
|
||||
call SendByte
|
||||
push hl
|
||||
ld b, $e
|
||||
ld d, 0
|
||||
|
||||
.checksumLoop
|
||||
call ReadHeaderByte
|
||||
add d
|
||||
ld d, a
|
||||
dec b
|
||||
jr nz, .checksumLoop
|
||||
|
||||
; Send checksum
|
||||
call SendByte
|
||||
pop hl
|
||||
|
||||
ld b, $e
|
||||
.sendLoop
|
||||
call ReadHeaderByte
|
||||
call SendByte
|
||||
dec b
|
||||
jr nz, .sendLoop
|
||||
|
||||
; Done bit
|
||||
ld a, $20
|
||||
ld [c], a
|
||||
ld a, $30
|
||||
ld [c], a
|
||||
|
||||
; Update command
|
||||
ldh a, [$80]
|
||||
add 2
|
||||
ldh [$80], a
|
||||
|
||||
ld a, $58
|
||||
cp l
|
||||
jr nz, .sendCommand
|
||||
|
||||
; Write to sound registers for DMG compatibility
|
||||
ld c, $13
|
||||
ld a, $c1
|
||||
ld [c], a
|
||||
inc c
|
||||
ld a, 7
|
||||
ld [c], a
|
||||
|
||||
; Init BG palette
|
||||
ld a, $fc
|
||||
ldh [$47], a
|
||||
|
||||
; Set registers to match the original SGB boot
|
||||
IF DEF(SGB2)
|
||||
ld a, $FF
|
||||
ELSE
|
||||
ld a, 1
|
||||
ENDC
|
||||
ld hl, $c060
|
||||
|
||||
; Boot the game
|
||||
jp BootGame
|
||||
|
||||
ReadHeaderByte:
|
||||
ld a, $4F
|
||||
cp l
|
||||
jr c, .zero
|
||||
ld a, [hli]
|
||||
ret
|
||||
.zero:
|
||||
inc hl
|
||||
xor a
|
||||
ret
|
||||
|
||||
SendByte:
|
||||
ld e, a
|
||||
ld d, 8
|
||||
.loop
|
||||
ld a, $10
|
||||
rr e
|
||||
jr c, .zeroBit
|
||||
add a ; 10 -> 20
|
||||
.zeroBit
|
||||
ld [c], a
|
||||
ld a, $30
|
||||
ld [c], a
|
||||
dec d
|
||||
ret z
|
||||
jr .loop
|
||||
|
||||
DoubleBitsAndWriteRow:
|
||||
; Double the most significant 4 bits, b is shifted by 4
|
||||
ld a, 4
|
||||
ld c, 0
|
||||
.doubleCurrentBit
|
||||
sla b
|
||||
push af
|
||||
rl c
|
||||
pop af
|
||||
rl c
|
||||
dec a
|
||||
jr nz, .doubleCurrentBit
|
||||
ld a, c
|
||||
; Write as two rows
|
||||
ldi [hl], a
|
||||
inc hl
|
||||
ldi [hl], a
|
||||
inc hl
|
||||
ret
|
||||
|
||||
WaitFrame:
|
||||
push hl
|
||||
ld hl, $FF0F
|
||||
res 0, [hl]
|
||||
.wait
|
||||
bit 0, [hl]
|
||||
jr z, .wait
|
||||
pop hl
|
||||
ret
|
||||
|
||||
TrademarkSymbol:
|
||||
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
|
||||
|
||||
SECTION "BootGame", ROM0[$fe]
|
||||
BootGame:
|
||||
ldh [$50], a
|
||||
BIN
BootROMs/sgb_boot.bin
Normal file
BIN
BootROMs/sgb_boot.bin
Normal file
Binary file not shown.
@@ -351,6 +351,7 @@ set_location_assignment PIN_W20 -to SW[3]
|
||||
|
||||
set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:sys/build_id.tcl"
|
||||
|
||||
set_global_assignment -name VERILOG_FILE fast_boot_rom.v
|
||||
set_global_assignment -name CDF_FILE jtag.cdf
|
||||
set_global_assignment -name QIP_FILE sys/sys.qip
|
||||
set_global_assignment -name QIP_FILE t80/T80.qip
|
||||
|
||||
@@ -172,6 +172,8 @@ localparam CONF_STR5 = {
|
||||
"O34,Aspect ratio,4:3,10:9,16:9;",
|
||||
"O78,Stereo mix,none,25%,50%,100%;",
|
||||
"-;",
|
||||
"O2,Boot,Normal,Fast;",
|
||||
"-;",
|
||||
"R0,Reset;",
|
||||
"J1,A,B,Select,Start;",
|
||||
"V,v",`BUILD_DATE
|
||||
@@ -536,7 +538,7 @@ gb gb (
|
||||
.ce ( ce_cpu ), // the whole gameboy runs on 4mhnz
|
||||
.ce_2x ( ce_cpu2x ), // ~8MHz in dualspeed mode (GBC)
|
||||
|
||||
.fast_boot ( 0 ),
|
||||
.fast_boot ( status[2] ),
|
||||
.joystick ( joystick ),
|
||||
.isGBC ( isGBC ),
|
||||
.isGBC_game ( isGBC_game ),
|
||||
@@ -635,7 +637,7 @@ end
|
||||
wire [7:0] bios_do;
|
||||
wire [11:0] bios_addr;
|
||||
|
||||
dpram_dif #(12,8,11,16) boot_rom_gbc (
|
||||
dpram_dif #(12,8,11,16,"BootROMs/cgb_boot.mif") boot_rom_gbc (
|
||||
.clock (clk_sys),
|
||||
|
||||
.address_a (bios_addr),
|
||||
|
||||
@@ -5,8 +5,8 @@ This is port of [Gameboy for MiST](https://github.com/mist-devel/mist-board/tree
|
||||
* Place RBF file into root of SD card.
|
||||
* Place *.gb files into Gameboy folder.
|
||||
|
||||
## Gameboy Color Support
|
||||
Place the Gameboy color bios/bootrom into the Gameboy folder and rename it to boot1.rom
|
||||
## Open Source Bootstrap roms
|
||||
This now includes the open source boot ROMs from [https://github.com/LIJI32/SameBoy/](https://github.com/LIJI32/SameBoy/) (for maximum GBC compatibility/authenticity you can still place the Gameboy color bios/bootrom into the Gameboy folder and rename it to boot1.rom)
|
||||
|
||||
## Palettes
|
||||
Core supports custom palettes (*.gbp) which should be places into Gameboy folder. Some examples are available in palettes folder.
|
||||
|
||||
@@ -23,7 +23,7 @@ architecture prom of boot_rom is
|
||||
X"06",X"1E",X"C1",X"FE",X"64",X"20",X"06",X"7B",X"E2",X"0C",X"3E",X"87",X"E2",X"F0",X"42",X"90",
|
||||
X"E0",X"42",X"15",X"20",X"D2",X"05",X"20",X"64",X"16",X"20",X"18",X"CB",X"E0",X"40",X"18",X"5C",
|
||||
X"06",X"04",X"C5",X"CB",X"11",X"17",X"C1",X"CB",X"11",X"17",X"05",X"20",X"F5",X"22",X"22",X"22",
|
||||
X"22",X"C9",X"3C",X"42",X"A5",X"81",X"A5",X"99",X"42",X"3C",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",
|
||||
X"22",X"C9",X"3C",X"42",X"B9",X"A5",X"B9",X"A5",X"42",X"3C",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",
|
||||
X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",
|
||||
X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",
|
||||
X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",
|
||||
|
||||
19
fast_boot_rom.v
Normal file
19
fast_boot_rom.v
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
module fast_boot_rom(
|
||||
input clk,
|
||||
input [7:0] addr,
|
||||
output reg [7:0] data
|
||||
);
|
||||
|
||||
reg [7:0] rom_data [255:0];
|
||||
|
||||
initial begin
|
||||
$readmemh("BootROMs/dmg_boot.mem", rom_data);
|
||||
end
|
||||
|
||||
always @(posedge clk)
|
||||
begin
|
||||
data <= rom_data[addr];
|
||||
end
|
||||
|
||||
endmodule
|
||||
9
gb.v
9
gb.v
@@ -590,7 +590,7 @@ wire [7:0] rom_do = isGBC? //GameBoy Color?
|
||||
((cpu_addr[14:9] == 6'h00) || (hdma_rd&& hdma_source_addr[14:9] == 6'h00))? cart_do: //100-1FF Cart Header
|
||||
(((cpu_addr[14:12] == 3'h0) || (hdma_rd&& hdma_source_addr[14:12] == 3'h0)) && boot_rom_enabled)?gbc_bios_do: //200-8FF bootrom 2nd part
|
||||
cart_do: //rest of card
|
||||
((cpu_addr[14:8] == 7'h00) && boot_rom_enabled)?boot_rom_do:cart_do; //GB
|
||||
((cpu_addr[14:8] == 7'h00) && boot_rom_enabled)?fast_boot?fast_boot_rom_do:boot_rom_do:cart_do; //GB
|
||||
|
||||
|
||||
wire is_dma_cart_addr = (dma_sel_rom || dma_sel_cram); //rom or external ram
|
||||
@@ -610,4 +610,11 @@ boot_rom boot_rom (
|
||||
.data ( boot_rom_do )
|
||||
);
|
||||
|
||||
wire [7:0] fast_boot_rom_do;
|
||||
fast_boot_rom fast_boot_rom (
|
||||
.addr ( cpu_addr[7:0] ),
|
||||
.clk ( clk ),
|
||||
.data ( fast_boot_rom_do )
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
@@ -375,7 +375,7 @@ begin
|
||||
MCycles <= "000";
|
||||
DO <= "00000000";
|
||||
|
||||
ACC <= (others => '1');
|
||||
ACC <= (others => '0');
|
||||
if Mode = 3 then
|
||||
F <= "11110000";
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user