first commit

This commit is contained in:
2023-03-24 23:59:36 +01:00
commit 0d482bbbcc
15 changed files with 2273 additions and 0 deletions

BIN
Font96.FNT Normal file

Binary file not shown.

269
GB_HelloWorld.asm Normal file
View File

@@ -0,0 +1,269 @@
NextCharX equ &C000
NextCharY equ &C001
org &0000 ;RST 0-7
org &0040 ;Interrupt: Vblank
reti
org &0048 ;Interrupt: LCD-Stat
reti
org &0050 ;Interrupt: Timer
reti
org &0058 ;Interrupt: Serial
reti
org &0060 ;Interrupt:Joypad
reti
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Init routine
sstart:
org &0100
nop ;0100 0103 Entry point (start of program)
jp begin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Header
;0104-0133 Nintendo logo (must match rom logo)
db &CE,&ED,&66,&66,&CC,&0D,&00,&0B,&03,&73,&00,&83,&00,&0C,&00,&0D
db &00,&08,&11,&1F,&88,&89,&00,&0E,&DC,&CC,&6E,&E6,&DD,&DD,&D9,&99
db &BB,&BB,&67,&63,&6E,&0E,&EC,&CC,&DD,&DC,&99,&9F,&BB,&B9,&33,&3E
db "CHIBIAKUMAS.COM" ;0134-0142 Game Name (UCASE)
ifdef BuildGBC
db &80 ;0143 Color gameboy flag (&80 = GB+CGB,&C0 = CGB only)
else
db &00
endif
db 0,0 ;0144-0145 Game Manufacturer code
db 0 ;0146 Super GameBoy flag (&00=normal, &03=SGB)
db 2 ;0147 Cartridge type (special upgrade hardware)
;(0=normal ROM , 1/2=MBC1(max 2MByte ROM and/or 32KByte RAM)
;0 - ROM ONLY 12 - ROM+MBC3+RAM
;1 - ROM+MBC1 13 - ROM+MBC3+RAM+BATT
;2 - ROM+MBC1+RAM 19 - ROM+MBC5 (max 8MByte ROM and/or 128KByte RAM)
;3 - ROM+MBC1+RAM+BATT 1A - ROM+MBC5+RAM
;5 - ROM+MBC2 1B - ROM+MBC5+RAM+BATT
;6 - ROM+MBC2+BATTERY 1C - ROM+MBC5+RUMBLE
;8 - ROM+RAM 1D - ROM+MBC5+RUMBLE+SRAM
;9 - ROM+RAM+BATTERY 1E - ROM+MBC5+RUMBLE+SRAM+BATT
;B - ROM+MMM01 1F - Pocket Camera
;C - ROM+MMM01+SRAM FD - Bandai TAMA5
;D - ROM+MMM01+SRAM+BATT FE - Hudson HuC-3
;F - ROM+MBC3+TIMER+BATT FF - Hudson HuC-1
;10 - ROM+MBC3+TIMER+RAM+BATT
;11 - ROM+MBC3
db 2 ;0148 Rom size (0=32k, 1=64k,2=128k etc)
db 3 ;0149 Cart Ram size (0=none,1=2k 2=8k, 3=32k)
db 1 ;014A Destination Code (0=JPN 1=EU/US)
db &33 ;014B Old Licensee code (must be &33 for SGB)
db 0 ;014C Rom Version Number (usually 0)
db 0 ;014D Header Checksum - ones complement' checksum of bytes 0134-014C… (not needed for emulators)
dw 0 ;014E-014F Global Checksum 16 bit sum of all rom bytes (except 014E-014F)… unused by gameboy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start of code
begin:
nop
di
ld sp, &ffff ; set the stack pointer to highest mem location + 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Position tilemap
xor a
ld hl,&FF42
ldi (hl), a ;FF42: SCY - Tile Scroll Y
ld (hl), a ;FF43: SCX - Tile Scroll X
ld (NextCharX),a ;Set cursor to pos 0,0
ld (NextCharY),a
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Turn off screen
StopLCD_wait: ;Turn off the screen so we can define our patterns
ld a,(&FF44) ;Loop until we are in VBlank
cp 145 ;Is display on scan line 145 yet?
jr nz,StopLCD_wait ;no? keep waiting!
ld hl,&FF40 ;LCDC - LCD Control (R/W)
res 7,(hl) ;Turn off the screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define bitmap font
ld de, BitmapFont ;Source bitmaps
ld hl, &8000 ;Dest in Vram
ld bc, BitmapFontEnd-BitmapFont ;Bytes of font
Copy2Bitloop
ld a,(de) ;Read in a byte and INC HL
inc de
ldi (hl),a ;Fill Bitplane 1
ldi (hl),a ;Fill Bitplane 2
dec bc
ld a,b
or c
jr nz,Copy2Bitloop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define palette
ifdef BuildGBC
ld c,0*8 ;palette no 0 (back)
call SetGBCPalettes
ld c,7*8 ;palette no 7 (used by font)
call SetGBCPalettes
else
ld a,%00011011 ;DDCCBBAA .... A=Background 0=Black, 3=White
ld hl,&FF47
ldi (hl),a ;FF47 BGP BG & Window Palette Data (R/W) = &FC
ldi (hl),a ;FF48 OBP0 Object Palette 0 Data (R/W) = &FF
cpl ;Set sprite Palette 2 to the opposite
ldi (hl),a ;FF49 OBP1 Object Palette 1 Data (R/W) = &FF
endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Turn on screen
ld hl,&FF40 ;LCDC - LCD Control (R/W) EWwBbOoC
set 7,(hl) ;Turn on the screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Our program
ld hl,Message ;Address of string
Call PrintString ;Show String to screen
di
halt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintString:
ld a,(hl) ;Print a '255' terminated string
cp 255
ret z
inc hl
call PrintChar
jr PrintString
Message: db 'Hello World 323!',255
PrintChar:
push hl
push bc
push af
ld a,(NextCharY)
ld b,a ;YYYYYYYY --------
ld hl,NextCharX
ld a,(hl)
ld c,a ;-------- ---XXXXX
inc (hl)
cp 20-1
call z,NewLine
xor a
rr b ;-YYYYYYY Y-------
rra
rr b ;--YYYYYY YY------
rra
rr b ;---YYYYY YYY-----
rra
or c ;---YYYYY YYYXXXXX
ld c,a
ld hl, &9800 ;Tilemap base
add hl,bc
pop af
push af
sub 32 ;no char <32!
call LCDWait ;Wait for VDP Sync
ld (hl),a
ifdef BuildGBC
ld bc,&FF4F ;VBK - CGB Mode Only - VRAM Bank
ld a,1 ;Turn on GBC extras
ld (bc),a
ld (hl),7 ;Palette 7
xor a ;Turn off GBC extras
ld (bc),a
endif
pop af
pop bc
pop hl
ret
NewLine:
push hl
ld hl,NextCharY ;Inc Ypos
inc (hl)
ld hl,NextCharX
ld (hl),0 ;Reset Xpos
pop hl
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LCDWait:
push af
di
LCDWaitAgain
ld a,(&FF41) ;STAT - LCD Status (R/W)
;-LOVHCMM
and %00000010 ;MM=video mode (0/1 =Vram available)
jr nz,LCDWaitAgain
pop af
ret
SetGBCPalettes:
ifdef BuildGBC
ld hl,GBPal
SetGBCPalettesb:
ldi a,(hl) ;GGGRRRRR
ld e,a
ldi a,(hl) ;xBBBBBGG
ld d,a
inc a ;cp 255
ret z
push hl
call lcdwait ;Wait for VDP Sync
ld hl,&ff68
ld (hl),c ;FF68 - BCPS/BGPI - CGB Mode Only - Background Palette Index
inc hl
ld (hl),e ;FF69 - BCPD/BGPD - CGB Mode Only - Background Palette Data
dec hl
inc c ;Increase palette address
ld (hl),c ;FF68 - BCPS/BGPI - CGB Mode Only - Background Palette Index
inc hl
ld (hl),d ;FF69 - BCPD/BGPD - CGB Mode Only - Background Palette Data
inc c ;Increase palette address
pop hl
jr SetGBCPalettesb
endif
; xBBBBBGGGGGRRRRR
GBPal: dw %0111110000000000 ;col 0
dw %0111111111100000 ;col 1
dw %0000000000011111 ;col 2
dw %0000001111111111 ;col 3
dw %1111111111111111 ;End of list
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Font (1bpp / Black & White)
BitmapFont:
incbin "\ResALL\Font96.FNT" ;Font bitmap,
BitmapFontEnd: ; this is common to all systems

BIN
bgb/bgb.exe Normal file

Binary file not shown.

681
bgb/bgb.html Normal file
View File

@@ -0,0 +1,681 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>bgb readme</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2>BGB version 1.5.9</h2>
<b>homepage: </b><a href="https://bgb.bircd.org/">https://bgb.bircd.org/</a><br>
<b>email: </b>bgb at bircd dot org
<p>
this is a gameboy/color emulator/debugger for win32 which will probably never be finished
<p>
<h3>disclaimer:</h3>
no warranty of any kind, use at your own risk. This program is guaranteed to do nothing but taking disk space. Don't blame me if it damages your computer, or erases your hard drive, etc.
Using copyrighted roms with an emulator is illegal if you don't own the real cartridge or have explicit permission from the copyright holder. If you choose to do so, that is your responsibility.
<p>
<h3>table of contents</h3>
<a href="#rightclick">right click menu</a><br>
<a href="#defaultkeys">default keys</a><br>
<a href="#features">features in this version</a><br>
<a href="#requirements">supported platforms/system requirements</a><br>
<a href="#pdroms">accurate emulation and broken PD roms</a><br>
<a href="#knownproblems">known problems</a><br>
<a href="#savformat">SAV (battery) file format</a><br>
<a href="#options">options window</a><br>
<a href="#cheats">GameGenie/GameShark cheat</a><br>
<a href="#cheatsearcher">cheat searcher</a><br>
<a href="#debugkeys">debugger hotkeys</a><br>
<a href="#expressions">expressions, breakpoint conditions, and debug messages</a><br>
<a href="#commandlineparams">Commandline parameters</a><br>
<a href="#demorec">Demo recording/playback</a><br>
<a href="#slowpc">How to make bgb run faster if you have a slow computer</a><br>
<a href="#fullscreenmode">full screen mode</a><br>
<a href="#gamelink">game link</a><br>
<a href="#avirecorder">AVI recorder</a><br>
<a href="#speedruns">Note for speedrun or "race" use</a><br>
<a href="#history">version history</a><br>
<h3 id="rightclick">right click menu:</h3>
Click the right mouse button in the emulator window to get the popup menu, from which you can access the options and functions.
<p>
<h3 id="defaultkeys">default keys:</h3>
<table border="0">
<tr><td width="50%">numpad +</td><td>fast forward</tr>
<tr><td>numpad *</td><td>reset gameboy</tr>
<tr><td>numpad -</td><td>cheat codes on/off</tr>
<tr><td>A</td><td>B button</tr>
<tr><td>S</td><td>A button</tr>
<tr><td>Shift</td><td>Select button</tr>
<tr><td>Enter</td><td>Start button</tr>
<tr><td>F2</td><td>save state</tr>
<tr><td>F3</td><td>select state</tr>
<tr><td>F4</td><td>load state</tr>
<tr><td>Esc</td><td>debugger</tr>
<tr><td>Alt+F4</td><td>exit</tr>
</table>
<p>
<h3 id="features">features in this version:</h3>
<ul>
<li>emulation of the GameBoy, GameBoy Color, and Super Gameboy</li>
<li>accurate emulation of the hardware, based on research with lots of test roms, useful for debugging/rom development. some highlights:
<ul>
<li>clock exact timing of LCD behavior/state changes</li>
<li>realistic initial ram values - random but with specific bit patterns, and simulated values left by bootroms (for example "nibbler (pd)" depends on this)</li>
<li>accurate emulation of LCD register writes during scanline (prehistorik man, demotronic demo)</li>
<li>emulation of inaccessible VRAM and OAM as on real hardware</li>
<li>10 sprites per line limit</li>
<li>clock exact emulation of sprites causing mode 3 to take longer</li>
<li>correct memory access timing (access happening at the last/second to last clock of an opcode)</li>
<li>accurate emulation of the differences between DMG and GBC, including timing differences, differences in hardware behavior, initial state, etc.</li>
<li>can run a GBC rom as on a DMG, and a DMG rom as on a GBC</li>
</ul></li>
<li>powerful debugger:
<ul>
<li>disassembler</li>
<li>assembler (change code and ability to save modified rom)</li>
<li>symbols (SYM file) support</li>
<li>"inline" editing in code, data, and stack viewer</li>
<li>breakpoints</li>
<li>break on access</li>
<li>conditional breakpoints</li>
<li>"on jump" access breakpoints for breaking before a jump into a range is taken.</li>
<li>source code breakpoints (ld b,b)</li>
<li>singlestepping/tracing/animating/step out/step over</li>
<li>vram viewer: BG map, tiles, OAM, palette.</li>
<li>IO registers viewer</li>
<li>live display of data during emulation and freezing of ram values</li>
<li>break on exceptions (accessing inaccessible VRAM, read unitialized RAM, echo ram access, access locked external ram, disable lcd outside vblank)</li>
<li>ability to modify all registers and state at any time</li>
<li>joypad window allows simulating button presses at any time while debugging</li>
</ul></li>
<li>SGB multiplayer with up to 4 gamepads</li>
<li>graphics output: GDI, DirectDraw, Direct3D, OpenGL, null output</li>
<li>graphics doubler: HQ2X, Scale2x, scanlines filter, blocky</li>
<li>sound output: waveout, directsound, null, and disk writer supported. support for writing the 4 channels to separate wav files</li>
<li>AVI recording, to installed system codec of choice. No sound included but is in sync and conveniently named with recorded wav file.</li>
<li>runs almost all roms perfectly, compatibility comparable with the best GB/C emulators</li>
<li>Accurate/high quality sound emulation, bandlimited synthesis</li>
<li>accurate video emulation including "high color" graphics, correct sprite/background priorities, 10 sprites/line limit, and mid-scanline register changes.</li>
<li>This emulator is fast.</li>
<li>Joystick/Gamepad support, everything mappable to every button</li>
<li>some user interface keys are configurable and can be mapped to joystick/gamepad buttons</li>
<li>MBC3 Real Time Clock emulation. RTC is saved/loaded in the .sav file, compatible with VBA</li>
<li>Auto delay/frameskip, emulation runs at 100% real speed and full 60 fps</li>
<li>GameGenie and GameShark cheat, load/save cheats (auto and manual), "cheat searcher", easy creation of new cheat codes</li>
<li>save/load state with quick (zsnes style, and mappable) keys, and preview screenshots for slots in select window.</li>
<li>Load from ZIP and GZIP files</li>
<li>good OS/platform compatibility/low requirements (works well on wine, windows 98, and on slow/old PCs)</li>
<li>support for optional border bitmap and pseudo and real fullscreen modes.</li>
<li>TCP/IP game link support</li>
</ul>
<p>
<h3 id="requirements">supported platforms/system requirements</h3>
<p>OS: supported/known to work on windows 98 up to windows 10, DirextX 7 or later. Wine on Linux and OS X.
<p>
soundcard and joystick/gamepad are optional. A videocard with 3D hardware acceleration is recommended.
200 MHz pentium or faster CPU. BGB runs perfectly on an atom netbook.<p>
<h3 id="pdroms">accurate emulation and broken PD roms:</h3>
by default, BGB emulates the real hardware very accurately, including behavior that some broken PD/unofficial roms may have problems with. These roms would also fail on real hardware, or on a real cartridge: they rely on an inaccurate emulator, or a flashcart.
in the "except" tab, one can choose <i>"Troubleshoot broken PD roms"</i>, and then set aspects of deliberately inaccurate emulation, to see which one a broken PD rom depends on. Choosing <i>"Emulate as in reality"</i> disables and locks out all inaccuracies and should be done if not trying to fix a problem with a bad rom.<br>
one can also set "break on ..." settings to break (go to the debugger) if a rom misbehaves.<br>
note that if you enable any <i>"break on"</i> settings, or set breakpoints of any kind, bgb will run in "debug mode", and will be about twice as slow because of extra checks.
this is done to allow bgb to run as fast as possible if debug features are disabled.
<p>
<h3 id="knownproblems">known problems:</h3>
<ul>
<li>bgb 0.x will hang/crash when attempting to open bgb 1.0 save states because the old save state format had no version information.</li></ul>
<p>
<h3 id="savformat">SAV (battery) file format</h3>
SAV files are raw battery ram images, except for MBC3 RTC games, where 48 bytes of RTC data is appended, in a way that is compatible with Visualboy Advance. Some emulators are unable to load such SAV files, for example 3ds VC. If you encounter this problem, you can disable <i>"Save RTC in SAV file (VBA compatible)"</i> in the settings, <i>"misc"</i> tab. To "fix" an existing SAV file, load the game and close it again.
<p>
<h3 id="options">options window:</h3>
Popup menu --> <i>Options.</i><br>
here you can change a lot of settings such as the joypad keys, configure a gamepad/jostick, change the colors of the gameboy screen, and graphics and sound options.
Besides obvious "preference" settings, most settings are optimal as default and should not be changed unless trying to fix a problem.<p>
<ul>
<li><h4><i>Sound:</i></h4>
<ul>
<li><b><i>Soundcard</i></b> (auto) enable sound output to soundcard API. if this and WAV writer are disabled, sound rendering is disabled completely.</li>
<li><b><i>disable events:</i></b> (off) do not time sound output on callback events. can be used with null output for performance testing.</li>
<li><b><i>8 bits output:</i></b> (off) enable this if 16 bits audio is not supported or gives problems. Gives lower sound quality, not recommended.</li>
<li><b><i>mono output:</i></b> (off) enable this to output mono and mix the channels into it. useful if you listen with one headphone, or soundcard does not support stereo.</li>
<li><b><i>High quality sound rendering:</i></b> (on) bandlimited synthesis. disable this if you're on a very slow PC and you're trying to speed up emulation.</li>
<li><b><i>Latency:</i></b> (57) setting this higher means lower latency. setting it too high causes sound to skip.</li>
<li><b><i>WAV file writer:</i></b> (off) writes wav file. each time it is re-inited, a new WAV with a different timestamp is created</li>
<li><b><i>Save individual channels:</i></b> (off) write 4 wav files for the individual hardware channels. this works in addition to/independently of "WAV file writer"</li>
<li><b><i>animation recording:</i></b> (off) saves a BMP screenshot for every 1 or 2 frames (as desired), with timestamp prefix matching the WAV file and a frame number.</li>
<li><b><i>record AVI:</i></b> (off) record animation to AVI. Give fourcc in box to choose codec. "Config" will open the codec's settings dialog.</li>
<li><b><i>record half framerate:</i></b> (on) record ~30 fps instead of ~60 fps, saving only every other frame.</li>
</ul></li>
<li><h4><i>Joypad:</i></h4>
click on <i>"configure keyboard"</i> or <i>"configure game controller"</i>, to show the wizard. press the desired keys/buttons for the hilighted buttons.
to change keys for user interface functions (load/save state, fast forward, reset, etc), check <i>"configure extra buttons"</i>, then click on <i>"configure ..."</i><p>
To change only one one or some buttons, click <i>"skip/keep"</i> for every other button. For each button, it says which key it is currently mapped to.<p>
<i>Mappable button records</i> button can be mapped through <i>"configure extra buttons"</i>.
<i>Screenshot button</i> - <i>saves</i>, <i>copies</i>, <i>both</i> controls whether screenshot are saved as BMP file in the "scrnshot" folder, or copied to clipboard. The screenshot button can be mapped through <i>"configure extra buttons"</i>.
<li><h4><i>Misc:</i></h4>
<ul>
<li><b><i>show framerate:</i></b> (off) shows framerate in the window title bar, 2 numbers: drawed frames/sec, executed frames/sec.</li>
<li><b><i>freeze recent roms menu:</i></b> (off) Use this to make "recent roms" not change. Can be used for "favorite roms".</li>
<li><b><i>Show errors on rom load:</i></b> (on) When loading a rom, show if something is wrong with the rom header so it would not work on real hardware.</li>
<li><b><i>Show warnings on rom load:</i></b> (on) When loading a rom, show any problems/inconsistencies in a rom header. When developing a rom, you should make sure to have no warnings.</li>
<li><b><i>reduce CPU usage:</i></b> (on) causes bgb to use the minimum possible cpu by issuing sleep calls when waiting</li>
<li><b><i>reduce input latency:</i></b> (auto) use an algorithm that, if vsync is used, delays input polling and emulation to reduce input-to-screen latency.</li>
<li><b><i>pause if losing focus:</i></b> (off) pauses/stops bgb if switching to another app.</li>
<li><b><i>use fast open files dialog:</i></b> (off) uses bgb's builtin open/save files dialog instead of the default windows one. The fast open dialog also allows selecting Unicode filenames.</li>
<li><b><i>framerate:</i></b> (0) can be used to make bgb run slower or faster than real speed, at a desired framerate. 0 runs at the real ~59.72 fps</li>
<li><b><i>adjust sound speed:</i></b> (off) change the sound's pitch to match the alternative emulation speed (like a real GB does if you change the clock signal).</li>
<li><b><i>undelayed speed:</i></b> (10) how fast to run if pressing the "fast forward" button, 1 is equal to real speed. can also be used to turn the key into a "slow down" key if desired (with a value less than 1)</li>
</ul></li>
<li><h4><i>Graphics:</i></h4>
<ul>
<li><b><i>Mix current and last frame:</i></b> (off) can be used to make games show correctly which use "flickering" to mix colors (for example "ballistic")</li>
<li><b><i>doubler:</i></b> (off) applies a screen filter effect such as scanlines or HQ2X, also doubles the size in pixels (useful for fullscreen pageflipped mode if you can't use 320x240)</li>
</ul>
the "auto" settings are defaults and are recommended settings. other settings may sometimes have specific benefits or uses.
<ul>
<li><b><i>bpp:</i></b> (auto) override bits per pixel selection</li>
<li><b><i>output:</i></b> (auto) override choice of output method. use GDI if other methods have problems. null can be used for speed testing (does render, but not output. to disable graphics rendering *and* outputting, change the window's height to 0 instead).</li>
<li><b><i>vsync:</i></b> (auto) override choice of vertical synchronization method. vsync eliminates tearing in the animation. one can disable vsync, or set 1 frame/vblank (instead of synchronizing to real speed)</li>
<li><b><i>stretch:</i></b> (blocky) instruct the graphics output to use "blocky" (point sampling) or "blurry" (bilinear filter) stretching</li>
<li><b><i>fullscreen pageflipped:</i></b> (off) run in a real double/triple buffered fullscreen mode. may have benefits for performance or smooth animation</li>
<li><b><i>GBC LCD colors:</i></b> (on) make GBC colors look as on real GBC. disable to use RGB values directly without conversion.</li>
<li><b><i>border BMP file:</i></b> (<i>only SGB border</i>) you can use a BMP file as border for BGB (it will show if enabled, and there is no SGB border). use a 160x144 pixels plain, one color rectangle to define the location of the GB screen. You can also drag and drop a bitmap file to use it as background.</li>
</ul></li>
<li><h4><i>System:</i></h4>
<ul>
<li><b><i>Gameboy:</i></b> runs any rom as on a DMG (original gameboy)</li>
<li><b><i>Gameboy Color:</i></b> runs any rom as on a GBC (gameboy color). this also emulates a DMG rom as on a real GBC in DMG mode, to allow testing/debugging this (for example, legend of zerd breaks as in reality)</li>
<li><b><i>Super Gameboy:</i></b> runs any rom as on a SGB. non-SGB supporting roms are run with SGB initial state, or with SGB bootrom.</li>
<li><b><i>automatic, prefer GBC:</i></b> (default) runs DMG, SGB, and GBC roms on the proper system. runs GBC+SGB roms as on a GBC.</li>
<li><b><i>automatic, prefer SGB:</i></b> runs DMG, SGB, and GBC roms on the proper system. runs GBC+SGB roms as on a SGB.</li>
<li><b><i>SGB + GBC:</i></b> emulates both SGB and GBC features at the same time. because this system does not exist, roms may have problems/unpredictable behavior.</li>
<li><b><i>GBC + initial SGB border:</i></b> starts SGB+GBC roms in SGB mode, until they transferred a border, then resets in GBC mode. this is required for some GBC+SGB roms to show a border.</li>
<li><b><i>Gameboy or GBC:</i></b> runs GBC supporting roms as on GBC, otherwise on DMG (does not enable SGB)</li>
<li><b><i>detect GB pocket / SGB2:</i></b> (off) when in DMG mode, make roms detect a gameboy pocket, possibly unlocking features.</li>
<li><b><i>detect GBA:</i></b> (off) when in GBC mode, make roms detect a gameboy advance, possibly unlocking features (example: "legend of zelda oracle of ages/seasons")</li>
<li><b><i>GB player:</i></b> (off) if GBA mode and bootrom enabled, hard reset simulates fade and delay like a Gameboy Player</li>
<li><b><i>SGB faster as in reality:</i></b> (off) if emulation is as SGB (and not as SGB2), emulate at ~61.1679 fps like a real SGB (NTSC), including sound being sharp</li>
<li><b><i>fast SGB transfers:</i></b> (off) run at unlimited speed during SGB VRAM transfers (inaccurate and can cause problems).</li>
<li><b><i>Waitloop detection:</i></b> (on) detect and shortcut waitloops (which most roms use), speeding up emulation. this is done without compromise on accuracy and has no known problems so it should be left enabled.</li>
<li><b><i>boot roms:</i></b> (off) run the DMG, SGB and GBC bootrom (rom images must be obtained elsewhere). if used with the "gameboy color" system setting, this lets the GBC bootrom colorize DMG roms. The bootroms are not necessary for normal emulation.</li>
</ul><p>
If a bootrom is used, it will automatically be patched in ram based on <i>"detect GBP"</i> and <i>"detect GBA"</i> settings, to give accurate emulation of a GBP or SGB2 or GBA. If this behavior is undesired, find and set <i>"BootromPatch=0"</i> in bgb.ini.
<li><h4><i>Exceptions:</i></h4>
Controls emulation relevant for debugging roms.
<p>
For <b>playing games</b>, the defaults are recommended: <i>"Emulate as in reality"</i>, and disabling all <i>"break on"</i> settings. Enabling any <i>"break on"</i> setting will enable "debug mode" and cause emulation to use at least twice as much CPU.
</p><p>
If <b>developing a rom</b>, keep <i>"Emulate as in reality"</i> and enable the <i>"break on"</i> settings to help catch common problems. If your rom works in bgb with <i>"Emulate as in reality"</i> then it is likely to work on real hardware, but you should still test that too.
</p><p>
To <b>make a 3rd party unofficial rom work which doesn't work</b>, you can enable deliberate inaccuracies with with <i>"Troubleshoot broken PD roms"</i> and then enable individual inaccuracies, effectively emulating a poor emulator or a generic flash cart. This can help to pinpoint the cause of problems. Such roms will not work on a real gameboy, or on the real cart they report in the header. Do not rely on this when developing a rom.
</p>
</li>
</ul>
<p>
<h3 id="cheats">GameGenie/GameShark cheat:</h3>
how to use a gamegenie/shark code: press F10, or use the rightclick menu and choose <i>"cheat"</i>, to show the cheat window.
click <i>"Add"</i>. click in the <i>"Code"</i> field, and paste or type the code. optionally, click in the <i>"Comment"</i> field, and enter a description. click "OK".
click on the newly added code in the list, and click <i>"Enable"</i>.<p>
the cheat window shows a list. you can add/edit/delete cheat entries, with a code and a description. you can load/save the cheats to a file.<br>
meaning of the letters:
<ul>
<li>G = game genie</li>
<li>S = game shark</li>
<li>P = patched. means a gamegenie code changed values in the rom. if it does not show, the gamegenie code does not work for the used rom.</li>
<li>E = enabled (toggled with enable/disable buttons)</li>
</ul>
in the cheat edit window, you can either enter a code, and internal values will be displayed, or you can enter internal values, and the corresponding code will be displayed.<p>
for a gameshark cheat, you can either use <i>"enable"</i> to make it work constantly, or "poke" to make it change the ram value once.<p>
rightclick on a cheat to set an "access breakpoint" (for gameshark codes only), or go to this cheat's rom or ram address in the debugger.<p>
<h3 id="cheatsearcher">cheat searcher:</h3>
with the cheat searcher and the debugger, you can make new gameshark and gamegenie cheats<p>
Play the game to the point where you want to influence behavior (for example, the game action itself)
press esc to enter debugger. menu: <i>Window</i> -> <i>cheat searcher</i>. select value type (normally 8 bits) and press start.<p>
you may be looking for a value such as "3 lives", in that case, the value in RAM may be 3 as well, but it's not guaranteed.<p>
continue the game, walking around, killing enemies, etc, but making the value you're looking for *not* change (not dying, not getting hurt, etc), use the criteria <i>"equal to the previous value"</i> and search.
the number of addresses displayed goes down.
you can repeat this a few times.
now run the game, but make the value you are looking for change, for example by dying or getting hurt in the game.
now search for values which are, for example, <i>"lower than the previous value"</i>.
the number of matching addresses in the list become smaller each time you run the game and do a search, and you should end up with only one address.<p>
Now, rightclick on the address, and choose <i>"go here in debugger"</i>. this will select the address in the ram viewer (on the bottom of the window). then rightclick on that address, and choose <i>"freeze ram value"</i>, and enter the desired value. This will create a gameshark code. You can open the cheat window to see the code listed.<p>
if you want to create a gamegenie code, rightclick on the gameshark code, and choose <i>"set access breakpoint"</i>. Run the game until the value is changed (for example, die in the game), and it should stop and show the code line on which the value is changed.
interpret how the code changes the value, and use game genie codes to change bytes in the code - such as changing an instruction to a nop, or change a "number to decrease" (value 01 to 00), in the cheat window, add new code, enter the address, existing and desired values, and a gamegenie code is produced automatically.<p>
<h3 id="debugkeys">debugger hotkeys</h3>
A list of shortcut keys that work in the debugger:
<p>
<table>
<tr><td>F2</td><td>Toggle breakpoint</td></tr>
<tr><td>F3</td><td>Step Over</td></tr>
<tr><td>F4</td><td>Run to cursor</td></tr>
<tr><td>F5</td><td>VRAM viewer</td></tr>
<tr><td>F6</td><td>Jump to cursor</td></tr>
<tr><td>F7</td><td>Trace (step into)</td></tr>
<tr><td>F8</td><td>Step out</td></tr>
<tr><td>F9</td><td>Run</td></tr>
<tr><td>Shift+F9</td><td>Run and ignore all breakpoint types</td></tr>
<tr><td>Ctrl+F9</td><td>Run and ignore the last tripped breakpoint type</td></tr>
<tr><td>F10</td><td>IO Map</td></tr>
<tr><td>F11</td><td>Options</td></tr>
<tr><td>F12</td><td>Load Rom</td></tr>
<tr><td>Ctrl+S</td><td>Save ROM as</td></tr>
<tr><td>Alt+A</td><td>Animate</td></tr>
<tr><td>Ctrl+G</td><td>Go to address</td></tr>
<tr><td>Ctrl+A</td><td>Go to PC</td></tr>
<tr><td>Ctrl+Shift+number</td><td>create bookmark</td></tr>
<tr><td>Ctrl+number</td><td>go to bookmark</td></tr>
<tr><td>Ctrl+B</td><td>go to previous bookmark or breakpoint</td></tr>
<tr><td>Ctrl+N</td><td>go to next bookmark or breakpoint</td></tr>
<tr><td>Ctrl+H</td><td>breakpoints</td></tr>
<tr><td>Ctrl+J</td><td>access breakpoints</td></tr>
<tr><td>Right arrow</td><td>follow jump or address dereference</td></tr>
<tr><td>Left arrow</td><td>undo follow or go to address</td></tr>
<tr><td>Tab</td><td>toggle symbols view</td></tr>
<tr><td>Ctrl+Tab</td><td>go to next viewer area</td></tr>
<tr><td>Ctrl+Shift+Tab</td><td>go to previous viewer area</td></tr>
<tr><td>letter or number</td><td>Modify code/data</td></tr>
<tr><td>Ctrl+Z</td><td>Undo modify code/data</td></tr>
<tr><td>Ctrl+Alt+Z</td><td>Redo</td></tr>
</table>
<h3 id="expressions">expressions, breakpoint conditions, and debug messages</h3>
In the "condition" field of a breakpoint, one can enter an expression. for example ($ff44)=$90, to trip on the start of each vblank. the condition will only trip once every time when it becomes true.
besides constant values and addresses, one can use the following:<p>
CPU registers: AF, BC, DE, HL, SP, PC, B, C, D, E, H, L, A, ZERO, ZF, Z, CARRY, CY, IME, ALLREGS<br>
other state values: ROMBANK, XRAMBANK, SRAMBANK, WRAMBANK, VRAMBANK, TOTALCLKS, LASTCLKS, CLKS2VBLANK<p>
These values can also be evaluated by using the menu, <i>"Debug"</i>, <i>"Evaluate expression"</i>.<p>
The unit of all "clocks" values is 1 nop in doublespeed mode, or about 0.5 microseconds. Clocks values are, like all other numerical values, in hexadecimal. The expression "ZEROCLKS" will reset the counter for LASTCLKS. TOTALCLKS is the same value as the clocks counter ("internal divider") in the IO map.<p>
To add "ld d,d" debug messages into the code, assemble an opcode in the form: .msg 'message' where message is the message content. debug messages can contain expressions between %%. When enabled in the settings, whenever a debug message is encountered in the code, it will be logged to the debug messages window or log file.<p>
Debug messages also support ternary operators in the form: "%boolean expression%text if true;text if false;".<p>
The internal code that makes up a debug message is as follows: ld d,d; jr @end; dw $6464; dw $0000; db "message"; @end<p>
One can also create debug messages that point to a null terminated text string elsewhere: ld d,d; jr @end; dw $6464; dw $0001; dw address; dw bank; @end<p>
<h3 id="commandlineparams">Commandline parameters</h3>
All -params also work as --param.
<ul><li><b>[<i>-rom</i>] &lt;filename of rom or state&gt;</b> load a rom or save state
</li><li><b><i>-setting</i> name=value</b> load bgb with a custom setting. this is useful for running multiple (linked) instances on a different position (with winx setting).
</li><li><b><i>-set</i> name=value</b> shorthand for -setting
</li><li><b><i>-listen</i> [[addr:]port]</b> start bgb listening for game link. if addr/port is omitted, take from settings
</li><li><b><i>-connect</i> [addr:port]</b> start bgb connecting for game link. if addr/port is omitted, take from settings
</li><li><b><i>-demorec</i> filename</b> record demo
</li><li><b><i>-demoplay</i> filename</b> play back demo
</li><li><b><i>-demoofs</i> offset</b> apply offset in bytes to demo when playing
</li><li><b><i>-demonoreset</i></b> disable support for $ff byte hard reset in demo
</li><li><b><i>-demo152conv</i> filename</b> convert demo between old (1.5.2) and new format (swap nibble order). Works in both directions.
</li><li><b><i>-demo152format</i> </b> play or record demos in old 1.5.2 format
</li><li><b><i>-demo157compat</i> </b> emulate an inaccuracy in 1.5.7 and before (only for demo playback) to allow playing old demos of some games (such as pokemon red and blue) in SGB mode.
</li><li><b><i>-headless</i> </b> headless mode: run without window, without sound/graphics/joypad IO. exit when it would break to debugger or when demo finishes. useful for automation. use with start /wait to wait for it to finish.
</li><li><b><i>-autoexit</i> </b> terminate when breaking to debugger or finishing demo playback. implied by headless.
</li><li><b><i>-nowarn</i> </b> suppress most warning dialogs. useful with automated or unattended use. implied by headless.
</li><li><b><i>-runfast</i> </b> run undelayed. useful with headless mode.
</li><li><b><i>-hf</i> </b> shorthand for -headless -runfast
</li><li><b><i>-stateonexit</i> [filename]</b> save a state when exiting. useful with headless mode.
</li><li><b><i>-screenonexit</i> [filename]</b> save a screenshot when exiting. useful with headless mode.
</li><li><b><i>-nobatt</i> </b> disable loading/saving of .sav (battery) files.
</li><li><b><i>-nobattsave</i> </b> load .sav file read only if it exists, and don't save it.
</li><li><b><i>-loadbatt</i> filename</b> load .sav file from filename to go with rom, regardless of -nobatt or settings. useful for automation.
</li><li><b><i>-state</i> filename</b> used together with -rom, you can load a save state and specify the rom to use, overriding the rom path given in the save state.
</li><li><b><i>-br</i> [address][/[condition][/d]][,...]</b> comma separated list of breakpoints. only in combination with -rom
</li><li><b><i>-ab</i> [address][/[value][/drwxj]][,...]</b> comma separated list of access breakpoints. only in combination with -rom
</li><li><b><i>-watch</i></b> automatically reload rom when it changes on disk
</li></ul>
BGB will exit with an exit code of 1 in case of an error, and 0 for normal termination. Sadly, console output is not currently possible (console can't be programmatically enabled or disabled).
<h3 id="demorec">Demo recording/playback</h3>
There is minimal support for recording and playing back a demo. The support must be considered "experimental", and it may change in the future.
It is only intended to be used from the commandline, where the rom to run is also given on the commandline (and not through the menus). One should start from a save state to ensure an exact identical starting state for recording and playback.
<p>
The following commandline loads a rom, saves a state, and exits:
<pre>bgb -hf -br any -rom game.gb -stateonexit game.sna</pre>
To record a demo:
<pre>bgb -rom game.sna -demorec game.dem</pre>
To play back a demo:
<pre>bgb -rom game.sna -demoplay game.dem</pre>
One can still load a rom directly (without using a save state) but with a risk that the playback differs from the recording.<p>
Demo recording of linked bgb's works, but only on the same machine, not over lan. This is done because it's the only way that both instances will run at the exact same timing, to allow the demo to be played back. To do this, also link listen or connect using commandline parameters (not the menu). Use commandlines such as the following to start the two instances:
<pre>
bgb -rom red.sna -demorec red.dem -setting winx=300 -listen 127.0.0.1:8765
bgb -rom blue.sna -demorec blue.dem -setting winx=800 -connect 127.0.0.1:8765
</pre>
The demo file format is very simple, with 1 byte per frame for joypad buttons pressed, at the start of each vblank, and before emulation, so it could be handled easily with external tools. If LCD is disabled, no bytes are added to the demo, this was done to keep the demo format deterministic (consistent).<p>
Note: i changed the nibble order around from what it was in 1.5.2, to make it conform to the standard used everywhere: the d-pad should be in the high bits, the other buttons in the low bits. To change existing demo files between the new and old format, use the following command:
<pre>
bgb -demo152conv filename.dem
</pre>
If you need it, there is support for the old format. use the parameter -demo152format (in addition to -demoplay or -demorec), but the old format must be considered deprecated.
<h3 id="slowpc">How to make bgb run faster if you have a slow computer</h3>
This should not be necessary on any PC later than ~1998. if you have choppy graphics on a modern PC, the problem is something else.
<ul>
<li>disable high quality sound rendering, set the sound samplerate to 22KHz, or turn sound off.</li>
<li>make sure <i>"debug mode"</i> is not active (menu, <i>"other"</i>, <i>"debug mode"</i>)</li>
<li>disable <i>"mix current and last frame"</i> and set <i>"doubler"</i> to <i>"off"</i></li>
<li>Set the desktop resolution to 16 bpp, set emulation to 16 or 8 bpp</li>
<li>try <i>"fullscreen pageflipped"</i> mode, especially combined with 8 bpp.</li>
</ul>
<p>
<h3 id="fullscreenmode">full screen mode:</h3>
select window size -> full screen, to go to a "pseudo full screen" mode (borderless). the GB screen will be at the center of the screen and has the same size which the window had before going to fullscreen mode.
"full screen stretched" is a pseudo fullscreen mode where the GB screen covers the whole screen.
<p>
real (pageflipped) fullscreen modes are also available in the graphics tab of the settings.<p>
<h3 id="gamelink">game link:</h3>
for bgb game link to work at all, you need a modern PC (around 1-2 GHz) and &lt;1ms lag (fast LAN, or localhost). it does not work with all games. on one bgb, you select "listen", on the other you select "connect". it should then show "linked" in the titlebar. there is also an option "remotejoy" so joypad 2 of one bgb controls the other bgb (which does not have keyboard focus, for example).<p>
As of 1.5.2, link in most games should work, and pokemon should work without any glitches (before, pokemon had occasional glitches). one can link between different games, for example pokemon red and blue. Also, a new feature was added: automatic connecting/reconnecting and re-listening: if the link is broken, it will connect or listen again. Also, it will keep trying to connect until it succeeded. This makes the link feature easier to use, and potentially enables unattended use. If the behavior causes problems, it can be disabled in the ini with <i>"LinkAutoListen"</i> and <i>"LinkAutoConnect"</i>.
<p>
<h3 id="avirecorder">AVI recorder</h3>
As of 1.5, one can record to AVI, in addition to recording to BMP screenshots. this allows for greatly improved efficiency while recording, and allow for longer recordings. Sound is still not included in the AVI; enable WAV file writing too, to record sound. The AVI and WAV will have the same filename (and then .avi and .wav), will be perfectly in sync, and can easily be combined in video editing/transcoding software.
"media player classic" will automatically use the WAV accompanying the AVI file, allowing for quick preview.<p>
I recommend getting and installing the "camstudio lossless codec". I tested version 1.5. then in bgb, set the codec field to "cscd" to choose the codec. click "Config" to open the configure dialog, and choose "gzip compression" (this will produce smaller AVI files still). Turn off "record half framerate" to record full ~60 fps, which will still not produce too big AVI files, if desired.<p>
The codec can be uploaded as is to youtube, which supports it, or be edited and transcoded to another codec afterwards.<p>
To stitch together multiple recordings (for example if interrupted by the debugger), it is recommended to first combine the video pieces, and the audio pieces, and then mux the audio and video together.
<h3 id="speedruns">Note for speedrun or "race" use</h3>
Speedruns, also known as "races", refer to playing games fast, competitively. Speedrun communities may or may not allow the use of emulators, but if they allow them, requirements may be imposed on them, only some emulators may be allowed, etc.<p>
bgb will, by default, run at the real speed (~59.727 fps). When using bgb for speedruns, and one is not sure whether the settings are default, make sure of the following settings, to ensure running at the real speed:<p>
<ul><li>on the <i>"Graphics"</i> tab, <i>"vsync"</i> is set to <i>"auto"</i> (the default), or to <i>"Vsync disabled"</i></li>
<li>on the <i>"Misc"</i> tab, <i>"framerate"</i> is set to "0" (the default)</li></ul>
BGB has a "speedrun mode" which changes a lot of behavior. Restart bgb after changing the speedrun mode setting:<br>
<ul><li>speed is locked to real speed ~59.727 fps, or optionally ~61.1679 fps for SGB only
</li><li>caption shows <i>"bgb"</i> + version + <i>"SR"</i>
</li><li>caption shows platform being emulated: <i>"D"</i> for DMG, <i>"M"</i> for GB pocket, <i>"S"</i> for SGB at ~59.727 fps, <i>"SF"</i> for SGB at ~61.1679 fps, <i>"S2"</i> for SGB2, <i>"C"</i> for GBC, <i>"A"</i> for GBA, "P" for GB player
</li><li>caption shows <i>"B"</i> if bootrom was enabled on last reset.
</li><li>messages and information are also shown as an overlay in the screen (can be disabled with <i>"TextOverlay"</i> setting)
</li><li>after a rom is loaded, choice of platform, GBA mode, GB player, bootrom setting, and SGB speed can't be changed (restart BGB, then change)
</li><li>if bootrom is incorrect, or failed to load when bootrom setting is enabled, show <i>"BOOTERR"</i> message
</li><li>rom md5 hash is shown briefly when rom is loaded or reset
</li><li>fast forward button is disabled
</li><li>rapid A/B buttons are disabled
</li><li>message is shown in caption for reset
</li><li>caption shows <i>"demo"</i> if demo is being played
</li><li>on loading a state, <i>"L"</i> + a counter is shown in caption
</li><li>gamegenie and gameshark cheats are disabled
</li><li>debugger is locked out
</li><li>deliberately inaccurate emulation features are locked out
</li><li>invalid opcode hangs cpu as in reality
</li><li>in GBA mode and GB player setting and bootroms enabled, reset does a fade and delay like a GB player, where controls briefly still work.
</li><li>pressing L+R and U+D simultaneously setting is disabled
</li><li>recovery save state is disabled
</li></ul>
BGB as of 1.5.7 has correct TID (trainer ID) in pokemon games, on GBC and GBA, with and without bootroms.
<ul><li>confirmed on GBC and GBA for: red, blue, yellow, gold, silver, crystal (english), and crystal (japanese).
</li><li>confirmed on DMG for red.
</li><li>confirmed on SGB for red and blue. (as of 1.5.8)
</li></ul>
<p>
As of 1.5.8, hard resets (pressing the reset key, * by default), will be recorded and played back in demos. A demo can be recorded during a speedrun, and played back later in non-speedrun mode, as long as all platform settings are the same (choice of platform, GBA, GB player, bootroms), and the BGB version is the same.
<h3 id="history">version history:</h3>
<b>1.5.9 (2021-04-23)</b>
<ul><li>Added Xinput support, fixes: gamepad stops working if bgb loses focus in windows 10. Re-run the configure wizard to utilize Xinput.
</li><li>Improved sound accuracy. "voice" sound works in perfect dark, donkey kong country, medarot 5 and others. added PCM registers.
</li><li>Improved HuC3 support (robopon sun, pocket family)
</li><li>Improvement to speedrun mode
</li><li>Added support for BESS, one can now interchange save states between bgb and other supporting emulators such as Sameboy
</li><li>Added support for the homebrew TPP1 mapper
</li><li>Many accuracy improvements
</li><li>Fixed many bugs
</li></ul>
<b>1.5.8 (2020-03-17)</b> - Added mode where RTC stays at real time. Accuracy improvements. improved speedrun mode. Fixed graphics not showing on some wine setups. Improved fullscreen pageflipped mode. Improvements to debugger. Fixed many bugs.
<p>
<b>1.5.7 (2018-09-14)</b>
<ul><li>Greatly improved accuracy, including pinball deluxe/fantasies, japanese crystal, koro dice, and many test roms
</li><li>speedrun mode
</li><li>recovery save state
</li><li>mappable button to start/stop recording audio/video
</li><li>setting to not break on invalid opcode, instead hang as in reality
</li><li>Made available a 64 bits version
</li><li>MBC1 multicart (MBC1M) support
</li><li>Improvements to debugger, including undo rom edits, ctrl+tab changes active control.
</li><li>Fixed many bugs
</li></ul>
<b>1.5.6 (2017-12-06)</b> - Fixed regression: choppy framerate and sound glitches after pause.
<p>
<b>1.5.5 (2017-11-27)</b> - Added support for GUI display scaling. Improved input lag on 120 Hz display mode. Improvements to debug messages. A number of bug fixes and small improvements.
<p>
<b>1.5.4 (2017-07-17)</b> - Fixed regression: pokemon yellow broken in SGB mode. Fixed a number of bugs.
<p>
<b>1.5.3 (2017-03-04)</b> - Accuracy improvements, including: pokemon (all versions) now has correct TID for speedruns. Fixed a large number of bugs and problems, including: "uncoverable direct3d error" on some Optimus laptops. Added improved support for automation/commandline use. Significant performance/efficiency improvement with most roms. Added support for loading RTC .sav files where a timestamp in the future does not (incorrectly) advance time.
<p>
<b>1.5.2 (2015-08-17)</b> - Fixed a large number of bugs and problems, including: glitches in pokemon linking. Screensaver now doesn't start if you play with gamepad. Crash/stability fixes. Many small improvements, including efficiency improvements. Added support for more joypad axes (xbox 360 controller). Various debugger GUI improvements including local symbols.
<p>
<b>1.5.1 (2014-11-14)</b> - Fixed a number of bugs, including Donkey Kong Land and possibly other roms being broken, and a bug that caused it to sometimes not work on a secondary monitor.
<p>
<b>1.5 (2014-10-18)</b>
<ul><li>AVI writer
</li><li>Greatly improved efficiency (about 10-30% faster, depending on the system)
</li><li>Improved accuracy
</li><li>Improved sound quality
</li><li>Lower audio latency
</li><li>Preview screenshots in select state window
</li><li>Improvements to debugger, including selectable RGBDS or WLA assembler syntax, "ld d,d" debug messages, and editing the palette in the vram viewer.
</li><li>Fixed a large number of bugs, including "alt+F4 loads state", and "timing in LSDJ is unstable"
</li></ul>
<b>1.4.3 (2013-07-01)</b> - fixed: loading/saving save files for roms with unicode filenames was broken if a save dir is not set. this was broken in 1.4.2.
<p>
<b>1.4.2 (2013-06-30)</b> - fixed a large number of small problems and bugs including: direct3d now works on secondary monitors, some accuracy fixes (including sagaia problem), added some features including: mono sound output and an exception break if making bad accesses during an OAM DMA transfer. tested to work on windows 8.
<p>
<b>1.4.1 (2012-08-27)</b> - fixed time keeping problems (hiccups) on windows 7. fixed inaccuracy in mid-scanline change of LCDC bits (gejmboj). fixed a condition that would cause inaccurate timing of interrupt (final fantasy adventure). added "gameboy or GBC" system mode setting. fixed searching any opcode with a space giving "IO error 105". added field in IO map to view/edit the "low" bank of multicart emulation. fixed "remotejoy" being broken. screen window can now init on secondary monitor. fixed failure of GUI elements initing on secondary monitor. fixed wrong field in wav file written.
<p>
<b>1.4 (2012-05-25)</b>
<ul><li>greatly improved game link accuracy, most games should now work perfectly.
</li><li>added optional HQ2X and Scale2x graphics filters
</li><li>various accuracy improvements including sound registers, joypad timing, and lcd/interrupt timing
</li><li>Performance/efficiency improvements including waitloop detection and more efficient high quality sound rendering and others
</li><li>Major debugger improvements: Supports SYM files containing debug symbols. "on jump" access breakpoints. immediate entry of data into assembler, data, and stack viewer. improved assembler flexibility. Multiline code/data entry window. Keyboard shortcut for navigation to previous/next breakpoint, label etc. Live update memory mode. edit IO map registers. Fixed causes of accidental running while debugging.
</li><li>Sound quality improvements: CH3 and CH4 are now bandlimited in high quality mode. Improved DC offset accuracy. fixed sound timing inaccuracies.
</li><li>Improved WAV writer + screenshot recording. Fixed audio/video desync problems. Exported files are now better named.
</li><li>fixed windows 98 compatibility problem. eliminated requirement for DX9. improved wine support.
</li><li>New truecolor/hi-res icon.
</li><li>Many small bug fixes and improvements.
</li></ul>
<p>
<b>1.3.2 (2011-04-10)</b> - more accurate SGB color scheme. improved detection of non-working vsync. fixed: bootroms don't load if read only. fixed: "load rom dialog on startup" not working. fixed: "game controller works only if focus" not working. fixed: setting borderless window, and switching to fullscreen, if using directdraw, the "window" can still move, and cause graphical glitches and crash. fixed: GBC accurate initial WRAM values as left by bootrom (fixes the menu in baby felix - halloween). fixed: a sprite on X = 0 uses more time in mode 3, too. fixed: inconsistent timing if resetting in the debugger.
<p>
<b>1.3.1 (2011-02-09)</b> - fixed: a DMG rom with GBC bootrom would show a white background instead of colorized palette. fixed: header checksum suggestion showed only one hex digit. fixed: menu->reset did not correctly reset emulation.
<p>
<b>1.3 (2011-02-07)</b>
<ul><li>added direct3D and OpenGL output, giving accelerated graphics on windows vista/7.
</li><li>greatly improved emulation accuracy based on lots of test roms/research, also fixing a number of remaining rom compatibility problems.
</li><li>added VBA compatible RTC loading/saving (in the .sav file).
</li><li>added support for the GBC bootrom.
</li><li>fixed lots of bugs.
</li><li>improved debugger functionality.
</li><li>redone cheat searcher.
</li><li>various performance improvements.
</li><li>various gameplay experience related improvements.
</li></ul>
<p>
<b>1.12 (2006-01-05)</b> - Fixed bug in graphics introduced in 1.1, affecting legend of zelda oracle of ages/seasons, and alfred chicken. Added separate settings for DMG and GBC border bitmaps. various fixes.
<p>
<b>1.11 (2005-11-08)</b> - fixed problem with saving color schemes. show ram values in cheat searcher. analog joystick can be used with mbc7. cpu registers can be changed in debugger. various fixes.
<p>
<b>1.1 (2005-06-27)</b> - rewritten graphics output to allow 24 bits accurate color reproduction. added support for directdraw pageflipped fullscreen mode (can be faster on old pc's). added support for loading the DMG bootrom (available elsewhere). some emulation accuracy fixes. pop 'n music GB (all versions) now work. added support for "POV hat" (fixed a possible cause for gamepads/joysticks d-pad to not work properly with BGB).
<p>
<b>1.03 (2005-04-01)</b> -
Emulating hardware behavior for "gin &amp; tonic trick" in the "mental respirator" demo by Phantasy.
Fixed the "on blt2: action not supported" problem which happens on some videocards - if it still happens for you, please contact me.
Added 24 bpp directdraw support.
Made joypad wizard better support "broken" controllers with things like flickering buttons (must press button for 0.5 secs).
Added optional screen on startup to tell the user what to do.
Added "cpu idle" wait for vblank routine - if it's not smooth on your pc, disable "reduce cpu usage".
Added support for up to 32 joypad buttons.
<p>
<b>1.02 (2004-10-29)</b> - fixed a bug in the emulation core which may have broken roms. added japanese documentation (thanks, translator). show error if trying to add duplicate cheat code. allow saving disassembler output to text file.
<p>
<b>1.01 (2004-10-18)</b> - fixed "Cannot change Visible in OnShow or OnHide" bug. fixed bugs related to gamegenie cheats and cheats GUI. fixed problems/bug with window/fullscreen behavior.
<p>
<b>1.0 (2004-10-11)</b><ul>
<li>added debugger</li>
<li>added cheat searcher</li>
<li>added optional directdraw and directsound support.</li>
<li>greatly improved accuracy/compatibility/rom support, fixed many known problem roms.</li>
<li>added "GBC + initial SGB border" support, allowing a number of GBC roms to show a border.</li>
<li>added experimental support for sub-scanline timing graphics, "demotronic demo" works perfectly.</li>
<li>new, more accurate, extendable, save state format. Old states are automatically converted/resaved by default.
<li>made bgb faster by optimizing/rewriting parts</li>
<li>added support for 4 gamepads.</li>
<li>redone joypad config, easy to use GUI</li>
<li>new GBC LCD colors, more like the real GBC</li>
<li>lots of minor changes</li>
</ul>
<p>
<b>0.9 (2003-08-10)</b> - Color schemes can be edited. Increased precision of frequencies in sound code (alone in the dark intro interference effect). Centralized/wrapped sound output (waveout, disk writer) code. Fixed AV if showing registers w/o rom loaded.
<p>
<b>0.88 (2003-05-08)</b> - fixed: save file name gets corrupted if loading a rom causes a warning, making load/save impossible. added: you can now change the current save name, by changing the save dir in the options, without reloading the rom.
<p>
<b>0.87c (2003-04-24)</b> - fixed: the info screen still showed my old email adres...</p>
<p>
<b>0.87b (2003-03-15)</b> - fixed: linkspeed was not initialized, causing problems when not linked, such as breaking alleyway</p>
<p>
<b>0.87 (2002-12-19)</b> - added experimental TCP game link support.</p>
<p>
<b>0.86 (2002-11-27)</b> - added support for japanese pokemon crystal. fixed: accessing a word on address $ffff caused AccessViolation. fixed saving of joystick buttons config. Redone code which searches GB screen rectangle in border bitmap.
<p>
<b>0.85 (2002-10-30)</b> - emulation of 2 joypads for SGB multiplayer. fixed memory leak when loading a rom fails. added support for gzipped roms. fixed some bugs in zip header code, bgb is less likely to hang on corrupt zips. new time synchronization code. sound bugfixes and accuracy improvements. Added option to use GB colors in SGB mode.</p>
<p>
<b>0.84 (2002-09-29)</b> - Fixed pokemon crystal (HDMA behavior guesswork). Option for generating high quality anti aliased rectangular waves (CH1 and CH2).
<p>
<b>0.83 (2002-09-09)</b> - fixed some sound bugs introduced in 0.82. CH4 anti aliasing, especially CH4 high pitch tones sound better. Fixed a resize problem in wine.
<p>
<b>0.82 (2002-08-28)</b> - fixed "magical drop" and "miahamm soccer shootout". fixed "little mermaid ii pinball frenzy", speculation about HDMA behavior. rewritten sound code, improved sound. CH4 (noise) is more like real gb now. implemented anti emulator detection.
<p>
<b>0.81 (2002-08-11)</b> - redone STAT/timing/interrupts core, more accurate now (?), fixed *many* known problem roms. implemented DI+HALT hardware bug now, needed to fix smurfs/thunderbirds again (thanks no$gmb history text). "little mermaid ii pinball frenzy" graphics will be broken until i have exact HDMA timing. added "no visible window" mode (doubleclick in bgb window to toggle). GB screen can now be off-center in the border bitmap. SGB border can now overlap main screen in 16 bits gfx mode (alfred chicken). minor fixes/changes.
<p>
<b>0.8 (2002-08-03)</b> - Added SGB support. renamed "snapshot" to "state" to prevent confusion with "screenshot". changed I/O register behavior, it should be more like the real hardware, i might break something. fixed bugs. added options.
<p>
<b>0.71b (2002-07-21)</b> - i removed the hide taskbar code for fullscreen, i think its not needed. added support for "the smurfs" and "pocket puyo sun" (i didn't HALT if ints disabled)
<p>
<b>0.71 (2007-07-21)</b> - Added support for HuC1 and HuC3. Improved control panel GUI. The 4 sound channels can be enabled/disabled independently. Colors of background, window and sprites can be set. Improved full screen support. Bugfixes. Changed DMA behavior, "little mermaid II pinball frenzy" and "le mans 24h" both have correct GFX. fixed nintendo logo screen (ishido)
<p>
<b>0.7 (2002-06-22)</b> - improved compatibility, a number of problems fixed; tested: "legend of zerd", "magical chase", "elmo in grouchland", "faceball 2000" (framerate), "dragon slayer" (music). Emulation speed can be adjusted. added "delay" option so bgb doesnt have to use 100% cpu. emulation of absence of external ram (reads $ff). more cleanup.
<p>
<b>0.66b (2002-01-27)</b> - Saving zero length .sav files problem is fixed. save-filenames were truncated at first dot, fixed. problem with pressing U+D or L+R key simultaneously is fixed. Fixed problem of "Mr. do!" hanging at hi-scores screen.
<p>
<b>0.66 (2001-11-25)</b> - You can drag and drop files to the BGB window. BGB can start with no rom loaded - you don't get the load rom dialog.
<p>
<b>0.65b (2001-11-04)</b> - i did the changes from 0.64 to 0.65 again... this time i did yet another gfx engine, i didnt like 0.65 being 5 fps slower on my pc.
<p>
<b>0.65 (2001-10-30)</b> - Support for bilinear filter. removed the vram viewer; i didn't use it, and it was not stable. Fixed problems with "Mr. Do!". fix in gfx engine: dirty statusbar-split in "fortress of fear". small sound fix (broken in 0.64)
<p>
<b>0.64 (2001-09-15)</b> - minor update+bugfix. based on diagnose roms. Fixed speed of envelope sweep, it is now 1/64 sec per unit as in reality. sound registers now behave more like on real gb. OAM is now zero filled on reset, sprites were flipped incorrectly.
<p>
<b>0.63 (2001-09-09)</b> - minor update. Fixed (reversed) sound stereo. Added option for GBC "LCD colors", similar to the "real colors" option in no$gmb. Joystick buttons up to #16 can now be used. Fixed problem with puzzle road.
<p>
<b>0.62 (2001-08-25)</b> - Added support for joystick/gamepad. Added support for rumble carts. Cleaned up the LCD/STAT/interrupts code; a few rom problems solved, runs pinball deluxe/fantasies. Fixed sound volume rounding, better sound. Fixed the in 0.61 introduced sound problem with Cannon Fodder.
<p>
<b>0.61 (2001-08-13)</b> - Added support for zip files. Added 16 bits gfx engine for old GB (faster if window is big/maximized).
<p>
<b>0.6 (2001-08-09)</b> - Added GameShark support. Fixed many bugs. Great sound improvements (also fixed a bug which messed up the sound in GBC mode). Sprite priority as on real gb.
<p>
<b>0.52 (2001-08-05)</b> - Added a setting which automaticly switches between the faster 8 bits gfx and the 16 bits gfx when needed. Changed window behavior again, it should be correct by now (alfred's adventure). WAV writer didn't work if soundcard disabled... minor fixes. Fixed problem with Hook.
<p>
<b>0.51 (2001-08-02)</b> - fixed problems, even more roms supported, check out the screenshots page. Added "Tiles viewer". Fixed a problem with the filename of the wav-writer.
<p>
<b>0.5 (2001-07-29)</b> - Added hicolor GBC graphics engine. Added background priority support. Added MBC3 timer emulation. Problems solved, more roms run correctly. Wait-loop detection, some games run faster. Maximum frameskip option. BackGround map vram viewer. Minor changes.
<p>
<b>0.4 (2001-07-24)</b> - Added GBC support. Fixed bug in auto-frameskip code, it is now smoother. Minor change in video engine, "the addams family" and "starfight" now run.
<p>
<b>0.32 (2001-07-08)</b> - Added icon. Fixed serial transfer; Mortal Kombat and Alleyway now run. CPU optimized with assembler. Emulated behavior of window (startrek briefing screen). minor changes.
<p>
<b>0.31 (2001-07-02)</b> - Added support for MBC5 (games like warioland 2). Added gamegenie on/off key. Changed behavior of select snapshot window.
<p>
<b>0.3 (2001-06-29)</b> - First released version
<p>
<h3>feedback:</h3>
If you have comments, questions, hints or problems/bugs which are not described here, send me mail.
</body></html>

255
bgb/bgb.ini Normal file
View File

@@ -0,0 +1,255 @@
Version=159
WaveOut=1
WavFileOut=0
Outchan=0
Samplerate=44100
8Bits=0
SoundMono=0
SoundLeftRight=0
SoundInverted=0
RecordPrefix=bgb
RecordMovie=0
RecordAVI=0
RecordAVIfourCC=DIB
RecordHalfSpeed=1
RecordButtonAudio=1
RecordButtonVideo=1
RecordButtonChannels=0
ScreenshotButtonCopies=0
LastRomDir=Z:\home\jackal\Daten\GBC
RomDir=
SaveRamDir=
RecSave=1
RecSaveInterval=600
Width=640
Height=545
WinX=3454
WinY=747
ScreenWidth=1920
ScreenHeight=1080
PauseOnDefocus=0
MenuHelpMessage=1
NoWindow=0
DblClickBorderless=0
MouseHideTime=3
Windowmode=0
FullscreenMode=1
Gamma=2
ColorSaturation=0.85
ColorWhitepoint=16777215
ReflectorColor=
DetectGBP=0
DetectGBA=0
GbPlayer=0
StayOnTop=0
WineWinFocusFix=0
FixHang200Mode=1
RecreateWndFix=1
FrameRate=0
MaxSkip=3
CheatAutoSave=0
StateAutoConvert=1
StateRomPath=0
StateBessLoad=1
StateBessSave=1
RTCLegacy=1
RTCVBA=1
RTCRealTime=0
RTCShiftSaveState=0
Volume=90
LCDcolors=1
Interpolation=0
Pitch=0
Sleep=1
PriorityBoost=0
JoySleep=1
JoySleepMargin=0.007
JoyRandom=1
WaitloopDetect=1
Speed=1
UndelayedSpeed=10
SgbRealSpeed=0
Speedrun=0
TextOverlay=0
Background=backgrnd.bmp
BackgroundGBC=
SoundBufSize=57
SoundPages=4
SoundPagesAhead=3
Border=1
Blend=0
Doubler=off
StartOpen=0
RecentFrozen=0
SQWave=1
SoundHighPass=1
CH3CacheCap=1
SGBnocolors=0
SgbOverlayIfNoBorder=1
SgbOnePage=1
ScrnshotSgbBorder=0
nullgfx=0
bpp=0
DSoundWarning=0
SoundOut=auto
SoundNoTimed=0
GfxOut=auto
DDrawBB=1
DDrawFS=0
DDrawForceNT6=0
TripleBuffer=0
DDrawFSWidth=640
DDrawFSHeight=480
DDrawFSHz=
DDrawWarning=0
VSync=0
fastSGB=0
SpriteLimit=1
DebugEcho=0
EmulateHaltBug=1
DebugHaltBugBreak=0
DebugSgbStartBreak=0
EmulateInaccVRAM=1
DebugVRAMbreak=0
DebugDisableLCD=0
DebugOAMDMABreak=0
InvalidOpBreak=1
DebugMemLive=1
DebugSaveChecksumWarning=1
EmulateSramD=1
DebugSramBreak=0
DebugMBCaddr=0
DebugSrcBrk=0
UninitedWRAM=0
WRAMinitvalue=00
DebugWRAMbreak=0
DebugInc16OAMBreak=0
DebugScreen=0
DebugScreenSize=1
DebugScreenPreferKeys=0
DebugWinX=
DebugWinY=
DebugWinWidth=
DebugWinHeight=
DebugWinMode=0
DebugWinNoMinWidth=0
VramWinX=
VramWinY=
VramWinWidth=
VramWinHeight=
VramWinMode=0
VramWinTab=
IomapWinX=
IomapWinY=
DebugStrictRun=0
DebugHexLower=0
DebugLocalSymbols=0
DebugSymRgbdsPrefix=1
DisasmSyntax=rgbds
DebugLowercase=1
DebugCountedClocks=1
DisasmRgbdsJphl=1
DebugMsgDisasm=1
DebugMsgFile=0
DebugMsgFileTS=0
DebugMsgWindow=0
DebugMsgWinIfOpen=1
CpuMeter=1
SystemMode=3
RegClick=1
StartDebug=0
DebugEsc=1
DebugBgColor=16777215
DebugTextColor=0
DebugHLTextColor=16777215
DebugBrkColor=255
DebugCurrentColor=16711680
DebugHilightColor=8421504
DebugFreezeColor=65535
DebugHiddenColor=6316128
DebugFontSize=9
DebugFont=courier new
DebugFontDense=2
DataFollow=1
PDMode=0
PDCartMode=0
GBCpalPD=0
LoadRomErrors=1
LoadRomWarnings=1
UnlicensedNoWarn=1
MaxRomSizeMiB=64
RelaxSizeWarningAboveMiB=4
BOpendialog=0
StateForm2=1
JoyFocus=1
JoyKbFocus=1
JoyUnplugFix=1
XinputEnabled=1
JoyOpposite=0
RemoteJoy=1
LinkListenAddr=8765
LinkConnectAddr=127.0.0.1
LinkAutoConnect=1
LinkAutoListen=1
DmgBootRom=
CgbBootRom=
SgbBootRom=
BootromEnabled=0
BootromPatch=1
MBC7Joystick=0
MBC7Sensitivity=1
MBC7Deadzone=0
Joypad0=272526285341100DFFFF6B73716A6D1BFFFFFF
JoystickBtn0=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
JoystickNum0=0
JoystickXNum0=0
Joypad1=3132333435363738FFFFFFFFFFFFFFFFFFFFFF
JoystickBtn1=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
JoystickNum1=0
JoystickXNum1=0
Joypad2=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
JoystickBtn2=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
JoystickNum2=0
JoystickXNum2=0
Joypad3=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
JoystickBtn3=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
JoystickNum3=0
JoystickXNum3=0
Color0=D0F8E0
Color1=70C088
Color2=566834
Color3=201808
Color4=D0F8E0
Color5=70C088
Color6=566834
Color7=201808
Color8=D0F8E0
Color9=70C088
Color10=566834
Color11=201808
Color12=D0F8E0
Color13=70C088
Color14=566834
Color15=201808
Recent0=Z:\home\jackal\Dokumente\Code\GB-HelloWorld\main.gb
Recent1=Z:\home\jackal\Daten\GBC\Pokemon Silberne Edition.gbc
Recent2=Z:\home\jackal\Dokumente\GB-HelloWorld\main.gb
Recent3=Z:\home\jackal\Daten\GB-HelloWorld\main.gb
Recent4=Z:\home\jackal\Daten\GB-HelloWorld\bgb\bgbtest.gb
Recent5=
Recent6=
Recent7=
Recent8=
Recent9=
ColorScheme=D0F8E0.70C088.566834.201808.D0F8E0.70C088.566834.201808.D0F8E0.70C088.566834.201808.D0F8E0.70C088.566834.201808.BGB (lcd green)
ColorScheme=E8E8E8.A0A0A0.585858.101010.E8E8E8.A0A0A0.585858.101010.E8E8E8.A0A0A0.585858.101010.E8E8E8.A0A0A0.585858.101010.grey
ColorScheme=CCFCE8.90D4AC.708C54.382C14.CCFCE8.90D4AC.708C54.382C14.CCFCE8.90D4AC.708C54.382C14.CCFCE8.90D4AC.708C54.382C14.BGB 0.3
ColorScheme=88E0F8.58B0D8.387898.183848.88E0F8.58B0D8.387898.183848.88E0F8.58B0D8.387898.183848.88E0F8.58B0D8.387898.183848.no$gmb (brown)
ColorScheme=81B500.719A00.4A6900.3B4F00.81B500.719A00.4A6900.3B4F00.81B500.719A00.4A6900.3B4F00.81B500.719A00.4A6900.3B4F00.gameboy light
ColorScheme=B0EDEC.18BBBB.006E6B.003710.B0EDEC.18BBBB.006E6B.003710.B0EDEC.18BBBB.006E6B.003710.B0EDEC.18BBBB.006E6B.003710.gameboy kiosk
ColorScheme=CEEFFF.4A94DE.2129AD.521831.CEEFFF.4A94DE.2129AD.521831.CEEFFF.4A94DE.2129AD.521831.CEEFFF.4A94DE.2129AD.521831.super gameboy
ColorScheme=50D050.40A040.307030.204020.50D050.40A040.307030.204020.50D050.40A040.307030.204020.50D050.40A040.307030.204020.KiGB (green)
ColorScheme=78F0F8.48A8B0.306868.102020.78F0F8.48A8B0.306868.102020.78F0F8.48A8B0.306868.102020.78F0F8.48A8B0.306868.102020.yellow
ColorScheme=C0C0FF.6060FF.0000C0.000060.C0C0FF.6060FF.0000C0.000060.C0C0FF.6060FF.0000C0.000060.C0C0FF.6060FF.0000C0.000060.red
ColorScheme=FFC0C0.FF605F.C00000.600000.FFC0C0.FF605F.C00000.600000.FFC0C0.FF605F.C00000.600000.FFC0C0.FF605F.C00000.600000.blue
ColorScheme=FFFFFF.B0B0B0.686868.000000.FFFFFF.B0B0B0.686868.000000.FFFFFF.B0B0B0.686868.000000.FFFFFF.B0B0B0.686868.000000.greys high contrast

BIN
bgb/bgbrecovery.sna Normal file

Binary file not shown.

BIN
bgb/bgbtest.gb Normal file

Binary file not shown.

3
compile.sh Normal file
View File

@@ -0,0 +1,3 @@
rgbasm -o main.o main.asm
rgblink -d -o main.gb main.o
rgbfix -p 0 -r 0 -v main.gb

BIN
font_8x8.chr Normal file

Binary file not shown.

843
hardware.inc Normal file
View File

@@ -0,0 +1,843 @@
;*
;* Gameboy Hardware definitions
;*
;* Based on Jones' hardware.inc
;* And based on Carsten Sorensen's ideas.
;*
;* Rev 1.1 - 15-Jul-97 : Added define check
;* Rev 1.2 - 18-Jul-97 : Added revision check macro
;* Rev 1.3 - 19-Jul-97 : Modified for RGBASM V1.05
;* Rev 1.4 - 27-Jul-97 : Modified for new subroutine prefixes
;* Rev 1.5 - 15-Aug-97 : Added _HRAM, PAD, CART defines
;* : and Nintendo Logo
;* Rev 1.6 - 30-Nov-97 : Added rDIV, rTIMA, rTMA, & rTAC
;* Rev 1.7 - 31-Jan-98 : Added _SCRN0, _SCRN1
;* Rev 1.8 - 15-Feb-98 : Added rSB, rSC
;* Rev 1.9 - 16-Feb-98 : Converted I/O registers to $FFXX format
;* Rev 2.0 - : Added GBC registers
;* Rev 2.1 - : Added MBC5 & cart RAM enable/disable defines
;* Rev 2.2 - : Fixed NR42,NR43, & NR44 equates
;* Rev 2.3 - : Fixed incorrect _HRAM equate
;* Rev 2.4 - 27-Apr-13 : Added some cart defines (AntonioND)
;* Rev 2.5 - 03-May-15 : Fixed format (AntonioND)
;* Rev 2.6 - 09-Apr-16 : Added GBC OAM and cart defines (AntonioND)
;* Rev 2.7 - 19-Jan-19 : Added rPCMXX (ISSOtm)
;* Rev 2.8 - 03-Feb-19 : Added audio registers flags (Álvaro Cuesta)
;* Rev 2.9 - 28-Feb-20 : Added utility rP1 constants
; If all of these are already defined, don't do it again.
IF !DEF(HARDWARE_INC)
HARDWARE_INC SET 1
rev_Check_hardware_inc : MACRO
;NOTE: REVISION NUMBER CHANGES MUST BE ADDED
;TO SECOND PARAMETER IN FOLLOWING LINE.
IF \1 > 2.9 ;PUT REVISION NUMBER HERE
WARN "Version \1 or later of 'hardware.inc' is required."
ENDC
ENDM
_HW EQU $FF00
_VRAM EQU $8000 ; $8000->$9FFF
_SCRN0 EQU $9800 ; $9800->$9BFF
_SCRN1 EQU $9C00 ; $9C00->$9FFF
_SRAM EQU $A000 ; $A000->$BFFF
_RAM EQU $C000 ; $C000->$DFFF
_OAMRAM EQU $FE00 ; $FE00->$FE9F
_AUD3WAVERAM EQU $FF30 ; $FF30->$FF3F
_HRAM EQU $FF80 ; $FF80->$FFFE
; *** MBC5 Equates ***
rRAMG EQU $0000 ; $0000->$1fff
rROMB0 EQU $2000 ; $2000->$2fff
rROMB1 EQU $3000 ; $3000->$3fff - If more than 256 ROM banks are present.
rRAMB EQU $4000 ; $4000->$5fff - Bit 3 enables rumble (if present)
; --
; -- OAM flags
; --
OAMF_PRI EQU %10000000 ; Priority
OAMF_YFLIP EQU %01000000 ; Y flip
OAMF_XFLIP EQU %00100000 ; X flip
OAMF_PAL0 EQU %00000000 ; Palette number; 0,1 (DMG)
OAMF_PAL1 EQU %00010000 ; Palette number; 0,1 (DMG)
OAMF_BANK0 EQU %00000000 ; Bank number; 0,1 (GBC)
OAMF_BANK1 EQU %00001000 ; Bank number; 0,1 (GBC)
OAMF_PALMASK EQU %00000111 ; Palette (GBC)
OAMB_PRI EQU 7 ; Priority
OAMB_YFLIP EQU 6 ; Y flip
OAMB_XFLIP EQU 5 ; X flip
OAMB_PAL1 EQU 4 ; Palette number; 0,1 (DMG)
OAMB_BANK1 EQU 3 ; Bank number; 0,1 (GBC)
;***************************************************************************
;*
;* Custom registers
;*
;***************************************************************************
; --
; -- P1 ($FF00)
; -- Register for reading joy pad info. (R/W)
; --
rP1 EQU $FF00
P1F_5 EQU %00100000 ; P15 out port, set to 0 to get buttons
P1F_4 EQU %00010000 ; P14 out port, set to 0 to get dpad
P1F_3 EQU %00001000 ; P13 in port
P1F_2 EQU %00000100 ; P12 in port
P1F_1 EQU %00000010 ; P11 in port
P1F_0 EQU %00000001 ; P10 in port
P1F_GET_DPAD EQU P1F_5
P1F_GET_BTN EQU P1F_4
P1F_GET_NONE EQU P1F_4 | P1F_5
; --
; -- SB ($FF01)
; -- Serial Transfer Data (R/W)
; --
rSB EQU $FF01
; --
; -- SC ($FF02)
; -- Serial I/O Control (R/W)
; --
rSC EQU $FF02
; --
; -- DIV ($FF04)
; -- Divider register (R/W)
; --
rDIV EQU $FF04
; --
; -- TIMA ($FF05)
; -- Timer counter (R/W)
; --
rTIMA EQU $FF05
; --
; -- TMA ($FF06)
; -- Timer modulo (R/W)
; --
rTMA EQU $FF06
; --
; -- TAC ($FF07)
; -- Timer control (R/W)
; --
rTAC EQU $FF07
TACF_START EQU %00000100
TACF_STOP EQU %00000000
TACF_4KHZ EQU %00000000
TACF_16KHZ EQU %00000011
TACF_65KHZ EQU %00000010
TACF_262KHZ EQU %00000001
; --
; -- IF ($FF0F)
; -- Interrupt Flag (R/W)
; --
rIF EQU $FF0F
; --
; -- LCDC ($FF40)
; -- LCD Control (R/W)
; --
rLCDC EQU $FF40
LCDCF_OFF EQU %00000000 ; LCD Control Operation
LCDCF_ON EQU %10000000 ; LCD Control Operation
LCDCF_WIN9800 EQU %00000000 ; Window Tile Map Display Select
LCDCF_WIN9C00 EQU %01000000 ; Window Tile Map Display Select
LCDCF_WINOFF EQU %00000000 ; Window Display
LCDCF_WINON EQU %00100000 ; Window Display
LCDCF_BG8800 EQU %00000000 ; BG & Window Tile Data Select
LCDCF_BG8000 EQU %00010000 ; BG & Window Tile Data Select
LCDCF_BG9800 EQU %00000000 ; BG Tile Map Display Select
LCDCF_BG9C00 EQU %00001000 ; BG Tile Map Display Select
LCDCF_OBJ8 EQU %00000000 ; OBJ Construction
LCDCF_OBJ16 EQU %00000100 ; OBJ Construction
LCDCF_OBJOFF EQU %00000000 ; OBJ Display
LCDCF_OBJON EQU %00000010 ; OBJ Display
LCDCF_BGOFF EQU %00000000 ; BG Display
LCDCF_BGON EQU %00000001 ; BG Display
; "Window Character Data Select" follows BG
; --
; -- STAT ($FF41)
; -- LCDC Status (R/W)
; --
rSTAT EQU $FF41
STATF_LYC EQU %01000000 ; LYCEQULY Coincidence (Selectable)
STATF_MODE10 EQU %00100000 ; Mode 10
STATF_MODE01 EQU %00010000 ; Mode 01 (V-Blank)
STATF_MODE00 EQU %00001000 ; Mode 00 (H-Blank)
STATF_LYCF EQU %00000100 ; Coincidence Flag
STATF_HB EQU %00000000 ; H-Blank
STATF_VB EQU %00000001 ; V-Blank
STATF_OAM EQU %00000010 ; OAM-RAM is used by system
STATF_LCD EQU %00000011 ; Both OAM and VRAM used by system
STATF_BUSY EQU %00000010 ; When set, VRAM access is unsafe
; --
; -- SCY ($FF42)
; -- Scroll Y (R/W)
; --
rSCY EQU $FF42
; --
; -- SCY ($FF43)
; -- Scroll X (R/W)
; --
rSCX EQU $FF43
; --
; -- LY ($FF44)
; -- LCDC Y-Coordinate (R)
; --
; -- Values range from 0->153. 144->153 is the VBlank period.
; --
rLY EQU $FF44
; --
; -- LYC ($FF45)
; -- LY Compare (R/W)
; --
; -- When LYEQUEQULYC, STATF_LYCF will be set in STAT
; --
rLYC EQU $FF45
; --
; -- DMA ($FF46)
; -- DMA Transfer and Start Address (W)
; --
rDMA EQU $FF46
; --
; -- BGP ($FF47)
; -- BG Palette Data (W)
; --
; -- Bit 7-6 - Intensity for %11
; -- Bit 5-4 - Intensity for %10
; -- Bit 3-2 - Intensity for %01
; -- Bit 1-0 - Intensity for %00
; --
rBGP EQU $FF47
; --
; -- OBP0 ($FF48)
; -- Object Palette 0 Data (W)
; --
; -- See BGP for info
; --
rOBP0 EQU $FF48
; --
; -- OBP1 ($FF49)
; -- Object Palette 1 Data (W)
; --
; -- See BGP for info
; --
rOBP1 EQU $FF49
; --
; -- WY ($FF4A)
; -- Window Y Position (R/W)
; --
; -- 0 <EQU WY <EQU 143
; --
rWY EQU $FF4A
; --
; -- WX ($FF4B)
; -- Window X Position (R/W)
; --
; -- 7 <EQU WX <EQU 166
; --
rWX EQU $FF4B
; --
; -- KEY 1 ($FF4D)
; -- Select CPU Speed (R/W)
; --
rKEY1 EQU $FF4D
; --
; -- VBK ($FF4F)
; -- Select Video RAM Bank (R/W)
; --
rVBK EQU $FF4F
; --
; -- HDMA1 ($FF51)
; -- Horizontal Blanking, General Purpose DMA (W)
; --
rHDMA1 EQU $FF51
; --
; -- HDMA2 ($FF52)
; -- Horizontal Blanking, General Purpose DMA (W)
; --
rHDMA2 EQU $FF52
; --
; -- HDMA3 ($FF53)
; -- Horizontal Blanking, General Purpose DMA (W)
; --
rHDMA3 EQU $FF53
; --
; -- HDMA4 ($FF54)
; -- Horizontal Blanking, General Purpose DMA (W)
; --
rHDMA4 EQU $FF54
; --
; -- HDMA5 ($FF55)
; -- Horizontal Blanking, General Purpose DMA (R/W)
; --
rHDMA5 EQU $FF55
; --
; -- RP ($FF56)
; -- Infrared Communications Port (R/W)
; --
rRP EQU $FF56
; --
; -- BCPS ($FF68)
; -- Background Color Palette Specification (R/W)
; --
rBCPS EQU $FF68
; --
; -- BCPD ($FF69)
; -- Background Color Palette Data (R/W)
; --
rBCPD EQU $FF69
; --
; -- BCPS ($FF6A)
; -- Object Color Palette Specification (R/W)
; --
rOCPS EQU $FF6A
; --
; -- BCPD ($FF6B)
; -- Object Color Palette Data (R/W)
; --
rOCPD EQU $FF6B
; --
; -- SVBK ($FF4F)
; -- Select Main RAM Bank (R/W)
; --
rSVBK EQU $FF70
; --
; -- IE ($FFFF)
; -- Interrupt Enable (R/W)
; --
rIE EQU $FFFF
IEF_HILO EQU %00010000 ; Transition from High to Low of Pin number P10-P13
IEF_SERIAL EQU %00001000 ; Serial I/O transfer end
IEF_TIMER EQU %00000100 ; Timer Overflow
IEF_LCDC EQU %00000010 ; LCDC (see STAT)
IEF_VBLANK EQU %00000001 ; V-Blank
;***************************************************************************
;*
;* Sound control registers
;*
;***************************************************************************
; --
; -- AUDVOL/NR50 ($FF24)
; -- Channel control / ON-OFF / Volume (R/W)
; --
; -- Bit 7 - Vin->SO2 ON/OFF (Vin??)
; -- Bit 6-4 - SO2 output level (volume) (# 0-7)
; -- Bit 3 - Vin->SO1 ON/OFF (Vin??)
; -- Bit 2-0 - SO1 output level (volume) (# 0-7)
; --
rNR50 EQU $FF24
rAUDVOL EQU rNR50
AUDVOL_VIN_LEFT EQU %10000000 ; SO2
AUDVOL_VIN_RIGHT EQU %00001000 ; SO1
; --
; -- AUDTERM/NR51 ($FF25)
; -- Selection of Sound output terminal (R/W)
; --
; -- Bit 7 - Output sound 4 to SO2 terminal
; -- Bit 6 - Output sound 3 to SO2 terminal
; -- Bit 5 - Output sound 2 to SO2 terminal
; -- Bit 4 - Output sound 1 to SO2 terminal
; -- Bit 3 - Output sound 4 to SO1 terminal
; -- Bit 2 - Output sound 3 to SO1 terminal
; -- Bit 1 - Output sound 2 to SO1 terminal
; -- Bit 0 - Output sound 0 to SO1 terminal
; --
rNR51 EQU $FF25
rAUDTERM EQU rNR51
; SO2
AUDTERM_4_LEFT EQU %10000000
AUDTERM_3_LEFT EQU %01000000
AUDTERM_2_LEFT EQU %00100000
AUDTERM_1_LEFT EQU %00010000
; SO1
AUDTERM_4_RIGHT EQU %00001000
AUDTERM_3_RIGHT EQU %00000100
AUDTERM_2_RIGHT EQU %00000010
AUDTERM_1_RIGHT EQU %00000001
; --
; -- AUDENA/NR52 ($FF26)
; -- Sound on/off (R/W)
; --
; -- Bit 7 - All sound on/off (sets all audio regs to 0!)
; -- Bit 3 - Sound 4 ON flag (doesn't work!)
; -- Bit 2 - Sound 3 ON flag (doesn't work!)
; -- Bit 1 - Sound 2 ON flag (doesn't work!)
; -- Bit 0 - Sound 1 ON flag (doesn't work!)
; --
rNR52 EQU $FF26
rAUDENA EQU rNR52
AUDENA_ON EQU %10000000
AUDENA_OFF EQU %00000000 ; sets all audio regs to 0!
;***************************************************************************
;*
;* SoundChannel #1 registers
;*
;***************************************************************************
; --
; -- AUD1SWEEP/NR10 ($FF10)
; -- Sweep register (R/W)
; --
; -- Bit 6-4 - Sweep Time
; -- Bit 3 - Sweep Increase/Decrease
; -- 0: Addition (frequency increases???)
; -- 1: Subtraction (frequency increases???)
; -- Bit 2-0 - Number of sweep shift (# 0-7)
; -- Sweep Time: (n*7.8ms)
; --
rNR10 EQU $FF10
rAUD1SWEEP EQU rNR10
AUD1SWEEP_UP EQU %00000000
AUD1SWEEP_DOWN EQU %00001000
; --
; -- AUD1LEN/NR11 ($FF11)
; -- Sound length/Wave pattern duty (R/W)
; --
; -- Bit 7-6 - Wave Pattern Duty (00:12.5% 01:25% 10:50% 11:75%)
; -- Bit 5-0 - Sound length data (# 0-63)
; --
rNR11 EQU $FF11
rAUD1LEN EQU rNR11
; --
; -- AUD1ENV/NR12 ($FF12)
; -- Envelope (R/W)
; --
; -- Bit 7-4 - Initial value of envelope
; -- Bit 3 - Envelope UP/DOWN
; -- 0: Decrease
; -- 1: Range of increase
; -- Bit 2-0 - Number of envelope sweep (# 0-7)
; --
rNR12 EQU $FF12
rAUD1ENV EQU rNR12
; --
; -- AUD1LOW/NR13 ($FF13)
; -- Frequency lo (W)
; --
rNR13 EQU $FF13
rAUD1LOW EQU rNR13
; --
; -- AUD1HIGH/NR14 ($FF14)
; -- Frequency hi (W)
; --
; -- Bit 7 - Initial (when set, sound restarts)
; -- Bit 6 - Counter/consecutive selection
; -- Bit 2-0 - Frequency's higher 3 bits
; --
rNR14 EQU $FF14
rAUD1HIGH EQU rNR14
;***************************************************************************
;*
;* SoundChannel #2 registers
;*
;***************************************************************************
; --
; -- AUD2LEN/NR21 ($FF16)
; -- Sound Length; Wave Pattern Duty (R/W)
; --
; -- see AUD1LEN for info
; --
rNR21 EQU $FF16
rAUD2LEN EQU rNR21
; --
; -- AUD2ENV/NR22 ($FF17)
; -- Envelope (R/W)
; --
; -- see AUD1ENV for info
; --
rNR22 EQU $FF17
rAUD2ENV EQU rNR22
; --
; -- AUD2LOW/NR23 ($FF18)
; -- Frequency lo (W)
; --
rNR23 EQU $FF18
rAUD2LOW EQU rNR23
; --
; -- AUD2HIGH/NR24 ($FF19)
; -- Frequency hi (W)
; --
; -- see AUD1HIGH for info
; --
rNR24 EQU $FF19
rAUD2HIGH EQU rNR24
;***************************************************************************
;*
;* SoundChannel #3 registers
;*
;***************************************************************************
; --
; -- AUD3ENA/NR30 ($FF1A)
; -- Sound on/off (R/W)
; --
; -- Bit 7 - Sound ON/OFF (1EQUON,0EQUOFF)
; --
rNR30 EQU $FF1A
rAUD3ENA EQU rNR30
; --
; -- AUD3LEN/NR31 ($FF1B)
; -- Sound length (R/W)
; --
; -- Bit 7-0 - Sound length
; --
rNR31 EQU $FF1B
rAUD3LEN EQU rNR31
; --
; -- AUD3LEVEL/NR32 ($FF1C)
; -- Select output level
; --
; -- Bit 6-5 - Select output level
; -- 00: 0/1 (mute)
; -- 01: 1/1
; -- 10: 1/2
; -- 11: 1/4
; --
rNR32 EQU $FF1C
rAUD3LEVEL EQU rNR32
; --
; -- AUD3LOW/NR33 ($FF1D)
; -- Frequency lo (W)
; --
; -- see AUD1LOW for info
; --
rNR33 EQU $FF1D
rAUD3LOW EQU rNR33
; --
; -- AUD3HIGH/NR34 ($FF1E)
; -- Frequency hi (W)
; --
; -- see AUD1HIGH for info
; --
rNR34 EQU $FF1E
rAUD3HIGH EQU rNR34
; --
; -- AUD4LEN/NR41 ($FF20)
; -- Sound length (R/W)
; --
; -- Bit 5-0 - Sound length data (# 0-63)
; --
rNR41 EQU $FF20
rAUD4LEN EQU rNR41
; --
; -- AUD4ENV/NR42 ($FF21)
; -- Envelope (R/W)
; --
; -- see AUD1ENV for info
; --
rNR42 EQU $FF21
rAUD4ENV EQU rNR42
; --
; -- AUD4POLY/NR43 ($FF22)
; -- Polynomial counter (R/W)
; --
; -- Bit 7-4 - Selection of the shift clock frequency of the (scf)
; -- polynomial counter (0000-1101)
; -- freqEQUdrf*1/2^scf (not sure)
; -- Bit 3 - Selection of the polynomial counter's step
; -- 0: 15 steps
; -- 1: 7 steps
; -- Bit 2-0 - Selection of the dividing ratio of frequencies (drf)
; -- 000: f/4 001: f/8 010: f/16 011: f/24
; -- 100: f/32 101: f/40 110: f/48 111: f/56 (fEQU4.194304 Mhz)
; --
rNR43 EQU $FF22
rAUD4POLY EQU rNR43
; --
; -- AUD4GO/NR44 ($FF23)
; -- (has wrong name and value (ff30) in Dr.Pan's doc!)
; --
; -- Bit 7 - Inital
; -- Bit 6 - Counter/consecutive selection
; --
rNR44 EQU $FF23
rAUD4GO EQU rNR44 ; silly name!
; --
; -- PCM12 ($FF76)
; -- Sound channel 1&2 PCM amplitude (R)
; --
; -- Bit 7-4 - Copy of sound channel 2's PCM amplitude
; -- Bit 3-0 - Copy of sound channel 1's PCM amplitude
; --
rPCM12 EQU $FF76
; --
; -- PCM34 ($FF77)
; -- Sound channel 3&4 PCM amplitude (R)
; --
; -- Bit 7-4 - Copy of sound channel 4's PCM amplitude
; -- Bit 3-0 - Copy of sound channel 3's PCM amplitude
; --
rPCM34 EQU $FF77
;***************************************************************************
;*
;* Flags common to multiple sound channels
;*
;***************************************************************************
; --
; -- Square wave duty cycle
; --
; -- Can be used with AUD1LEN and AUD2LEN
; -- See AUD1LEN for more info
; --
AUDLEN_DUTY_12_5 EQU %00000000 ; 12.5%
AUDLEN_DUTY_25 EQU %01000000 ; 25%
AUDLEN_DUTY_50 EQU %10000000 ; 50%
AUDLEN_DUTY_75 EQU %11000000 ; 75%
; --
; -- Audio envelope flags
; --
; -- Can be used with AUD1ENV, AUD2ENV, AUD4ENV
; -- See AUD1ENV for more info
; --
AUDENV_UP EQU %00001000
AUDENV_DOWN EQU %00000000
; --
; -- Audio trigger flags
; --
; -- Can be used with AUD1HIGH, AUD2HIGH, AUD3HIGH
; -- See AUD1HIGH for more info
; --
AUDHIGH_RESTART EQU %10000000
AUDHIGH_LENGTH_ON EQU %01000000
AUDHIGH_LENGTH_OFF EQU %00000000
;***************************************************************************
;*
;* Cart related
;*
;***************************************************************************
CART_COMPATIBLE_DMG EQU $00
CART_COMPATIBLE_DMG_GBC EQU $80
CART_COMPATIBLE_GBC EQU $C0
CART_ROM EQU $00
CART_ROM_MBC1 EQU $01
CART_ROM_MBC1_RAM EQU $02
CART_ROM_MBC1_RAM_BAT EQU $03
CART_ROM_MBC2 EQU $05
CART_ROM_MBC2_BAT EQU $06
CART_ROM_RAM EQU $08
CART_ROM_RAM_BAT EQU $09
CART_ROM_MBC3_BAT_RTC EQU $0F
CART_ROM_MBC3_RAM_BAT_RTC EQU $10
CART_ROM_MBC3 EQU $11
CART_ROM_MBC3_RAM EQU $12
CART_ROM_MBC3_RAM_BAT EQU $13
CART_ROM_MBC5 EQU $19
CART_ROM_MBC5_BAT EQU $1A
CART_ROM_MBC5_RAM_BAT EQU $1B
CART_ROM_MBC5_RUMBLE EQU $1C
CART_ROM_MBC5_RAM_RUMBLE EQU $1D
CART_ROM_MBC5_RAM_BAT_RUMBLE EQU $1E
CART_ROM_MBC7_RAM_BAT_GYRO EQU $22
CART_ROM_POCKET_CAMERA EQU $FC
CART_ROM_256K EQU 0 ; 2 banks
CART_ROM_512K EQU 1 ; 4 banks
CART_ROM_1M EQU 2 ; 8 banks
CART_ROM_2M EQU 3 ; 16 banks
CART_ROM_4M EQU 4 ; 32 banks
CART_ROM_8M EQU 5 ; 64 banks
CART_ROM_16M EQU 6 ; 128 banks
CART_ROM_32M EQU 7 ; 256 banks
CART_ROM_64M EQU 8 ; 512 banks
CART_RAM_NONE EQU 0
CART_RAM_16K EQU 1 ; 1 incomplete bank
CART_RAM_64K EQU 2 ; 1 bank
CART_RAM_256K EQU 3 ; 4 banks
CART_RAM_1M EQU 4 ; 16 banks
CART_RAM_ENABLE EQU $0A
CART_RAM_DISABLE EQU $00
;***************************************************************************
;*
;* Keypad related
;*
;***************************************************************************
PADF_DOWN EQU $80
PADF_UP EQU $40
PADF_LEFT EQU $20
PADF_RIGHT EQU $10
PADF_START EQU $08
PADF_SELECT EQU $04
PADF_B EQU $02
PADF_A EQU $01
PADB_DOWN EQU $7
PADB_UP EQU $6
PADB_LEFT EQU $5
PADB_RIGHT EQU $4
PADB_START EQU $3
PADB_SELECT EQU $2
PADB_B EQU $1
PADB_A EQU $0
;***************************************************************************
;*
;* Screen related
;*
;***************************************************************************
SCRN_X EQU 160 ; Width of screen in pixels
SCRN_Y EQU 144 ; Height of screen in pixels
SCRN_X_B EQU 20 ; Width of screen in bytes
SCRN_Y_B EQU 18 ; Height of screen in bytes
SCRN_VX EQU 256 ; Virtual width of screen in pixels
SCRN_VY EQU 256 ; Virtual height of screen in pixels
SCRN_VX_B EQU 32 ; Virtual width of screen in bytes
SCRN_VY_B EQU 32 ; Virtual height of screen in bytes
;*
;* Nintendo scrolling logo
;* (Code won't work on a real GameBoy)
;* (if next lines are altered.)
NINTENDO_LOGO : MACRO
DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
ENDM
ENDC ;HARDWARE_INC

125
hello.asm Normal file
View File

@@ -0,0 +1,125 @@
; -----------------------------------------------------------------------------
; Example: Hello world - DMG ver.
; -----------------------------------------------------------------------------
; Font comes from ZX Spectrum - https://en.wikipedia.org/wiki/ZX_Spectrum_character_set
; More examples by tmk @ https://github.com/gitendo/helloworld
; -----------------------------------------------------------------------------
INCLUDE "hardware.inc" ; system defines
SECTION "Start",ROM0[$100] ; start vector, followed by header data applied by rgbfix.exe
nop
jp start
SECTION "Example",ROM0[$150] ; code starts here
start:
di ; disable interrupts
ld sp,$E000 ; setup stack
.wait_vbl ; wait for vblank to properly disable lcd
ld a,[rLY]
cp $90
jr nz,.wait_vbl
xor a
ld [rIF],a ; reset important registers
ld [rLCDC],a
ld [rSTAT],a
ld [rSCX],a
ld [rSCY],a
ld [rLYC],a
ld [rIE],a
ld hl,_RAM ; clear ram (fill with a which is 0 here)
ld bc,$2000-2 ; watch out for stack ;)
call fill
ld hl,_HRAM ; clear hram
ld c,$80 ; a = 0, b = 0 here, so let's save a byte and 4 cycles (ld c,$80 - 2/8 vs ld bc,$80 - 3/12)
call fill
ld hl,_VRAM ; clear vram
ld b,$18 ; a = 0, bc should be $1800; c = 0 here, so..
call fill
ld a,$20 ; ascii code for 'space' character
; no need to setup hl since _SCRN0 ($9800) and _SCRN1 ($9C00) are part of _VRAM, just continue
ld b,8 ; bc should be $800 (_SCRN0/1 are 32*32 bytes); c = 0 here, so..
call fill
ld a,%10010011 ; bits: 7-6 = 1st color, 5-4 = 2nd, 3-2 = 3rd and 1-0 = 4th color
; color values: 00 - light, 01 - gray, 10 - dark gray, 11 - dark
ld [rBGP],a ; bg palette
ld [rOBP0],a ; obj palettes (not used in this example)
ld [rOBP1],a
ld hl,font ; font data
ld de,_VRAM+$200 ; place it here to get ascii mapping ('space' code is $20, tile size $10)
ld bc,1776 ; font_8x8.chr file size
call copy
ld hl,text ; hello message
ld de,_SCRN0+$100 ; center it a bit
ld c,text_end-text ; b = 0, our string = 18 chars, so..
call copy ; lcdc is disabled so you have 'easy' access to vram
ld a,LCDCF_ON | LCDCF_BG8000 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_WINOFF | LCDCF_BGON
; lcd setup: tiles at $8000, map at $9800, 8x8 sprites (disabled), no window, etc.
ld [rLCDC],a ; enable lcd
.the_end
halt ; save battery
; nop ; nop after halt is mandatory but rgbasm takes care of it :)
jr .the_end ; endless loop
;-------------------------------------------------------------------------------
copy:
;-------------------------------------------------------------------------------
; hl - source address
; de - destination
; bc - size
inc b
inc c
jr .skip
.copy
ld a,[hl+]
ld [de],a
inc de
.skip
dec c
jr nz,.copy
dec b
jr nz,.copy
ret
;-------------------------------------------------------------------------------
fill:
;-------------------------------------------------------------------------------
; a - byte to fill with
; hl - destination address
; bc - size of area to fill
inc b
inc c
jr .skip
.fill
ld [hl+],a
.skip
dec c
jr nz,.fill
dec b
jr nz,.fill
ret
;-------------------------------------------------------------------------------
font:
INCBIN "font_8x8.chr" ; converted with https://github.com/gitendo/bmp2cgb
text:
DB " Hello 8-bit world! "
text_end:

95
main.asm Normal file
View File

@@ -0,0 +1,95 @@
include "hardware.inc"
section "Start",rom0[$100] ; hier startet der Gameboy
di ; Interrupts ausschalten
jp Program ; Springe zum eigentlichen Programm
section "Programm",rom0[$150] ; hier läuft das Programm
Program:
call LCDOff
ld a, %11111100 ; Hintergrund Farbpallette definieren
ld [rBGP], a ; Hintergrund Farbpallette laden
;;; Font in VRAM kopieren
ld de, font ; Font Quelle
ld bc, font_end-font ; Font Länge
ld hl, _VRAM+$200 ; Ziel
call TileCopy
;;; Text schreiben
ld a, $3
ld [$C000], a
ld a, $99
ld [$C001], a
ld hl, _SCRN0
.bgfill
ld de, text
ld bc, text_end-text
.charcopy
ld a, [de]
ld [hli], a
inc de
dec bc
ld a, b
or a, c
jr nz, .skip
ld de, text
ld bc, text_end-text
.skip
ld a, [$C001]
dec a
ld [$C001], a
or a, 0
jr nz, .charcopy
ld a, $FF
ld [$C001], a
ld a, [$C000]
dec a
ld [$C000], a
or a, 0
jr nz, .bgfill
;;; LCD einschalten
ld a, 0
ld [rSCX], a
ld [rSCY], a
ld a, LCDCF_ON ; LCD Einschaltbit nach a Laden
or a, LCDCF_BG8000
or a, LCDCF_BGON
ld [rLCDC], a ; LCD einschalten
.loop
halt
jr .loop
LCDOff:
.turn_of_LCD ; Bildschirm auschalten
ld a, [rLY] ; Y Koordinate vom LCD nach a
cp a, $90 ; Vergleich ob LCD in Zeile 144
jr nz, .turn_of_LCD ; Wiederholen bis LCD in Zeile 144 ist
ld a, LCDCF_OFF ; LCD Ausschaltbit nach a Laden
ld [rLCDC], a ; LCD ausschalten
ret
TileCopy:
.copy
ld a, [de]
inc de
ld [hli], a
dec bc
ld a, b
or a, c
jr nz, .copy
ret
section "assets",rom0[$300]
text: db "Hello World! "
text_end:
font: incbin "font_8x8.chr"
font_end:

BIN
main.gb Normal file

Binary file not shown.

BIN
main.o Normal file

Binary file not shown.

2
test.sh Normal file
View File

@@ -0,0 +1,2 @@
./compile.sh
wine bgb/bgb.exe main.gb >& /dev/null