Merge branch 'master' into JoyKit

# Conflicts:
#	Cocoa/Document.m
#	Cocoa/GBView.h
#	Cocoa/GBView.m
#	Cocoa/joypad.m
#	Cocoa/main.m
#	Core/display.c
#	Core/gb.h
#	Core/save_state.c
This commit is contained in:
Lior Halphon 2020-04-29 15:52:03 +03:00
commit 5a14eb93c6
94 changed files with 5524 additions and 1051 deletions

25
.github/actions/LICENSE vendored Normal file
View File

@ -0,0 +1,25 @@
Blargg's Test ROMs by Shay Green <gblargg@gmail.com>
Acid2 tests by Matt Currie under MIT:
MIT License
Copyright (c) 2020 Matt Currie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

BIN
.github/actions/cgb-acid2.gbc vendored Normal file

Binary file not shown.

BIN
.github/actions/cgb_sound.gb vendored Normal file

Binary file not shown.

BIN
.github/actions/dmg-acid2.gb vendored Normal file

Binary file not shown.

BIN
.github/actions/dmg_sound-2.gb vendored Executable file

Binary file not shown.

23
.github/actions/install_deps.sh vendored Executable file
View File

@ -0,0 +1,23 @@
case `echo $1 | cut -d '-' -f 1` in
ubuntu)
sudo apt-get -qq update
sudo apt-get install -yq bison libpng-dev pkg-config libsdl2-dev
(
cd `mktemp -d`
curl -L https://github.com/rednex/rgbds/archive/v0.4.0.zip > rgbds.zip
unzip rgbds.zip
cd rgbds-*
make -sj
sudo make install
cd ..
rm -rf *
)
;;
macos)
brew install rgbds sdl2
;;
*)
echo "Unsupported OS"
exit 1
;;
esac

BIN
.github/actions/oam_bug-2.gb vendored Executable file

Binary file not shown.

33
.github/actions/sanity_tests.sh vendored Executable file
View File

@ -0,0 +1,33 @@
set -e
./build/bin/tester/sameboy_tester --jobs 5 \
--length 40 .github/actions/cgb_sound.gb \
--length 10 .github/actions/cgb-acid2.gbc \
--length 10 .github/actions/dmg-acid2.gb \
--dmg --length 40 .github/actions/dmg_sound-2.gb \
--dmg --length 20 .github/actions/oam_bug-2.gb
mv .github/actions/dmg{,-mode}-acid2.bmp
./build/bin/tester/sameboy_tester \
--dmg --length 10 .github/actions/dmg-acid2.gb
set +e
FAILED_TESTS=`
shasum .github/actions/*.bmp | grep -q -E -v \(\
44ce0c7d49254df0637849c9155080ac7dc3ef3d\ \ .github/actions/cgb-acid2.bmp\|\
dbcc438dcea13b5d1b80c5cd06bda2592cc5d9e0\ \ .github/actions/cgb_sound.bmp\|\
0caadf9634e40247ae9c15ff71992e8f77bbf89e\ \ .github/actions/dmg-acid2.bmp\|\
c50daed36c57a8170ff362042694786676350997\ \ .github/actions/dmg-mode-acid2.bmp\|\
c9e944b7e01078bdeba1819bc2fa9372b111f52d\ \ .github/actions/dmg_sound-2.bmp\|\
f0172cc91867d3343fbd113a2bb98100074be0de\ \ .github/actions/oam_bug-2.bmp\
\)`
if [ -n "$FAILED_TESTS" ] ; then
echo "Failed the following tests:"
echo $FAILED_TESTS | tr " " "\n" | grep -q -o -E "[^/]+\.bmp" | sed s/.bmp// | sort
exit 1
fi
echo Passed all tests

35
.github/workflows/sanity.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: "Bulidability and Sanity"
on: push
jobs:
sanity:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, ubuntu-16.04]
cc: [gcc, clang]
include:
- os: macos-latest
cc: clang
extra_target: cocoa
exclude:
- os: macos-latest
cc: gcc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install deps
shell: bash
run: |
./.github/actions/install_deps.sh ${{ matrix.os }}
- name: Build
run: |
${{ matrix.cc }} -v; (make -j sdl tester libretro ${{ matrix.extra_target }} CONF=release CC=${{ matrix.cc }} || (echo "==== Build Failed ==="; make sdl tester libretro ${{ matrix.extra_target }} CONF=release CC=${{ matrix.cc }}))
- name: Sanity tests
shell: bash
run: |
./.github/actions/sanity_tests.sh
- name: Upload binaries
uses: actions/upload-artifact@v1
with:
name: sameboy-canary-${{ matrix.os }}-${{ matrix.cc }}
path: build/bin

View File

@ -24,7 +24,7 @@ Start:
ldh [$24], a ldh [$24], a
; Init BG palette ; Init BG palette
ld a, $fc ld a, $54
ldh [$47], a ldh [$47], a
; Load logo from ROM. ; Load logo from ROM.
@ -69,13 +69,35 @@ Start:
jr .tilemapLoop jr .tilemapLoop
.tilemapDone .tilemapDone
ld a, 30
ldh [$ff42], a
; Turn on LCD ; Turn on LCD
ld a, $91 ld a, $91
ldh [$40], a ldh [$40], a
; Wait ~0.75 seconds ld d, (-119) & $FF
ld b, 45 ld c, 15
call WaitBFrames
.animate
call WaitFrame
ld a, d
sra a
sra a
ldh [$ff42], a
ld a, d
add c
ld d, a
ld a, c
cp 8
jr nz, .noPaletteChange
ld a, $A8
ldh [$47], a
.noPaletteChange
dec c
jr nz, .animate
ld a, $fc
ldh [$47], a
; Play first sound ; Play first sound
ld a, $83 ld a, $83
@ -86,8 +108,10 @@ Start:
ld a, $c1 ld a, $c1
call PlaySound call PlaySound
; Wait ~1.15 seconds
ld b, 70
; Wait ~1 second
ld b, 60
call WaitBFrames call WaitBFrames
; Set registers to match the original DMG boot ; Set registers to match the original DMG boot

View File

@ -97,7 +97,8 @@ LoadTileset:
* @param blocklength size of an independent input block in bytes * @param blocklength size of an independent input block in bytes
* @return 0 for reaching infp end of file, or EOF for error * @return 0 for reaching infp end of file, or EOF for error
*/ */
int pb8(FILE *infp, FILE *outfp, size_t blocklength) { int pb8(FILE *infp, FILE *outfp, size_t blocklength)
{
blocklength >>= 3; // convert bytes to blocks blocklength >>= 3; // convert bytes to blocks
assert(blocklength > 0); assert(blocklength > 0);
while (1) { while (1) {
@ -113,7 +114,8 @@ int pb8(FILE *infp, FILE *outfp, size_t blocklength) {
control_byte <<= 1; control_byte <<= 1;
if (c == last_byte) { if (c == last_byte) {
control_byte |= 0x01; control_byte |= 0x01;
} else { }
else {
literals[nliterals++] = last_byte = c; literals[nliterals++] = last_byte = c;
} }
} }
@ -143,7 +145,8 @@ int pb8(FILE *infp, FILE *outfp, size_t blocklength) {
* @param outfp output stream * @param outfp output stream
* @return 0 for reaching infp end of file, or EOF for error * @return 0 for reaching infp end of file, or EOF for error
*/ */
int unpb8(FILE *infp, FILE *outfp) { int unpb8(FILE *infp, FILE *outfp)
{
int last_byte = 0; int last_byte = 0;
while (1) { while (1) {
int control_byte = fgetc(infp); int control_byte = fgetc(infp);
@ -165,7 +168,8 @@ int unpb8(FILE *infp, FILE *outfp) {
/* CLI frontend ****************************************************/ /* CLI frontend ****************************************************/
static inline void set_fd_binary(unsigned int fd) { static inline void set_fd_binary(unsigned int fd)
{
#ifdef _WIN32 #ifdef _WIN32
_setmode(fd, _O_BINARY); _setmode(fd, _O_BINARY);
#else #else
@ -197,7 +201,8 @@ static const char *version_msg =
static const char *toomanyfilenames_msg = static const char *toomanyfilenames_msg =
"pb8: too many filenames; try pb8 --help\n"; "pb8: too many filenames; try pb8 --help\n";
int main(int argc, char **argv) { int main(int argc, char **argv)
{
const char *infilename = NULL; const char *infilename = NULL;
const char *outfilename = NULL; const char *outfilename = NULL;
bool decompress = false; bool decompress = false;
@ -248,11 +253,14 @@ int main(int argc, char **argv) {
fprintf(stderr, "pb8: unknown option -%c\n", argtype); fprintf(stderr, "pb8: unknown option -%c\n", argtype);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else if (!infilename) { }
else if (!infilename) {
infilename = argv[i]; infilename = argv[i];
} else if (!outfilename) { }
else if (!outfilename) {
outfilename = argv[i]; outfilename = argv[i];
} else { }
else {
fputs(toomanyfilenames_msg, stderr); fputs(toomanyfilenames_msg, stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -282,7 +290,8 @@ int main(int argc, char **argv) {
perror("for reading"); perror("for reading");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else { }
else {
infp = stdin; infp = stdin;
set_fd_binary(0); set_fd_binary(0);
} }
@ -296,7 +305,8 @@ int main(int argc, char **argv) {
fclose(infp); fclose(infp);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else { }
else {
outfp = stdout; outfp = stdout;
set_fd_binary(1); set_fd_binary(1);
} }
@ -305,7 +315,8 @@ int main(int argc, char **argv) {
int has_ferror = 0; int has_ferror = 0;
if (decompress) { if (decompress) {
compfailed = unpb8(infp, outfp); compfailed = unpb8(infp, outfp);
} else { }
else {
compfailed = pb8(infp, outfp, blocklength); compfailed = pb8(infp, outfp, blocklength);
} }
fflush(outfp); fflush(outfp);

View File

@ -1,5 +1,6 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#include "GBButtons.h" #include "GBButtons.h"
#include "GBView.h"
#include <Core/gb.h> #include <Core/gb.h>
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#import <JoyKit/JoyKit.h> #import <JoyKit/JoyKit.h>
@ -37,6 +38,7 @@
@"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE), @"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE),
@"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET), @"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET),
@"GBRewindLength": @(10), @"GBRewindLength": @(10),
@"GBFrameBlendingMode": @([defaults boolForKey:@"DisableFrameBlending"]? GB_FRAME_BLENDING_MODE_DISABLED : GB_FRAME_BLENDING_MODE_ACCURATE),
@"GBDMGModel": @(GB_MODEL_DMG_B), @"GBDMGModel": @(GB_MODEL_DMG_B),
@"GBCGBModel": @(GB_MODEL_CGB_E), @"GBCGBModel": @(GB_MODEL_CGB_E),

View File

@ -1,8 +1,11 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "GBView.h" #include "GBView.h"
#include "GBImageView.h" #include "GBImageView.h"
#include "GBSplitView.h"
@interface Document : NSDocument <NSWindowDelegate, GBImageViewDelegate, NSTableViewDataSource, NSTableViewDelegate> @class GBCheatWindowController;
@interface Document : NSDocument <NSWindowDelegate, GBImageViewDelegate, NSTableViewDataSource, NSTableViewDelegate, NSSplitViewDelegate>
@property (strong) IBOutlet GBView *view; @property (strong) IBOutlet GBView *view;
@property (strong) IBOutlet NSTextView *consoleOutput; @property (strong) IBOutlet NSTextView *consoleOutput;
@property (strong) IBOutlet NSPanel *consoleWindow; @property (strong) IBOutlet NSPanel *consoleWindow;
@ -30,6 +33,10 @@
@property (strong) IBOutlet NSButton *feedSaveButton; @property (strong) IBOutlet NSButton *feedSaveButton;
@property (strong) IBOutlet NSTextView *debuggerSideViewInput; @property (strong) IBOutlet NSTextView *debuggerSideViewInput;
@property (strong) IBOutlet NSTextView *debuggerSideView; @property (strong) IBOutlet NSTextView *debuggerSideView;
@property (strong) IBOutlet GBSplitView *debuggerSplitView;
@property (strong) IBOutlet NSBox *debuggerVerticalLine;
@property (strong) IBOutlet NSPanel *cheatsWindow;
@property (strong) IBOutlet GBCheatWindowController *cheatWindowController;
-(uint8_t) readMemory:(uint16_t) addr; -(uint8_t) readMemory:(uint16_t) addr;
-(void) writeMemory:(uint16_t) addr value:(uint8_t)value; -(void) writeMemory:(uint16_t) addr value:(uint8_t)value;

View File

@ -7,6 +7,7 @@
#include "HexFiend/HexFiend.h" #include "HexFiend/HexFiend.h"
#include "GBMemoryByteArray.h" #include "GBMemoryByteArray.h"
#include "GBWarningPopover.h" #include "GBWarningPopover.h"
#include "GBCheatWindowController.h"
/* Todo: The general Objective-C coding style conflicts with SameBoy's. This file needs a cleanup. */ /* Todo: The general Objective-C coding style conflicts with SameBoy's. This file needs a cleanup. */
/* Todo: Split into category files! This is so messy!!! */ /* Todo: Split into category files! This is so messy!!! */
@ -61,6 +62,8 @@ enum model {
size_t audioBufferSize; size_t audioBufferSize;
size_t audioBufferPosition; size_t audioBufferPosition;
size_t audioBufferNeeded; size_t audioBufferNeeded;
bool borderModeChanged;
} }
@property GBAudioClient *audioClient; @property GBAudioClient *audioClient;
@ -75,8 +78,15 @@ enum model {
exposure:(unsigned) exposure; exposure:(unsigned) exposure;
- (void) gotNewSample:(GB_sample_t *)sample; - (void) gotNewSample:(GB_sample_t *)sample;
- (void) rumbleChanged:(double)amp; - (void) rumbleChanged:(double)amp;
- (void) loadBootROM:(GB_boot_rom_t)type;
@end @end
static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type)
{
Document *self = (__bridge Document *)GB_get_user_data(gb);
[self loadBootROM: type];
}
static void vblank(GB_gameboy_t *gb) static void vblank(GB_gameboy_t *gb)
{ {
Document *self = (__bridge Document *)GB_get_user_data(gb); Document *self = (__bridge Document *)GB_get_user_data(gb);
@ -147,7 +157,8 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
NSMutableArray *debugger_input_queue; NSMutableArray *debugger_input_queue;
} }
- (instancetype)init { - (instancetype)init
{
self = [super init]; self = [super init];
if (self) { if (self) {
has_debugger_input = [[NSConditionLock alloc] initWithCondition:0]; has_debugger_input = [[NSConditionLock alloc] initWithCondition:0];
@ -191,15 +202,44 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
} }
} }
- (void) updatePalette
{
switch ([[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorPalette"]) {
case 1:
GB_set_palette(&gb, &GB_PALETTE_DMG);
break;
case 2:
GB_set_palette(&gb, &GB_PALETTE_MGB);
break;
case 3:
GB_set_palette(&gb, &GB_PALETTE_GBL);
break;
default:
GB_set_palette(&gb, &GB_PALETTE_GREY);
break;
}
}
- (void) updateBorderMode
{
borderModeChanged = true;
}
- (void) initCommon - (void) initCommon
{ {
GB_init(&gb, [self internalModel]); GB_init(&gb, [self internalModel]);
GB_set_user_data(&gb, (__bridge void *)(self)); GB_set_user_data(&gb, (__bridge void *)(self));
GB_set_boot_rom_load_callback(&gb, (GB_boot_rom_load_callback_t)boot_rom_load);
GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank); GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank);
GB_set_log_callback(&gb, (GB_log_callback_t) consoleLog); GB_set_log_callback(&gb, (GB_log_callback_t) consoleLog);
GB_set_input_callback(&gb, (GB_input_callback_t) consoleInput); GB_set_input_callback(&gb, (GB_input_callback_t) consoleInput);
GB_set_async_input_callback(&gb, (GB_input_callback_t) asyncConsoleInput); GB_set_async_input_callback(&gb, (GB_input_callback_t) asyncConsoleInput);
GB_set_color_correction_mode(&gb, (GB_color_correction_mode_t) [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorCorrection"]); GB_set_color_correction_mode(&gb, (GB_color_correction_mode_t) [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorCorrection"]);
GB_set_border_mode(&gb, (GB_border_mode_t) [[NSUserDefaults standardUserDefaults] integerForKey:@"GBBorderMode"]);
[self updatePalette];
GB_set_rgb_encode_callback(&gb, rgbEncode); GB_set_rgb_encode_callback(&gb, rgbEncode);
GB_set_camera_get_pixel_callback(&gb, cameraGetPixel); GB_set_camera_get_pixel_callback(&gb, cameraGetPixel);
GB_set_camera_update_request_callback(&gb, cameraRequestUpdate); GB_set_camera_update_request_callback(&gb, cameraRequestUpdate);
@ -209,9 +249,29 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
GB_set_rumble_callback(&gb, rumbleCallback); GB_set_rumble_callback(&gb, rumbleCallback);
} }
- (void) updateMinSize
{
self.mainWindow.contentMinSize = NSMakeSize(GB_get_screen_width(&gb), GB_get_screen_height(&gb));
if (self.mainWindow.contentView.bounds.size.width < GB_get_screen_width(&gb) ||
self.mainWindow.contentView.bounds.size.width < GB_get_screen_height(&gb)) {
[self.mainWindow zoom:nil];
}
}
- (void) vblank - (void) vblank
{ {
[self.view flip]; [self.view flip];
if (borderModeChanged) {
dispatch_sync(dispatch_get_main_queue(), ^{
size_t previous_width = GB_get_screen_width(&gb);
GB_set_border_mode(&gb, (GB_border_mode_t) [[NSUserDefaults standardUserDefaults] integerForKey:@"GBBorderMode"]);
if (GB_get_screen_width(&gb) != previous_width) {
[self.view screenSizeChanged];
[self updateMinSize];
}
});
borderModeChanged = false;
}
GB_set_pixels_output(&gb, self.view.pixels); GB_set_pixels_output(&gb, self.view.pixels);
if (self.vramWindow.isVisible) { if (self.vramWindow.isVisible) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
@ -270,6 +330,12 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[audioLock wait]; [audioLock wait];
} }
if (stopping) {
memset(buffer, 0, nFrames * sizeof(*buffer));
[audioLock unlock];
return;
}
if (audioBufferPosition >= nFrames && audioBufferPosition < nFrames + 4800) { if (audioBufferPosition >= nFrames && audioBufferPosition < nFrames + 4800) {
memcpy(buffer, audioBuffer, nFrames * sizeof(*buffer)); memcpy(buffer, audioBuffer, nFrames * sizeof(*buffer));
memmove(audioBuffer, audioBuffer + nFrames, (audioBufferPosition - nFrames) * sizeof(*buffer)); memmove(audioBuffer, audioBuffer + nFrames, (audioBufferPosition - nFrames) * sizeof(*buffer));
@ -308,6 +374,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
self.audioClient = nil; self.audioClient = nil;
self.view.mouseHidingEnabled = NO; self.view.mouseHidingEnabled = NO;
GB_save_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]); GB_save_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
GB_save_cheats(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"cht"] UTF8String]);
[_view setRumble:false]; [_view setRumble:false];
stopping = false; stopping = false;
} }
@ -326,21 +393,32 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
if (GB_debugger_is_stopped(&gb)) { if (GB_debugger_is_stopped(&gb)) {
[self interruptDebugInputRead]; [self interruptDebugInputRead];
} }
[audioLock lock];
stopping = true; stopping = true;
[audioLock signal];
[audioLock unlock];
running = false; running = false;
while (stopping); while (stopping) {
[audioLock lock];
[audioLock signal];
[audioLock unlock];
}
GB_debugger_set_disabled(&gb, false); GB_debugger_set_disabled(&gb, false);
} }
- (void) loadBootROM - (void) loadBootROM: (GB_boot_rom_t)type
{ {
static NSString * const boot_names[] = {@"dmg_boot", @"cgb_boot", @"agb_boot", @"sgb_boot"}; static NSString *const names[] = {
if ([self internalModel] == GB_MODEL_SGB2) { [GB_BOOT_ROM_DMG0] = @"dmg0_boot",
GB_load_boot_rom(&gb, [[self bootROMPathForName:@"sgb2_boot"] UTF8String]); [GB_BOOT_ROM_DMG] = @"dmg_boot",
} [GB_BOOT_ROM_MGB] = @"mgb_boot",
else { [GB_BOOT_ROM_SGB] = @"sgb_boot",
GB_load_boot_rom(&gb, [[self bootROMPathForName:boot_names[current_model - 1]] UTF8String]); [GB_BOOT_ROM_SGB2] = @"sgb2_boot",
} [GB_BOOT_ROM_CGB0] = @"cgb0_boot",
[GB_BOOT_ROM_CGB] = @"cgb_boot",
[GB_BOOT_ROM_AGB] = @"agb_boot",
};
GB_load_boot_rom(&gb, [[self bootROMPathForName:names[type]] UTF8String]);
} }
- (IBAction)reset:(id)sender - (IBAction)reset:(id)sender
@ -352,8 +430,6 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
current_model = (enum model)[sender tag]; current_model = (enum model)[sender tag];
} }
[self loadBootROM];
if (!modelsChanging && [sender tag] == MODEL_NONE) { if (!modelsChanging && [sender tag] == MODEL_NONE) {
GB_reset(&gb); GB_reset(&gb);
} }
@ -365,11 +441,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[self.view screenSizeChanged]; [self.view screenSizeChanged];
} }
self.mainWindow.contentMinSize = NSMakeSize(GB_get_screen_width(&gb), GB_get_screen_height(&gb)); [self updateMinSize];
if (self.mainWindow.contentView.bounds.size.width < GB_get_screen_width(&gb) ||
self.mainWindow.contentView.bounds.size.width < GB_get_screen_height(&gb)) {
[self.mainWindow zoom:nil];
}
if ([sender tag] != 0) { if ([sender tag] != 0) {
/* User explictly selected a model, save the preference */ /* User explictly selected a model, save the preference */
@ -413,9 +485,11 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
} }
} }
- (void)windowControllerDidLoadNib:(NSWindowController *)aController { - (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
[super windowControllerDidLoadNib:aController]; [super windowControllerDidLoadNib:aController];
// Interface Builder bug?
[self.consoleWindow setContentSize:self.consoleWindow.minSize];
/* Close Open Panels, if any */ /* Close Open Panels, if any */
for (NSWindow *window in [[NSApplication sharedApplication] windows]) { for (NSWindow *window in [[NSApplication sharedApplication] windows]) {
if ([window isKindOfClass:[NSOpenPanel class]]) { if ([window isKindOfClass:[NSOpenPanel class]]) {
@ -437,7 +511,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
self.consoleOutput.textContainerInset = NSMakeSize(4, 4); self.consoleOutput.textContainerInset = NSMakeSize(4, 4);
[self.view becomeFirstResponder]; [self.view becomeFirstResponder];
self.view.shouldBlendFrameWithPrevious = ![[NSUserDefaults standardUserDefaults] boolForKey:@"DisableFrameBlending"]; self.view.frameBlendingMode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBFrameBlendingMode"];
CGRect window_frame = self.mainWindow.frame; CGRect window_frame = self.mainWindow.frame;
window_frame.size.width = MAX([[NSUserDefaults standardUserDefaults] integerForKey:@"LastWindowWidth"], window_frame.size.width = MAX([[NSUserDefaults standardUserDefaults] integerForKey:@"LastWindowWidth"],
window_frame.size.width); window_frame.size.width);
@ -450,6 +524,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[self.feedSaveButton removeFromSuperview]; [self.feedSaveButton removeFromSuperview];
self.consoleWindow.title = [NSString stringWithFormat:@"Debug Console %@", [[self.fileURL path] lastPathComponent]]; self.consoleWindow.title = [NSString stringWithFormat:@"Debug Console %@", [[self.fileURL path] lastPathComponent]];
self.debuggerSplitView.dividerColor = [NSColor clearColor];
/* contentView.superview.subviews.lastObject is the titlebar view */ /* contentView.superview.subviews.lastObject is the titlebar view */
NSView *titleView = self.printerFeedWindow.contentView.superview.subviews.lastObject; NSView *titleView = self.printerFeedWindow.contentView.superview.subviews.lastObject;
@ -466,6 +541,21 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
name:@"GBColorCorrectionChanged" name:@"GBColorCorrectionChanged"
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateFrameBlendingMode)
name:@"GBFrameBlendingModeChanged"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updatePalette)
name:@"GBColorPaletteChanged"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateBorderMode)
name:@"GBBorderModeChanged"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateRewindLength) selector:@selector(updateRewindLength)
name:@"GBRewindLengthChanged" name:@"GBRewindLengthChanged"
@ -551,11 +641,13 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
self.memoryBankItem.enabled = false; self.memoryBankItem.enabled = false;
} }
+ (BOOL)autosavesInPlace { + (BOOL)autosavesInPlace
{
return YES; return YES;
} }
- (NSString *)windowNibName { - (NSString *)windowNibName
{
// Override returning the nib file name of the document // Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead. // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"Document"; return @"Document";
@ -569,9 +661,18 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
- (void) loadROM - (void) loadROM
{ {
NSString *rom_warnings = [self captureOutputForBlock:^{ NSString *rom_warnings = [self captureOutputForBlock:^{
GB_load_rom(&gb, [self.fileName UTF8String]);
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
GB_debugger_clear_symbols(&gb); GB_debugger_clear_symbols(&gb);
if ([[self.fileType pathExtension] isEqualToString:@"isx"]) {
GB_load_isx(&gb, [self.fileName UTF8String]);
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"ram"] UTF8String]);
}
else {
GB_load_rom(&gb, [self.fileName UTF8String]);
}
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
GB_load_cheats(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"cht"] UTF8String]);
[self.cheatWindowController cheatsUpdated];
GB_debugger_load_symbol_file(&gb, [[[NSBundle mainBundle] pathForResource:@"registers" ofType:@"sym"] UTF8String]); GB_debugger_load_symbol_file(&gb, [[[NSBundle mainBundle] pathForResource:@"registers" ofType:@"sym"] UTF8String]);
GB_debugger_load_symbol_file(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sym"] UTF8String]); GB_debugger_load_symbol_file(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sym"] UTF8String]);
}]; }];
@ -612,15 +713,9 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[[NSUserDefaults standardUserDefaults] setBool:!self.audioClient.isPlaying forKey:@"Mute"]; [[NSUserDefaults standardUserDefaults] setBool:!self.audioClient.isPlaying forKey:@"Mute"];
} }
- (IBAction)toggleBlend:(id)sender
{
self.view.shouldBlendFrameWithPrevious ^= YES;
[[NSUserDefaults standardUserDefaults] setBool:!self.view.shouldBlendFrameWithPrevious forKey:@"DisableFrameBlending"];
}
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)anItem - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)anItem
{ {
if([anItem action] == @selector(mute:)) { if ([anItem action] == @selector(mute:)) {
[(NSMenuItem*)anItem setState:!self.audioClient.isPlaying]; [(NSMenuItem*)anItem setState:!self.audioClient.isPlaying];
} }
else if ([anItem action] == @selector(togglePause:)) { else if ([anItem action] == @selector(togglePause:)) {
@ -630,9 +725,6 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
else if ([anItem action] == @selector(reset:) && anItem.tag != MODEL_NONE) { else if ([anItem action] == @selector(reset:) && anItem.tag != MODEL_NONE) {
[(NSMenuItem*)anItem setState:anItem.tag == current_model]; [(NSMenuItem*)anItem setState:anItem.tag == current_model];
} }
else if ([anItem action] == @selector(toggleBlend:)) {
[(NSMenuItem*)anItem setState:self.view.shouldBlendFrameWithPrevious];
}
else if ([anItem action] == @selector(interrupt:)) { else if ([anItem action] == @selector(interrupt:)) {
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]) { if (![[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]) {
return false; return false;
@ -644,6 +736,9 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
else if ([anItem action] == @selector(connectPrinter:)) { else if ([anItem action] == @selector(connectPrinter:)) {
[(NSMenuItem*)anItem setState:accessory == GBAccessoryPrinter]; [(NSMenuItem*)anItem setState:accessory == GBAccessoryPrinter];
} }
else if ([anItem action] == @selector(toggleCheats:)) {
[(NSMenuItem*)anItem setState:GB_cheats_enabled(&gb)];
}
return [super validateUserInterfaceItem:anItem]; return [super validateUserInterfaceItem:anItem];
} }
@ -670,8 +765,8 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
NSRect rect = window.contentView.frame; NSRect rect = window.contentView.frame;
int titlebarSize = window.contentView.superview.frame.size.height - rect.size.height; unsigned titlebarSize = window.contentView.superview.frame.size.height - rect.size.height;
int step = width / [[window screen] backingScaleFactor]; unsigned step = width / [[window screen] backingScaleFactor];
rect.size.width = floor(rect.size.width / step) * step + step; rect.size.width = floor(rect.size.width / step) * step + step;
rect.size.height = rect.size.width * height / width + titlebarSize; rect.size.height = rect.size.width * height / width + titlebarSize;
@ -752,9 +847,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
} }
if (![console_output_timer isValid]) { if (![console_output_timer isValid]) {
console_output_timer = [NSTimer timerWithTimeInterval:(NSTimeInterval)0.05 repeats:NO block:^(NSTimer * _Nonnull timer) { console_output_timer = [NSTimer timerWithTimeInterval:(NSTimeInterval)0.05 target:self selector:@selector(appendPendingOutput) userInfo:nil repeats:NO];
[self appendPendingOutput];
}];
[[NSRunLoop mainRunLoop] addTimer:console_output_timer forMode:NSDefaultRunLoopMode]; [[NSRunLoop mainRunLoop] addTimer:console_output_timer forMode:NSDefaultRunLoopMode];
} }
@ -769,7 +862,8 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[self.consoleWindow orderBack:nil]; [self.consoleWindow orderBack:nil];
} }
- (IBAction)consoleInput:(NSTextField *)sender { - (IBAction)consoleInput:(NSTextField *)sender
{
NSString *line = [sender stringValue]; NSString *line = [sender stringValue];
if ([line isEqualToString:@""] && lastConsoleInput) { if ([line isEqualToString:@""] && lastConsoleInput) {
line = lastConsoleInput; line = lastConsoleInput;
@ -947,7 +1041,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
{ {
CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef) data); CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef) data);
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
CGImageRef iref = CGImageCreate(width, CGImageRef iref = CGImageCreate(width,
@ -1407,7 +1501,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn]; NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
if (tableView == self.paletteTableView) { if (tableView == self.paletteTableView) {
if (columnIndex == 0) { if (columnIndex == 0) {
return [NSString stringWithFormat:@"%s %d", row >=8 ? "Object" : "Background", (int)(row & 7)]; return [NSString stringWithFormat:@"%s %u", row >= 8 ? "Object" : "Background", (unsigned)(row & 7)];
} }
uint8_t *palette_data = GB_get_direct_access(&gb, row >= 8? GB_DIRECT_ACCESS_OBP : GB_DIRECT_ACCESS_BGP, NULL, NULL); uint8_t *palette_data = GB_get_direct_access(&gb, row >= 8? GB_DIRECT_ACCESS_OBP : GB_DIRECT_ACCESS_BGP, NULL, NULL);
@ -1425,9 +1519,9 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
height:oamHeight height:oamHeight
scale:16.0/oamHeight]; scale:16.0/oamHeight];
case 1: case 1:
return @((int)oamInfo[row].x - 8); return @((unsigned)oamInfo[row].x - 8);
case 2: case 2:
return @((int)oamInfo[row].y - 16); return @((unsigned)oamInfo[row].y - 16);
case 3: case 3:
return [NSString stringWithFormat:@"$%02x", oamInfo[row].tile]; return [NSString stringWithFormat:@"$%02x", oamInfo[row].tile];
case 4: case 4:
@ -1504,7 +1598,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
[self stop]; [self stop];
NSSavePanel * savePanel = [NSSavePanel savePanel]; NSSavePanel * savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:@[@"png"]]; [savePanel setAllowedFileTypes:@[@"png"]];
[savePanel beginSheetModalForWindow:self.printerFeedWindow completionHandler:^(NSInteger result){ [savePanel beginSheetModalForWindow:self.printerFeedWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) { if (result == NSFileHandlingPanelOKButton) {
[savePanel orderOut:self]; [savePanel orderOut:self];
CGImageRef cgRef = [self.feedImageView.image CGImageForProposedRect:NULL CGImageRef cgRef = [self.feedImageView.image CGImageForProposedRect:NULL
@ -1552,6 +1646,11 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
} }
} }
- (void) updateFrameBlendingMode
{
self.view.frameBlendingMode = (GB_frame_blending_mode_t) [[NSUserDefaults standardUserDefaults] integerForKey:@"GBFrameBlendingMode"];
}
- (void) updateRewindLength - (void) updateRewindLength
{ {
[self performAtomicBlock:^{ [self performAtomicBlock:^{
@ -1594,4 +1693,53 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
self.consoleWindow.title = [NSString stringWithFormat:@"Debug Console %@", [[fileURL path] lastPathComponent]]; self.consoleWindow.title = [NSString stringWithFormat:@"Debug Console %@", [[fileURL path] lastPathComponent]];
} }
- (BOOL)splitView:(GBSplitView *)splitView canCollapseSubview:(NSView *)subview;
{
if ([[splitView arrangedSubviews] lastObject] == subview) {
return YES;
}
return NO;
}
- (CGFloat)splitView:(GBSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex
{
return 600;
}
- (CGFloat)splitView:(GBSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex
{
return splitView.frame.size.width - 321;
}
- (BOOL)splitView:(GBSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view
{
if ([[splitView arrangedSubviews] lastObject] == view) {
return NO;
}
return YES;
}
- (void)splitViewDidResizeSubviews:(NSNotification *)notification
{
GBSplitView *splitview = notification.object;
if ([[[splitview arrangedSubviews] firstObject] frame].size.width < 600) {
[splitview setPosition:600 ofDividerAtIndex:0];
}
/* NSSplitView renders its separator without the proper vibrancy, so we made it transparent and move an
NSBox-based separator that renders properly so it acts like the split view's separator. */
NSRect rect = self.debuggerVerticalLine.frame;
rect.origin.x = [[[splitview arrangedSubviews] firstObject] frame].size.width - 1;
self.debuggerVerticalLine.frame = rect;
}
- (IBAction)showCheats:(id)sender
{
[self.cheatsWindow makeKeyAndOrderFront:nil];
}
- (IBAction)toggleCheats:(id)sender
{
GB_set_cheats_enabled(&gb, !GB_cheats_enabled(&gb));
}
@end @end

View File

@ -1,19 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="Document"> <customObject id="-2" userLabel="File's Owner" customClass="Document">
<connections> <connections>
<outlet property="TilemapSetButton" destination="k4c-Vg-MBu" id="Ak1-6d-B1N"/> <outlet property="TilemapSetButton" destination="k4c-Vg-MBu" id="Ak1-6d-B1N"/>
<outlet property="cheatController" destination="v7q-gT-jHT" id="yg2-23-kOX"/>
<outlet property="cheatWindowController" destination="v7q-gT-jHT" id="UNn-g4-2kP"/>
<outlet property="cheatsWindow" destination="4Yb-Np-JrF" id="YCZ-cj-gn5"/>
<outlet property="consoleInput" destination="l22-S8-uji" id="Heu-am-YgB"/> <outlet property="consoleInput" destination="l22-S8-uji" id="Heu-am-YgB"/>
<outlet property="consoleOutput" destination="doS-dM-hnl" id="Gn5-ju-Wb0"/> <outlet property="consoleOutput" destination="doS-dM-hnl" id="Gn5-ju-Wb0"/>
<outlet property="consoleWindow" destination="21F-Ah-yHX" id="eQ4-ug-LsT"/> <outlet property="consoleWindow" destination="21F-Ah-yHX" id="eQ4-ug-LsT"/>
<outlet property="debuggerSideView" destination="JgV-7E-iwp" id="RaA-fw-3i1"/> <outlet property="debuggerSideView" destination="JgV-7E-iwp" id="RaA-fw-3i1"/>
<outlet property="debuggerSideViewInput" destination="w0g-eK-jM4" id="GBf-WK-ryI"/> <outlet property="debuggerSideViewInput" destination="w0g-eK-jM4" id="GBf-WK-ryI"/>
<outlet property="debuggerSplitView" destination="pUc-ZN-vl5" id="0sG-0D-cID"/>
<outlet property="debuggerVerticalLine" destination="7bR-gM-1At" id="rfy-7Z-388"/>
<outlet property="feedImageView" destination="Ar0-nN-eop" id="wHa-St-o4G"/> <outlet property="feedImageView" destination="Ar0-nN-eop" id="wHa-St-o4G"/>
<outlet property="feedSaveButton" destination="RLc-0I-sYZ" id="Yy9-dG-xXY"/> <outlet property="feedSaveButton" destination="RLc-0I-sYZ" id="Yy9-dG-xXY"/>
<outlet property="gridButton" destination="fL6-2S-Rgd" id="jtV-jh-GHC"/> <outlet property="gridButton" destination="fL6-2S-Rgd" id="jtV-jh-GHC"/>
@ -39,22 +44,21 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="xOd-HO-29H" userLabel="Window"> <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="xOd-HO-29H" userLabel="Window">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="160" height="144"/>
<rect key="contentRect" x="133" y="235" width="160" height="144"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="160" height="144"/> <value key="minSize" type="size" width="160" height="144"/>
<view key="contentView" id="gIp-Ho-8D9"> <view key="contentView" id="gIp-Ho-8D9">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/> <rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<customView id="KTk-4M-J7t" customClass="GBBorderView"> <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KTk-4M-J7t" customClass="GBBorderView">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/> <rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<view id="uqf-pe-VAF" customClass="GBView"> <view fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uqf-pe-VAF" customClass="GBView">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/> <rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view> </view>
@ -67,49 +71,17 @@
</connections> </connections>
<point key="canvasLocation" x="293" y="347"/> <point key="canvasLocation" x="293" y="347"/>
</window> </window>
<window title="Debug Console" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="21F-Ah-yHX" customClass="NSPanel"> <window title="Debug Console" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="21F-Ah-yHX" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES" utility="YES" HUD="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES" utility="YES" HUD="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="921" height="400"/>
<rect key="contentRect" x="272" y="172" width="921" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="921" height="400"/> <value key="minSize" type="size" width="921" height="400"/>
<view key="contentView" id="dCP-E5-7Fi"> <view key="contentView" id="dCP-E5-7Fi">
<rect key="frame" x="0.0" y="0.0" width="921" height="400"/> <rect key="frame" x="0.0" y="0.0" width="921" height="400"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<scrollView misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="oTo-zx-o6N"> <textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="l22-S8-uji">
<rect key="frame" x="0.0" y="25" width="600" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="EQe-Ad-L7S">
<rect key="frame" x="0.0" y="0.0" width="600" height="376"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" id="doS-dM-hnl">
<rect key="frame" x="0.0" y="0.0" width="600" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.14901960784313725" green="0.14901960784313725" blue="0.14901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="600" height="376"/>
<size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" red="0.16470588235294117" green="0.16470588235294117" blue="0.16470588235294117" alpha="1" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="3fZ-tl-Zi7">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="cwi-6E-rbh">
<rect key="frame" x="584" y="0.0" width="16" height="376"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<textField focusRingType="none" verticalHuggingPriority="750" mirrorLayoutDirectionWhenInternationalizing="never" id="l22-S8-uji">
<rect key="frame" x="0.0" y="0.0" width="921" height="24"/> <rect key="frame" x="0.0" y="0.0" width="921" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" focusRingType="none" id="p3j-nS-44f" customClass="GBTerminalTextFieldCell"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" focusRingType="none" id="p3j-nS-44f" customClass="GBTerminalTextFieldCell">
@ -124,91 +96,147 @@
<action selector="consoleInput:" target="-2" id="ylQ-vw-ARS"/> <action selector="consoleInput:" target="-2" id="ylQ-vw-ARS"/>
</connections> </connections>
</textField> </textField>
<box verticalHuggingPriority="750" boxType="separator" id="960-dL-7ZY"> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="960-dL-7ZY">
<rect key="frame" x="0.0" y="23" width="921" height="5"/> <rect key="frame" x="0.0" y="23" width="921" height="5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</box> </box>
<scrollView misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="vts-CC-ZjQ"> <box horizontalHuggingPriority="750" boxType="separator" id="7bR-gM-1At">
<rect key="frame" x="601" y="25" width="320" height="328"/> <rect key="frame" x="590" y="25" width="5" height="376"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="Cs9-3x-ATg">
<rect key="frame" x="0.0" y="0.0" width="320" height="328"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" spellingCorrection="YES" id="JgV-7E-iwp">
<rect key="frame" x="0.0" y="0.0" width="320" height="328"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.14901960780000001" green="0.14901960780000001" blue="0.14901960780000001" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="320" height="328"/>
<size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" red="0.1647058824" green="0.1647058824" blue="0.1647058824" alpha="1" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="J2i-lz-QJW">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="4jm-Gm-D2R">
<rect key="frame" x="304" y="0.0" width="16" height="328"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<scrollView misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" scrollerKnobStyle="dark" id="V9U-Ua-F4z">
<rect key="frame" x="601" y="354" width="320" height="47"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="YHx-TM-zIC">
<rect key="frame" x="0.0" y="0.0" width="320" height="47"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" spellingCorrection="YES" id="w0g-eK-jM4">
<rect key="frame" x="0.0" y="0.0" width="320" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="320" height="47"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="24d-1i-uBk">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="qgN-F8-fdB">
<rect key="frame" x="304" y="0.0" width="16" height="47"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<box verticalHuggingPriority="750" misplaced="YES" boxType="separator" id="5qI-qZ-nkh">
<rect key="frame" x="603" y="352" width="318" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
</box>
<box horizontalHuggingPriority="750" misplaced="YES" boxType="separator" id="Onx-Oe-fBx">
<rect key="frame" x="600" y="25" width="5" height="376"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
</box> </box>
<splitView dividerStyle="thin" vertical="YES" id="pUc-ZN-vl5" customClass="GBSplitView">
<rect key="frame" x="0.0" y="25" width="921" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<customView fixedFrame="YES" id="2rj-7i-kxc">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oTo-zx-o6N">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="EQe-Ad-L7S">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" id="doS-dM-hnl">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.14901960784313725" green="0.14901960784313725" blue="0.14901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="591" height="376"/>
<size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" red="0.16470588235294117" green="0.16470588235294117" blue="0.16470588235294117" alpha="1" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="3fZ-tl-Zi7">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="cwi-6E-rbh">
<rect key="frame" x="575" y="0.0" width="16" height="376"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</customView>
<customView fixedFrame="YES" id="4Z2-33-dYY">
<rect key="frame" x="592" y="0.0" width="329" height="376"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" scrollerKnobStyle="dark" translatesAutoresizingMaskIntoConstraints="NO" id="V9U-Ua-F4z">
<rect key="frame" x="0.0" y="329" width="329" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="YHx-TM-zIC">
<rect key="frame" x="0.0" y="0.0" width="329" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" spellingCorrection="YES" id="w0g-eK-jM4">
<rect key="frame" x="0.0" y="0.0" width="329" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="329" height="47"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="24d-1i-uBk">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="qgN-F8-fdB">
<rect key="frame" x="313" y="0.0" width="16" height="47"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="5qI-qZ-nkh">
<rect key="frame" x="0.0" y="327" width="327" height="5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
</box>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vts-CC-ZjQ">
<rect key="frame" x="0.0" y="2" width="329" height="328"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="Cs9-3x-ATg">
<rect key="frame" x="0.0" y="0.0" width="329" height="328"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" spellingCorrection="YES" id="JgV-7E-iwp">
<rect key="frame" x="0.0" y="0.0" width="329" height="328"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.14901960780000001" green="0.14901960780000001" blue="0.14901960780000001" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="329" height="328"/>
<size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" red="0.1647058824" green="0.1647058824" blue="0.1647058824" alpha="1" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="J2i-lz-QJW">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="4jm-Gm-D2R">
<rect key="frame" x="313" y="0.0" width="16" height="328"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</customView>
</subviews>
<holdingPriorities>
<real value="250"/>
<real value="250"/>
</holdingPriorities>
<connections>
<outlet property="delegate" destination="-2" id="c8R-36-VRD"/>
</connections>
</splitView>
</subviews> </subviews>
</view> </view>
<point key="canvasLocation" x="347.5" y="-29"/> <point key="canvasLocation" x="347.5" y="-29"/>
</window> </window>
<window title="Memory" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="mRm-dL-mCj" customClass="NSPanel"> <window title="Memory" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="mRm-dL-mCj" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="528" height="320"/>
<rect key="contentRect" x="272" y="172" width="528" height="320"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="8hr-8o-3rN"> <view key="contentView" id="8hr-8o-3rN">
<rect key="frame" x="0.0" y="0.0" width="528" height="320"/> <rect key="frame" x="0.0" y="0.0" width="528" height="320"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view> </view>
<toolbar key="toolbar" implicitIdentifier="D857E961-E523-4295-83F8-0849316E827C" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="82v-uB-RPi"> <toolbar key="toolbar" implicitIdentifier="D857E961-E523-4295-83F8-0849316E827C" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="82v-uB-RPi">
<allowedToolbarItems> <allowedToolbarItems>
@ -248,7 +276,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" id="JCn-Y1-eHS"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" id="JCn-Y1-eHS">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
@ -265,7 +293,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" bezelStyle="round" id="vg5-Nn-abb"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" bezelStyle="round" id="vg5-Nn-abb">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
@ -284,21 +312,20 @@
<point key="canvasLocation" x="-185" y="61"/> <point key="canvasLocation" x="-185" y="61"/>
</window> </window>
<menuItem title="Cartridge RAM" id="ylM-ah-PNQ"/> <menuItem title="Cartridge RAM" id="ylM-ah-PNQ"/>
<window title="VRAM Viewer" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="mbr-db-iZh" customClass="NSPanel"> <window title="VRAM Viewer" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="mbr-db-iZh" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="512" height="432"/>
<rect key="contentRect" x="283" y="305" width="512" height="432"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="GYW-dv-Um1"> <view key="contentView" id="GYW-dv-Um1">
<rect key="frame" x="0.0" y="0.0" width="512" height="432"/> <rect key="frame" x="0.0" y="0.0" width="512" height="432"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<box verticalHuggingPriority="750" boxType="separator" id="ucG-cD-wfs"> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="ucG-cD-wfs">
<rect key="frame" x="0.0" y="406" width="512" height="5"/> <rect key="frame" x="0.0" y="406" width="512" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box> </box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="6vK-IP-PmP"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6vK-IP-PmP">
<rect key="frame" x="-2" y="4" width="516" height="14"/> <rect key="frame" x="-2" y="4" width="516" height="14"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" id="umk-4r-VNg"> <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" id="umk-4r-VNg">
@ -307,17 +334,17 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<tabView drawsBackground="NO" type="noTabsNoBorder" initialItem="pXb-od-Wb1" id="AZz-Mh-rPA"> <tabView fixedFrame="YES" drawsBackground="NO" type="noTabsNoBorder" initialItem="pXb-od-Wb1" translatesAutoresizingMaskIntoConstraints="NO" id="AZz-Mh-rPA">
<rect key="frame" x="0.0" y="24" width="512" height="408"/> <rect key="frame" x="0.0" y="24" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<tabViewItems> <tabViewItems>
<tabViewItem label="Tileset" identifier="1" id="pXb-od-Wb1"> <tabViewItem label="Tileset" identifier="1" id="pXb-od-Wb1">
<view key="view" id="lCG-Gt-XMF"> <view key="view" ambiguous="YES" id="lCG-Gt-XMF">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="QcQ-ex-36R" customClass="GBImageView"> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QcQ-ex-36R" customClass="GBImageView">
<rect key="frame" x="0.0" y="0.0" width="512" height="384"/> <rect key="frame" x="0.0" y="0.0" width="512" height="384"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="pXc-O8-jg5"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="pXc-O8-jg5"/>
@ -326,7 +353,7 @@
<outlet property="delegate" destination="-2" id="xoo-Uo-872"/> <outlet property="delegate" destination="-2" id="xoo-Uo-872"/>
</connections> </connections>
</imageView> </imageView>
<popUpButton focusRingType="none" verticalHuggingPriority="750" id="TLv-xS-X5K"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TLv-xS-X5K">
<rect key="frame" x="4" y="388" width="128" height="17"/> <rect key="frame" x="4" y="388" width="128" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="None" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="G8p-CH-PlV" id="1jI-s4-4YY"> <popUpButtonCell key="cell" type="roundRect" title="None" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="G8p-CH-PlV" id="1jI-s4-4YY">
@ -358,7 +385,7 @@
<action selector="reloadVRAMData:" target="-2" id="Qtf-p4-Rqh"/> <action selector="reloadVRAMData:" target="-2" id="Qtf-p4-Rqh"/>
</connections> </connections>
</popUpButton> </popUpButton>
<button verticalHuggingPriority="750" id="fL6-2S-Rgd"> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fL6-2S-Rgd">
<rect key="frame" x="452" y="388" width="56" height="17"/> <rect key="frame" x="452" y="388" width="56" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="Grid" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="pDn-9a-Se6"> <buttonCell key="cell" type="roundRect" title="Grid" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="pDn-9a-Se6">
@ -377,7 +404,7 @@
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<button verticalHuggingPriority="750" misplaced="YES" id="DhM-Em-hj7"> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DhM-Em-hj7">
<rect key="frame" x="385" y="388" width="63" height="17"/> <rect key="frame" x="385" y="388" width="63" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="Scrolling" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="P2E-5t-BN9"> <buttonCell key="cell" type="roundRect" title="Scrolling" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="P2E-5t-BN9">
@ -388,7 +415,7 @@
<action selector="toggleScrollingDisplay:" target="-2" id="VhQ-9W-sjU"/> <action selector="toggleScrollingDisplay:" target="-2" id="VhQ-9W-sjU"/>
</connections> </connections>
</button> </button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="LlK-tV-bjv" customClass="GBImageView"> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LlK-tV-bjv" customClass="GBImageView">
<rect key="frame" x="0.0" y="0.0" width="512" height="384"/> <rect key="frame" x="0.0" y="0.0" width="512" height="384"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="RvP-El-ILj"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="RvP-El-ILj"/>
@ -397,7 +424,7 @@
<outlet property="delegate" destination="-2" id="EAG-Zh-oRi"/> <outlet property="delegate" destination="-2" id="EAG-Zh-oRi"/>
</connections> </connections>
</imageView> </imageView>
<popUpButton focusRingType="none" verticalHuggingPriority="750" misplaced="YES" id="loB-0k-Qff"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="loB-0k-Qff">
<rect key="frame" x="4" y="388" width="128" height="17"/> <rect key="frame" x="4" y="388" width="128" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="Effective Palettes" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="oUH-Sa-Ec1" id="Eij-Cp-URa"> <popUpButtonCell key="cell" type="roundRect" title="Effective Palettes" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="oUH-Sa-Ec1" id="Eij-Cp-URa">
@ -430,7 +457,7 @@
<action selector="reloadVRAMData:" target="-2" id="BmB-JE-W8g"/> <action selector="reloadVRAMData:" target="-2" id="BmB-JE-W8g"/>
</connections> </connections>
</popUpButton> </popUpButton>
<popUpButton focusRingType="none" verticalHuggingPriority="750" misplaced="YES" id="YIJ-Qc-SIZ"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YIJ-Qc-SIZ">
<rect key="frame" x="135" y="388" width="96" height="17"/> <rect key="frame" x="135" y="388" width="96" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="Effective Tilemap" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="XRF-Vj-3gs" id="3W1-Db-wDn"> <popUpButtonCell key="cell" type="roundRect" title="Effective Tilemap" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="XRF-Vj-3gs" id="3W1-Db-wDn">
@ -448,7 +475,7 @@
<action selector="reloadVRAMData:" target="-2" id="xwp-Ju-p00"/> <action selector="reloadVRAMData:" target="-2" id="xwp-Ju-p00"/>
</connections> </connections>
</popUpButton> </popUpButton>
<popUpButton focusRingType="none" verticalHuggingPriority="750" misplaced="YES" id="k4c-Vg-MBu"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="k4c-Vg-MBu">
<rect key="frame" x="235" y="388" width="96" height="17"/> <rect key="frame" x="235" y="388" width="96" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="Effective Tileset" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="CRe-dX-rzY" id="h53-sb-Odg"> <popUpButtonCell key="cell" type="roundRect" title="Effective Tileset" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="CRe-dX-rzY" id="h53-sb-Odg">
@ -474,10 +501,10 @@
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="krD-gH-o5I"> <scrollView fixedFrame="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="krD-gH-o5I">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" id="3VT-AA-xVT"> <clipView key="contentView" ambiguous="YES" drawsBackground="NO" id="3VT-AA-xVT">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
@ -597,11 +624,11 @@
</subviews> </subviews>
<nil key="backgroundColor"/> <nil key="backgroundColor"/>
</clipView> </clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="n53-qA-NpY"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="n53-qA-NpY">
<rect key="frame" x="0.0" y="392" width="512" height="16"/> <rect key="frame" x="0.0" y="392" width="512" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="mqp-NY-g8d"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="mqp-NY-g8d">
<rect key="frame" x="224" y="17" width="15" height="102"/> <rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
@ -618,12 +645,12 @@
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<scrollView borderType="none" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" id="iSs-Ow-wwb"> <scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="iSs-Ow-wwb">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="bP9-su-zQw"> <clipView key="contentView" ambiguous="YES" id="bP9-su-zQw">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" id="gfC-d3-dmq"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" id="gfC-d3-dmq">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
@ -659,7 +686,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="" width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="syl-os-nSf"> <tableColumn width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="syl-os-nSf">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -672,7 +699,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="" width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="Qw3-u2-c1s"> <tableColumn width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="Qw3-u2-c1s">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -685,7 +712,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="" width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="gTl-gN-qLn"> <tableColumn width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="gTl-gN-qLn">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -706,11 +733,11 @@
</tableView> </tableView>
</subviews> </subviews>
</clipView> </clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="OS3-sw-bjv"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="OS3-sw-bjv">
<rect key="frame" x="-100" y="-100" width="510" height="16"/> <rect key="frame" x="-100" y="-100" width="510" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="4HA-2m-8TZ"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="4HA-2m-8TZ">
<rect key="frame" x="-100" y="-100" width="15" height="102"/> <rect key="frame" x="-100" y="-100" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
@ -756,16 +783,15 @@
<contentBorderThickness minY="24"/> <contentBorderThickness minY="24"/>
<point key="canvasLocation" x="182" y="760"/> <point key="canvasLocation" x="182" y="760"/>
</window> </window>
<window title="Printer Feed" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="NdE-0B-WCf" customClass="NSPanel"> <window title="Printer Feed" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="NdE-0B-WCf" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="320" height="288"/>
<rect key="contentRect" x="272" y="172" width="320" height="288"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="RRS-aa-bPT"> <view key="contentView" id="RRS-aa-bPT">
<rect key="frame" x="0.0" y="0.0" width="320" height="288"/> <rect key="frame" x="0.0" y="0.0" width="320" height="288"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="Ar0-nN-eop" customClass="GBImageView"> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ar0-nN-eop" customClass="GBImageView">
<rect key="frame" x="0.0" y="0.0" width="320" height="288"/> <rect key="frame" x="0.0" y="0.0" width="320" height="288"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageAlignment="topLeft" id="sff-hk-4nM"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageAlignment="topLeft" id="sff-hk-4nM"/>
@ -775,7 +801,7 @@
<point key="canvasLocation" x="-159" y="356"/> <point key="canvasLocation" x="-159" y="356"/>
</window> </window>
<button verticalHuggingPriority="750" id="RLc-0I-sYZ"> <button verticalHuggingPriority="750" id="RLc-0I-sYZ">
<rect key="frame" x="0.0" y="0.0" width="48" height="25"/> <rect key="frame" x="0.5" y="0.0" width="48" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" title="Save" bezelStyle="texturedRounded" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="shw-MJ-B3T"> <buttonCell key="cell" type="roundTextured" title="Save" bezelStyle="texturedRounded" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="shw-MJ-B3T">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -786,5 +812,264 @@
</connections> </connections>
<point key="canvasLocation" x="-507" y="397"/> <point key="canvasLocation" x="-507" y="397"/>
</button> </button>
<window title="Cheats" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="4Yb-Np-JrF" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="0.0" y="0.0" width="692" height="272"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="gBP-5p-BTh">
<rect key="frame" x="0.0" y="0.0" width="692" height="272"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view id="fWr-0i-K1d" customClass="GBOptionalVisualEffectView">
<rect key="frame" x="0.0" y="0.0" width="294" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="hqi-ob-NW9">
<rect key="frame" x="16" y="174" width="154" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="To value:" id="Ycx-oE-aA4">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Kq8-6F-9GK">
<rect key="frame" x="16" y="142" width="154" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Only if old value was: " bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="LkB-WQ-9Qd">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="updateCheat:" target="v7q-gT-jHT" id="kNc-cj-bmF"/>
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" id="D6k-Pe-23u">
<rect key="frame" x="10" y="129" width="274" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r5T-ol-Dod">
<rect key="frame" x="16" y="107" width="270" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Import GameShark or GameGenie cheat:" id="0mf-EN-cKc">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="X7K-nJ-alF">
<rect key="frame" x="39" y="78" width="233" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" focusRingType="none" placeholderString="Code" drawsBackground="YES" usesSingleLineMode="YES" id="2bz-dT-7Fi">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="selectText:" target="KHj-uX-Wbk" id="11z-0U-tMA"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KHj-uX-Wbk">
<rect key="frame" x="39" y="47" width="233" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" focusRingType="none" placeholderString="Description" drawsBackground="YES" usesSingleLineMode="YES" id="50d-va-Cen">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="performClick:" target="C3V-Ep-bMj" id="kIN-jl-A8d"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="C6E-oI-hDC">
<rect key="frame" x="20" y="233" width="252" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" focusRingType="none" placeholderString="Description" drawsBackground="YES" usesSingleLineMode="YES" id="2uR-9N-hBb">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="v7q-gT-jHT" id="zyw-h0-hRP"/>
</connections>
</textField>
<button verticalHuggingPriority="750" id="C3V-Ep-bMj">
<rect key="frame" x="202.5" y="12" width="82" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" title="Import" bezelStyle="texturedRounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="mMP-KW-YNy">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="importCheat:" target="v7q-gT-jHT" id="lkX-N5-wD1"/>
</connections>
</button>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="qHx-1z-daR">
<rect key="frame" x="176" y="204" width="96" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" focusRingType="none" drawsBackground="YES" usesSingleLineMode="YES" id="edq-46-JeP" customClass="GBCheatTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="consoleInput:" target="-2" id="sMf-aM-OvR"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="79v-33-R1X"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="N3I-PP-X85">
<rect key="frame" x="176" y="174" width="96" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" focusRingType="none" drawsBackground="YES" usesSingleLineMode="YES" id="CV2-D9-WsB" customClass="GBCheatTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="consoleInput:" target="-2" id="SYC-cW-RjC"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="P69-nT-oOt"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="S6O-LB-gSj">
<rect key="frame" x="176" y="144" width="96" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" focusRingType="none" drawsBackground="YES" usesSingleLineMode="YES" id="tpM-ys-MEO" customClass="GBCheatTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="consoleInput:" target="-2" id="io6-ha-QNb"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="6RH-dg-SL7"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="uFo-ly-Veq">
<rect key="frame" x="16" y="204" width="152" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Change byte at address:" id="xwa-TF-eY1">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="6rU-Xg-KHc">
<rect key="frame" x="293" y="-1" width="400" height="275"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
<clipView key="contentView" id="mzf-yu-RID">
<rect key="frame" x="1" y="0.0" width="398" height="274"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" headerView="pvX-uJ-qK5" id="tA3-8T-bxb">
<rect key="frame" x="0.0" y="0.0" width="398" height="249"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="32" minWidth="32" maxWidth="1000" id="JNd-HW-LvS">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<buttonCell key="dataCell" type="bevel" bezelStyle="regularSquare" image="NSStopProgressFreestandingTemplate" imagePosition="only" inset="2" id="5xh-hN-jHH">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn width="50" minWidth="40" maxWidth="1000" id="9DZ-oW-Scx">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Enabled">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="only" inset="2" id="SdJ-Xw-UAG">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn editable="NO" width="160" minWidth="40" maxWidth="1000" id="4Qa-FQ-QWY">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Description">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Description" id="1hX-Sr-bGz">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn editable="NO" width="144" minWidth="40" maxWidth="1000" id="ACq-gU-K36">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Action">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Action" id="8Sq-h9-eV7">
<font key="font" metaFont="fixedUser" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="v7q-gT-jHT" id="3ns-bk-yQI"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="fVI-Z9-gTJ"/>
</connections>
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="3Hg-LL-VqH">
<rect key="frame" x="1" y="258" width="398" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="zET-KH-qF4">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="pvX-uJ-qK5">
<rect key="frame" x="0.0" y="0.0" width="398" height="25"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
</subviews>
</view>
<point key="canvasLocation" x="254" y="-463"/>
</window>
<customObject id="v7q-gT-jHT" customClass="GBCheatWindowController">
<connections>
<outlet property="addressField" destination="qHx-1z-daR" id="FWo-4u-Qse"/>
<outlet property="cheatsTable" destination="tA3-8T-bxb" id="Z2r-AQ-5th"/>
<outlet property="descriptionField" destination="C6E-oI-hDC" id="tc0-gI-FBa"/>
<outlet property="document" destination="-2" id="5NX-N4-5Rt"/>
<outlet property="importCodeField" destination="X7K-nJ-alF" id="ni0-zH-XDU"/>
<outlet property="importDescriptionField" destination="KHj-uX-Wbk" id="W0E-ec-BXk"/>
<outlet property="oldValueCheckbox" destination="Kq8-6F-9GK" id="A4a-nz-KMN"/>
<outlet property="oldValueField" destination="S6O-LB-gSj" id="fAc-OW-ZC9"/>
<outlet property="valueField" destination="N3I-PP-X85" id="0zP-9x-4LQ"/>
</connections>
</customObject>
</objects> </objects>
<resources>
<image name="NSStopProgressFreestandingTemplate" width="14" height="14"/>
</resources>
</document> </document>

View File

@ -26,8 +26,7 @@ static OSStatus render(
-(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block -(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
andSampleRate:(UInt32) rate andSampleRate:(UInt32) rate
{ {
if(!(self = [super init])) if (!(self = [super init])) {
{
return nil; return nil;
} }
@ -102,7 +101,8 @@ static OSStatus render(
_playing = NO; _playing = NO;
} }
-(void) dealloc { -(void) dealloc
{
[self stop]; [self stop];
AudioUnitUninitialize(audioUnit); AudioUnitUninitialize(audioUnit);
AudioComponentInstanceDispose(audioUnit); AudioComponentInstanceDispose(audioUnit);

View File

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
@interface GBCheatTextFieldCell : NSTextFieldCell
@property bool usesAddressFormat;
@end

View File

@ -0,0 +1,121 @@
#import "GBCheatTextFieldCell.h"
@interface GBCheatTextView : NSTextView
@property bool usesAddressFormat;
@end
@implementation GBCheatTextView
- (bool)_insertText:(NSString *)string replacementRange:(NSRange)range
{
if (range.location == NSNotFound) {
range = self.selectedRange;
}
NSString *new = [self.string stringByReplacingCharactersInRange:range withString:string];
if (!self.usesAddressFormat) {
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(\\$[0-9A-Fa-f]{1,2}|[0-9]{1,3})$" options:0 error:NULL];
if ([regex numberOfMatchesInString:new options:0 range:NSMakeRange(0, new.length)]) {
[super insertText:string replacementRange:range];
return true;
}
if ([regex numberOfMatchesInString:[@"$" stringByAppendingString:new] options:0 range:NSMakeRange(0, new.length + 1)]) {
[super insertText:string replacementRange:range];
[super insertText:@"$" replacementRange:NSMakeRange(0, 0)];
return true;
}
if ([new isEqualToString:@"$"] || [string length] == 0) {
self.string = @"$00";
self.selectedRange = NSMakeRange(1, 2);
return true;
}
}
else {
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(\\$[0-9A-Fa-f]{1,3}:)?\\$[0-9a-fA-F]{1,4}$" options:0 error:NULL];
if ([regex numberOfMatchesInString:new options:0 range:NSMakeRange(0, new.length)]) {
[super insertText:string replacementRange:range];
return true;
}
if ([string length] == 0) {
NSUInteger index = [new rangeOfString:@":"].location;
if (index != NSNotFound) {
if (range.location > index) {
self.string = [[new componentsSeparatedByString:@":"] firstObject];
self.selectedRange = NSMakeRange(self.string.length, 0);
return true;
}
self.string = [[new componentsSeparatedByString:@":"] lastObject];
self.selectedRange = NSMakeRange(0, 0);
return true;
}
else if ([[self.string substringWithRange:range] isEqualToString:@":"]) {
self.string = [[self.string componentsSeparatedByString:@":"] lastObject];
self.selectedRange = NSMakeRange(0, 0);
return true;
}
}
if ([new isEqualToString:@"$"] || [string length] == 0) {
self.string = @"$0000";
self.selectedRange = NSMakeRange(1, 4);
return true;
}
if (([string isEqualToString:@"$"] || [string isEqualToString:@":"]) && range.length == 0 && range.location == 0) {
if ([self _insertText:@"$00:" replacementRange:range]) {
self.selectedRange = NSMakeRange(1, 2);
return true;
}
}
if ([string isEqualToString:@":"] && range.length + range.location == self.string.length) {
if ([self _insertText:@":$0" replacementRange:range]) {
self.selectedRange = NSMakeRange(self.string.length - 2, 2);
return true;
}
}
if ([string isEqualToString:@"$"]) {
if ([self _insertText:@"$0" replacementRange:range]) {
self.selectedRange = NSMakeRange(range.location + 1, 1);
return true;
}
}
}
return false;
}
- (NSUndoManager *)undoManager
{
return nil;
}
- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
{
if (![self _insertText:string replacementRange:replacementRange]) {
NSBeep();
}
}
/* Private API, don't tell the police! */
- (void)_userReplaceRange:(NSRange)range withString:(NSString *)string
{
[self insertText:string replacementRange:range];
}
@end
@implementation GBCheatTextFieldCell
{
bool _drawing, _editing;
GBCheatTextView *_fieldEditor;
}
- (NSTextView *)fieldEditorForView:(NSView *)controlView
{
if (_fieldEditor) {
_fieldEditor.usesAddressFormat = self.usesAddressFormat;
return _fieldEditor;
}
_fieldEditor = [[GBCheatTextView alloc] initWithFrame:controlView.frame];
_fieldEditor.fieldEditor = YES;
_fieldEditor.usesAddressFormat = self.usesAddressFormat;
return _fieldEditor;
}
@end

View File

@ -0,0 +1,17 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "Document.h"
@interface GBCheatWindowController : NSObject <NSTableViewDelegate, NSTableViewDataSource, NSTextFieldDelegate>
@property (weak) IBOutlet NSTableView *cheatsTable;
@property (weak) IBOutlet NSTextField *addressField;
@property (weak) IBOutlet NSTextField *valueField;
@property (weak) IBOutlet NSTextField *oldValueField;
@property (weak) IBOutlet NSButton *oldValueCheckbox;
@property (weak) IBOutlet NSTextField *descriptionField;
@property (weak) IBOutlet NSTextField *importCodeField;
@property (weak) IBOutlet NSTextField *importDescriptionField;
@property (weak) IBOutlet Document *document;
- (void)cheatsUpdated;
@end

View File

@ -0,0 +1,240 @@
#import "GBCheatWindowController.h"
#import "GBWarningPopover.h"
#import "GBCheatTextFieldCell.h"
@implementation GBCheatWindowController
+ (NSString *)addressStringFromCheat:(const GB_cheat_t *)cheat
{
if (cheat->bank != GB_CHEAT_ANY_BANK) {
return [NSString stringWithFormat:@"$%x:$%04x", cheat->bank, cheat->address];
}
return [NSString stringWithFormat:@"$%04x", cheat->address];
}
+ (NSString *)actionDescriptionForCheat:(const GB_cheat_t *)cheat
{
if (cheat->use_old_value) {
return [NSString stringWithFormat:@"[%@]($%02x) = $%02x", [self addressStringFromCheat:cheat], cheat->old_value, cheat->value];
}
return [NSString stringWithFormat:@"[%@] = $%02x", [self addressStringFromCheat:cheat], cheat->value];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return 0;
size_t cheatCount;
GB_get_cheats(gb, &cheatCount);
return cheatCount + 1;
}
- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return nil;
size_t cheatCount;
GB_get_cheats(gb, &cheatCount);
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
if (row >= cheatCount && columnIndex == 0) {
return [[NSCell alloc] init];
}
return nil;
}
- (nullable id)tableView:(NSTableView *)tableView objectValueForTableColumn:(nullable NSTableColumn *)tableColumn row:(NSInteger)row
{
size_t cheatCount;
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return nil;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
if (row >= cheatCount) {
switch (columnIndex) {
case 0:
return @(YES);
case 1:
return @NO;
case 2:
return @"Add Cheat...";
case 3:
return @"";
}
}
switch (columnIndex) {
case 0:
return @(NO);
case 1:
return @(cheats[row]->enabled);
case 2:
return @(cheats[row]->description);
case 3:
return [GBCheatWindowController actionDescriptionForCheat:cheats[row]];
}
return nil;
}
- (IBAction)importCheat:(id)sender
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
[self.document performAtomicBlock:^{
if (GB_import_cheat(gb,
self.importCodeField.stringValue.UTF8String,
self.importDescriptionField.stringValue.UTF8String,
true)) {
self.importCodeField.stringValue = @"";
self.importDescriptionField.stringValue = @"";
[self.cheatsTable reloadData];
[self tableViewSelectionDidChange:nil];
}
else {
NSBeep();
[GBWarningPopover popoverWithContents:@"This code is not a valid GameShark or GameGenie code" onView:self.importCodeField];
}
}];
}
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
[self.document performAtomicBlock:^{
if (columnIndex == 1) {
if (row >= cheatCount) {
GB_add_cheat(gb, "New Cheat", 0, 0, 0, 0, false, true);
}
else {
GB_update_cheat(gb, cheats[row], cheats[row]->description, cheats[row]->address, cheats[row]->bank, cheats[row]->value, cheats[row]->old_value, cheats[row]->use_old_value, !cheats[row]->enabled);
}
}
else if (row < cheatCount) {
GB_remove_cheat(gb, cheats[row]);
}
}];
[self.cheatsTable reloadData];
[self tableViewSelectionDidChange:nil];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
unsigned row = self.cheatsTable.selectedRow;
const GB_cheat_t *cheat = NULL;
if (row >= cheatCount) {
static const GB_cheat_t template = {
.address = 0,
.bank = 0,
.value = 0,
.old_value = 0,
.use_old_value = false,
.enabled = false,
.description = "New Cheat",
};
cheat = &template;
}
else {
cheat = cheats[row];
}
self.addressField.stringValue = [GBCheatWindowController addressStringFromCheat:cheat];
self.valueField.stringValue = [NSString stringWithFormat:@"$%02x", cheat->value];
self.oldValueField.stringValue = [NSString stringWithFormat:@"$%02x", cheat->old_value];
self.oldValueCheckbox.state = cheat->use_old_value;
self.descriptionField.stringValue = @(cheat->description);
}
- (void)awakeFromNib
{
[self tableViewSelectionDidChange:nil];
((GBCheatTextFieldCell *)self.addressField.cell).usesAddressFormat = true;
}
- (void)controlTextDidChange:(NSNotification *)obj
{
[self updateCheat:nil];
}
- (IBAction)updateCheat:(id)sender
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
uint16_t address = 0;
uint16_t bank = GB_CHEAT_ANY_BANK;
if ([self.addressField.stringValue rangeOfString:@":"].location != NSNotFound) {
sscanf(self.addressField.stringValue.UTF8String, "$%hx:$%hx", &bank, &address);
}
else {
sscanf(self.addressField.stringValue.UTF8String, "$%hx", &address);
}
uint8_t value = 0;
if ([self.valueField.stringValue characterAtIndex:0] == '$') {
sscanf(self.valueField.stringValue.UTF8String, "$%02hhx", &value);
}
else {
sscanf(self.valueField.stringValue.UTF8String, "%hhd", &value);
}
uint8_t oldValue = 0;
if ([self.oldValueField.stringValue characterAtIndex:0] == '$') {
sscanf(self.oldValueField.stringValue.UTF8String, "$%02hhx", &oldValue);
}
else {
sscanf(self.oldValueField.stringValue.UTF8String, "%hhd", &oldValue);
}
size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
unsigned row = self.cheatsTable.selectedRow;
[self.document performAtomicBlock:^{
if (row >= cheatCount) {
GB_add_cheat(gb,
self.descriptionField.stringValue.UTF8String,
address,
bank,
value,
oldValue,
self.oldValueCheckbox.state,
false);
}
else {
GB_update_cheat(gb,
cheats[row],
self.descriptionField.stringValue.UTF8String,
address,
bank,
value,
oldValue,
self.oldValueCheckbox.state,
cheats[row]->enabled);
}
}];
[self.cheatsTable reloadData];
}
- (void)cheatsUpdated
{
[self.cheatsTable reloadData];
[self tableViewSelectionDidChange:nil];
}
@end

View File

@ -1,6 +1,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "GBView.h"
@interface GBGLShader : NSObject @interface GBGLShader : NSObject
- (instancetype)initWithName:(NSString *) shaderName; - (instancetype)initWithName:(NSString *) shaderName;
- (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale; - (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale withBlendingMode: (GB_frame_blending_mode_t)blendingMode;
@end @end

View File

@ -21,7 +21,7 @@ void main(void) {\n\
GLuint resolution_uniform; GLuint resolution_uniform;
GLuint texture_uniform; GLuint texture_uniform;
GLuint previous_texture_uniform; GLuint previous_texture_uniform;
GLuint mix_previous_uniform; GLuint frame_blending_mode_uniform;
GLuint position_attribute; GLuint position_attribute;
GLuint texture; GLuint texture;
@ -70,7 +70,7 @@ void main(void) {\n\
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
previous_texture_uniform = glGetUniformLocation(program, "previous_image"); previous_texture_uniform = glGetUniformLocation(program, "previous_image");
mix_previous_uniform = glGetUniformLocation(program, "mix_previous"); frame_blending_mode_uniform = glGetUniformLocation(program, "frame_blending_mode");
// Configure OpenGL // Configure OpenGL
[self configureOpenGL]; [self configureOpenGL];
@ -79,7 +79,7 @@ void main(void) {\n\
return self; return self;
} }
- (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale - (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale withBlendingMode:(GB_frame_blending_mode_t)blendingMode
{ {
glUseProgram(program); glUseProgram(program);
glUniform2f(resolution_uniform, dstSize.width * scale, dstSize.height * scale); glUniform2f(resolution_uniform, dstSize.width * scale, dstSize.height * scale);
@ -87,8 +87,8 @@ void main(void) {\n\
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
glUniform1i(texture_uniform, 0); glUniform1i(texture_uniform, 0);
glUniform1i(mix_previous_uniform, previous != NULL); glUniform1i(frame_blending_mode_uniform, blendingMode);
if (previous) { if (blendingMode) {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, previous_texture); glBindTexture(GL_TEXTURE_2D, previous_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, previous); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, previous);
@ -169,7 +169,7 @@ void main(void) {\n\
+ (GLuint)shaderWithContents:(NSString*)contents type:(GLenum)type + (GLuint)shaderWithContents:(NSString*)contents type:(GLenum)type
{ {
const GLchar* source = [contents UTF8String]; const GLchar *source = [contents UTF8String];
// Create the shader object // Create the shader object
GLuint shader = glCreateShader(type); GLuint shader = glCreateShader(type);
// Load the shader source // Load the shader source

View File

@ -3,7 +3,7 @@
@implementation GBImageCell @implementation GBImageCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{ {
CGContextRef context = [[NSGraphicsContext currentContext] CGContext]; CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetInterpolationQuality(context, kCGInterpolationNone); CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawWithFrame:cellFrame inView:controlView]; [super drawWithFrame:cellFrame inView:controlView];
} }

View File

@ -16,7 +16,7 @@
} }
- (void)drawRect:(NSRect)dirtyRect - (void)drawRect:(NSRect)dirtyRect
{ {
CGContextRef context = [[NSGraphicsContext currentContext] CGContext]; CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetInterpolationQuality(context, kCGInterpolationNone); CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawRect:dirtyRect]; [super drawRect:dirtyRect];
CGFloat y_ratio = self.frame.size.height / self.image.size.height; CGFloat y_ratio = self.frame.size.height / self.image.size.height;
@ -93,7 +93,7 @@
- (void)updateTrackingAreas - (void)updateTrackingAreas
{ {
if(trackingArea != nil) { if (trackingArea != nil) {
[self removeTrackingArea:trackingArea]; [self removeTrackingArea:trackingArea];
} }

View File

@ -4,7 +4,8 @@
@implementation GBOpenGLView @implementation GBOpenGLView
- (void)drawRect:(NSRect)dirtyRect { - (void)drawRect:(NSRect)dirtyRect
{
if (!self.shader) { if (!self.shader) {
self.shader = [[GBGLShader alloc] initWithName:[[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"]]; self.shader = [[GBGLShader alloc] initWithName:[[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"]];
} }
@ -13,11 +14,14 @@
double scale = self.window.backingScaleFactor; double scale = self.window.backingScaleFactor;
glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale);
[self.shader renderBitmap:gbview.currentBuffer if (gbview.gb) {
previous:gbview.shouldBlendFrameWithPrevious? gbview.previousBuffer : NULL [self.shader renderBitmap:gbview.currentBuffer
sized:NSMakeSize(GB_get_screen_width(gbview.gb), GB_get_screen_height(gbview.gb)) previous:gbview.frameBlendingMode? gbview.previousBuffer : NULL
inSize:self.bounds.size sized:NSMakeSize(GB_get_screen_width(gbview.gb), GB_get_screen_height(gbview.gb))
scale:scale]; inSize:self.bounds.size
scale:scale
withBlendingMode:gbview.frameBlendingMode];
}
glFlush(); glFlush();
} }

View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
/* Fake interface so the compiler assumes it conforms to NSVisualEffectView */
@interface GBOptionalVisualEffectView : NSVisualEffectView
@end

View File

@ -0,0 +1,18 @@
#import <Cocoa/Cocoa.h>
@interface GBOptionalVisualEffectView : NSView
@end
@implementation GBOptionalVisualEffectView
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
Class NSVisualEffectView = NSClassFromString(@"NSVisualEffectView");
if (NSVisualEffectView) {
return (id)[NSVisualEffectView alloc];
}
return [super allocWithZone:zone];
}
@end

View File

@ -8,6 +8,9 @@
@property (strong) IBOutlet NSButton *aspectRatioCheckbox; @property (strong) IBOutlet NSButton *aspectRatioCheckbox;
@property (strong) IBOutlet NSPopUpButton *highpassFilterPopupButton; @property (strong) IBOutlet NSPopUpButton *highpassFilterPopupButton;
@property (strong) IBOutlet NSPopUpButton *colorCorrectionPopupButton; @property (strong) IBOutlet NSPopUpButton *colorCorrectionPopupButton;
@property (strong) IBOutlet NSPopUpButton *frameBlendingModePopupButton;
@property (strong) IBOutlet NSPopUpButton *colorPalettePopupButton;
@property (strong) IBOutlet NSPopUpButton *displayBorderPopupButton;
@property (strong) IBOutlet NSPopUpButton *rewindPopupButton; @property (strong) IBOutlet NSPopUpButton *rewindPopupButton;
@property (strong) IBOutlet NSButton *configureJoypadButton; @property (strong) IBOutlet NSButton *configureJoypadButton;
@property (strong) IBOutlet NSButton *skipButton; @property (strong) IBOutlet NSButton *skipButton;

View File

@ -14,6 +14,9 @@
NSPopUpButton *_graphicsFilterPopupButton; NSPopUpButton *_graphicsFilterPopupButton;
NSPopUpButton *_highpassFilterPopupButton; NSPopUpButton *_highpassFilterPopupButton;
NSPopUpButton *_colorCorrectionPopupButton; NSPopUpButton *_colorCorrectionPopupButton;
NSPopUpButton *_frameBlendingModePopupButton;
NSPopUpButton *_colorPalettePopupButton;
NSPopUpButton *_displayBorderPopupButton;
NSPopUpButton *_rewindPopupButton; NSPopUpButton *_rewindPopupButton;
NSButton *_aspectRatioCheckbox; NSButton *_aspectRatioCheckbox;
NSButton *_analogControlsCheckbox; NSButton *_analogControlsCheckbox;
@ -32,6 +35,7 @@
@"NearestNeighbor", @"NearestNeighbor",
@"Bilinear", @"Bilinear",
@"SmoothBilinear", @"SmoothBilinear",
@"MonoLCD",
@"LCD", @"LCD",
@"CRT", @"CRT",
@"Scale2x", @"Scale2x",
@ -85,6 +89,42 @@
return _colorCorrectionPopupButton; return _colorCorrectionPopupButton;
} }
- (void)setFrameBlendingModePopupButton:(NSPopUpButton *)frameBlendingModePopupButton
{
_frameBlendingModePopupButton = frameBlendingModePopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBFrameBlendingMode"];
[_frameBlendingModePopupButton selectItemAtIndex:mode];
}
- (NSPopUpButton *)frameBlendingModePopupButton
{
return _frameBlendingModePopupButton;
}
- (void)setColorPalettePopupButton:(NSPopUpButton *)colorPalettePopupButton
{
_colorPalettePopupButton = colorPalettePopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorPalette"];
[_colorPalettePopupButton selectItemAtIndex:mode];
}
- (NSPopUpButton *)colorPalettePopupButton
{
return _colorPalettePopupButton;
}
- (void)setDisplayBorderPopupButton:(NSPopUpButton *)displayBorderPopupButton
{
_displayBorderPopupButton = displayBorderPopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBBorderMode"];
[_displayBorderPopupButton selectItemWithTag:mode];
}
- (NSPopUpButton *)displayBorderPopupButton
{
return _displayBorderPopupButton;
}
- (void)setRewindPopupButton:(NSPopUpButton *)rewindPopupButton - (void)setRewindPopupButton:(NSPopUpButton *)rewindPopupButton
{ {
_rewindPopupButton = rewindPopupButton; _rewindPopupButton = rewindPopupButton;
@ -203,7 +243,28 @@
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem]) [[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBColorCorrection"]; forKey:@"GBColorCorrection"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorCorrectionChanged" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorCorrectionChanged" object:nil];
}
- (IBAction)franeBlendingModeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBFrameBlendingMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBFrameBlendingModeChanged" object:nil];
}
- (IBAction)colorPaletteChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBColorPalette"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorPaletteChanged" object:nil];
}
- (IBAction)displayBorderChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedItem].tag)
forKey:@"GBBorderMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBBorderModeChanged" object:nil];
} }
- (IBAction)rewindLengthChanged:(id)sender - (IBAction)rewindLengthChanged:(id)sender

7
Cocoa/GBSplitView.h Normal file
View File

@ -0,0 +1,7 @@
#import <Cocoa/Cocoa.h>
@interface GBSplitView : NSSplitView
-(void) setDividerColor:(NSColor *)color;
- (NSArray<NSView *> *)arrangedSubviews;
@end

33
Cocoa/GBSplitView.m Normal file
View File

@ -0,0 +1,33 @@
#import "GBSplitView.h"
@implementation GBSplitView
{
NSColor *_dividerColor;
}
- (void)setDividerColor:(NSColor *)color
{
_dividerColor = color;
[self setNeedsDisplay:YES];
}
- (NSColor *)dividerColor
{
if (_dividerColor) {
return _dividerColor;
}
return [super dividerColor];
}
/* Mavericks comaptibility */
- (NSArray<NSView *> *)arrangedSubviews
{
if (@available(macOS 10.11, *)) {
return [super arrangedSubviews];
}
else {
return [self subviews];
}
}
@end

View File

@ -173,7 +173,8 @@
[super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag]; [super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag];
} }
- (BOOL)resignFirstResponder { - (BOOL)resignFirstResponder
{
reverse_search_mode = false; reverse_search_mode = false;
return [super resignFirstResponder]; return [super resignFirstResponder];
} }

View File

@ -2,11 +2,19 @@
#include <Core/gb.h> #include <Core/gb.h>
#import <JoyKit/JoyKit.h> #import <JoyKit/JoyKit.h>
typedef enum {
GB_FRAME_BLENDING_MODE_DISABLED,
GB_FRAME_BLENDING_MODE_SIMPLE,
GB_FRAME_BLENDING_MODE_ACCURATE,
GB_FRAME_BLENDING_MODE_ACCURATE_EVEN = GB_FRAME_BLENDING_MODE_ACCURATE,
GB_FRAME_BLENDING_MODE_ACCURATE_ODD,
} GB_frame_blending_mode_t;
@interface GBView : NSView<JOYListener> @interface GBView : NSView<JOYListener>
- (void) flip; - (void) flip;
- (uint32_t *) pixels; - (uint32_t *) pixels;
@property GB_gameboy_t *gb; @property GB_gameboy_t *gb;
@property (nonatomic) BOOL shouldBlendFrameWithPrevious; @property (nonatomic) GB_frame_blending_mode_t frameBlendingMode;
@property (getter=isMouseHidingEnabled) BOOL mouseHidingEnabled; @property (getter=isMouseHidingEnabled) BOOL mouseHidingEnabled;
@property bool isRewinding; @property bool isRewinding;
@property NSView *internalView; @property NSView *internalView;

View File

@ -22,6 +22,7 @@
bool analogClockMultiplierValid; bool analogClockMultiplierValid;
NSEventModifierFlags previousModifiers; NSEventModifierFlags previousModifiers;
JOYController *lastController; JOYController *lastController;
GB_frame_blending_mode_t _frameBlendingMode;
} }
+ (instancetype)alloc + (instancetype)alloc
@ -47,7 +48,6 @@
- (void) _init - (void) _init
{ {
_shouldBlendFrameWithPrevious = 1;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ratioKeepingChanged) name:@"GBAspectChanged" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ratioKeepingChanged) name:@"GBAspectChanged" object:nil];
tracking_area = [ [NSTrackingArea alloc] initWithRect:(NSRect){} tracking_area = [ [NSTrackingArea alloc] initWithRect:(NSRect){}
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect
@ -69,9 +69,9 @@
size_t buffer_size = sizeof(image_buffers[0][0]) * GB_get_screen_width(_gb) * GB_get_screen_height(_gb); size_t buffer_size = sizeof(image_buffers[0][0]) * GB_get_screen_width(_gb) * GB_get_screen_height(_gb);
image_buffers[0] = malloc(buffer_size); image_buffers[0] = calloc(1, buffer_size);
image_buffers[1] = malloc(buffer_size); image_buffers[1] = calloc(1, buffer_size);
image_buffers[2] = malloc(buffer_size); image_buffers[2] = calloc(1, buffer_size);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self setFrame:self.superview.frame]; [self setFrame:self.superview.frame];
@ -83,15 +83,26 @@
[self setFrame:self.superview.frame]; [self setFrame:self.superview.frame];
} }
- (void) setShouldBlendFrameWithPrevious:(BOOL)shouldBlendFrameWithPrevious - (void) setFrameBlendingMode:(GB_frame_blending_mode_t)frameBlendingMode
{ {
_shouldBlendFrameWithPrevious = shouldBlendFrameWithPrevious; _frameBlendingMode = frameBlendingMode;
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
} }
- (GB_frame_blending_mode_t)frameBlendingMode
{
if (_frameBlendingMode == GB_FRAME_BLENDING_MODE_ACCURATE) {
if (!_gb || GB_is_sgb(_gb)) {
return GB_FRAME_BLENDING_MODE_SIMPLE;
}
return GB_is_odd_frame(_gb)? GB_FRAME_BLENDING_MODE_ACCURATE_ODD : GB_FRAME_BLENDING_MODE_ACCURATE_EVEN;
}
return _frameBlendingMode;
}
- (unsigned char) numberOfBuffers - (unsigned char) numberOfBuffers
{ {
return _shouldBlendFrameWithPrevious? 3 : 2; return _frameBlendingMode? 3 : 2;
} }
- (void)dealloc - (void)dealloc
@ -109,8 +120,7 @@
} }
- (instancetype)initWithCoder:(NSCoder *)coder - (instancetype)initWithCoder:(NSCoder *)coder
{ {
if (!(self = [super initWithCoder:coder])) if (!(self = [super initWithCoder:coder])) {
{
return self; return self;
} }
[self _init]; [self _init];
@ -119,8 +129,7 @@
- (instancetype)initWithFrame:(NSRect)frameRect - (instancetype)initWithFrame:(NSRect)frameRect
{ {
if (!(self = [super initWithFrame:frameRect])) if (!(self = [super initWithFrame:frameRect])) {
{
return self; return self;
} }
[self _init]; [self _init];

View File

@ -1,4 +1,6 @@
#import "GBViewMetal.h" #import "GBViewMetal.h"
#pragma clang diagnostic ignored "-Wpartial-availability"
static const vector_float2 rect[] = static const vector_float2 rect[] =
{ {
@ -15,7 +17,7 @@ static const vector_float2 rect[] =
id<MTLBuffer> vertices; id<MTLBuffer> vertices;
id<MTLRenderPipelineState> pipeline_state; id<MTLRenderPipelineState> pipeline_state;
id<MTLCommandQueue> command_queue; id<MTLCommandQueue> command_queue;
id<MTLBuffer> mix_previous_buffer; id<MTLBuffer> frame_blending_mode_buffer;
id<MTLBuffer> output_resolution_buffer; id<MTLBuffer> output_resolution_buffer;
vector_float2 output_resolution; vector_float2 output_resolution;
} }
@ -56,10 +58,10 @@ static const vector_float2 rect[] =
length:sizeof(rect) length:sizeof(rect)
options:MTLResourceStorageModeShared]; options:MTLResourceStorageModeShared];
static const bool default_mix_value = false; static const GB_frame_blending_mode_t default_blending_mode = GB_FRAME_BLENDING_MODE_DISABLED;
mix_previous_buffer = [device newBufferWithBytes:&default_mix_value frame_blending_mode_buffer = [device newBufferWithBytes:&default_blending_mode
length:sizeof(default_mix_value) length:sizeof(default_blending_mode)
options:MTLResourceStorageModeShared]; options:MTLResourceStorageModeShared];
output_resolution_buffer = [device newBufferWithBytes:&output_resolution output_resolution_buffer = [device newBufferWithBytes:&output_resolution
length:sizeof(output_resolution) length:sizeof(output_resolution)
@ -147,7 +149,7 @@ static const vector_float2 rect[] =
mipmapLevel:0 mipmapLevel:0
withBytes:[self currentBuffer] withBytes:[self currentBuffer]
bytesPerRow:texture.width * 4]; bytesPerRow:texture.width * 4];
if ([self shouldBlendFrameWithPrevious]) { if ([self frameBlendingMode]) {
[previous_texture replaceRegion:region [previous_texture replaceRegion:region
mipmapLevel:0 mipmapLevel:0
withBytes:[self previousBuffer] withBytes:[self previousBuffer]
@ -157,9 +159,8 @@ static const vector_float2 rect[] =
MTLRenderPassDescriptor *render_pass_descriptor = view.currentRenderPassDescriptor; MTLRenderPassDescriptor *render_pass_descriptor = view.currentRenderPassDescriptor;
id<MTLCommandBuffer> command_buffer = [command_queue commandBuffer]; id<MTLCommandBuffer> command_buffer = [command_queue commandBuffer];
if(render_pass_descriptor != nil) if (render_pass_descriptor != nil) {
{ *(GB_frame_blending_mode_t *)[frame_blending_mode_buffer contents] = [self frameBlendingMode];
*(bool *)[mix_previous_buffer contents] = [self shouldBlendFrameWithPrevious];
*(vector_float2 *)[output_resolution_buffer contents] = output_resolution; *(vector_float2 *)[output_resolution_buffer contents] = output_resolution;
id<MTLRenderCommandEncoder> render_encoder = id<MTLRenderCommandEncoder> render_encoder =
@ -176,7 +177,7 @@ static const vector_float2 rect[] =
offset:0 offset:0
atIndex:0]; atIndex:0];
[render_encoder setFragmentBuffer:mix_previous_buffer [render_encoder setFragmentBuffer:frame_blending_mode_buffer
offset:0 offset:0
atIndex:0]; atIndex:0];

View File

@ -16,7 +16,7 @@
<key>CFBundleTypeIconFile</key> <key>CFBundleTypeIconFile</key>
<string>Cartridge</string> <string>Cartridge</string>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>GameBoy Game</string> <string>Game Boy Game</string>
<key>CFBundleTypeRole</key> <key>CFBundleTypeRole</key>
<string>Viewer</string> <string>Viewer</string>
<key>LSItemContentTypes</key> <key>LSItemContentTypes</key>
@ -36,7 +36,7 @@
<key>CFBundleTypeIconFile</key> <key>CFBundleTypeIconFile</key>
<string>ColorCartridge</string> <string>ColorCartridge</string>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>GameBoy Color Game</string> <string>Game Boy Color Game</string>
<key>CFBundleTypeRole</key> <key>CFBundleTypeRole</key>
<string>Viewer</string> <string>Viewer</string>
<key>LSItemContentTypes</key> <key>LSItemContentTypes</key>
@ -48,6 +48,26 @@
<key>NSDocumentClass</key> <key>NSDocumentClass</key>
<string>Document</string> <string>Document</string>
</dict> </dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gbc</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>ColorCartridge</string>
<key>CFBundleTypeName</key>
<string>Game Boy ISX File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.github.liji32.sameboy.isx</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>Document</string>
</dict>
</array> </array>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>SameBoy</string> <string>SameBoy</string>
@ -85,7 +105,7 @@
<string>public.data</string> <string>public.data</string>
</array> </array>
<key>UTTypeDescription</key> <key>UTTypeDescription</key>
<string>GameBoy Game</string> <string>Game Boy Game</string>
<key>UTTypeIconFile</key> <key>UTTypeIconFile</key>
<string>Cartridge</string> <string>Cartridge</string>
<key>UTTypeIdentifier</key> <key>UTTypeIdentifier</key>
@ -104,7 +124,7 @@
<string>public.data</string> <string>public.data</string>
</array> </array>
<key>UTTypeDescription</key> <key>UTTypeDescription</key>
<string>GameBoy Color Game</string> <string>Game Boy Color Game</string>
<key>UTTypeIconFile</key> <key>UTTypeIconFile</key>
<string>ColorCartridge</string> <string>ColorCartridge</string>
<key>UTTypeIdentifier</key> <key>UTTypeIdentifier</key>
@ -117,6 +137,25 @@
</array> </array>
</dict> </dict>
</dict> </dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Game Boy ISX File</string>
<key>UTTypeIconFile</key>
<string>ColorCartridge</string>
<key>UTTypeIdentifier</key>
<string>com.github.liji32.sameboy.isx</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>isx</string>
</array>
</dict>
</dict>
</array> </array>
<key>NSCameraUsageDescription</key> <key>NSCameraUsageDescription</key>
<string>SameBoy needs to access your camera to emulate the Game Boy Camera</string> <string>SameBoy needs to access your camera to emulate the Game Boy Camera</string>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@ -342,11 +342,22 @@
<action selector="mute:" target="-1" id="YE5-mi-Yzd"/> <action selector="mute:" target="-1" id="YE5-mi-Yzd"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="YIZ-pz-N4V"/> </items>
<menuItem title="Blend Frames" id="AWj-r8-L6U"> </menu>
</menuItem>
<menuItem title="Cheats" id="8ld-Ad-nvc">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Cheats" id="Ucc-Hm-TVA">
<items>
<menuItem title="Enable Cheats" keyEquivalent="C" id="vtx-LG-v6y">
<connections>
<action selector="toggleCheats:" target="-1" id="gsw-UY-fhu"/>
</connections>
</menuItem>
<menuItem title="Show Cheats" id="LZV-QK-YXi">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="toggleBlend:" target="-1" id="TjO-ce-UxL"/> <action selector="showCheats:" target="-1" id="tfr-qM-q8X"/>
</connections> </connections>
</menuItem> </menuItem>
</items> </items>
@ -371,9 +382,9 @@
</items> </items>
</menu> </menu>
</menuItem> </menuItem>
<menuItem title="Developer" id="IwX-DJ-dBk"> <menuItem title="Develop" id="IwX-DJ-dBk">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Developer" id="UVb-cc-at0"> <menu key="submenu" title="Develop" id="UVb-cc-at0">
<items> <items>
<menuItem title="Developer Mode" id="Qx6-Tt-zZR"> <menuItem title="Developer Mode" id="Qx6-Tt-zZR">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
@ -454,6 +465,7 @@
</menu> </menu>
</menuItem> </menuItem>
</items> </items>
<point key="canvasLocation" x="140" y="260"/>
</menu> </menu>
</objects> </objects>
</document> </document>

View File

@ -0,0 +1,7 @@
#import <AppKit/AppKit.h>
@implementation NSObject (MavericksCompat)
- (instancetype)initWithCoder:(NSCoder *)coder
{
return [self init];
}
@end

View File

@ -64,10 +64,13 @@
<outlet property="bootROMsFolderItem" destination="Dzv-Gc-zoL" id="yhV-ZI-avD"/> <outlet property="bootROMsFolderItem" destination="Dzv-Gc-zoL" id="yhV-ZI-avD"/>
<outlet property="cgbPopupButton" destination="dlD-sk-SHO" id="4tg-SR-e17"/> <outlet property="cgbPopupButton" destination="dlD-sk-SHO" id="4tg-SR-e17"/>
<outlet property="colorCorrectionPopupButton" destination="VEz-N4-uP6" id="EO2-Vt-JFJ"/> <outlet property="colorCorrectionPopupButton" destination="VEz-N4-uP6" id="EO2-Vt-JFJ"/>
<outlet property="colorPalettePopupButton" destination="Iwr-eI-SD1" id="Xzc-RZ-JtV"/>
<outlet property="configureJoypadButton" destination="Qa7-Z7-yfO" id="RaX-P3-oCX"/> <outlet property="configureJoypadButton" destination="Qa7-Z7-yfO" id="RaX-P3-oCX"/>
<outlet property="controlsTableView" destination="UDd-IJ-fxX" id="a1D-Md-yXv"/> <outlet property="controlsTableView" destination="UDd-IJ-fxX" id="a1D-Md-yXv"/>
<outlet property="delegate" destination="-2" id="ASc-vN-Zbq"/> <outlet property="delegate" destination="-2" id="ASc-vN-Zbq"/>
<outlet property="displayBorderPopupButton" destination="R9D-FV-bpd" id="VfO-b4-gqH"/>
<outlet property="dmgPopupButton" destination="LFw-Uk-cPR" id="KDw-i2-k4u"/> <outlet property="dmgPopupButton" destination="LFw-Uk-cPR" id="KDw-i2-k4u"/>
<outlet property="frameBlendingModePopupButton" destination="lxk-db-Sxv" id="wzt-uo-TE6"/>
<outlet property="graphicsFilterPopupButton" destination="6pP-kK-EEC" id="LS7-HY-kHC"/> <outlet property="graphicsFilterPopupButton" destination="6pP-kK-EEC" id="LS7-HY-kHC"/>
<outlet property="highpassFilterPopupButton" destination="T69-6N-dhT" id="0p6-4m-hb1"/> <outlet property="highpassFilterPopupButton" destination="T69-6N-dhT" id="0p6-4m-hb1"/>
<outlet property="playerListButton" destination="gWx-7h-0xq" id="zo6-82-JId"/> <outlet property="playerListButton" destination="gWx-7h-0xq" id="zo6-82-JId"/>
@ -79,33 +82,34 @@
<point key="canvasLocation" x="183" y="354"/> <point key="canvasLocation" x="183" y="354"/>
</window> </window>
<customView id="sRK-wO-K6R"> <customView id="sRK-wO-K6R">
<rect key="frame" x="0.0" y="0.0" width="292" height="166"/> <rect key="frame" x="0.0" y="0.0" width="292" height="323"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T91-rh-rRp"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T91-rh-rRp">
<rect key="frame" x="18" y="129" width="256" height="17"/> <rect key="frame" x="18" y="286" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Graphics Filter:" id="pXg-WY-8Q5"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Graphics filter:" id="pXg-WY-8Q5">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6pP-kK-EEC"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6pP-kK-EEC">
<rect key="frame" x="30" y="97" width="234" height="26"/> <rect key="frame" x="30" y="254" width="234" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Nearest Neighbor (Pixelated)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="neN-eo-LA7" id="I1w-05-lGl"> <popUpButtonCell key="cell" type="push" title="Nearest neighbor (Pixelated)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="neN-eo-LA7" id="I1w-05-lGl">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/> <font key="font" metaFont="menu"/>
<menu key="menu" id="xDC-0T-Qg9"> <menu key="menu" id="xDC-0T-Qg9">
<items> <items>
<menuItem title="Nearest Neighbor (Pixelated)" state="on" id="neN-eo-LA7"> <menuItem title="Nearest neighbor (Pixelated)" state="on" id="neN-eo-LA7">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
</menuItem> </menuItem>
<menuItem title="Bilinear (Blurry)" id="iDe-si-atu"/> <menuItem title="Bilinear (Blurry)" id="iDe-si-atu"/>
<menuItem title="Smooth Bilinear (Less blurry)" id="1jN-pO-1iD"/> <menuItem title="Smooth bilinear (Less blurry)" id="1jN-pO-1iD"/>
<menuItem title="LCD Display" id="b8u-LZ-UQf"/> <menuItem title="Monochrome LCD display" id="b8u-LZ-UQf"/>
<menuItem title="CRT Display" id="FT9-FT-RZu"/> <menuItem title="LCD display" id="pj3-Jt-bNU"/>
<menuItem title="CRT display" id="FT9-FT-RZu"/>
<menuItem title="Scale2x" id="C1I-L2-Up1"/> <menuItem title="Scale2x" id="C1I-L2-Up1"/>
<menuItem title="Scale4x" id="uWA-Zp-JY9"/> <menuItem title="Scale4x" id="uWA-Zp-JY9"/>
<menuItem title="Anti-aliased Scale2x" id="iP6-DJ-CVH"/> <menuItem title="Anti-aliased Scale2x" id="iP6-DJ-CVH"/>
@ -128,16 +132,16 @@
</connections> </connections>
</popUpButton> </popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wc3-2K-6CD"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wc3-2K-6CD">
<rect key="frame" x="18" y="75" width="256" height="17"/> <rect key="frame" x="18" y="232" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Color Correction:" id="5Si-hz-EK3"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Color correction:" id="5Si-hz-EK3">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VEz-N4-uP6"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VEz-N4-uP6">
<rect key="frame" x="30" y="43" width="234" height="26"/> <rect key="frame" x="30" y="200" width="234" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="D2J-wV-1vu" id="fNJ-Fi-yOm"> <popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="D2J-wV-1vu" id="fNJ-Fi-yOm">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -147,9 +151,10 @@
<menuItem title="Disabled" state="on" id="D2J-wV-1vu"> <menuItem title="Disabled" state="on" id="D2J-wV-1vu">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
</menuItem> </menuItem>
<menuItem title="Correct Color Curves" id="B3Q-x1-VRl"/> <menuItem title="Correct color curves" id="B3Q-x1-VRl"/>
<menuItem title="Emulate Hardware" id="XBL-hS-7ke"/> <menuItem title="Emulate hardware" id="XBL-hS-7ke"/>
<menuItem title="Preserve Brightness" id="tlx-WB-Bkw"/> <menuItem title="Preserve brightness" id="tlx-WB-Bkw"/>
<menuItem title="Reduce contrast" id="wuO-Xv-0mQ"/>
</items> </items>
</menu> </menu>
</popUpButtonCell> </popUpButtonCell>
@ -157,10 +162,98 @@
<action selector="colorCorrectionChanged:" target="QvC-M9-y7g" id="Oq4-B5-nO6"/> <action selector="colorCorrectionChanged:" target="QvC-M9-y7g" id="Oq4-B5-nO6"/>
</connections> </connections>
</popUpButton> </popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MLC-Rx-FgO">
<rect key="frame" x="20" y="178" width="252" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Frame blending" id="UCa-EO-tzh">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lxk-db-Sxv">
<rect key="frame" x="32" y="149" width="229" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="iHP-Yz-fiH" id="aQ6-HN-7Aj">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="Q9L-qo-kF4">
<items>
<menuItem title="Disabled" state="on" id="iHP-Yz-fiH">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Simple" id="Hxy-jw-x6E"/>
<menuItem title="Accurate" id="Aaq-uy-Csa"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="franeBlendingModeChanged:" target="QvC-M9-y7g" id="kE1-pm-MIp"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8fG-zm-hpr">
<rect key="frame" x="18" y="122" width="252" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Color palette for monochrome models:" id="LAN-8Y-T7H">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Iwr-eI-SD1">
<rect key="frame" x="30" y="93" width="234" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Greyscale" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Ajr-5r-iIk" id="rEU-jh-m3j">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="dHJ-3R-Ora">
<items>
<menuItem title="Greyscale" state="on" id="Ajr-5r-iIk">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Lime (Game Boy)" id="snU-ht-fQq"/>
<menuItem title="Olive (Pocket)" id="MQi-yt-nsT"/>
<menuItem title="Teal (Light)" id="xlg-6i-Fhl"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="colorPaletteChanged:" target="QvC-M9-y7g" id="ui3-rg-PTs"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Kz-cf-5X6">
<rect key="frame" x="18" y="71" width="248" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Display border:" id="HZd-qi-yyk">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="R9D-FV-bpd">
<rect key="frame" x="30" y="39" width="234" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Never" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="heL-AV-0az" id="DY9-2D-h1L">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="Rgf-mF-K9q">
<items>
<menuItem title="Never" state="on" tag="1" id="heL-AV-0az">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Super Game Boy only" id="bBJ-Vn-5rk"/>
<menuItem title="Always" tag="2" id="JUs-gW-qcM"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="displayBorderChanged:" target="QvC-M9-y7g" id="GoA-BU-v3h"/>
</connections>
</popUpButton>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Vfj-tg-7OP"> <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Vfj-tg-7OP">
<rect key="frame" x="18" y="18" width="256" height="18"/> <rect key="frame" x="18" y="18" width="256" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Keep Aspect Ratio" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lsj-rC-Eo6"> <buttonCell key="cell" type="check" title="Keep aspect ratio" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lsj-rC-Eo6">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
@ -169,7 +262,7 @@
</connections> </connections>
</button> </button>
</subviews> </subviews>
<point key="canvasLocation" x="-176" y="589"/> <point key="canvasLocation" x="-176" y="667.5"/>
</customView> </customView>
<customView id="ymk-46-SX7"> <customView id="ymk-46-SX7">
<rect key="frame" x="0.0" y="0.0" width="292" height="320"/> <rect key="frame" x="0.0" y="0.0" width="292" height="320"/>
@ -202,7 +295,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w9w-yX-KxB"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w9w-yX-KxB">
<rect key="frame" x="18" y="225" width="256" height="17"/> <rect key="frame" x="18" y="225" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Rewinding Duration:" id="JaO-5h-ugl"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Rewinding duration:" id="JaO-5h-ugl">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@ -220,12 +313,12 @@
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wC4-aJ-mhQ"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wC4-aJ-mhQ">
<rect key="frame" x="30" y="251" width="234" height="26"/> <rect key="frame" x="30" y="251" width="234" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Use Built-in Boot ROMs" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Tnm-SR-ZEm" id="T3Y-Ln-Onl"> <popUpButtonCell key="cell" type="push" title="Use built-in boot ROMs" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Tnm-SR-ZEm" id="T3Y-Ln-Onl">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/> <font key="font" metaFont="menu"/>
<menu key="menu" id="edo-AN-gRh"> <menu key="menu" id="edo-AN-gRh">
<items> <items>
<menuItem title="Use Built-in Boot ROMs" state="on" id="Tnm-SR-ZEm"> <menuItem title="Use built-in boot ROMs" state="on" id="Tnm-SR-ZEm">
<connections> <connections>
<action selector="useBuiltinBootROMs:" target="QvC-M9-y7g" id="Kmo-wz-ZtB"/> <action selector="useBuiltinBootROMs:" target="QvC-M9-y7g" id="Kmo-wz-ZtB"/>
</connections> </connections>
@ -244,7 +337,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wg8-hJ-df9"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wg8-hJ-df9">
<rect key="frame" x="18" y="157" width="256" height="17"/> <rect key="frame" x="18" y="157" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy Revision:" id="GIA-ep-SBi"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy revision:" id="GIA-ep-SBi">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@ -272,7 +365,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MAq-1X-Gpo"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MAq-1X-Gpo">
<rect key="frame" x="18" y="49" width="256" height="17"/> <rect key="frame" x="18" y="49" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy Color Revision:" id="edD-t7-vwk"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Game Boy Color revision:" id="edD-t7-vwk">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@ -302,7 +395,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tAa-0A-0fP"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tAa-0A-0fP">
<rect key="frame" x="18" y="103" width="256" height="17"/> <rect key="frame" x="18" y="103" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Super Game Boy Model:" id="d0g-rk-FK0"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Super Game Boy model:" id="d0g-rk-FK0">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@ -340,16 +433,16 @@
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T69-6N-dhT"> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T69-6N-dhT">
<rect key="frame" x="30" y="17" width="233" height="26"/> <rect key="frame" x="30" y="17" width="233" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Disabled (Keep DC Offset)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Fgo-0S-zUG" id="om2-Bn-43B"> <popUpButtonCell key="cell" type="push" title="Disabled (Keep DC offset)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Fgo-0S-zUG" id="om2-Bn-43B">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/> <font key="font" metaFont="menu"/>
<menu key="menu" id="VCM-zy-2Dd"> <menu key="menu" id="VCM-zy-2Dd">
<items> <items>
<menuItem title="Disabled (Keep DC Offset)" state="on" id="Fgo-0S-zUG"> <menuItem title="Disabled (Keep DC offset)" state="on" id="Fgo-0S-zUG">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
</menuItem> </menuItem>
<menuItem title="Accurate (Emulate Hardware)" id="82j-Vv-nE6"/> <menuItem title="Accurate (Emulate hardware)" id="82j-Vv-nE6"/>
<menuItem title="Preserve Waveform" id="iUF-c2-fgt"/> <menuItem title="Preserve waveform" id="iUF-c2-fgt"/>
</items> </items>
</menu> </menu>
</popUpButtonCell> </popUpButtonCell>
@ -360,7 +453,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WU3-oV-KHO"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WU3-oV-KHO">
<rect key="frame" x="18" y="49" width="256" height="17"/> <rect key="frame" x="18" y="49" width="256" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="High-pass Filter:" id="YLF-RL-b2D"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="High-pass filter:" id="YLF-RL-b2D">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>

View File

@ -139,7 +139,7 @@ static double smooth(double x)
static void render(GB_gameboy_t *gb) static void render(GB_gameboy_t *gb)
{ {
GB_sample_t output = {0,0}; GB_sample_t output = {0, 0};
UNROLL UNROLL
for (unsigned i = 0; i < GB_N_CHANNELS; i++) { for (unsigned i = 0; i < GB_N_CHANNELS; i++) {
@ -230,13 +230,13 @@ static void render(GB_gameboy_t *gb)
gb->apu_output.sample_callback(gb, &filtered_output); gb->apu_output.sample_callback(gb, &filtered_output);
} }
static uint16_t new_sweep_sample_legnth(GB_gameboy_t *gb) static uint16_t new_sweep_sample_length(GB_gameboy_t *gb)
{ {
uint16_t delta = gb->apu.shadow_sweep_sample_legnth >> (gb->io_registers[GB_IO_NR10] & 7); uint16_t delta = gb->apu.shadow_sweep_sample_length >> (gb->io_registers[GB_IO_NR10] & 7);
if (gb->io_registers[GB_IO_NR10] & 8) { if (gb->io_registers[GB_IO_NR10] & 8) {
return gb->apu.shadow_sweep_sample_legnth - delta; return gb->apu.shadow_sweep_sample_length - delta;
} }
return gb->apu.shadow_sweep_sample_legnth + delta; return gb->apu.shadow_sweep_sample_length + delta;
} }
static void update_square_sample(GB_gameboy_t *gb, unsigned index) static void update_square_sample(GB_gameboy_t *gb, unsigned index)
@ -329,11 +329,16 @@ static void tick_noise_envelope(GB_gameboy_t *gb)
void GB_apu_div_event(GB_gameboy_t *gb) void GB_apu_div_event(GB_gameboy_t *gb)
{ {
if (!gb->apu.global_enable) return; if (!gb->apu.global_enable) return;
if (gb->apu.skip_div_event) { if (gb->apu.skip_div_event == GB_SKIP_DIV_EVENT_SKIP) {
gb->apu.skip_div_event = false; gb->apu.skip_div_event = GB_SKIP_DIV_EVENT_SKIPPED;
return; return;
} }
gb->apu.div_divider++; if (gb->apu.skip_div_event == GB_SKIP_DIV_EVENT_SKIPPED) {
gb->apu.skip_div_event = GB_SKIP_DIV_EVENT_INACTIVE;
}
else {
gb->apu.div_divider++;
}
if ((gb->apu.div_divider & 1) == 0) { if ((gb->apu.div_divider & 1) == 0) {
for (unsigned i = GB_SQUARE_2 + 1; i--;) { for (unsigned i = GB_SQUARE_2 + 1; i--;) {
@ -395,8 +400,8 @@ void GB_apu_div_event(GB_gameboy_t *gb)
if (!--gb->apu.square_sweep_countdown) { if (!--gb->apu.square_sweep_countdown) {
if ((gb->io_registers[GB_IO_NR10] & 0x70) && (gb->io_registers[GB_IO_NR10] & 0x07)) { if ((gb->io_registers[GB_IO_NR10] & 0x70) && (gb->io_registers[GB_IO_NR10] & 0x07)) {
gb->apu.square_channels[GB_SQUARE_1].sample_length = gb->apu.square_channels[GB_SQUARE_1].sample_length =
gb->apu.shadow_sweep_sample_legnth = gb->apu.shadow_sweep_sample_length =
gb->apu.new_sweep_sample_legnth; gb->apu.new_sweep_sample_length;
} }
if (gb->io_registers[GB_IO_NR10] & 0x70) { if (gb->io_registers[GB_IO_NR10] & 0x70) {
@ -430,8 +435,8 @@ void GB_apu_run(GB_gameboy_t *gb)
} }
else { else {
/* APU bug: sweep frequency is checked after adding the sweep delta twice */ /* APU bug: sweep frequency is checked after adding the sweep delta twice */
gb->apu.new_sweep_sample_legnth = new_sweep_sample_legnth(gb); gb->apu.new_sweep_sample_length = new_sweep_sample_length(gb);
if (gb->apu.new_sweep_sample_legnth > 0x7ff) { if (gb->apu.new_sweep_sample_length > 0x7ff) {
gb->apu.is_active[GB_SQUARE_1] = false; gb->apu.is_active[GB_SQUARE_1] = false;
update_sample(gb, GB_SQUARE_1, 0, gb->apu.square_sweep_calculate_countdown - cycles); update_sample(gb, GB_SQUARE_1, 0, gb->apu.square_sweep_calculate_countdown - cycles);
gb->apu.sweep_enabled = false; gb->apu.sweep_enabled = false;
@ -534,7 +539,8 @@ void GB_apu_init(GB_gameboy_t *gb)
/* APU glitch: When turning the APU on while DIV's bit 4 (or 5 in double speed mode) is on, /* APU glitch: When turning the APU on while DIV's bit 4 (or 5 in double speed mode) is on,
the first DIV/APU event is skipped. */ the first DIV/APU event is skipped. */
if (gb->div_counter & (gb->cgb_double_speed? 0x2000 : 0x1000)) { if (gb->div_counter & (gb->cgb_double_speed? 0x2000 : 0x1000)) {
gb->apu.skip_div_event = true; gb->apu.skip_div_event = GB_SKIP_DIV_EVENT_SKIP;
gb->apu.div_divider = 1;
} }
} }
@ -542,7 +548,7 @@ uint8_t GB_apu_read(GB_gameboy_t *gb, uint8_t reg)
{ {
if (reg == GB_IO_NR52) { if (reg == GB_IO_NR52) {
uint8_t value = 0; uint8_t value = 0;
for (int i = 0; i < GB_N_CHANNELS; i++) { for (unsigned i = 0; i < GB_N_CHANNELS; i++) {
value >>= 1; value >>= 1;
if (gb->apu.is_active[i]) { if (gb->apu.is_active[i]) {
value |= 0x8; value |= 0x8;
@ -718,8 +724,8 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
gb->apu.square_channels[index].sample_length &= 0xFF; gb->apu.square_channels[index].sample_length &= 0xFF;
gb->apu.square_channels[index].sample_length |= (value & 7) << 8; gb->apu.square_channels[index].sample_length |= (value & 7) << 8;
if (index == GB_SQUARE_1) { if (index == GB_SQUARE_1) {
gb->apu.shadow_sweep_sample_legnth = gb->apu.shadow_sweep_sample_length =
gb->apu.new_sweep_sample_legnth = gb->apu.new_sweep_sample_length =
gb->apu.square_channels[0].sample_length; gb->apu.square_channels[0].sample_length;
} }
if (value & 0x80) { if (value & 0x80) {
@ -901,7 +907,7 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
gb->apu.is_active[GB_NOISE] = false; gb->apu.is_active[GB_NOISE] = false;
update_sample(gb, GB_NOISE, 0, 0); update_sample(gb, GB_NOISE, 0, 0);
} }
else if (gb->apu.is_active[GB_NOISE]){ else if (gb->apu.is_active[GB_NOISE]) {
nrx2_glitch(&gb->apu.noise_channel.current_volume, value, gb->io_registers[reg]); nrx2_glitch(&gb->apu.noise_channel.current_volume, value, gb->io_registers[reg]);
update_sample(gb, GB_NOISE, update_sample(gb, GB_NOISE,
gb->apu.current_lfsr_sample ? gb->apu.current_lfsr_sample ?

View File

@ -64,8 +64,8 @@ typedef struct
uint8_t square_sweep_countdown; // In 128Hz uint8_t square_sweep_countdown; // In 128Hz
uint8_t square_sweep_calculate_countdown; // In 2 MHz uint8_t square_sweep_calculate_countdown; // In 2 MHz
uint16_t new_sweep_sample_legnth; uint16_t new_sweep_sample_length;
uint16_t shadow_sweep_sample_legnth; uint16_t shadow_sweep_sample_length;
bool sweep_enabled; bool sweep_enabled;
bool sweep_decreasing; bool sweep_decreasing;
@ -114,7 +114,10 @@ typedef struct
} noise_channel; } noise_channel;
bool skip_div_event; #define GB_SKIP_DIV_EVENT_INACTIVE 0
#define GB_SKIP_DIV_EVENT_SKIPPED 1
#define GB_SKIP_DIV_EVENT_SKIP 2
uint8_t skip_div_event;
bool current_lfsr_sample; bool current_lfsr_sample;
} GB_apu_t; } GB_apu_t;
@ -159,6 +162,7 @@ void GB_apu_div_event(GB_gameboy_t *gb);
void GB_apu_init(GB_gameboy_t *gb); void GB_apu_init(GB_gameboy_t *gb);
void GB_apu_run(GB_gameboy_t *gb); void GB_apu_run(GB_gameboy_t *gb);
void GB_apu_update_cycles_per_sample(GB_gameboy_t *gb); void GB_apu_update_cycles_per_sample(GB_gameboy_t *gb);
void GB_borrow_sgb_border(GB_gameboy_t *gb);
#endif #endif
#endif /* apu_h */ #endif /* apu_h */

View File

@ -1,17 +1,17 @@
#include "gb.h" #include "gb.h"
static int noise_seed = 0; static signed noise_seed = 0;
/* This is not a complete emulation of the camera chip. Only the features used by the GameBoy Camera ROMs are supported. /* This is not a complete emulation of the camera chip. Only the features used by the GameBoy Camera ROMs are supported.
We also do not emulate the timing of the real cart, as it might be actually faster than the webcam. */ We also do not emulate the timing of the real cart, as it might be actually faster than the webcam. */
static uint8_t generate_noise(uint8_t x, uint8_t y) static uint8_t generate_noise(uint8_t x, uint8_t y)
{ {
int value = (x + y * 128 + noise_seed); signed value = (x + y * 128 + noise_seed);
uint8_t *data = (uint8_t *) &value; uint8_t *data = (uint8_t *) &value;
unsigned hash = 0; unsigned hash = 0;
while ((int *) data != &value + 1) { while ((signed *) data != &value + 1) {
hash ^= (*data << 8); hash ^= (*data << 8);
if (hash & 0x8000) { if (hash & 0x8000) {
hash ^= 0x8a00; hash ^= 0x8a00;

316
Core/cheats.c Normal file
View File

@ -0,0 +1,316 @@
#include "gb.h"
#include "cheats.h"
#include <stdio.h>
#include <assert.h>
#include <errno.h>
static inline uint8_t hash_addr(uint16_t addr)
{
return addr;
}
static uint16_t bank_for_addr(GB_gameboy_t *gb, uint16_t addr)
{
if (addr < 0x4000) {
return gb->mbc_rom0_bank;
}
if (addr < 0x8000) {
return gb->mbc_rom_bank;
}
if (addr < 0xD000) {
return 0;
}
if (addr < 0xE000) {
return gb->cgb_ram_bank;
}
return 0;
}
void GB_apply_cheat(GB_gameboy_t *gb, uint16_t address, uint8_t *value)
{
if (!gb->cheat_enabled) return;
if (!gb->boot_rom_finished) return;
const GB_cheat_hash_t *hash = gb->cheat_hash[hash_addr(address)];
if (hash) {
for (unsigned i = 0; i < hash->size; i++) {
GB_cheat_t *cheat = hash->cheats[i];
if (cheat->address == address && cheat->enabled && (!cheat->use_old_value || cheat->old_value == *value)) {
if (cheat->bank == GB_CHEAT_ANY_BANK || cheat->bank == bank_for_addr(gb, address)) {
*value = cheat->value;
break;
}
}
}
}
}
bool GB_cheats_enabled(GB_gameboy_t *gb)
{
return gb->cheat_enabled;
}
void GB_set_cheats_enabled(GB_gameboy_t *gb, bool enabled)
{
gb->cheat_enabled = enabled;
}
void GB_add_cheat(GB_gameboy_t *gb, const char *description, uint16_t address, uint16_t bank, uint8_t value, uint8_t old_value, bool use_old_value, bool enabled)
{
GB_cheat_t *cheat = malloc(sizeof(*cheat));
cheat->address = address;
cheat->bank = bank;
cheat->value = value;
cheat->old_value = old_value;
cheat->use_old_value = use_old_value;
cheat->enabled = enabled;
strncpy(cheat->description, description, sizeof(cheat->description));
cheat->description[sizeof(cheat->description) - 1] = 0;
gb->cheats = realloc(gb->cheats, (++gb->cheat_count) * sizeof(*cheat));
gb->cheats[gb->cheat_count - 1] = cheat;
GB_cheat_hash_t **hash = &gb->cheat_hash[hash_addr(address)];
if (!*hash) {
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat));
(*hash)->size = 1;
(*hash)->cheats[0] = cheat;
}
else {
(*hash)->size++;
*hash = realloc(*hash, sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
(*hash)->cheats[(*hash)->size - 1] = cheat;
}
}
const GB_cheat_t *const *GB_get_cheats(GB_gameboy_t *gb, size_t *size)
{
*size = gb->cheat_count;
return (void *)gb->cheats;
}
void GB_remove_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat)
{
for (unsigned i = 0; i < gb->cheat_count; i++) {
if (gb->cheats[i] == cheat) {
gb->cheats[i] = gb->cheats[--gb->cheat_count];
if (gb->cheat_count == 0) {
free(gb->cheats);
gb->cheats = NULL;
}
else {
gb->cheats = realloc(gb->cheats, gb->cheat_count * sizeof(*cheat));
}
break;
}
}
GB_cheat_hash_t **hash = &gb->cheat_hash[hash_addr(cheat->address)];
for (unsigned i = 0; i < (*hash)->size; i++) {
if ((*hash)->cheats[i] == cheat) {
(*hash)->cheats[i] = (*hash)->cheats[(*hash)->size--];
if ((*hash)->size == 0) {
free(*hash);
*hash = NULL;
}
else {
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
}
break;
}
}
free((void *)cheat);
}
bool GB_import_cheat(GB_gameboy_t *gb, const char *cheat, const char *description, bool enabled)
{
uint8_t dummy;
/* GameShark */
{
uint8_t bank;
uint8_t value;
uint16_t address;
if (sscanf(cheat, "%02hhx%02hhx%04hx%c", &bank, &value, &address, &dummy) == 3) {
if (address > 0x7FFF) {
return false;
}
if (bank >= 0x80) {
bank &= 0xF;
}
GB_add_cheat(gb, description, address, bank, value, 0, false, enabled);
return true;
}
}
/* GameGnie */
{
char stripped_cheat[10] = {0,};
for (unsigned i = 0; i < 9 && *cheat; i++) {
stripped_cheat[i] = *(cheat++);
while (*cheat == '-') {
cheat++;
}
}
// Delete the 7th character;
stripped_cheat[7] = stripped_cheat[8];
stripped_cheat[8] = 0;
uint8_t old_value;
uint8_t value;
uint16_t address;
if (sscanf(stripped_cheat, "%02hhx%04hx%02hhx%c", &value, &address, &old_value, &dummy) == 3) {
address = (uint16_t)(address >> 4) | (uint16_t)(address << 12);
address ^= 0xF000;
if (address > 0x7FFF) {
return false;
}
old_value = (uint8_t)(old_value >> 2) | (uint8_t)(old_value << 6);
old_value ^= 0xBA;
GB_add_cheat(gb, description, address, GB_CHEAT_ANY_BANK, value, old_value, true, enabled);
return true;
}
if (sscanf(stripped_cheat, "%02hhx%04hx%c", &value, &address, &dummy) == 2) {
address = (uint16_t)(address >> 4) | (uint16_t)(address << 12);
address ^= 0xF000;
if (address > 0x7FFF) {
return false;
}
GB_add_cheat(gb, description, address, GB_CHEAT_ANY_BANK, value, false, true, enabled);
return true;
}
}
return false;
}
void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *_cheat, const char *description, uint16_t address, uint16_t bank, uint8_t value, uint8_t old_value, bool use_old_value, bool enabled)
{
GB_cheat_t *cheat = NULL;
for (unsigned i = 0; i < gb->cheat_count; i++) {
if (gb->cheats[i] == _cheat) {
cheat = gb->cheats[i];
break;
}
}
assert(cheat);
if (cheat->address != address) {
/* Remove from old bucket */
GB_cheat_hash_t **hash = &gb->cheat_hash[hash_addr(cheat->address)];
for (unsigned i = 0; i < (*hash)->size; i++) {
if ((*hash)->cheats[i] == cheat) {
(*hash)->cheats[i] = (*hash)->cheats[(*hash)->size--];
if ((*hash)->size == 0) {
free(*hash);
*hash = NULL;
}
else {
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
}
break;
}
}
cheat->address = address;
/* Add to new bucket */
hash = &gb->cheat_hash[hash_addr(address)];
if (!*hash) {
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat));
(*hash)->size = 1;
(*hash)->cheats[0] = cheat;
}
else {
(*hash)->size++;
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
(*hash)->cheats[(*hash)->size - 1] = cheat;
}
}
cheat->bank = bank;
cheat->value = value;
cheat->old_value = old_value;
cheat->use_old_value = use_old_value;
cheat->enabled = enabled;
if (description != cheat->description) {
strncpy(cheat->description, description, sizeof(cheat->description));
cheat->description[sizeof(cheat->description) - 1] = 0;
}
}
#define CHEAT_MAGIC 'SBCh'
void GB_load_cheats(GB_gameboy_t *gb, const char *path)
{
FILE *f = fopen(path, "rb");
if (!f) {
return;
}
uint32_t magic = 0;
uint32_t struct_size = 0;
fread(&magic, sizeof(magic), 1, f);
fread(&struct_size, sizeof(struct_size), 1, f);
if (magic != CHEAT_MAGIC && magic != __builtin_bswap32(CHEAT_MAGIC)) {
GB_log(gb, "The file is not a SameBoy cheat database");
return;
}
if (struct_size != sizeof(GB_cheat_t)) {
GB_log(gb, "This cheat database is not compatible with this version of SameBoy");
return;
}
// Remove all cheats first
while (gb->cheats) {
GB_remove_cheat(gb, gb->cheats[0]);
}
GB_cheat_t cheat;
while (fread(&cheat, sizeof(cheat), 1, f)) {
if (magic == __builtin_bswap32(CHEAT_MAGIC)) {
cheat.address = __builtin_bswap16(cheat.address);
cheat.bank = __builtin_bswap16(cheat.bank);
}
cheat.description[sizeof(cheat.description) - 1] = 0;
GB_add_cheat(gb, cheat.description, cheat.address, cheat.bank, cheat.value, cheat.old_value, cheat.use_old_value, cheat.enabled);
}
return;
}
int GB_save_cheats(GB_gameboy_t *gb, const char *path)
{
if (!gb->cheat_count) return 0; // Nothing to save.
FILE *f = fopen(path, "wb");
if (!f) {
GB_log(gb, "Could not dump cheat database: %s.\n", strerror(errno));
return errno;
}
uint32_t magic = CHEAT_MAGIC;
uint32_t struct_size = sizeof(GB_cheat_t);
if (fwrite(&magic, sizeof(magic), 1, f) != 1) {
fclose(f);
return EIO;
}
if (fwrite(&struct_size, sizeof(struct_size), 1, f) != 1) {
fclose(f);
return EIO;
}
for (size_t i = 0; i <gb->cheat_count; i++) {
if (fwrite(gb->cheats[i], sizeof(*gb->cheats[i]), 1, f) != 1) {
fclose(f);
return EIO;
}
}
errno = 0;
fclose(f);
return errno;
}

42
Core/cheats.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef cheats_h
#define cheats_h
#include "gb_struct_def.h"
#define GB_CHEAT_ANY_BANK 0xFFFF
typedef struct GB_cheat_s GB_cheat_t;
void GB_add_cheat(GB_gameboy_t *gb, const char *description, uint16_t address, uint16_t bank, uint8_t value, uint8_t old_value, bool use_old_value, bool enabled);
void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat, const char *description, uint16_t address, uint16_t bank, uint8_t value, uint8_t old_value, bool use_old_value, bool enabled);
bool GB_import_cheat(GB_gameboy_t *gb, const char *cheat, const char *description, bool enabled);
const GB_cheat_t *const *GB_get_cheats(GB_gameboy_t *gb, size_t *size);
void GB_remove_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat);
bool GB_cheats_enabled(GB_gameboy_t *gb);
void GB_set_cheats_enabled(GB_gameboy_t *gb, bool enabled);
void GB_load_cheats(GB_gameboy_t *gb, const char *path);
int GB_save_cheats(GB_gameboy_t *gb, const char *path);
#ifdef GB_INTERNAL
#ifdef GB_DISABLE_CHEATS
#define GB_apply_cheat(...)
#else
void GB_apply_cheat(GB_gameboy_t *gb, uint16_t address, uint8_t *value);
#endif
#endif
typedef struct {
size_t size;
GB_cheat_t *cheats[];
} GB_cheat_hash_t;
struct GB_cheat_s {
uint16_t address;
uint16_t bank;
uint8_t value;
uint8_t old_value;
bool use_old_value;
bool enabled;
char description[128];
};
#endif

View File

@ -220,7 +220,8 @@ static value_t read_lvalue(GB_gameboy_t *gb, lvalue_t lvalue)
banking_state_t state; banking_state_t state;
save_banking_state(gb, &state); save_banking_state(gb, &state);
switch_banking_state(gb, lvalue.memory_address.bank); switch_banking_state(gb, lvalue.memory_address.bank);
value_t r = VALUE_16(GB_read_memory(gb, lvalue.memory_address.value)); value_t r = VALUE_16(GB_read_memory(gb, lvalue.memory_address.value) |
(GB_read_memory(gb, lvalue.memory_address.value + 1) * 0x100));
restore_banking_state(gb, &state); restore_banking_state(gb, &state);
return r; return r;
} }
@ -261,6 +262,7 @@ static void write_lvalue(GB_gameboy_t *gb, lvalue_t lvalue, uint16_t value)
save_banking_state(gb, &state); save_banking_state(gb, &state);
switch_banking_state(gb, lvalue.memory_address.bank); switch_banking_state(gb, lvalue.memory_address.bank);
GB_write_memory(gb, lvalue.memory_address.value, value); GB_write_memory(gb, lvalue.memory_address.value, value);
GB_write_memory(gb, lvalue.memory_address.value + 1, value >> 8);
restore_banking_state(gb, &state); restore_banking_state(gb, &state);
return; return;
} }
@ -296,13 +298,15 @@ static void write_lvalue(GB_gameboy_t *gb, lvalue_t lvalue, uint16_t value)
static value_t add(value_t a, value_t b) {return FIX_BANK(a.value + b.value);} static value_t add(value_t a, value_t b) {return FIX_BANK(a.value + b.value);}
static value_t sub(value_t a, value_t b) {return FIX_BANK(a.value - b.value);} static value_t sub(value_t a, value_t b) {return FIX_BANK(a.value - b.value);}
static value_t mul(value_t a, value_t b) {return FIX_BANK(a.value * b.value);} static value_t mul(value_t a, value_t b) {return FIX_BANK(a.value * b.value);}
static value_t _div(value_t a, value_t b) { static value_t _div(value_t a, value_t b)
{
if (b.value == 0) { if (b.value == 0) {
return FIX_BANK(0); return FIX_BANK(0);
} }
return FIX_BANK(a.value / b.value); return FIX_BANK(a.value / b.value);
}; };
static value_t mod(value_t a, value_t b) { static value_t mod(value_t a, value_t b)
{
if (b.value == 0) { if (b.value == 0) {
return FIX_BANK(0); return FIX_BANK(0);
} }
@ -332,7 +336,7 @@ static value_t bank(value_t a, value_t b) {return (value_t) {true, a.value, b.va
static struct { static struct {
const char *string; const char *string;
char priority; int8_t priority;
value_t (*operator)(value_t, value_t); value_t (*operator)(value_t, value_t);
value_t (*lvalue_operator)(GB_gameboy_t *, lvalue_t, uint16_t); value_t (*lvalue_operator)(GB_gameboy_t *, lvalue_t, uint16_t);
} operators[] = } operators[] =
@ -350,15 +354,15 @@ static struct {
{"&", 1, and}, {"&", 1, and},
{"^", 1, xor}, {"^", 1, xor},
{"<<", 2, shleft}, {"<<", 2, shleft},
{"<=", -1, lower_equals}, {"<=", 3, lower_equals},
{"<", -1, lower}, {"<", 3, lower},
{">>", 2, shright}, {">>", 2, shright},
{">=", -1, greater_equals}, {">=", 3, greater_equals},
{">", -1, greater}, {">", 3, greater},
{"==", -1, equals}, {"==", 3, equals},
{"=", -2, NULL, assign}, {"=", -1, NULL, assign},
{"!=", -1, different}, {"!=", 3, different},
{":", 3, bank}, {":", 4, bank},
}; };
value_t debugger_evaluate(GB_gameboy_t *gb, const char *string, value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
@ -378,16 +382,15 @@ static lvalue_t debugger_evaluate_lvalue(GB_gameboy_t *gb, const char *string,
while (length && (string[length-1] == ' ' || string[length-1] == '\n' || string[length-1] == '\r' || string[length-1] == '\t')) { while (length && (string[length-1] == ' ' || string[length-1] == '\n' || string[length-1] == '\r' || string[length-1] == '\t')) {
length--; length--;
} }
if (length == 0) if (length == 0) {
{
GB_log(gb, "Expected expression.\n"); GB_log(gb, "Expected expression.\n");
*error = true; *error = true;
return (lvalue_t){0,}; return (lvalue_t){0,};
} }
if (string[0] == '(' && string[length - 1] == ')') { if (string[0] == '(' && string[length - 1] == ')') {
// Attempt to strip parentheses // Attempt to strip parentheses
signed int depth = 0; signed depth = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '(') depth++; if (string[i] == '(') depth++;
if (depth == 0) { if (depth == 0) {
// First and last are not matching // First and last are not matching
@ -400,8 +403,8 @@ static lvalue_t debugger_evaluate_lvalue(GB_gameboy_t *gb, const char *string,
} }
else if (string[0] == '[' && string[length - 1] == ']') { else if (string[0] == '[' && string[length - 1] == ']') {
// Attempt to strip square parentheses (memory dereference) // Attempt to strip square parentheses (memory dereference)
signed int depth = 0; signed depth = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '[') depth++; if (string[i] == '[') depth++;
if (depth == 0) { if (depth == 0) {
// First and last are not matching // First and last are not matching
@ -416,8 +419,8 @@ static lvalue_t debugger_evaluate_lvalue(GB_gameboy_t *gb, const char *string,
} }
else if (string[0] == '{' && string[length - 1] == '}') { else if (string[0] == '{' && string[length - 1] == '}') {
// Attempt to strip curly parentheses (memory dereference) // Attempt to strip curly parentheses (memory dereference)
signed int depth = 0; signed depth = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '{') depth++; if (string[i] == '{') depth++;
if (depth == 0) { if (depth == 0) {
// First and last are not matching // First and last are not matching
@ -485,16 +488,15 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
while (length && (string[length-1] == ' ' || string[length-1] == '\n' || string[length-1] == '\r' || string[length-1] == '\t')) { while (length && (string[length-1] == ' ' || string[length-1] == '\n' || string[length-1] == '\r' || string[length-1] == '\t')) {
length--; length--;
} }
if (length == 0) if (length == 0) {
{
GB_log(gb, "Expected expression.\n"); GB_log(gb, "Expected expression.\n");
*error = true; *error = true;
goto exit; goto exit;
} }
if (string[0] == '(' && string[length - 1] == ')') { if (string[0] == '(' && string[length - 1] == ')') {
// Attempt to strip parentheses // Attempt to strip parentheses
signed int depth = 0; signed depth = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '(') depth++; if (string[i] == '(') depth++;
if (depth == 0) { if (depth == 0) {
// First and last are not matching // First and last are not matching
@ -510,8 +512,8 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
} }
else if (string[0] == '[' && string[length - 1] == ']') { else if (string[0] == '[' && string[length - 1] == ']') {
// Attempt to strip square parentheses (memory dereference) // Attempt to strip square parentheses (memory dereference)
signed int depth = 0; signed depth = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '[') depth++; if (string[i] == '[') depth++;
if (depth == 0) { if (depth == 0) {
// First and last are not matching // First and last are not matching
@ -537,8 +539,8 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
} }
else if (string[0] == '{' && string[length - 1] == '}') { else if (string[0] == '{' && string[length - 1] == '}') {
// Attempt to strip curly parentheses (memory dereference) // Attempt to strip curly parentheses (memory dereference)
signed int depth = 0; signed depth = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '{') depth++; if (string[i] == '{') depth++;
if (depth == 0) { if (depth == 0) {
// First and last are not matching // First and last are not matching
@ -563,24 +565,24 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
} }
} }
// Search for lowest priority operator // Search for lowest priority operator
signed int depth = 0; signed depth = 0;
unsigned operator_index = -1; unsigned operator_index = -1;
unsigned operator_pos = 0; unsigned operator_pos = 0;
for (int i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
if (string[i] == '(') depth++; if (string[i] == '(') depth++;
else if (string[i] == ')') depth--; else if (string[i] == ')') depth--;
else if (string[i] == '[') depth++; else if (string[i] == '[') depth++;
else if (string[i] == ']') depth--; else if (string[i] == ']') depth--;
else if (depth == 0) { else if (depth == 0) {
for (int j = 0; j < sizeof(operators) / sizeof(operators[0]); j++) { for (unsigned j = 0; j < sizeof(operators) / sizeof(operators[0]); j++) {
if (strlen(operators[j].string) > length - i) continue; // Operator too big. unsigned operator_length = strlen(operators[j].string);
// Priority higher than what we already have. if (operator_length > length - i) continue; // Operator too long
unsigned long operator_length = strlen(operators[j].string);
if (memcmp(string + i, operators[j].string, operator_length) == 0) { if (memcmp(string + i, operators[j].string, operator_length) == 0) {
if (operator_index != -1 && operators[operator_index].priority < operators[j].priority) { if (operator_index != -1 && operators[operator_index].priority < operators[j].priority) {
/* for supporting = vs ==, etc*/ /* for supporting = vs ==, etc*/
i += operator_length - 1; i += operator_length - 1;
continue; break;
} }
// Found an operator! // Found an operator!
operator_pos = i; operator_pos = i;
@ -667,7 +669,7 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
} }
char *end; char *end;
int base = 10; unsigned base = 10;
if (string[0] == '$') { if (string[0] == '$') {
string++; string++;
base = 16; base = 16;
@ -816,16 +818,17 @@ static bool registers(GB_gameboy_t *gb, char *arguments, char *modifiers, const
} }
GB_log(gb, "AF = $%04x (%c%c%c%c)\n", gb->registers[GB_REGISTER_AF], /* AF can't really be an address */ GB_log(gb, "AF = $%04x (%c%c%c%c)\n", gb->registers[GB_REGISTER_AF], /* AF can't really be an address */
(gb->f & GB_CARRY_FLAG)? 'C' : '-', (gb->f & GB_CARRY_FLAG)? 'C' : '-',
(gb->f & GB_HALF_CARRY_FLAG)? 'H' : '-', (gb->f & GB_HALF_CARRY_FLAG)? 'H' : '-',
(gb->f & GB_SUBTRACT_FLAG)? 'N' : '-', (gb->f & GB_SUBTRACT_FLAG)? 'N' : '-',
(gb->f & GB_ZERO_FLAG)? 'Z' : '-'); (gb->f & GB_ZERO_FLAG)? 'Z' : '-');
GB_log(gb, "BC = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_BC], false)); GB_log(gb, "BC = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_BC], false));
GB_log(gb, "DE = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_DE], false)); GB_log(gb, "DE = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_DE], false));
GB_log(gb, "HL = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_HL], false)); GB_log(gb, "HL = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_HL], false));
GB_log(gb, "SP = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_SP], false)); GB_log(gb, "SP = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_SP], false));
GB_log(gb, "PC = %s\n", value_to_string(gb, gb->pc, false)); GB_log(gb, "PC = %s\n", value_to_string(gb, gb->pc, false));
GB_log(gb, "IME = %s\n", gb->ime? "Enabled" : "Disabled");
return true; return true;
} }
@ -838,8 +841,8 @@ static uint16_t find_breakpoint(GB_gameboy_t *gb, value_t addr)
uint32_t key = BP_KEY(addr); uint32_t key = BP_KEY(addr);
int min = 0; unsigned min = 0;
int max = gb->n_breakpoints; unsigned max = gb->n_breakpoints;
while (min < max) { while (min < max) {
uint16_t pivot = (min + max) / 2; uint16_t pivot = (min + max) / 2;
if (gb->breakpoints[pivot].key == key) return pivot; if (gb->breakpoints[pivot].key == key) return pivot;
@ -1005,8 +1008,8 @@ static uint16_t find_watchpoint(GB_gameboy_t *gb, value_t addr)
return 0; return 0;
} }
uint32_t key = WP_KEY(addr); uint32_t key = WP_KEY(addr);
int min = 0; unsigned min = 0;
int max = gb->n_watchpoints; unsigned max = gb->n_watchpoints;
while (min < max) { while (min < max) {
uint16_t pivot = (min + max) / 2; uint16_t pivot = (min + max) / 2;
if (gb->watchpoints[pivot].key == key) return pivot; if (gb->watchpoints[pivot].key == key) return pivot;
@ -1164,7 +1167,7 @@ static bool unwatch(GB_gameboy_t *gb, char *arguments, char *modifiers, const de
memmove(&gb->watchpoints[index], &gb->watchpoints[index + 1], (gb->n_watchpoints - index - 1) * sizeof(gb->watchpoints[0])); memmove(&gb->watchpoints[index], &gb->watchpoints[index + 1], (gb->n_watchpoints - index - 1) * sizeof(gb->watchpoints[0]));
gb->n_watchpoints--; gb->n_watchpoints--;
gb->watchpoints = realloc(gb->watchpoints, gb->n_watchpoints* sizeof(gb->watchpoints[0])); gb->watchpoints = realloc(gb->watchpoints, gb->n_watchpoints *sizeof(gb->watchpoints[0]));
GB_log(gb, "Watchpoint removed from %s\n", debugger_value_to_string(gb, result, true)); GB_log(gb, "Watchpoint removed from %s\n", debugger_value_to_string(gb, result, true));
return true; return true;
@ -1213,7 +1216,7 @@ static bool list(GB_gameboy_t *gb, char *arguments, char *modifiers, const debug
gb->watchpoints[i].condition); gb->watchpoints[i].condition);
} }
else { else {
GB_log(gb, " %d. %s (%c%c)\n", i + 1, debugger_value_to_string(gb,addr, addr.has_bank), GB_log(gb, " %d. %s (%c%c)\n", i + 1, debugger_value_to_string(gb, addr, addr.has_bank),
(gb->watchpoints[i].flags & GB_WATCHPOINT_R)? 'r' : '-', (gb->watchpoints[i].flags & GB_WATCHPOINT_R)? 'r' : '-',
(gb->watchpoints[i].flags & GB_WATCHPOINT_W)? 'w' : '-'); (gb->watchpoints[i].flags & GB_WATCHPOINT_W)? 'w' : '-');
} }
@ -1339,7 +1342,7 @@ static bool examine(GB_gameboy_t *gb, char *arguments, char *modifiers, const de
while (count) { while (count) {
GB_log(gb, "%02x:%04x: ", addr.bank, addr.value); GB_log(gb, "%02x:%04x: ", addr.bank, addr.value);
for (int i = 0; i < 16 && count; i++) { for (unsigned i = 0; i < 16 && count; i++) {
GB_log(gb, "%02x ", GB_read_memory(gb, addr.value + i)); GB_log(gb, "%02x ", GB_read_memory(gb, addr.value + i));
count--; count--;
} }
@ -1352,7 +1355,7 @@ static bool examine(GB_gameboy_t *gb, char *arguments, char *modifiers, const de
else { else {
while (count) { while (count) {
GB_log(gb, "%04x: ", addr.value); GB_log(gb, "%04x: ", addr.value);
for (int i = 0; i < 16 && count; i++) { for (unsigned i = 0; i < 16 && count; i++) {
GB_log(gb, "%02x ", GB_read_memory(gb, addr.value + i)); GB_log(gb, "%02x ", GB_read_memory(gb, addr.value + i));
count--; count--;
} }
@ -1419,15 +1422,20 @@ static bool mbc(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugg
} }
if (cartridge->mbc_type) { if (cartridge->mbc_type) {
static const char * const mapper_names[] = { if (gb->is_mbc30) {
[GB_MBC1] = "MBC1", GB_log(gb, "MBC30\n");
[GB_MBC2] = "MBC2", }
[GB_MBC3] = "MBC3", else {
[GB_MBC5] = "MBC5", static const char *const mapper_names[] = {
[GB_HUC1] = "HUC1", [GB_MBC1] = "MBC1",
[GB_HUC3] = "HUC3", [GB_MBC2] = "MBC2",
}; [GB_MBC3] = "MBC3",
GB_log(gb, "%s\n", mapper_names[cartridge->mbc_type]); [GB_MBC5] = "MBC5",
[GB_HUC1] = "HUC1",
[GB_HUC3] = "HUC3",
};
GB_log(gb, "%s\n", mapper_names[cartridge->mbc_type]);
}
GB_log(gb, "Current mapped ROM bank: %x\n", gb->mbc_rom_bank); GB_log(gb, "Current mapped ROM bank: %x\n", gb->mbc_rom_bank);
if (cartridge->has_ram) { if (cartridge->has_ram) {
GB_log(gb, "Current mapped RAM bank: %x\n", gb->mbc_ram_bank); GB_log(gb, "Current mapped RAM bank: %x\n", gb->mbc_ram_bank);
@ -1485,7 +1493,7 @@ static bool ticks(GB_gameboy_t *gb, char *arguments, char *modifiers, const debu
return true; return true;
} }
GB_log(gb, "Ticks: %lu. (Resetting)\n", gb->debugger_ticks); GB_log(gb, "Ticks: %llu. (Resetting)\n", (unsigned long long)gb->debugger_ticks);
gb->debugger_ticks = 0; gb->debugger_ticks = 0;
return true; return true;
@ -1573,7 +1581,7 @@ static bool lcd(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugg
} }
GB_log(gb, "LY: %d\n", gb->io_registers[GB_IO_LY]); GB_log(gb, "LY: %d\n", gb->io_registers[GB_IO_LY]);
GB_log(gb, "LYC: %d\n", gb->io_registers[GB_IO_LYC]); GB_log(gb, "LYC: %d\n", gb->io_registers[GB_IO_LYC]);
GB_log(gb, "Window position: %d, %d\n", (signed) gb->io_registers[GB_IO_WX] - 7 , gb->io_registers[GB_IO_WY]); GB_log(gb, "Window position: %d, %d\n", (signed) gb->io_registers[GB_IO_WX] - 7, gb->io_registers[GB_IO_WY]);
GB_log(gb, "Interrupt line: %s\n", gb->stat_interrupt_line? "On" : "Off"); GB_log(gb, "Interrupt line: %s\n", gb->stat_interrupt_line? "On" : "Off");
return true; return true;
@ -1722,7 +1730,7 @@ static bool wave(GB_gameboy_t *gb, char *arguments, char *modifiers, const debug
uint8_t shift_amount = 1, mask; uint8_t shift_amount = 1, mask;
if (modifiers) { if (modifiers) {
switch(modifiers[0]) { switch (modifiers[0]) {
case 'c': case 'c':
shift_amount = 2; shift_amount = 2;
break; break;
@ -1758,10 +1766,11 @@ static const debugger_command_t commands[] = {
{"next", 1, next, "Run the next instruction, skipping over function calls"}, {"next", 1, next, "Run the next instruction, skipping over function calls"},
{"step", 1, step, "Run the next instruction, stepping into function calls"}, {"step", 1, step, "Run the next instruction, stepping into function calls"},
{"finish", 1, finish, "Run until the current function returns"}, {"finish", 1, finish, "Run until the current function returns"},
{"backtrace", 2, backtrace, "Display the current call stack"}, {"backtrace", 2, backtrace, "Displays the current call stack"},
{"bt", 2, }, /* Alias */ {"bt", 2, }, /* Alias */
{"sld", 3, stack_leak_detection, "Like finish, but stops if a stack leak is detected (Experimental)"}, {"sld", 3, stack_leak_detection, "Like finish, but stops if a stack leak is detected (Experimental)"},
{"ticks", 2, ticks, "Display the number of CPU ticks since the last time 'ticks' was used"}, {"ticks", 2, ticks, "Displays the number of CPU ticks since the last time 'ticks' was" HELP_NEWLINE
"used"},
{"registers", 1, registers, "Print values of processor registers and other important registers"}, {"registers", 1, registers, "Print values of processor registers and other important registers"},
{"cartridge", 2, mbc, "Displays information about the MBC and cartridge"}, {"cartridge", 2, mbc, "Displays information about the MBC and cartridge"},
{"mbc", 3, }, /* Alias */ {"mbc", 3, }, /* Alias */
@ -1817,7 +1826,7 @@ static const debugger_command_t *find_command(const char *string)
static void print_command_shortcut(GB_gameboy_t *gb, const debugger_command_t *command) static void print_command_shortcut(GB_gameboy_t *gb, const debugger_command_t *command)
{ {
GB_attributed_log(gb, GB_LOG_BOLD | GB_LOG_UNDERLINE, "%.*s", command->min_length, command->command); GB_attributed_log(gb, GB_LOG_BOLD | GB_LOG_UNDERLINE, "%.*s", command->min_length, command->command);
GB_attributed_log(gb, GB_LOG_BOLD , "%s", command->command + command->min_length); GB_attributed_log(gb, GB_LOG_BOLD, "%s", command->command + command->min_length);
} }
static void print_command_description(GB_gameboy_t *gb, const debugger_command_t *command) static void print_command_description(GB_gameboy_t *gb, const debugger_command_t *command)
@ -2059,7 +2068,7 @@ void GB_debugger_run(GB_gameboy_t *gb)
if (gb->debug_disable) return; if (gb->debug_disable) return;
char *input = NULL; char *input = NULL;
if (gb->debug_next_command && gb->debug_call_depth <= 0) { if (gb->debug_next_command && gb->debug_call_depth <= 0 && !gb->halted) {
gb->debug_stopped = true; gb->debug_stopped = true;
} }
if (gb->debug_fin_command && gb->debug_call_depth == -1) { if (gb->debug_fin_command && gb->debug_call_depth == -1) {
@ -2151,6 +2160,19 @@ void GB_debugger_handle_async_commands(GB_gameboy_t *gb)
} }
} }
void GB_debugger_add_symbol(GB_gameboy_t *gb, uint16_t bank, uint16_t address, const char *symbol)
{
bank &= 0x1FF;
if (!gb->bank_symbols[bank]) {
gb->bank_symbols[bank] = GB_map_alloc();
}
GB_bank_symbol_t *allocated_symbol = GB_map_add_symbol(gb->bank_symbols[bank], address, symbol);
if (allocated_symbol) {
GB_reversed_map_add_symbol(&gb->reversed_symbol_map, bank, allocated_symbol);
}
}
void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path) void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path)
{ {
FILE *f = fopen(path, "r"); FILE *f = fopen(path, "r");
@ -2173,14 +2195,7 @@ void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path)
char symbol[length]; char symbol[length];
if (sscanf(line, "%x:%x %s", &bank, &address, symbol) == 3) { if (sscanf(line, "%x:%x %s", &bank, &address, symbol) == 3) {
bank &= 0x1FF; GB_debugger_add_symbol(gb, bank, address, symbol);
if (!gb->bank_symbols[bank]) {
gb->bank_symbols[bank] = GB_map_alloc();
}
GB_bank_symbol_t *allocated_symbol = GB_map_add_symbol(gb->bank_symbols[bank], address, symbol);
if (allocated_symbol) {
GB_reversed_map_add_symbol(&gb->reversed_symbol_map, bank, allocated_symbol);
}
} }
} }
free(line); free(line);
@ -2189,13 +2204,13 @@ void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path)
void GB_debugger_clear_symbols(GB_gameboy_t *gb) void GB_debugger_clear_symbols(GB_gameboy_t *gb)
{ {
for (int i = sizeof(gb->bank_symbols) / sizeof(gb->bank_symbols[0]); i--;) { for (unsigned i = sizeof(gb->bank_symbols) / sizeof(gb->bank_symbols[0]); i--;) {
if (gb->bank_symbols[i]) { if (gb->bank_symbols[i]) {
GB_map_free(gb->bank_symbols[i]); GB_map_free(gb->bank_symbols[i]);
gb->bank_symbols[i] = 0; gb->bank_symbols[i] = 0;
} }
} }
for (int i = sizeof(gb->reversed_symbol_map.buckets) / sizeof(gb->reversed_symbol_map.buckets[0]); i--;) { for (unsigned i = sizeof(gb->reversed_symbol_map.buckets) / sizeof(gb->reversed_symbol_map.buckets[0]); i--;) {
while (gb->reversed_symbol_map.buckets[i]) { while (gb->reversed_symbol_map.buckets[i]) {
GB_symbol_t *next = gb->reversed_symbol_map.buckets[i]->next; GB_symbol_t *next = gb->reversed_symbol_map.buckets[i]->next;
free(gb->reversed_symbol_map.buckets[i]); free(gb->reversed_symbol_map.buckets[i]);

View File

@ -7,13 +7,15 @@
#ifdef GB_INTERNAL #ifdef GB_INTERNAL
#ifdef DISABLE_DEBUGGER #ifdef GB_DISABLE_DEBUGGER
#define GB_debugger_run(gb) (void)0 #define GB_debugger_run(gb) (void)0
#define GB_debugger_handle_async_commands(gb) (void)0 #define GB_debugger_handle_async_commands(gb) (void)0
#define GB_debugger_ret_hook(gb) (void)0 #define GB_debugger_ret_hook(gb) (void)0
#define GB_debugger_call_hook(gb, addr) (void)addr #define GB_debugger_call_hook(gb, addr) (void)addr
#define GB_debugger_test_write_watchpoint(gb, addr, value) ((void)addr, (void)value) #define GB_debugger_test_write_watchpoint(gb, addr, value) ((void)addr, (void)value)
#define GB_debugger_test_read_watchpoint(gb, addr) (void)addr #define GB_debugger_test_read_watchpoint(gb, addr) (void)addr
#define GB_debugger_add_symbol(gb, bank, address, symbol) ((void)bank, (void)address, (void)symbol)
#else #else
void GB_debugger_run(GB_gameboy_t *gb); void GB_debugger_run(GB_gameboy_t *gb);
void GB_debugger_handle_async_commands(GB_gameboy_t *gb); void GB_debugger_handle_async_commands(GB_gameboy_t *gb);
@ -22,7 +24,8 @@ void GB_debugger_ret_hook(GB_gameboy_t *gb);
void GB_debugger_test_write_watchpoint(GB_gameboy_t *gb, uint16_t addr, uint8_t value); void GB_debugger_test_write_watchpoint(GB_gameboy_t *gb, uint16_t addr, uint8_t value);
void GB_debugger_test_read_watchpoint(GB_gameboy_t *gb, uint16_t addr); void GB_debugger_test_read_watchpoint(GB_gameboy_t *gb, uint16_t addr);
const GB_bank_symbol_t *GB_debugger_find_symbol(GB_gameboy_t *gb, uint16_t addr); const GB_bank_symbol_t *GB_debugger_find_symbol(GB_gameboy_t *gb, uint16_t addr);
#endif /* DISABLE_DEBUGGER */ void GB_debugger_add_symbol(GB_gameboy_t *gb, uint16_t bank, uint16_t address, const char *symbol);
#endif /* GB_DISABLE_DEBUGGER */
#endif #endif
#ifdef GB_INTERNAL #ifdef GB_INTERNAL

View File

@ -99,6 +99,8 @@ static void fifo_overlay_object_row(GB_fifo_t *fifo, uint8_t lower, uint8_t uppe
#define LINE_LENGTH (456) #define LINE_LENGTH (456)
#define LINES (144) #define LINES (144)
#define WIDTH (160) #define WIDTH (160)
#define BORDERED_WIDTH 256
#define BORDERED_HEIGHT 224
#define FRAME_LENGTH (LCDC_PERIOD) #define FRAME_LENGTH (LCDC_PERIOD)
#define VIRTUAL_LINES (FRAME_LENGTH / LINE_LENGTH) // = 154 #define VIRTUAL_LINES (FRAME_LENGTH / LINE_LENGTH) // = 154
@ -109,16 +111,6 @@ typedef struct __attribute__((packed)) {
uint8_t flags; uint8_t flags;
} GB_object_t; } GB_object_t;
static bool window_enabled(GB_gameboy_t *gb)
{
if ((gb->io_registers[GB_IO_LCDC] & 0x1) == 0) {
if (!gb->cgb_mode) {
return false;
}
}
return (gb->io_registers[GB_IO_LCDC] & 0x20) && gb->io_registers[GB_IO_WX] < 167;
}
static void display_vblank(GB_gameboy_t *gb) static void display_vblank(GB_gameboy_t *gb)
{ {
gb->vblank_just_occured = true; gb->vblank_just_occured = true;
@ -134,19 +126,77 @@ static void display_vblank(GB_gameboy_t *gb)
} }
} }
if (!gb->disable_rendering && ((!(gb->io_registers[GB_IO_LCDC] & 0x80) || gb->stopped) || gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON)) { bool is_ppu_stopped = !GB_is_cgb(gb) && gb->stopped && gb->io_registers[GB_IO_LCDC] & 0x80;
if (!gb->disable_rendering && ((!(gb->io_registers[GB_IO_LCDC] & 0x80) || is_ppu_stopped) || gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON)) {
/* LCD is off, set screen to white or black (if LCD is on in stop mode) */ /* LCD is off, set screen to white or black (if LCD is on in stop mode) */
if (gb->sgb) { if (!GB_is_sgb(gb)) {
for (unsigned i = 0; i < WIDTH * LINES; i++) { uint32_t color = 0;
gb->sgb->screen_buffer[i] = 0x0; if (GB_is_cgb(gb)) {
color = GB_convert_rgb15(gb, 0x7FFF, false);
}
else {
color = is_ppu_stopped ?
gb->background_palettes_rgb[0] :
gb->background_palettes_rgb[4];
}
if (gb->border_mode == GB_BORDER_ALWAYS) {
for (unsigned y = 0; y < LINES; y++) {
for (unsigned x = 0; x < WIDTH; x++) {
gb ->screen[x + y * BORDERED_WIDTH + (BORDERED_WIDTH - WIDTH) / 2 + (BORDERED_HEIGHT - LINES) / 2 * BORDERED_WIDTH] = color;
}
}
}
else {
for (unsigned i = 0; i < WIDTH * LINES; i++) {
gb ->screen[i] = color;
}
} }
} }
else { }
uint32_t color = (gb->io_registers[GB_IO_LCDC] & 0x80) && gb->stopped && GB_is_cgb(gb) ?
gb->rgb_encode_callback(gb, 0, 0, 0) : if (gb->border_mode == GB_BORDER_ALWAYS && !GB_is_sgb(gb)) {
gb->rgb_encode_callback(gb, 0xFF, 0xFF, 0xFF); GB_borrow_sgb_border(gb);
for (unsigned i = 0; i < WIDTH * LINES; i++) { uint32_t border_colors[16 * 4];
gb ->screen[i] = color;
if (!gb->has_sgb_border && GB_is_cgb(gb) && gb->model != GB_MODEL_AGB) {
static uint16_t colors[] = {
0x2095, 0x5129, 0x1EAF, 0x1EBA, 0x4648,
0x30DA, 0x69AD, 0x2B57, 0x2B5D, 0x632C,
0x1050, 0x3C84, 0x0E07, 0x0E18, 0x2964,
};
unsigned index = gb->rom? gb->rom[0x14e] % 5 : 0;
gb->borrowed_border.palette[0] = colors[index];
gb->borrowed_border.palette[10] = colors[5 + index];
gb->borrowed_border.palette[14] = colors[10 + index];
}
for (unsigned i = 0; i < 16 * 4; i++) {
border_colors[i] = GB_convert_rgb15(gb, gb->borrowed_border.palette[i], true);
}
for (unsigned tile_y = 0; tile_y < 28; tile_y++) {
for (unsigned tile_x = 0; tile_x < 32; tile_x++) {
if (tile_x >= 6 && tile_x < 26 && tile_y >= 5 && tile_y < 23) {
continue;
}
uint16_t tile = gb->borrowed_border.map[tile_x + tile_y * 32];
uint8_t flip_x = (tile & 0x4000)? 0x7 : 0;
uint8_t flip_y = (tile & 0x8000)? 0x7 : 0;
uint8_t palette = (tile >> 10) & 3;
for (unsigned y = 0; y < 8; y++) {
for (unsigned x = 0; x < 8; x++) {
uint8_t color = gb->borrowed_border.tiles[(tile & 0xFF) * 64 + (x ^ flip_x) + (y ^ flip_y) * 8] & 0xF;
uint32_t *output = gb->screen + tile_x * 8 + x + (tile_y * 8 + y) * 256;
if (color == 0) {
*output = border_colors[0];
}
else {
*output = border_colors[color + palette * 16];
}
}
}
} }
} }
} }
@ -158,7 +208,9 @@ static void display_vblank(GB_gameboy_t *gb)
} }
} }
gb->vblank_callback(gb); if (gb->vblank_callback) {
gb->vblank_callback(gb);
}
GB_timing_sync(gb); GB_timing_sync(gb);
} }
@ -169,7 +221,7 @@ static inline uint8_t scale_channel(uint8_t x)
static inline uint8_t scale_channel_with_curve(uint8_t x) static inline uint8_t scale_channel_with_curve(uint8_t x)
{ {
return (uint8_t[]){0,2,4,7,12,18,25,34,42,52,62,73,85,97,109,121,134,146,158,170,182,193,203,213,221,230,237,243,248,251,253,255}[x]; return (uint8_t[]){0,5,8,11,16,22,28,36,43,51,59,67,77,87,97,107,119,130,141,153,166,177,188,200,209,221,230,238,245,249,252,255}[x];
} }
static inline uint8_t scale_channel_with_curve_agb(uint8_t x) static inline uint8_t scale_channel_with_curve_agb(uint8_t x)
@ -183,19 +235,19 @@ static inline uint8_t scale_channel_with_curve_sgb(uint8_t x)
} }
uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color) uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border)
{ {
uint8_t r = (color) & 0x1F; uint8_t r = (color) & 0x1F;
uint8_t g = (color >> 5) & 0x1F; uint8_t g = (color >> 5) & 0x1F;
uint8_t b = (color >> 10) & 0x1F; uint8_t b = (color >> 10) & 0x1F;
if (gb->color_correction_mode == GB_COLOR_CORRECTION_DISABLED) { if (gb->color_correction_mode == GB_COLOR_CORRECTION_DISABLED || (for_border && !gb->has_sgb_border)) {
r = scale_channel(r); r = scale_channel(r);
g = scale_channel(g); g = scale_channel(g);
b = scale_channel(b); b = scale_channel(b);
} }
else { else {
if (GB_is_sgb(gb)) { if (GB_is_sgb(gb) || for_border) {
return gb->rgb_encode_callback(gb, return gb->rgb_encode_callback(gb,
scale_channel_with_curve_sgb(r), scale_channel_with_curve_sgb(r),
scale_channel_with_curve_sgb(g), scale_channel_with_curve_sgb(g),
@ -209,16 +261,28 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color)
if (gb->color_correction_mode != GB_COLOR_CORRECTION_CORRECT_CURVES) { if (gb->color_correction_mode != GB_COLOR_CORRECTION_CORRECT_CURVES) {
uint8_t new_r, new_g, new_b; uint8_t new_r, new_g, new_b;
if (agb) { if (agb) {
new_r = (r * 7 + g * 1) / 8; new_g = (g * 6 + b * 1) / 7;
new_g = (g * 3 + b * 1) / 4;
new_b = (b * 7 + r * 1) / 8;
} }
else { else {
new_g = (g * 3 + b) / 4; new_g = (g * 3 + b) / 4;
new_r = r;
new_b = b;
} }
if (gb->color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) { new_r = r;
new_b = b;
if (gb->color_correction_mode == GB_COLOR_CORRECTION_REDUCE_CONTRAST) {
r = new_r;
g = new_r;
b = new_r;
new_r = new_r * 7 / 8 + ( g + b) / 16;
new_g = new_g * 7 / 8 + (r + b) / 16;
new_b = new_b * 7 / 8 + (r + g ) / 16;
new_r = new_r * (224 - 32) / 255 + 32;
new_g = new_g * (220 - 36) / 255 + 36;
new_b = new_b * (216 - 40) / 255 + 40;
}
else if (gb->color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) {
uint8_t old_max = MAX(r, MAX(g, b)); uint8_t old_max = MAX(r, MAX(g, b));
uint8_t new_max = MAX(new_r, MAX(new_g, new_b)); uint8_t new_max = MAX(new_r, MAX(new_g, new_b));
@ -252,7 +316,7 @@ void GB_palette_changed(GB_gameboy_t *gb, bool background_palette, uint8_t index
uint8_t *palette_data = background_palette? gb->background_palettes_data : gb->sprite_palettes_data; uint8_t *palette_data = background_palette? gb->background_palettes_data : gb->sprite_palettes_data;
uint16_t color = palette_data[index & ~1] | (palette_data[index | 1] << 8); uint16_t color = palette_data[index & ~1] | (palette_data[index | 1] << 8);
(background_palette? gb->background_palettes_rgb : gb->sprite_palettes_rgb)[index / 2] = GB_convert_rgb15(gb, color); (background_palette? gb->background_palettes_rgb : gb->sprite_palettes_rgb)[index / 2] = GB_convert_rgb15(gb, color, false);
} }
void GB_set_color_correction_mode(GB_gameboy_t *gb, GB_color_correction_mode_t mode) void GB_set_color_correction_mode(GB_gameboy_t *gb, GB_color_correction_mode_t mode)
@ -335,13 +399,11 @@ void GB_lcd_off(GB_gameboy_t *gb)
gb->vram_write_blocked = false; gb->vram_write_blocked = false;
gb->cgb_palettes_blocked = false; gb->cgb_palettes_blocked = false;
/* Reset window rendering state */
gb->wy_diff = 0;
gb->window_disabled_while_active = false;
gb->current_line = 0; gb->current_line = 0;
gb->ly_for_comparison = 0; gb->ly_for_comparison = 0;
gb->accessed_oam_row = -1; gb->accessed_oam_row = -1;
gb->wy_triggered = false;
} }
static void add_object_from_index(GB_gameboy_t *gb, unsigned index) static void add_object_from_index(GB_gameboy_t *gb, unsigned index)
@ -353,6 +415,10 @@ static void add_object_from_index(GB_gameboy_t *gb, unsigned index)
return; return;
} }
if (gb->oam_ppu_blocked) {
return;
}
/* This reverse sorts the visible objects by location and priority */ /* This reverse sorts the visible objects by location and priority */
GB_object_t *objects = (GB_object_t *) &gb->oam; GB_object_t *objects = (GB_object_t *) &gb->oam;
bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0; bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0;
@ -377,30 +443,30 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
bool draw_oam = false; bool draw_oam = false;
bool bg_enabled = true, bg_priority = false; bool bg_enabled = true, bg_priority = false;
if (!gb->bg_fifo_paused) { if (fifo_size(&gb->bg_fifo)) {
fifo_item = fifo_pop(&gb->bg_fifo); fifo_item = fifo_pop(&gb->bg_fifo);
bg_priority = fifo_item->bg_priority; bg_priority = fifo_item->bg_priority;
}
if (!gb->oam_fifo_paused && fifo_size(&gb->oam_fifo)) { if (fifo_size(&gb->oam_fifo)) {
oam_fifo_item = fifo_pop(&gb->oam_fifo); oam_fifo_item = fifo_pop(&gb->oam_fifo);
/* Todo: Verify access timings */ if (oam_fifo_item->pixel && (gb->io_registers[GB_IO_LCDC] & 2)) {
if (oam_fifo_item->pixel && (gb->io_registers[GB_IO_LCDC] & 2)) { draw_oam = true;
draw_oam = true; bg_priority |= oam_fifo_item->bg_priority;
bg_priority |= oam_fifo_item->bg_priority; }
} }
} }
if (!fifo_item) return;
/* Drop pixels for scrollings */ /* Drop pixels for scrollings */
if (gb->position_in_line >= 160 || gb->disable_rendering) { if (gb->position_in_line >= 160 || (gb->disable_rendering && !gb->sgb)) {
gb->position_in_line++; gb->position_in_line++;
return; return;
} }
if (gb->bg_fifo_paused) return;
/* Mixing */ /* Mixing */
/* Todo: Verify access timings */
if ((gb->io_registers[GB_IO_LCDC] & 0x1) == 0) { if ((gb->io_registers[GB_IO_LCDC] & 0x1) == 0) {
if (gb->cgb_mode) { if (gb->cgb_mode) {
bg_priority = false; bg_priority = false;
@ -411,6 +477,16 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
} }
uint8_t icd_pixel = 0; uint8_t icd_pixel = 0;
uint32_t *dest = NULL;
if (!gb->sgb) {
if (gb->border_mode != GB_BORDER_ALWAYS) {
dest = gb->screen + gb->lcd_x + gb->current_line * WIDTH;
}
else {
dest = gb->screen + gb->lcd_x + gb->current_line * BORDERED_WIDTH + (BORDERED_WIDTH - WIDTH) / 2 + (BORDERED_HEIGHT - LINES) / 2 * BORDERED_WIDTH;
}
}
{ {
uint8_t pixel = bg_enabled? fifo_item->pixel : 0; uint8_t pixel = bg_enabled? fifo_item->pixel : 0;
if (pixel && bg_priority) { if (pixel && bg_priority) {
@ -421,7 +497,7 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
} }
if (gb->sgb) { if (gb->sgb) {
if (gb->current_lcd_line < LINES) { if (gb->current_lcd_line < LINES) {
gb->sgb->screen_buffer[gb->position_in_line + gb->current_lcd_line * WIDTH] = gb->stopped? 0 : pixel; gb->sgb->screen_buffer[gb->lcd_x + gb->current_lcd_line * WIDTH] = gb->stopped? 0 : pixel;
} }
} }
else if (gb->model & GB_MODEL_NO_SFC_BIT) { else if (gb->model & GB_MODEL_NO_SFC_BIT) {
@ -429,8 +505,11 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
icd_pixel = pixel; icd_pixel = pixel;
} }
} }
else if (gb->cgb_palettes_ppu_blocked) {
*dest = gb->rgb_encode_callback(gb, 0, 0, 0);
}
else { else {
gb->screen[gb->position_in_line + gb->current_line * WIDTH] = gb->background_palettes_rgb[fifo_item->palette * 4 + pixel]; *dest = gb->background_palettes_rgb[fifo_item->palette * 4 + pixel];
} }
} }
@ -442,7 +521,7 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
} }
if (gb->sgb) { if (gb->sgb) {
if (gb->current_lcd_line < LINES) { if (gb->current_lcd_line < LINES) {
gb->sgb->screen_buffer[gb->position_in_line + gb->current_lcd_line * WIDTH] = gb->stopped? 0 : pixel; gb->sgb->screen_buffer[gb->lcd_x + gb->current_lcd_line * WIDTH] = gb->stopped? 0 : pixel;
} }
} }
else if (gb->model & GB_MODEL_NO_SFC_BIT) { else if (gb->model & GB_MODEL_NO_SFC_BIT) {
@ -451,8 +530,11 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
//gb->icd_pixel_callback(gb, pixel); //gb->icd_pixel_callback(gb, pixel);
} }
} }
else if (gb->cgb_palettes_ppu_blocked) {
*dest = gb->rgb_encode_callback(gb, 0, 0, 0);
}
else { else {
gb->screen[gb->position_in_line + gb->current_line * WIDTH] = gb->sprite_palettes_rgb[oam_fifo_item->palette * 4 + pixel]; *dest = gb->sprite_palettes_rgb[oam_fifo_item->palette * 4 + pixel];
} }
} }
@ -463,6 +545,8 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
} }
gb->position_in_line++; gb->position_in_line++;
gb->lcd_x++;
gb->window_is_being_fetched = false;
} }
/* All verified CGB timings are based on CGB CPU E. CGB CPUs >= D are known to have /* All verified CGB timings are based on CGB CPU E. CGB CPUs >= D are known to have
@ -472,7 +556,7 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
static inline uint8_t fetcher_y(GB_gameboy_t *gb) static inline uint8_t fetcher_y(GB_gameboy_t *gb)
{ {
return gb->current_line + (gb->in_window? - gb->io_registers[GB_IO_WY] - gb->wy_diff : gb->io_registers[GB_IO_SCY]); return gb->wx_triggered? gb->window_y : gb->current_line + gb->io_registers[GB_IO_SCY];
} }
static void advance_fetcher_state_machine(GB_gameboy_t *gb) static void advance_fetcher_state_machine(GB_gameboy_t *gb)
@ -492,36 +576,51 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
GB_FETCHER_GET_TILE_DATA_LOWER, GB_FETCHER_GET_TILE_DATA_LOWER,
GB_FETCHER_SLEEP, GB_FETCHER_SLEEP,
GB_FETCHER_GET_TILE_DATA_HIGH, GB_FETCHER_GET_TILE_DATA_HIGH,
GB_FETCHER_SLEEP, GB_FETCHER_PUSH,
GB_FETCHER_PUSH, GB_FETCHER_PUSH,
}; };
switch (fetcher_state_machine[gb->fetcher_state & 7]) {
switch (fetcher_state_machine[gb->fetcher_state]) {
case GB_FETCHER_GET_TILE: { case GB_FETCHER_GET_TILE: {
uint16_t map = 0x1800; uint16_t map = 0x1800;
if (!(gb->io_registers[GB_IO_LCDC] & 0x20)) {
gb->wx_triggered = false;
gb->wx166_glitch = false;
}
/* Todo: Verified for DMG (Tested: SGB2), CGB timing is wrong. */ /* Todo: Verified for DMG (Tested: SGB2), CGB timing is wrong. */
if (gb->io_registers[GB_IO_LCDC] & 0x08 && !gb->in_window) { if (gb->io_registers[GB_IO_LCDC] & 0x08 && !gb->wx_triggered) {
map = 0x1C00; map = 0x1C00;
} }
else if (gb->io_registers[GB_IO_LCDC] & 0x40 && gb->in_window) { else if (gb->io_registers[GB_IO_LCDC] & 0x40 && gb->wx_triggered) {
map = 0x1C00; map = 0x1C00;
} }
/* Todo: Verified for DMG (Tested: SGB2), CGB timing is wrong. */ /* Todo: Verified for DMG (Tested: SGB2), CGB timing is wrong. */
uint8_t y = fetcher_y(gb); uint8_t y = fetcher_y(gb);
uint8_t x = 0;
if (gb->wx_triggered) {
x = gb->window_tile_x;
}
else {
x = ((gb->io_registers[GB_IO_SCX] / 8) + gb->fetcher_x) & 0x1F;
}
if (gb->model > GB_MODEL_CGB_C) { if (gb->model > GB_MODEL_CGB_C) {
/* This value is cached on the CGB-D and newer, so it cannot be used to mix tiles together */ /* This value is cached on the CGB-D and newer, so it cannot be used to mix tiles together */
gb->fetcher_y = y; gb->fetcher_y = y;
} }
gb->current_tile = gb->vram[map + gb->fetcher_x + y / 8 * 32]; gb->current_tile = gb->vram[map + x + y / 8 * 32];
if (gb->vram_ppu_blocked) {
gb->current_tile = 0xFF;
}
if (GB_is_cgb(gb)) { if (GB_is_cgb(gb)) {
/* The CGB actually accesses both the tile index AND the attributes in the same T-cycle. /* The CGB actually accesses both the tile index AND the attributes in the same T-cycle.
This probably means the CGB has a 16-bit data bus for the VRAM. */ This probably means the CGB has a 16-bit data bus for the VRAM. */
gb->current_tile_attributes = gb->vram[map + gb->fetcher_x + y / 8 * 32 + 0x2000]; gb->current_tile_attributes = gb->vram[map + x + y / 8 * 32 + 0x2000];
if (gb->vram_ppu_blocked) {
gb->current_tile_attributes = 0xFF;
}
} }
gb->fetcher_x++;
gb->fetcher_x &= 0x1f;
} }
gb->fetcher_state++; gb->fetcher_state++;
break; break;
@ -545,7 +644,10 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
y_flip = 0x7; y_flip = 0x7;
} }
gb->current_tile_data[0] = gb->current_tile_data[0] =
gb->vram[tile_address + ((y & 7) ^ y_flip) * 2]; gb->vram[tile_address + ((y & 7) ^ y_flip) * 2];
if (gb->vram_ppu_blocked) {
gb->current_tile_data[0] = 0xFF;
}
} }
gb->fetcher_state++; gb->fetcher_state++;
break; break;
@ -572,18 +674,32 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
y_flip = 0x7; y_flip = 0x7;
} }
gb->current_tile_data[1] = gb->current_tile_data[1] =
gb->vram[tile_address + ((y & 7) ^ y_flip) * 2 + 1]; gb->vram[tile_address + ((y & 7) ^ y_flip) * 2 + 1];
if (gb->vram_ppu_blocked) {
gb->current_tile_data[1] = 0xFF;
}
}
if (gb->wx_triggered) {
gb->window_tile_x++;
gb->window_tile_x &= 0x1f;
} }
gb->fetcher_state++;
break;
// fallthrough
case GB_FETCHER_PUSH: { case GB_FETCHER_PUSH: {
if (gb->fetcher_state == 6) {
/* The background map index increase at this specific point. If this state is not reached,
it will simply not increase. */
gb->fetcher_x++;
gb->fetcher_x &= 0x1f;
}
if (gb->fetcher_state < 7) {
gb->fetcher_state++;
}
if (fifo_size(&gb->bg_fifo) > 0) break; if (fifo_size(&gb->bg_fifo) > 0) break;
fifo_push_bg_row(&gb->bg_fifo, gb->current_tile_data[0], gb->current_tile_data[1], fifo_push_bg_row(&gb->bg_fifo, gb->current_tile_data[0], gb->current_tile_data[1],
gb->current_tile_attributes & 7, gb->current_tile_attributes & 0x80, gb->current_tile_attributes & 0x20); gb->current_tile_attributes & 7, gb->current_tile_attributes & 0x80, gb->current_tile_attributes & 0x20);
gb->bg_fifo_paused = false; gb->fetcher_state = 0;
gb->oam_fifo_paused = false;
gb->fetcher_state++;
} }
break; break;
@ -593,8 +709,30 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
} }
break; break;
} }
}
gb->fetcher_state &= 7; static uint16_t get_object_line_address(GB_gameboy_t *gb, const GB_object_t *object)
{
/* TODO: what does the PPU read if DMA is active? */
if (gb->oam_ppu_blocked) {
static const GB_object_t blocked = {0xFF, 0xFF, 0xFF, 0xFF};
object = &blocked;
}
bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0; /* Todo: Which T-cycle actually reads this? */
uint8_t tile_y = (gb->current_line - object->y) & (height_16? 0xF : 7);
if (object->flags & 0x40) { /* Flip Y */
tile_y ^= height_16? 0xF : 7;
}
/* Todo: I'm not 100% sure an access to OAM can't trigger the OAM bug while we're accessing this */
uint16_t line_address = (height_16? object->tile & 0xFE : object->tile) * 0x10 + tile_y * 2;
if (gb->cgb_mode && (object->flags & 0x8)) { /* Use VRAM bank 2 */
line_address += 0x2000;
}
return line_address;
} }
/* /*
@ -652,7 +790,10 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
GB_STATE(gb, display, 36); GB_STATE(gb, display, 36);
GB_STATE(gb, display, 37); GB_STATE(gb, display, 37);
GB_STATE(gb, display, 38); GB_STATE(gb, display, 38);
GB_STATE(gb, display, 39);
GB_STATE(gb, display, 40);
GB_STATE(gb, display, 41);
GB_STATE(gb, display, 42);
} }
if (!(gb->io_registers[GB_IO_LCDC] & 0x80)) { if (!(gb->io_registers[GB_IO_LCDC] & 0x80)) {
@ -663,12 +804,23 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
return; return;
} }
gb->is_odd_frame = false;
if (!GB_is_cgb(gb)) { if (!GB_is_cgb(gb)) {
GB_SLEEP(gb, display, 23, 1); GB_SLEEP(gb, display, 23, 1);
} }
/* Handle mode 2 on the very first line 0 */ /* Handle mode 2 on the very first line 0 */
gb->current_line = 0; gb->current_line = 0;
gb->window_y = -1;
/* Todo: verify timings */
if (gb->io_registers[GB_IO_WY] == 0) {
gb->wy_triggered = true;
}
else {
gb->wy_triggered = false;
}
gb->ly_for_comparison = 0; gb->ly_for_comparison = 0;
gb->io_registers[GB_IO_STAT] &= ~3; gb->io_registers[GB_IO_STAT] &= ~3;
gb->mode_for_interrupt = -1; gb->mode_for_interrupt = -1;
@ -705,17 +857,25 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
GB_SLEEP(gb, display, 37, 2); GB_SLEEP(gb, display, 37, 2);
gb->cgb_palettes_blocked = true; gb->cgb_palettes_blocked = true;
gb->cycles_for_line += 2; gb->cycles_for_line += 3;
GB_SLEEP(gb, display, 38, 2); GB_SLEEP(gb, display, 38, 3);
gb->vram_read_blocked = true; gb->vram_read_blocked = true;
gb->vram_write_blocked = true; gb->vram_write_blocked = true;
gb->wx_triggered = false;
gb->wx166_glitch = false;
goto mode_3_start; goto mode_3_start;
while (true) { while (true) {
/* Lines 0 - 143 */ /* Lines 0 - 143 */
gb->window_y = -1;
for (; gb->current_line < LINES; gb->current_line++) { for (; gb->current_line < LINES; gb->current_line++) {
/* Todo: verify timings */
if ((gb->io_registers[GB_IO_WY] == gb->current_line ||
(gb->current_line != 0 && gb->io_registers[GB_IO_WY] == gb->current_line - 1))) {
gb->wy_triggered = true;
}
gb->oam_write_blocked = GB_is_cgb(gb) && !gb->cgb_double_speed; gb->oam_write_blocked = GB_is_cgb(gb) && !gb->cgb_double_speed;
gb->accessed_oam_row = 0; gb->accessed_oam_row = 0;
@ -801,17 +961,80 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
fifo_push_bg_row(&gb->bg_fifo, 0, 0, 0, false, false); fifo_push_bg_row(&gb->bg_fifo, 0, 0, 0, false, false);
/* Todo: find out actual access time of SCX */ /* Todo: find out actual access time of SCX */
gb->position_in_line = - (gb->io_registers[GB_IO_SCX] & 7) - 8; gb->position_in_line = - (gb->io_registers[GB_IO_SCX] & 7) - 8;
gb->lcd_x = 0;
gb->fetcher_x = ((gb->io_registers[GB_IO_SCX]) / 8) & 0x1f; gb->fetcher_x = 0;
gb->extra_penalty_for_sprite_at_0 = (gb->io_registers[GB_IO_SCX] & 7); gb->extra_penalty_for_sprite_at_0 = (gb->io_registers[GB_IO_SCX] & 7);
/* The actual rendering cycle */ /* The actual rendering cycle */
gb->fetcher_state = 0; gb->fetcher_state = 0;
gb->bg_fifo_paused = false;
gb->oam_fifo_paused = false;
gb->in_window = false;
while (true) { while (true) {
/* Handle window */
/* TODO: It appears that WX checks if the window begins *next* pixel, not *this* pixel. For this reason,
WX=167 has no effect at all (It checks if the PPU X position is 161, which never happens) and WX=166
has weird artifacts (It appears to activate the window during HBlank, as PPU X is temporarily 160 at
that point. The code should be updated to represent this, and this will fix the time travel hack in
WX's access conflict code. */
if (!gb->wx_triggered && gb->wy_triggered && (gb->io_registers[GB_IO_LCDC] & 0x20)) {
bool should_activate_window = false;
if (gb->io_registers[GB_IO_WX] == 0) {
static const uint8_t scx_to_wx0_comparisons[] = {-7, -9, -10, -11, -12, -13, -14, -14};
if (gb->position_in_line == scx_to_wx0_comparisons[gb->io_registers[GB_IO_SCX] & 7]) {
should_activate_window = true;
}
}
else if (gb->wx166_glitch) {
static const uint8_t scx_to_wx166_comparisons[] = {-8, -9, -10, -11, -12, -13, -14, -15};
if (gb->position_in_line == scx_to_wx166_comparisons[gb->io_registers[GB_IO_SCX] & 7]) {
should_activate_window = true;
}
}
else if (gb->io_registers[GB_IO_WX] < 166 + GB_is_cgb(gb)) {
if (gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 7)) {
should_activate_window = true;
}
else if (gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 6) && !gb->wx_just_changed) {
should_activate_window = true;
/* LCD-PPU horizontal desync! It only appears to happen on DMGs, but not all of them.
This doesn't seem to be CPU revision dependent, but most revisions */
if ((gb->model & GB_MODEL_FAMILY_MASK) == GB_MODEL_DMG_FAMILY && !GB_is_sgb(gb)) {
if (gb->lcd_x > 0) {
gb->lcd_x--;
}
}
}
}
if (should_activate_window) {
gb->window_y++;
/* TODO: Verify fetcher access timings in this case */
if (gb->io_registers[GB_IO_WX] == 0 && (gb->io_registers[GB_IO_SCX] & 7)) {
gb->cycles_for_line++;
GB_SLEEP(gb, display, 42, 1);
}
gb->wx_triggered = true;
gb->window_tile_x = 0;
fifo_clear(&gb->bg_fifo);
gb->fetcher_state = 0;
gb->window_is_being_fetched = true;
}
else if (!GB_is_cgb(gb) && gb->io_registers[GB_IO_WX] == 166 && gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 7)) {
gb->window_y++;
}
}
/* TODO: What happens when WX=0? */
if (!GB_is_cgb(gb) && gb->wx_triggered && !gb->window_is_being_fetched &&
gb->fetcher_state == 0 && gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 7) ) {
// Insert a pixel right at the FIFO's end
gb->bg_fifo.read_end--;
gb->bg_fifo.read_end &= GB_FIFO_LENGTH - 1;
gb->bg_fifo.fifo[gb->bg_fifo.read_end] = (GB_fifo_item_t){0,};
gb->window_is_being_fetched = false;
}
/* Handle objects */ /* Handle objects */
/* When the sprite enabled bit is off, this proccess is skipped entirely on the DMG, but not on the CGB. /* When the sprite enabled bit is off, this proccess is skipped entirely on the DMG, but not on the CGB.
On the CGB, this bit is checked only when the pixel is actually popped from the FIFO. */ On the CGB, this bit is checked only when the pixel is actually popped from the FIFO. */
@ -821,14 +1044,19 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
gb->obj_comparators[gb->n_visible_objs - 1] < (uint8_t)(gb->position_in_line + 8)) { gb->obj_comparators[gb->n_visible_objs - 1] < (uint8_t)(gb->position_in_line + 8)) {
gb->n_visible_objs--; gb->n_visible_objs--;
} }
gb->during_object_fetch = true;
while (gb->n_visible_objs != 0 && while (gb->n_visible_objs != 0 &&
(gb->io_registers[GB_IO_LCDC] & 2 || GB_is_cgb(gb)) && (gb->io_registers[GB_IO_LCDC] & 2 || GB_is_cgb(gb)) &&
gb->obj_comparators[gb->n_visible_objs - 1] == (uint8_t)(gb->position_in_line + 8)) { gb->obj_comparators[gb->n_visible_objs - 1] == (uint8_t)(gb->position_in_line + 8)) {
while (gb->fetcher_state < 5) { while (gb->fetcher_state < 5 || fifo_size(&gb->bg_fifo) == 0) {
advance_fetcher_state_machine(gb); advance_fetcher_state_machine(gb);
gb->cycles_for_line++; gb->cycles_for_line++;
GB_SLEEP(gb, display, 27, 1); GB_SLEEP(gb, display, 27, 1);
if (gb->object_fetch_aborted) {
goto abort_fetching_object;
}
} }
/* Todo: Measure if penalty occurs before or after waiting for the fetcher. */ /* Todo: Measure if penalty occurs before or after waiting for the fetcher. */
@ -837,56 +1065,63 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
gb->cycles_for_line += gb->extra_penalty_for_sprite_at_0; gb->cycles_for_line += gb->extra_penalty_for_sprite_at_0;
GB_SLEEP(gb, display, 28, gb->extra_penalty_for_sprite_at_0); GB_SLEEP(gb, display, 28, gb->extra_penalty_for_sprite_at_0);
gb->extra_penalty_for_sprite_at_0 = 0; gb->extra_penalty_for_sprite_at_0 = 0;
if (gb->object_fetch_aborted) {
goto abort_fetching_object;
}
} }
} }
gb->cycles_for_line += 6; /* TODO: Can this be deleted? { */
GB_SLEEP(gb, display, 20, 6); advance_fetcher_state_machine(gb);
/* TODO: what does the PPU read if DMA is active? */ gb->cycles_for_line++;
GB_object_t *object = &objects[gb->visible_objs[gb->n_visible_objs - 1]]; GB_SLEEP(gb, display, 41, 1);
if (gb->object_fetch_aborted) {
goto abort_fetching_object;
}
/* } */
bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0; /* Todo: Which T-cycle actually reads this? */ advance_fetcher_state_machine(gb);
uint8_t tile_y = (gb->current_line - object->y) & (height_16? 0xF : 7);
if (object->flags & 0x40) { /* Flip Y */ gb->cycles_for_line += 3;
tile_y ^= height_16? 0xF : 7; GB_SLEEP(gb, display, 20, 3);
if (gb->object_fetch_aborted) {
goto abort_fetching_object;
} }
/* Todo: I'm not 100% sure an access to OAM can't trigger the OAM bug while we're accessing this */ gb->object_low_line_address = get_object_line_address(gb, &objects[gb->visible_objs[gb->n_visible_objs - 1]]);
uint16_t line_address = (height_16? object->tile & 0xFE : object->tile) * 0x10 + tile_y * 2;
if (gb->cgb_mode && (object->flags & 0x8)) { /* Use VRAM bank 2 */ gb->cycles_for_line++;
line_address += 0x2000; GB_SLEEP(gb, display, 39, 1);
if (gb->object_fetch_aborted) {
goto abort_fetching_object;
} }
gb->during_object_fetch = false;
gb->cycles_for_line++;
GB_SLEEP(gb, display, 40, 1);
const GB_object_t *object = &objects[gb->visible_objs[gb->n_visible_objs - 1]];
uint16_t line_address = get_object_line_address(gb, object);
uint8_t palette = (object->flags & 0x10) ? 1 : 0; uint8_t palette = (object->flags & 0x10) ? 1 : 0;
if (gb->cgb_mode) { if (gb->cgb_mode) {
palette = object->flags & 0x7; palette = object->flags & 0x7;
} }
fifo_overlay_object_row(&gb->oam_fifo, fifo_overlay_object_row(&gb->oam_fifo,
gb->vram[line_address], gb->vram_ppu_blocked? 0xFF : gb->vram[gb->object_low_line_address],
gb->vram[line_address + 1], gb->vram_ppu_blocked? 0xFF : gb->vram[line_address + 1],
palette, palette,
object->flags & 0x80, object->flags & 0x80,
gb->cgb_mode? gb->visible_objs[gb->n_visible_objs - 1] : 0, gb->object_priority == GB_OBJECT_PRIORITY_INDEX? gb->visible_objs[gb->n_visible_objs - 1] : 0,
object->flags & 0x20); object->flags & 0x20);
gb->n_visible_objs--; gb->n_visible_objs--;
} }
/* Handle window */ abort_fetching_object:
/* Todo: Timing (Including penalty and access timings) not verified by test ROM */ gb->object_fetch_aborted = false;
if (!gb->in_window && window_enabled(gb) && gb->during_object_fetch = false;
gb->current_line >= gb->io_registers[GB_IO_WY] + gb->wy_diff &&
(uint8_t)(gb->position_in_line + 7) == gb->io_registers[GB_IO_WX]) {
gb->in_window = true;
fifo_clear(&gb->bg_fifo);
gb->bg_fifo_paused = true;
gb->oam_fifo_paused = true;
gb->fetcher_x = 0;
gb->fetcher_state = 0;
}
render_pixel_if_possible(gb); render_pixel_if_possible(gb);
advance_fetcher_state_machine(gb); advance_fetcher_state_machine(gb);
@ -896,6 +1131,29 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
GB_SLEEP(gb, display, 21, 1); GB_SLEEP(gb, display, 21, 1);
} }
while (gb->lcd_x != 160 && !gb->disable_rendering && gb->screen && !gb->sgb) {
/* Oh no! The PPU and LCD desynced! Fill the rest of the line whith white. */
uint32_t *dest = NULL;
if (gb->border_mode != GB_BORDER_ALWAYS) {
dest = gb->screen + gb->lcd_x + gb->current_line * WIDTH;
}
else {
dest = gb->screen + gb->lcd_x + gb->current_line * BORDERED_WIDTH + (BORDERED_WIDTH - WIDTH) / 2 + (BORDERED_HEIGHT - LINES) / 2 * BORDERED_WIDTH;
}
*dest = gb->background_palettes_rgb[0];
gb->lcd_x++;
}
/* TODO: Verify timing */
if (!GB_is_cgb(gb) && gb->wy_triggered && (gb->io_registers[GB_IO_LCDC] & 0x20) && gb->io_registers[GB_IO_WX] == 166) {
gb->wx166_glitch = true;
}
else {
gb->wx166_glitch = false;
}
gb->wx_triggered = false;
if (GB_is_cgb(gb) && gb->model <= GB_MODEL_CGB_C) { if (GB_is_cgb(gb) && gb->model <= GB_MODEL_CGB_C) {
gb->cycles_for_line++; gb->cycles_for_line++;
GB_SLEEP(gb, display, 30, 1); GB_SLEEP(gb, display, 30, 1);
@ -949,7 +1207,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
gb->icd_hreset_callback(gb); gb->icd_hreset_callback(gb);
} }
} }
gb->wx166_glitch = false;
/* Lines 144 - 152 */ /* Lines 144 - 152 */
for (; gb->current_line < VIRTUAL_LINES - 1; gb->current_line++) { for (; gb->current_line < VIRTUAL_LINES - 1; gb->current_line++) {
gb->io_registers[GB_IO_LY] = gb->current_line; gb->io_registers[GB_IO_LY] = gb->current_line;
@ -973,14 +1231,22 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
GB_STAT_update(gb); GB_STAT_update(gb);
if (gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON) { if (gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON) {
if (!GB_is_sgb(gb) || gb->current_lcd_line < LINES) { if (GB_is_cgb(gb)) {
display_vblank(gb); GB_timing_sync(gb);
gb->frame_skip_state = GB_FRAMESKIP_FIRST_FRAME_SKIPPED;
}
else {
if (!GB_is_sgb(gb) || gb->current_lcd_line < LINES) {
gb->is_odd_frame ^= true;
display_vblank(gb);
}
gb->frame_skip_state = GB_FRAMESKIP_SECOND_FRAME_RENDERED;
} }
gb->frame_skip_state = GB_FRAMESKIP_SECOND_FRAME_RENDERED;
} }
else { else {
gb->frame_skip_state = GB_FRAMESKIP_SECOND_FRAME_RENDERED; gb->frame_skip_state = GB_FRAMESKIP_SECOND_FRAME_RENDERED;
if (!GB_is_sgb(gb) || gb->current_lcd_line < LINES) { if (!GB_is_sgb(gb) || gb->current_lcd_line < LINES) {
gb->is_odd_frame ^= true;
display_vblank(gb); display_vblank(gb);
} }
} }
@ -1015,10 +1281,16 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
GB_SLEEP(gb, display, 17, LINE_LENGTH - 24); GB_SLEEP(gb, display, 17, LINE_LENGTH - 24);
/* Reset window rendering state */
gb->wy_diff = 0;
gb->window_disabled_while_active = false;
gb->current_line = 0; gb->current_line = 0;
/* Todo: verify timings */
if ((gb->io_registers[GB_IO_LCDC] & 0x20) &&
(gb->io_registers[GB_IO_WY] == 0)) {
gb->wy_triggered = true;
}
else {
gb->wy_triggered = false;
}
// TODO: not the correct timing // TODO: not the correct timing
gb->current_lcd_line = 0; gb->current_lcd_line = 0;
if (gb->icd_vreset_callback) { if (gb->icd_vreset_callback) {
@ -1156,7 +1428,7 @@ uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_h
GB_object_t *sprite = (GB_object_t *) &gb->oam; GB_object_t *sprite = (GB_object_t *) &gb->oam;
uint8_t sprites_in_line = 0; uint8_t sprites_in_line = 0;
for (uint8_t i = 0; i < 40; i++, sprite++) { for (uint8_t i = 0; i < 40; i++, sprite++) {
int sprite_y = sprite->y - 16; signed sprite_y = sprite->y - 16;
bool obscured = false; bool obscured = false;
// Is sprite not in this line? // Is sprite not in this line?
if (sprite_y > y || sprite_y + *sprite_height <= y) continue; if (sprite_y > y || sprite_y + *sprite_height <= y) continue;
@ -1205,30 +1477,8 @@ uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_h
return count; return count;
} }
/* Called when a write might enable or disable the window */
void GB_window_related_write(GB_gameboy_t *gb, uint8_t addr, uint8_t value)
{
bool before = window_enabled(gb);
gb->io_registers[addr] = value;
bool after = window_enabled(gb);
if (before != after && gb->current_line < LINES) { bool GB_is_odd_frame(GB_gameboy_t *gb)
/* Window was disabled or enabled outside of vblank */ {
if (gb->current_line >= gb->io_registers[GB_IO_WY]) { return gb->is_odd_frame;
if (after) {
if (!gb->window_disabled_while_active) {
/* Window was turned on for the first time this frame while LY > WY,
should start window in the next line */
gb->wy_diff = gb->current_line + 1 - gb->io_registers[GB_IO_WY];
}
else {
gb->wy_diff += gb->current_line;
}
}
else {
gb->wy_diff -= gb->current_line;
gb->window_disabled_while_active = true;
}
}
}
} }

View File

@ -8,9 +8,15 @@
#ifdef GB_INTERNAL #ifdef GB_INTERNAL
void GB_display_run(GB_gameboy_t *gb, uint8_t cycles); void GB_display_run(GB_gameboy_t *gb, uint8_t cycles);
void GB_palette_changed(GB_gameboy_t *gb, bool background_palette, uint8_t index); void GB_palette_changed(GB_gameboy_t *gb, bool background_palette, uint8_t index);
void GB_window_related_write(GB_gameboy_t *gb, uint8_t addr, uint8_t value);
void GB_STAT_update(GB_gameboy_t *gb); void GB_STAT_update(GB_gameboy_t *gb);
void GB_lcd_off(GB_gameboy_t *gb); void GB_lcd_off(GB_gameboy_t *gb);
enum {
GB_OBJECT_PRIORITY_UNDEFINED, // For save state compatibility
GB_OBJECT_PRIORITY_X,
GB_OBJECT_PRIORITY_INDEX,
};
#endif #endif
typedef enum { typedef enum {
@ -44,11 +50,13 @@ typedef enum {
GB_COLOR_CORRECTION_CORRECT_CURVES, GB_COLOR_CORRECTION_CORRECT_CURVES,
GB_COLOR_CORRECTION_EMULATE_HARDWARE, GB_COLOR_CORRECTION_EMULATE_HARDWARE,
GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS, GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS,
GB_COLOR_CORRECTION_REDUCE_CONTRAST,
} GB_color_correction_mode_t; } GB_color_correction_mode_t;
void GB_draw_tileset(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index); void GB_draw_tileset(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index);
void GB_draw_tilemap(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index, GB_map_type_t map_type, GB_tileset_type_t tileset_type); void GB_draw_tilemap(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index, GB_map_type_t map_type, GB_tileset_type_t tileset_type);
uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_height); uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_height);
uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color); uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border);
void GB_set_color_correction_mode(GB_gameboy_t *gb, GB_color_correction_mode_t mode); void GB_set_color_correction_mode(GB_gameboy_t *gb, GB_color_correction_mode_t mode);
bool GB_is_odd_frame(GB_gameboy_t *gb);
#endif /* display_h */ #endif /* display_h */

455
Core/gb.c
View File

@ -13,7 +13,7 @@
#include "gb.h" #include "gb.h"
#ifdef DISABLE_REWIND #ifdef GB_DISABLE_REWIND
#define GB_rewind_free(...) #define GB_rewind_free(...)
#define GB_rewind_push(...) #define GB_rewind_push(...)
#endif #endif
@ -57,7 +57,7 @@ void GB_log(GB_gameboy_t *gb, const char *fmt, ...)
va_end(args); va_end(args);
} }
#ifndef DISABLE_DEBUGGER #ifndef GB_DISABLE_DEBUGGER
static char *default_input_callback(GB_gameboy_t *gb) static char *default_input_callback(GB_gameboy_t *gb)
{ {
char *expression = NULL; char *expression = NULL;
@ -99,6 +99,42 @@ static char *default_async_input_callback(GB_gameboy_t *gb)
} }
#endif #endif
static void load_default_border(GB_gameboy_t *gb)
{
if (gb->has_sgb_border) return;
#define LOAD_BORDER() do { \
memcpy(gb->borrowed_border.map, tilemap, sizeof(tilemap));\
memcpy(gb->borrowed_border.palette, palette, sizeof(palette));\
\
/* Expand tileset */\
for (unsigned tile = 0; tile < sizeof(tiles) / 32; tile++) {\
for (unsigned y = 0; y < 8; y++) {\
for (unsigned x = 0; x < 8; x++) {\
gb->borrowed_border.tiles[tile * 8 * 8 + y * 8 + x] =\
(tiles[tile * 32 + y * 2 + 0] & (1 << (7 ^ x)) ? 1 : 0) |\
(tiles[tile * 32 + y * 2 + 1] & (1 << (7 ^ x)) ? 2 : 0) |\
(tiles[tile * 32 + y * 2 + 16] & (1 << (7 ^ x)) ? 4 : 0) |\
(tiles[tile * 32 + y * 2 + 17] & (1 << (7 ^ x)) ? 8 : 0);\
}\
}\
}\
} while (false);
if (gb->model == GB_MODEL_AGB) {
#include "graphics/agb_border.inc"
LOAD_BORDER();
}
else if (GB_is_cgb(gb)) {
#include "graphics/cgb_border.inc"
LOAD_BORDER();
}
else {
#include "graphics/dmg_border.inc"
LOAD_BORDER();
}
}
void GB_init(GB_gameboy_t *gb, GB_model_t model) void GB_init(GB_gameboy_t *gb, GB_model_t model)
{ {
memset(gb, 0, sizeof(*gb)); memset(gb, 0, sizeof(*gb));
@ -112,7 +148,7 @@ void GB_init(GB_gameboy_t *gb, GB_model_t model)
gb->vram = malloc(gb->vram_size = 0x2000); gb->vram = malloc(gb->vram_size = 0x2000);
} }
#ifndef DISABLE_DEBUGGER #ifndef GB_DISABLE_DEBUGGER
gb->input_callback = default_input_callback; gb->input_callback = default_input_callback;
gb->async_input_callback = default_async_input_callback; gb->async_input_callback = default_async_input_callback;
#endif #endif
@ -125,6 +161,7 @@ void GB_init(GB_gameboy_t *gb, GB_model_t model)
} }
GB_reset(gb); GB_reset(gb);
load_default_border(gb);
} }
GB_model_t GB_get_model(GB_gameboy_t *gb) GB_model_t GB_get_model(GB_gameboy_t *gb)
@ -156,10 +193,15 @@ void GB_free(GB_gameboy_t *gb)
if (gb->nontrivial_jump_state) { if (gb->nontrivial_jump_state) {
free(gb->nontrivial_jump_state); free(gb->nontrivial_jump_state);
} }
#ifndef DISABLE_DEBUGGER #ifndef GB_DISABLE_DEBUGGER
GB_debugger_clear_symbols(gb); GB_debugger_clear_symbols(gb);
#endif #endif
GB_rewind_free(gb); GB_rewind_free(gb);
#ifndef GB_DISABLE_CHEATS
while (gb->cheats) {
GB_remove_cheat(gb, gb->cheats[0]);
}
#endif
memset(gb, 0, sizeof(*gb)); memset(gb, 0, sizeof(*gb));
} }
@ -184,6 +226,46 @@ void GB_load_boot_rom_from_buffer(GB_gameboy_t *gb, const unsigned char *buffer,
memcpy(gb->boot_rom, buffer, size); memcpy(gb->boot_rom, buffer, size);
} }
void GB_borrow_sgb_border(GB_gameboy_t *gb)
{
if (GB_is_sgb(gb)) return;
if (gb->border_mode != GB_BORDER_ALWAYS) return;
if (gb->tried_loading_sgb_border) return;
gb->tried_loading_sgb_border = true;
if (gb->rom && gb->rom[0x146] != 3) return; // Not an SGB game, nothing to borrow
if (!gb->boot_rom_load_callback) return; // Can't borrow a border without this callback
GB_gameboy_t sgb;
GB_init(&sgb, GB_MODEL_SGB);
sgb.cartridge_type = gb->cartridge_type;
sgb.rom = gb->rom;
sgb.rom_size = gb->rom_size;
sgb.turbo = true;
sgb.turbo_dont_skip = true;
// sgb.disable_rendering = true;
/* Load the boot ROM using the existing gb object */
typeof(gb->boot_rom) boot_rom_backup;
memcpy(boot_rom_backup, gb->boot_rom, sizeof(gb->boot_rom));
gb->boot_rom_load_callback(gb, GB_BOOT_ROM_SGB);
memcpy(sgb.boot_rom, gb->boot_rom, sizeof(gb->boot_rom));
memcpy(gb->boot_rom, boot_rom_backup, sizeof(gb->boot_rom));
sgb.sgb->intro_animation = -1;
for (unsigned i = 600; i--;) {
GB_run_frame(&sgb);
if (sgb.sgb->border_animation) {
gb->has_sgb_border = true;
memcpy(&gb->borrowed_border, &sgb.sgb->pending_border, sizeof(gb->borrowed_border));
gb->borrowed_border.palette[0] = sgb.sgb->effective_palettes[0];
break;
}
}
sgb.rom = NULL;
sgb.rom_size = 0;
GB_free(&sgb);
}
int GB_load_rom(GB_gameboy_t *gb, const char *path) int GB_load_rom(GB_gameboy_t *gb, const char *path)
{ {
FILE *f = fopen(path, "rb"); FILE *f = fopen(path, "rb");
@ -199,6 +281,9 @@ int GB_load_rom(GB_gameboy_t *gb, const char *path)
gb->rom_size |= gb->rom_size >> 1; gb->rom_size |= gb->rom_size >> 1;
gb->rom_size++; gb->rom_size++;
} }
if (gb->rom_size == 0) {
gb->rom_size = 0x8000;
}
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
if (gb->rom) { if (gb->rom) {
free(gb->rom); free(gb->rom);
@ -208,8 +293,244 @@ int GB_load_rom(GB_gameboy_t *gb, const char *path)
fread(gb->rom, 1, gb->rom_size, f); fread(gb->rom, 1, gb->rom_size, f);
fclose(f); fclose(f);
GB_configure_cart(gb); GB_configure_cart(gb);
return 0;
}
int GB_load_isx(GB_gameboy_t *gb, const char *path)
{
FILE *f = fopen(path, "rb");
if (!f) {
GB_log(gb, "Could not open ISX file: %s.\n", strerror(errno));
return errno;
}
char magic[4];
#define READ(x) if (fread(&x, sizeof(x), 1, f) != 1) goto error
fread(magic, 1, sizeof(magic), f);
#ifdef GB_BIG_ENDIAN
bool extended = *(uint32_t *)&magic == 'ISX ';
#else
bool extended = *(uint32_t *)&magic == __builtin_bswap32('ISX ');
#endif
fseek(f, extended? 0x20 : 0, SEEK_SET);
uint8_t *old_rom = gb->rom;
uint32_t old_size = gb->rom_size;
gb->rom = NULL;
gb->rom_size = 0;
while (true) {
uint8_t record_type = 0;
if (fread(&record_type, sizeof(record_type), 1, f) != 1) break;
switch (record_type) {
case 0x01: { // Binary
uint16_t bank;
uint16_t address;
uint16_t length;
uint8_t byte;
READ(byte);
bank = byte;
if (byte >= 0x80) {
READ(byte);
bank |= byte << 8;
}
READ(address);
#ifdef GB_BIG_ENDIAN
address = __builtin_bswap16(address);
#endif
address &= 0x3FFF;
READ(length);
#ifdef GB_BIG_ENDIAN
length = __builtin_bswap16(length);
#endif
size_t needed_size = bank * 0x4000 + address + length;
if (needed_size > 1024 * 1024 * 32)
goto error;
if (gb->rom_size < needed_size) {
gb->rom = realloc(gb->rom, needed_size);
memset(gb->rom + gb->rom_size, 0, needed_size - gb->rom_size);
gb->rom_size = needed_size;
}
if (fread(gb->rom + (bank * 0x4000 + address), length, 1, f) != 1)
goto error;
break;
}
case 0x11: { // Extended Binary
uint32_t address;
uint32_t length;
READ(address);
#ifdef GB_BIG_ENDIAN
address = __builtin_bswap32(address);
#endif
READ(length);
#ifdef GB_BIG_ENDIAN
length = __builtin_bswap32(length);
#endif
size_t needed_size = address + length;
if (needed_size > 1024 * 1024 * 32)
goto error;
if (gb->rom_size < needed_size) {
gb->rom = realloc(gb->rom, needed_size);
memset(gb->rom + gb->rom_size, 0, needed_size - gb->rom_size);
gb->rom_size = needed_size;
}
if (fread(gb->rom + address, length, 1, f) != 1)
goto error;
break;
}
case 0x04: { // Symbol
uint16_t count;
uint8_t length;
char name[257];
uint8_t flag;
uint16_t bank;
uint16_t address;
uint8_t byte;
READ(count);
#ifdef GB_BIG_ENDIAN
count = __builtin_bswap16(count);
#endif
while (count--) {
READ(length);
if (fread(name, length, 1, f) != 1)
goto error;
name[length] = 0;
READ(flag); // unused
READ(byte);
bank = byte;
if (byte >= 0x80) {
READ(byte);
bank |= byte << 8;
}
READ(address);
#ifdef GB_BIG_ENDIAN
address = __builtin_bswap16(address);
#endif
GB_debugger_add_symbol(gb, bank, address, name);
}
break;
}
case 0x14: { // Extended Binary
uint16_t count;
uint8_t length;
char name[257];
uint8_t flag;
uint32_t address;
READ(count);
#ifdef GB_BIG_ENDIAN
count = __builtin_bswap16(count);
#endif
while (count--) {
READ(length);
if (fread(name, length + 1, 1, f) != 1)
goto error;
name[length] = 0;
READ(flag); // unused
READ(address);
#ifdef GB_BIG_ENDIAN
address = __builtin_bswap32(address);
#endif
// TODO: How to convert 32-bit addresses to Bank:Address? Needs to tell RAM and ROM apart
}
break;
}
default:
goto done;
}
}
done:;
#undef READ
if (gb->rom_size == 0) goto error;
size_t needed_size = (gb->rom_size + 0x3FFF) & ~0x3FFF; /* Round to bank */
/* And then round to a power of two */
while (needed_size & (needed_size - 1)) {
/* I promise this works. */
needed_size |= needed_size >> 1;
needed_size++;
}
if (needed_size < 0x8000) {
needed_size = 0x8000;
}
if (gb->rom_size < needed_size) {
gb->rom = realloc(gb->rom, needed_size);
memset(gb->rom + gb->rom_size, 0, needed_size - gb->rom_size);
gb->rom_size = needed_size;
}
GB_configure_cart(gb);
// Fix a common wrong MBC error
if (gb->rom[0x147] == 3) { // MBC1 + RAM + Battery
bool needs_fix = false;
if (gb->rom_size >= 0x21 * 0x4000) {
for (unsigned i = 0x20 * 0x4000; i < 0x21 * 0x4000; i++) {
if (gb->rom[i]) {
needs_fix = true;
break;
}
}
}
if (!needs_fix && gb->rom_size >= 0x41 * 0x4000) {
for (unsigned i = 0x40 * 0x4000; i < 0x41 * 0x4000; i++) {
if (gb->rom[i]) {
needs_fix = true;
break;
}
}
}
if (!needs_fix && gb->rom_size >= 0x61 * 0x4000) {
for (unsigned i = 0x60 * 0x4000; i < 0x61 * 0x4000; i++) {
if (gb->rom[i]) {
needs_fix = true;
break;
}
}
}
if (needs_fix) {
gb->rom[0x147] = 0x10; // MBC3 + RTC + RAM + Battery
GB_configure_cart(gb);
gb->rom[0x147] = 0x3;
GB_log(gb, "ROM claims to use MBC1 but appears to require MBC3 or 5, assuming MBC3.\n");
}
}
if (old_rom) {
free(old_rom);
}
return 0; return 0;
error:
GB_log(gb, "Invalid or unsupported ISX file.\n");
if (gb->rom) {
free(gb->rom);
gb->rom = old_rom;
gb->rom_size = old_size;
}
fclose(f);
return -1;
} }
void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size) void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size)
@ -219,6 +540,9 @@ void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t siz
gb->rom_size |= gb->rom_size >> 1; gb->rom_size |= gb->rom_size >> 1;
gb->rom_size++; gb->rom_size++;
} }
if (gb->rom_size == 0) {
gb->rom_size = 0x8000;
}
if (gb->rom) { if (gb->rom) {
free(gb->rom); free(gb->rom);
} }
@ -558,7 +882,7 @@ void GB_set_log_callback(GB_gameboy_t *gb, GB_log_callback_t callback)
void GB_set_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback) void GB_set_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback)
{ {
#ifndef DISABLE_DEBUGGER #ifndef GB_DISABLE_DEBUGGER
if (gb->input_callback == default_input_callback) { if (gb->input_callback == default_input_callback) {
gb->async_input_callback = NULL; gb->async_input_callback = NULL;
} }
@ -568,26 +892,46 @@ void GB_set_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback)
void GB_set_async_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback) void GB_set_async_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback)
{ {
#ifndef DISABLE_DEBUGGER #ifndef GB_DISABLE_DEBUGGER
gb->async_input_callback = callback; gb->async_input_callback = callback;
#endif #endif
} }
const GB_palette_t GB_PALETTE_GREY = {{{0x00, 0x00, 0x00}, {0x55, 0x55, 0x55}, {0xaa, 0xaa, 0xaa}, {0xff, 0xff, 0xff}, {0xff, 0xff, 0xff}}};
const GB_palette_t GB_PALETTE_DMG = {{{0x08, 0x18, 0x10}, {0x39, 0x61, 0x39}, {0x84, 0xa5, 0x63}, {0xc6, 0xde, 0x8c}, {0xd2, 0xe6, 0xa6}}};
const GB_palette_t GB_PALETTE_MGB = {{{0x07, 0x10, 0x0e}, {0x3a, 0x4c, 0x3a}, {0x81, 0x8d, 0x66}, {0xc2, 0xce, 0x93}, {0xcf, 0xda, 0xac}}};
const GB_palette_t GB_PALETTE_GBL = {{{0x0a, 0x1c, 0x15}, {0x35, 0x78, 0x62}, {0x56, 0xb4, 0x95}, {0x7f, 0xe2, 0xc3}, {0x91, 0xea, 0xd0}}};
static void update_dmg_palette(GB_gameboy_t *gb)
{
const GB_palette_t *palette = gb->dmg_palette ?: &GB_PALETTE_GREY;
if (gb->rgb_encode_callback && !GB_is_cgb(gb)) {
gb->sprite_palettes_rgb[4] = gb->sprite_palettes_rgb[0] = gb->background_palettes_rgb[0] =
gb->rgb_encode_callback(gb, palette->colors[3].r, palette->colors[3].g, palette->colors[3].b);
gb->sprite_palettes_rgb[5] = gb->sprite_palettes_rgb[1] = gb->background_palettes_rgb[1] =
gb->rgb_encode_callback(gb, palette->colors[2].r, palette->colors[2].g, palette->colors[2].b);
gb->sprite_palettes_rgb[6] = gb->sprite_palettes_rgb[2] = gb->background_palettes_rgb[2] =
gb->rgb_encode_callback(gb, palette->colors[1].r, palette->colors[1].g, palette->colors[1].b);
gb->sprite_palettes_rgb[7] = gb->sprite_palettes_rgb[3] = gb->background_palettes_rgb[3] =
gb->rgb_encode_callback(gb, palette->colors[0].r, palette->colors[0].g, palette->colors[0].b);
// LCD off color
gb->background_palettes_rgb[4] =
gb->rgb_encode_callback(gb, palette->colors[4].r, palette->colors[4].g, palette->colors[4].b);
}
}
void GB_set_palette(GB_gameboy_t *gb, const GB_palette_t *palette)
{
gb->dmg_palette = palette;
update_dmg_palette(gb);
}
void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callback) void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callback)
{ {
if (!gb->rgb_encode_callback && !GB_is_cgb(gb)) {
gb->sprite_palettes_rgb[4] = gb->sprite_palettes_rgb[0] = gb->background_palettes_rgb[0] =
callback(gb, 0xFF, 0xFF, 0xFF);
gb->sprite_palettes_rgb[5] = gb->sprite_palettes_rgb[1] = gb->background_palettes_rgb[1] =
callback(gb, 0xAA, 0xAA, 0xAA);
gb->sprite_palettes_rgb[6] = gb->sprite_palettes_rgb[2] = gb->background_palettes_rgb[2] =
callback(gb, 0x55, 0x55, 0x55);
gb->sprite_palettes_rgb[7] = gb->sprite_palettes_rgb[3] = gb->background_palettes_rgb[3] =
callback(gb, 0, 0, 0);
}
gb->rgb_encode_callback = callback; gb->rgb_encode_callback = callback;
update_dmg_palette(gb);
for (unsigned i = 0; i < 32; i++) { for (unsigned i = 0; i < 32; i++) {
GB_palette_changed(gb, true, i * 2); GB_palette_changed(gb, true, i * 2);
@ -607,7 +951,7 @@ void GB_set_infrared_input(GB_gameboy_t *gb, bool state)
gb->ir_queue_length = 0; gb->ir_queue_length = 0;
} }
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, long cycles_after_previous_change) void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, uint64_t cycles_after_previous_change)
{ {
if (gb->ir_queue_length == GB_MAX_IR_QUEUE) { if (gb->ir_queue_length == GB_MAX_IR_QUEUE) {
GB_log(gb, "IR Queue is full\n"); GB_log(gb, "IR Queue is full\n");
@ -858,6 +1202,36 @@ static void reset_ram(GB_gameboy_t *gb)
} }
} }
static void request_boot_rom(GB_gameboy_t *gb)
{
if (gb->boot_rom_load_callback) {
GB_boot_rom_t type = 0;
switch (gb->model) {
case GB_MODEL_DMG_B:
type = GB_BOOT_ROM_DMG;
break;
case GB_MODEL_SGB_NTSC:
case GB_MODEL_SGB_PAL:
case GB_MODEL_SGB_NTSC_NO_SFC:
case GB_MODEL_SGB_PAL_NO_SFC:
type = GB_BOOT_ROM_SGB;
break;
case GB_MODEL_SGB2:
case GB_MODEL_SGB2_NO_SFC:
type = GB_BOOT_ROM_SGB2;
break;
case GB_MODEL_CGB_C:
case GB_MODEL_CGB_E:
type = GB_BOOT_ROM_CGB;
break;
case GB_MODEL_AGB:
type = GB_BOOT_ROM_AGB;
break;
}
gb->boot_rom_load_callback(gb, type);
}
}
void GB_reset(GB_gameboy_t *gb) void GB_reset(GB_gameboy_t *gb)
{ {
uint32_t mbc_ram_size = gb->mbc_ram_size; uint32_t mbc_ram_size = gb->mbc_ram_size;
@ -876,22 +1250,15 @@ void GB_reset(GB_gameboy_t *gb)
gb->vram_size = 0x2000 * 2; gb->vram_size = 0x2000 * 2;
memset(gb->vram, 0, gb->vram_size); memset(gb->vram, 0, gb->vram_size);
gb->cgb_mode = true; gb->cgb_mode = true;
gb->object_priority = GB_OBJECT_PRIORITY_INDEX;
} }
else { else {
gb->ram_size = 0x2000; gb->ram_size = 0x2000;
gb->vram_size = 0x2000; gb->vram_size = 0x2000;
memset(gb->vram, 0, gb->vram_size); memset(gb->vram, 0, gb->vram_size);
gb->object_priority = GB_OBJECT_PRIORITY_X;
if (gb->rgb_encode_callback) { update_dmg_palette(gb);
gb->sprite_palettes_rgb[4] = gb->sprite_palettes_rgb[0] = gb->background_palettes_rgb[0] =
gb->rgb_encode_callback(gb, 0xFF, 0xFF, 0xFF);
gb->sprite_palettes_rgb[5] = gb->sprite_palettes_rgb[1] = gb->background_palettes_rgb[1] =
gb->rgb_encode_callback(gb, 0xAA, 0xAA, 0xAA);
gb->sprite_palettes_rgb[6] = gb->sprite_palettes_rgb[2] = gb->background_palettes_rgb[2] =
gb->rgb_encode_callback(gb, 0x55, 0x55, 0x55);
gb->sprite_palettes_rgb[7] = gb->sprite_palettes_rgb[3] = gb->background_palettes_rgb[3] =
gb->rgb_encode_callback(gb, 0, 0, 0);
}
} }
reset_ram(gb); reset_ram(gb);
@ -937,6 +1304,7 @@ void GB_reset(GB_gameboy_t *gb)
} }
gb->magic = state_magic(); gb->magic = state_magic();
request_boot_rom(gb);
} }
void GB_switch_model_and_reset(GB_gameboy_t *gb, GB_model_t model) void GB_switch_model_and_reset(GB_gameboy_t *gb, GB_model_t model)
@ -952,6 +1320,7 @@ void GB_switch_model_and_reset(GB_gameboy_t *gb, GB_model_t model)
} }
GB_rewind_free(gb); GB_rewind_free(gb);
GB_reset(gb); GB_reset(gb);
load_default_border(gb);
} }
void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t *size, uint16_t *bank) void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t *size, uint16_t *bank)
@ -1037,14 +1406,36 @@ uint32_t GB_get_clock_rate(GB_gameboy_t *gb)
return CPU_FREQUENCY * gb->clock_multiplier; return CPU_FREQUENCY * gb->clock_multiplier;
} }
void GB_set_border_mode(GB_gameboy_t *gb, GB_border_mode_t border_mode)
{
if (gb->border_mode > GB_BORDER_ALWAYS) return;
gb->border_mode = border_mode;
}
unsigned GB_get_screen_width(GB_gameboy_t *gb) unsigned GB_get_screen_width(GB_gameboy_t *gb)
{ {
return GB_is_hle_sgb(gb)? 256 : 160; switch (gb->border_mode) {
default:
case GB_BORDER_SGB:
return GB_is_hle_sgb(gb)? 256 : 160;
case GB_BORDER_NEVER:
return 160;
case GB_BORDER_ALWAYS:
return 256;
}
} }
unsigned GB_get_screen_height(GB_gameboy_t *gb) unsigned GB_get_screen_height(GB_gameboy_t *gb)
{ {
return GB_is_hle_sgb(gb)? 224 : 144; switch (gb->border_mode) {
default:
case GB_BORDER_SGB:
return GB_is_hle_sgb(gb)? 224 : 144;
case GB_BORDER_NEVER:
return 144;
case GB_BORDER_ALWAYS:
return 224;
}
} }
unsigned GB_get_player_count(GB_gameboy_t *gb) unsigned GB_get_player_count(GB_gameboy_t *gb)
@ -1082,3 +1473,9 @@ void GB_set_icd_vreset_callback(GB_gameboy_t *gb, GB_icd_vreset_callback_t callb
{ {
gb->icd_vreset_callback = callback; gb->icd_vreset_callback = callback;
} }
void GB_set_boot_rom_load_callback(GB_gameboy_t *gb, GB_boot_rom_load_callback_t callback)
{
gb->boot_rom_load_callback = callback;
request_boot_rom(gb);
}

107
Core/gb.h
View File

@ -21,6 +21,7 @@
#include "sm83_cpu.h" #include "sm83_cpu.h"
#include "symbol_hash.h" #include "symbol_hash.h"
#include "sgb.h" #include "sgb.h"
#include "cheats.h"
#define GB_STRUCT_VERSION 13 #define GB_STRUCT_VERSION 13
@ -34,7 +35,7 @@
#ifdef GB_INTERNAL #ifdef GB_INTERNAL
#if __clang__ #if __clang__
#define UNROLL _Pragma("unroll") #define UNROLL _Pragma("unroll")
#elif __GNUC__ #elif __GNUC__ >= 8
#define UNROLL _Pragma("GCC unroll 8") #define UNROLL _Pragma("GCC unroll 8")
#else #else
#define UNROLL #define UNROLL
@ -50,6 +51,17 @@
#error Unable to detect endianess #error Unable to detect endianess
#endif #endif
typedef struct {
struct {
uint8_t r, g, b;
} colors[5];
} GB_palette_t;
extern const GB_palette_t GB_PALETTE_GREY;
extern const GB_palette_t GB_PALETTE_DMG;
extern const GB_palette_t GB_PALETTE_MGB;
extern const GB_palette_t GB_PALETTE_GBL;
typedef union { typedef union {
struct { struct {
uint8_t seconds; uint8_t seconds;
@ -61,7 +73,6 @@ typedef union {
uint8_t data[5]; uint8_t data[5];
} GB_rtc_time_t; } GB_rtc_time_t;
typedef enum { typedef enum {
// GB_MODEL_DMG_0 = 0x000, // GB_MODEL_DMG_0 = 0x000,
// GB_MODEL_DMG_A = 0x001, // GB_MODEL_DMG_A = 0x001,
@ -102,6 +113,12 @@ enum {
GB_ZERO_FLAG = 128, GB_ZERO_FLAG = 128,
}; };
typedef enum {
GB_BORDER_SGB,
GB_BORDER_NEVER,
GB_BORDER_ALWAYS,
} GB_border_mode_t;
#define GB_MAX_IR_QUEUE 256 #define GB_MAX_IR_QUEUE 256
enum { enum {
@ -169,7 +186,7 @@ enum {
// Unfortunately it is not readable or writable after boot has finished, so research of this // Unfortunately it is not readable or writable after boot has finished, so research of this
// register is quite limited. The value written to this register, however, can be controlled // register is quite limited. The value written to this register, however, can be controlled
// in some cases. // in some cases.
GB_IO_DMG_EMULATION = 0x4c, GB_IO_KEY0 = 0x4c,
/* General CGB features */ /* General CGB features */
GB_IO_KEY1 = 0x4d, // CGB Mode Only - Prepare Speed Switch GB_IO_KEY1 = 0x4d, // CGB Mode Only - Prepare Speed Switch
@ -177,7 +194,7 @@ enum {
/* Missing */ /* Missing */
GB_IO_VBK = 0x4f, // CGB Mode Only - VRAM Bank GB_IO_VBK = 0x4f, // CGB Mode Only - VRAM Bank
GB_IO_BIOS = 0x50, // Write to disable the BIOS mapping GB_IO_BANK = 0x50, // Write to disable the BIOS mapping
/* CGB DMA */ /* CGB DMA */
GB_IO_HDMA1 = 0x51, // CGB Mode Only - New DMA Source, High GB_IO_HDMA1 = 0x51, // CGB Mode Only - New DMA Source, High
@ -196,9 +213,7 @@ enum {
GB_IO_BGPD = 0x69, // CGB Mode Only - Background Palette Data GB_IO_BGPD = 0x69, // CGB Mode Only - Background Palette Data
GB_IO_OBPI = 0x6a, // CGB Mode Only - Sprite Palette Index GB_IO_OBPI = 0x6a, // CGB Mode Only - Sprite Palette Index
GB_IO_OBPD = 0x6b, // CGB Mode Only - Sprite Palette Data GB_IO_OBPD = 0x6b, // CGB Mode Only - Sprite Palette Data
GB_IO_OPRI = 0x6c, // Affects object priority (X based or index based)
// 1 is written for DMG ROMs on a CGB. Does not appear to have an effect.
GB_IO_DMG_EMULATION_INDICATION = 0x6c, // (FEh) Bit 0 (Read/Write)
/* Missing */ /* Missing */
@ -219,6 +234,17 @@ typedef enum {
GB_LOG_UNDERLINE_MASK = GB_LOG_DASHED_UNDERLINE | GB_LOG_UNDERLINE GB_LOG_UNDERLINE_MASK = GB_LOG_DASHED_UNDERLINE | GB_LOG_UNDERLINE
} GB_log_attributes; } GB_log_attributes;
typedef enum {
GB_BOOT_ROM_DMG0,
GB_BOOT_ROM_DMG,
GB_BOOT_ROM_MGB,
GB_BOOT_ROM_SGB,
GB_BOOT_ROM_SGB2,
GB_BOOT_ROM_CGB0,
GB_BOOT_ROM_CGB,
GB_BOOT_ROM_AGB,
} GB_boot_rom_t;
#ifdef GB_INTERNAL #ifdef GB_INTERNAL
#define LCDC_PERIOD 70224 #define LCDC_PERIOD 70224
#define CPU_FREQUENCY 0x400000 #define CPU_FREQUENCY 0x400000
@ -228,11 +254,11 @@ typedef enum {
#define INTERNAL_DIV_CYCLES (0x40000) #define INTERNAL_DIV_CYCLES (0x40000)
#if !defined(MIN) #if !defined(MIN)
#define MIN(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) #define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })
#endif #endif
#if !defined(MAX) #if !defined(MAX)
#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) #define MAX(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
#endif #endif
#endif #endif
@ -240,7 +266,7 @@ typedef void (*GB_vblank_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_log_callback_t)(GB_gameboy_t *gb, const char *string, GB_log_attributes attributes); typedef void (*GB_log_callback_t)(GB_gameboy_t *gb, const char *string, GB_log_attributes attributes);
typedef char *(*GB_input_callback_t)(GB_gameboy_t *gb); typedef char *(*GB_input_callback_t)(GB_gameboy_t *gb);
typedef uint32_t (*GB_rgb_encode_callback_t)(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b); typedef uint32_t (*GB_rgb_encode_callback_t)(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b);
typedef void (*GB_infrared_callback_t)(GB_gameboy_t *gb, bool on, long cycles_since_last_update); typedef void (*GB_infrared_callback_t)(GB_gameboy_t *gb, bool on, uint64_t cycles_since_last_update);
typedef void (*GB_rumble_callback_t)(GB_gameboy_t *gb, double rumble_amplitude); typedef void (*GB_rumble_callback_t)(GB_gameboy_t *gb, double rumble_amplitude);
typedef void (*GB_serial_transfer_bit_start_callback_t)(GB_gameboy_t *gb, bool bit_to_send); typedef void (*GB_serial_transfer_bit_start_callback_t)(GB_gameboy_t *gb, bool bit_to_send);
typedef bool (*GB_serial_transfer_bit_end_callback_t)(GB_gameboy_t *gb); typedef bool (*GB_serial_transfer_bit_end_callback_t)(GB_gameboy_t *gb);
@ -249,10 +275,11 @@ typedef void (*GB_joyp_write_callback_t)(GB_gameboy_t *gb, uint8_t value);
typedef void (*GB_icd_pixel_callback_t)(GB_gameboy_t *gb, uint8_t row); typedef void (*GB_icd_pixel_callback_t)(GB_gameboy_t *gb, uint8_t row);
typedef void (*GB_icd_hreset_callback_t)(GB_gameboy_t *gb); typedef void (*GB_icd_hreset_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_icd_vreset_callback_t)(GB_gameboy_t *gb); typedef void (*GB_icd_vreset_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_boot_rom_load_callback_t)(GB_gameboy_t *gb, GB_boot_rom_t type);
typedef struct { typedef struct {
bool state; bool state;
long delay; uint64_t delay;
} GB_ir_queue_item_t; } GB_ir_queue_item_t;
struct GB_breakpoint_s; struct GB_breakpoint_s;
@ -377,9 +404,8 @@ struct GB_gameboy_internal_s {
} mbc2; } mbc2;
struct { struct {
uint8_t rom_bank:7; uint8_t rom_bank:8;
uint8_t padding:1; uint8_t ram_bank:3;
uint8_t ram_bank:4;
} mbc3; } mbc3;
struct { struct {
@ -446,7 +472,7 @@ struct GB_gameboy_internal_s {
uint8_t position_in_line; uint8_t position_in_line;
bool stat_interrupt_line; bool stat_interrupt_line;
uint8_t effective_scx; uint8_t effective_scx;
uint8_t wy_diff; uint8_t window_y;
/* The LCDC will skip the first frame it renders after turning it on. /* The LCDC will skip the first frame it renders after turning it on.
On the CGB, a frame is not skipped if the previous frame was skipped as well. On the CGB, a frame is not skipped if the previous frame was skipped as well.
See https://www.reddit.com/r/EmuDev/comments/6exyxu/ */ See https://www.reddit.com/r/EmuDev/comments/6exyxu/ */
@ -463,7 +489,7 @@ struct GB_gameboy_internal_s {
bool vram_read_blocked; bool vram_read_blocked;
bool oam_write_blocked; bool oam_write_blocked;
bool vram_write_blocked; bool vram_write_blocked;
bool window_disabled_while_active; bool fifo_insertion_glitch;
uint8_t current_line; uint8_t current_line;
uint16_t ly_for_comparison; uint16_t ly_for_comparison;
GB_fifo_t bg_fifo, oam_fifo; GB_fifo_t bg_fifo, oam_fifo;
@ -474,9 +500,9 @@ struct GB_gameboy_internal_s {
uint8_t current_tile_attributes; uint8_t current_tile_attributes;
uint8_t current_tile_data[2]; uint8_t current_tile_data[2];
uint8_t fetcher_state; uint8_t fetcher_state;
bool bg_fifo_paused; bool window_is_being_fetched;
bool oam_fifo_paused; bool wx166_glitch;
bool in_window; bool wx_triggered;
uint8_t visible_objs[10]; uint8_t visible_objs[10];
uint8_t obj_comparators[10]; uint8_t obj_comparators[10];
uint8_t n_visible_objs; uint8_t n_visible_objs;
@ -488,6 +514,17 @@ struct GB_gameboy_internal_s {
bool cgb_palettes_blocked; bool cgb_palettes_blocked;
uint8_t current_lcd_line; // The LCD can go out of sync since the vsync signal is skipped in some cases. uint8_t current_lcd_line; // The LCD can go out of sync since the vsync signal is skipped in some cases.
uint32_t cycles_in_stop_mode; uint32_t cycles_in_stop_mode;
uint8_t object_priority;
bool oam_ppu_blocked;
bool vram_ppu_blocked;
bool cgb_palettes_ppu_blocked;
bool object_fetch_aborted;
bool during_object_fetch;
uint16_t object_low_line_address;
bool wy_triggered;
uint8_t window_tile_x;
uint8_t lcd_x; // The LCD can go out of sync since the push signal is skipped in some cases.
bool is_odd_frame;
); );
/* Unsaved data. This includes all pointers, as well as everything that shouldn't be on a save state */ /* Unsaved data. This includes all pointers, as well as everything that shouldn't be on a save state */
@ -501,6 +538,7 @@ struct GB_gameboy_internal_s {
GB_STANDARD_MBC1_WIRING, GB_STANDARD_MBC1_WIRING,
GB_MBC1M_WIRING, GB_MBC1M_WIRING,
} mbc1_wiring; } mbc1_wiring;
bool is_mbc30;
unsigned pending_cycles; unsigned pending_cycles;
@ -513,8 +551,13 @@ struct GB_gameboy_internal_s {
uint32_t *screen; uint32_t *screen;
uint32_t background_palettes_rgb[0x20]; uint32_t background_palettes_rgb[0x20];
uint32_t sprite_palettes_rgb[0x20]; uint32_t sprite_palettes_rgb[0x20];
const GB_palette_t *dmg_palette;
GB_color_correction_mode_t color_correction_mode; GB_color_correction_mode_t color_correction_mode;
bool keys[4][GB_KEY_MAX]; bool keys[4][GB_KEY_MAX];
GB_border_mode_t border_mode;
GB_sgb_border_t borrowed_border;
bool tried_loading_sgb_border;
bool has_sgb_border;
/* Timing */ /* Timing */
uint64_t last_sync; uint64_t last_sync;
@ -542,10 +585,11 @@ struct GB_gameboy_internal_s {
GB_icd_vreset_callback_t icd_hreset_callback; GB_icd_vreset_callback_t icd_hreset_callback;
GB_icd_vreset_callback_t icd_vreset_callback; GB_icd_vreset_callback_t icd_vreset_callback;
GB_read_memory_callback_t read_memory_callback; GB_read_memory_callback_t read_memory_callback;
GB_boot_rom_load_callback_t boot_rom_load_callback;
/* IR */ /* IR */
long cycles_since_ir_change; // In 8MHz units uint64_t cycles_since_ir_change; // In 8MHz units
long cycles_since_input_ir_change; // In 8MHz units uint64_t cycles_since_input_ir_change; // In 8MHz units
GB_ir_queue_item_t ir_queue[GB_MAX_IR_QUEUE]; GB_ir_queue_item_t ir_queue[GB_MAX_IR_QUEUE];
size_t ir_queue_length; size_t ir_queue_length;
@ -562,7 +606,7 @@ struct GB_gameboy_internal_s {
/* SLD (Todo: merge with backtrace) */ /* SLD (Todo: merge with backtrace) */
bool stack_leak_detection; bool stack_leak_detection;
int debug_call_depth; signed debug_call_depth;
uint16_t sp_for_call_depth[0x200]; /* Should be much more than enough */ uint16_t sp_for_call_depth[0x200]; /* Should be much more than enough */
uint16_t addr_for_call_depth[0x200]; uint16_t addr_for_call_depth[0x200];
@ -583,7 +627,7 @@ struct GB_gameboy_internal_s {
GB_reversed_symbol_map_t reversed_symbol_map; GB_reversed_symbol_map_t reversed_symbol_map;
/* Ticks command */ /* Ticks command */
unsigned long debugger_ticks; uint64_t debugger_ticks;
/* Rewind */ /* Rewind */
#define GB_REWIND_FRAMES_PER_KEY 255 #define GB_REWIND_FRAMES_PER_KEY 255
@ -602,6 +646,12 @@ struct GB_gameboy_internal_s {
double sgb_intro_sweep_phase; double sgb_intro_sweep_phase;
double sgb_intro_sweep_previous_sample; double sgb_intro_sweep_previous_sample;
/* Cheats */
bool cheat_enabled;
size_t cheat_count;
GB_cheat_t **cheats;
GB_cheat_hash_t *cheat_hash[256];
/* Misc */ /* Misc */
bool turbo; bool turbo;
bool turbo_dont_skip; bool turbo_dont_skip;
@ -612,6 +662,9 @@ struct GB_gameboy_internal_s {
double clock_multiplier; double clock_multiplier;
uint32_t rumble_on_cycles; uint32_t rumble_on_cycles;
uint32_t rumble_off_cycles; uint32_t rumble_off_cycles;
/* Temporary state */
bool wx_just_changed;
); );
}; };
@ -670,6 +723,7 @@ int GB_load_boot_rom(GB_gameboy_t *gb, const char *path);
void GB_load_boot_rom_from_buffer(GB_gameboy_t *gb, const unsigned char *buffer, size_t size); void GB_load_boot_rom_from_buffer(GB_gameboy_t *gb, const unsigned char *buffer, size_t size);
int GB_load_rom(GB_gameboy_t *gb, const char *path); int GB_load_rom(GB_gameboy_t *gb, const char *path);
void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size); void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size);
int GB_load_isx(GB_gameboy_t *gb, const char *path);
int GB_save_battery_size(GB_gameboy_t *gb); int GB_save_battery_size(GB_gameboy_t *gb);
int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size); int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size);
@ -685,9 +739,10 @@ void GB_log(GB_gameboy_t *gb, const char *fmt, ...) __printflike(2, 3);
void GB_attributed_log(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, ...) __printflike(3, 4); void GB_attributed_log(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, ...) __printflike(3, 4);
void GB_set_pixels_output(GB_gameboy_t *gb, uint32_t *output); void GB_set_pixels_output(GB_gameboy_t *gb, uint32_t *output);
void GB_set_border_mode(GB_gameboy_t *gb, GB_border_mode_t border_mode);
void GB_set_infrared_input(GB_gameboy_t *gb, bool state); void GB_set_infrared_input(GB_gameboy_t *gb, bool state);
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, long cycles_after_previous_change); /* In 8MHz units*/ void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, uint64_t cycles_after_previous_change); /* In 8MHz units*/
void GB_set_vblank_callback(GB_gameboy_t *gb, GB_vblank_callback_t callback); void GB_set_vblank_callback(GB_gameboy_t *gb, GB_vblank_callback_t callback);
void GB_set_log_callback(GB_gameboy_t *gb, GB_log_callback_t callback); void GB_set_log_callback(GB_gameboy_t *gb, GB_log_callback_t callback);
@ -697,6 +752,10 @@ void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callb
void GB_set_infrared_callback(GB_gameboy_t *gb, GB_infrared_callback_t callback); void GB_set_infrared_callback(GB_gameboy_t *gb, GB_infrared_callback_t callback);
void GB_set_rumble_callback(GB_gameboy_t *gb, GB_rumble_callback_t callback); void GB_set_rumble_callback(GB_gameboy_t *gb, GB_rumble_callback_t callback);
void GB_set_update_input_hint_callback(GB_gameboy_t *gb, GB_update_input_hint_callback_t callback); void GB_set_update_input_hint_callback(GB_gameboy_t *gb, GB_update_input_hint_callback_t callback);
/* Called when a new boot ROM is needed. The callback should call GB_load_boot_rom or GB_load_boot_rom_from_buffer */
void GB_set_boot_rom_load_callback(GB_gameboy_t *gb, GB_boot_rom_load_callback_t callback);
void GB_set_palette(GB_gameboy_t *gb, const GB_palette_t *palette);
/* These APIs are used when using internal clock */ /* These APIs are used when using internal clock */
void GB_set_serial_transfer_bit_start_callback(GB_gameboy_t *gb, GB_serial_transfer_bit_start_callback_t callback); void GB_set_serial_transfer_bit_start_callback(GB_gameboy_t *gb, GB_serial_transfer_bit_start_callback_t callback);

View File

@ -0,0 +1,522 @@
static const uint16_t palette[] = {
0x410A, 0x0421, 0x35AD, 0x4A52, 0x7FFF, 0x2D49, 0x0C42, 0x1484,
0x18A5, 0x20C6, 0x6718, 0x5D6E, 0x0000, 0x0000, 0x0000, 0x0000,
};
static const uint16_t tilemap[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0001, 0x0002, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004,
0x0004, 0x0004, 0x0004, 0x0004, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0004, 0x0004, 0x0004, 0x0004,
0x0004, 0x0004, 0x0003, 0x0003, 0x0003, 0x4002, 0x4001, 0x0000,
0x0000, 0x0006, 0x0007, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x4007, 0x4006, 0x0000,
0x0000, 0x0009, 0x0008, 0x0008, 0x0008, 0x000A, 0x000B, 0x000B,
0x000B, 0x000B, 0x000B, 0x000B, 0x000B, 0x000B, 0x000B, 0x000B,
0x000B, 0x000B, 0x000B, 0x000B, 0x000B, 0x000B, 0x000B, 0x000B,
0x000B, 0x000B, 0x400A, 0x0008, 0x0008, 0x0008, 0xC009, 0x0000,
0x0000, 0x000C, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x400C, 0x0000,
0x0000, 0x000E, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC00E, 0x0000,
0x0000, 0x000F, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x400F, 0x0000,
0x0000, 0x0010, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC010, 0x0000,
0x0000, 0x0010, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC010, 0x0000,
0x0000, 0x0011, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC011, 0x0000,
0x0000, 0x0011, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC011, 0x0000,
0x0000, 0x0012, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x4012, 0x0000,
0x0000, 0x0013, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC013, 0x0000,
0x0014, 0x0015, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x4015, 0x4014,
0x0016, 0x0017, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC017, 0xC016,
0x0016, 0x0017, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC017, 0xC016,
0x0018, 0x0019, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x4019, 0x4018,
0x001A, 0x001B, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0xC01B, 0xC01A,
0x001C, 0x001D, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x401D, 0x401C,
0x001E, 0x0008, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x0008, 0xC01E,
0x001E, 0x0008, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x0008, 0xC01E,
0x001E, 0x0008, 0x0008, 0x0008, 0x0008, 0x000D, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC00D, 0x0008, 0x0008, 0x0008, 0x0008, 0xC01E,
0x001F, 0x801D, 0x0008, 0x0008, 0x0008, 0x0020, 0x0021, 0x0022,
0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A,
0x002B, 0x002C, 0x002D, 0x002D, 0x002D, 0x002D, 0x002D, 0x002D,
0x002E, 0x0021, 0x4020, 0x0008, 0x0008, 0x0008, 0xC01D, 0x401F,
0x002F, 0x0030, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0031,
0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039,
0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041,
0x0042, 0x0043, 0x0008, 0x0008, 0x0008, 0x0008, 0x4030, 0x402F,
0x0044, 0x0045, 0x0046, 0x0047, 0x0008, 0x0008, 0x0048, 0x0049,
0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051,
0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
0x005A, 0x005B, 0x0008, 0x0008, 0x4047, 0x4046, 0x4045, 0x4044,
0x0000, 0x0000, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061,
0x0061, 0x0062, 0x0063, 0x0063, 0x0063, 0x0063, 0x0063, 0x0063,
0x0063, 0x0063, 0x0063, 0x0063, 0x0063, 0x0063, 0x4062, 0x0061,
0x0061, 0x4060, 0x405F, 0x405E, 0x405D, 0x405C, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
const uint8_t tiles[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1F, 0x01,
0x7F, 0x1F, 0xFF, 0x7E, 0xFF, 0xE1, 0xFF, 0x9F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x1E,
0x1F, 0x60, 0x7F, 0x80, 0xFF, 0x00, 0xBF, 0x40,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0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20, 0xDF, 0x20, 0xDF, 0x20, 0xDF, 0x20,
0xDF, 0x20, 0xDF, 0x20, 0xBF, 0x40, 0xBF, 0x40,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0xFF, 0xBF, 0xFF, 0xBF, 0xFF, 0xBF, 0xFF, 0xBF,
0xFF, 0xBF, 0xFF, 0xBF, 0xFF, 0xBF, 0xFF, 0xBF,
0xBF, 0x40, 0xBF, 0x40, 0xBF, 0x40, 0xBF, 0x40,
0xBF, 0x40, 0xBF, 0x40, 0xBF, 0x40, 0xBF, 0x40,
0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0xFF, 0xBF, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F,
0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F,
0xBF, 0x40, 0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80,
0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F,
0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F,
0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80,
0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, 0x01,
0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80, 0x7F, 0x80,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06,
0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06,
0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, 0x01,
0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, 0x01,
0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, 0x01,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFE, 0x01, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,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, 0x82, 0x01, 0x02,
0x07, 0x80, 0xC2, 0x05, 0x86, 0x41, 0x9F, 0x40,
0x15, 0x2E, 0x09, 0x06, 0x09, 0x16, 0x0B, 0xD4,
0xC6, 0x49, 0x8E, 0x40, 0xCF, 0xC8, 0x06, 0x01,
0xCE, 0x20, 0xE6, 0x10, 0xE6, 0x00, 0x24, 0xD0,
0x39, 0x80, 0x38, 0x01, 0x31, 0x00, 0xF8, 0x00,
0x0C, 0x8B, 0x85, 0x8A, 0x03, 0x84, 0x27, 0x20,
0x22, 0x35, 0x12, 0x34, 0x20, 0x12, 0x10, 0x20,
0x73, 0x00, 0x72, 0x08, 0x7C, 0x80, 0xDC, 0x01,
0xC8, 0x11, 0xC9, 0x06, 0xCD, 0x22, 0xEF, 0x10,
0x83, 0x44, 0x86, 0x01, 0x03, 0x85, 0x26, 0x21,
0x46, 0x69, 0x46, 0x68, 0x8E, 0xCA, 0x86, 0x88,
0x39, 0x40, 0x78, 0x84, 0x7C, 0x80, 0xD8, 0x01,
0x90, 0x29, 0xD1, 0x28, 0x73, 0x00, 0xB3, 0x40,
0x00, 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x40,
0x03, 0x02, 0x01, 0x02, 0x41, 0x7C, 0x7F, 0x00,
0xFE, 0x00, 0xFF, 0x00, 0xC0, 0x00, 0x80, 0x40,
0xFC, 0x00, 0xFC, 0x00, 0x80, 0x02, 0xC0, 0x00,
0xC0, 0x00, 0x80, 0x4C, 0xCC, 0x43, 0x8E, 0x52,
0x80, 0x4C, 0x80, 0x00, 0x12, 0x1E, 0x9E, 0x00,
0x7F, 0x00, 0x33, 0x0C, 0x32, 0x01, 0x23, 0x50,
0x33, 0x4C, 0x7F, 0x00, 0x61, 0x80, 0xF1, 0x00,
0x7C, 0x02, 0x30, 0x48, 0x31, 0x40, 0x61, 0x50,
0x87, 0xE4, 0xE3, 0x84, 0x23, 0x44, 0x43, 0x44,
0x85, 0x42, 0x87, 0x40, 0x8F, 0x50, 0x8C, 0x12,
0x78, 0x00, 0x18, 0x20, 0xB8, 0x00, 0x98, 0x24,
0x03, 0x04, 0x03, 0xE0, 0xF1, 0x12, 0xF0, 0x09,
0xF9, 0x09, 0xF9, 0x08, 0xE1, 0x12, 0xF1, 0x12,
0xF8, 0x00, 0x1E, 0xE0, 0x0C, 0x02, 0x07, 0x08,
0x07, 0x00, 0x06, 0x00, 0x1C, 0x02, 0x0C, 0x00,
0x9F, 0x91, 0x86, 0x88, 0xC4, 0x4C, 0x80, 0x4C,
0xE1, 0x20, 0xC1, 0x22, 0x23, 0xD4, 0x22, 0xD5,
0x60, 0x00, 0xFB, 0x00, 0x37, 0x00, 0x73, 0x0C,
0x1F, 0x00, 0x3C, 0x00, 0xC8, 0x14, 0xC9, 0x14,
0x16, 0x2F, 0x76, 0x4F, 0x2D, 0xDE, 0xDD, 0xBE,
0xBA, 0x7D, 0x7A, 0xFD, 0x7A, 0xFD, 0xF4, 0xF8,
0xCF, 0x00, 0x8F, 0x00, 0x5E, 0x80, 0xBE, 0x00,
0x7D, 0x00, 0xFC, 0x00, 0xFC, 0x01, 0xF9, 0x02,
0xFF, 0x00, 0xBF, 0x78, 0x86, 0x09, 0x86, 0x89,
0x06, 0x25, 0x02, 0x25, 0x42, 0x45, 0x60, 0x11,
0x00, 0x00, 0x09, 0x00, 0x70, 0x81, 0x70, 0x09,
0xDC, 0x21, 0xD8, 0x01, 0x98, 0x25, 0xCC, 0x13,
0xFF, 0x00, 0xF3, 0xF8, 0x02, 0x03, 0x01, 0x30,
0x39, 0x09, 0x30, 0x09, 0x31, 0x09, 0x20, 0x19,
0x00, 0x00, 0x01, 0x04, 0xFC, 0x00, 0xCF, 0x30,
0xE6, 0x00, 0xE6, 0x01, 0xE6, 0x00, 0xF6, 0x08,
0xFF, 0x00, 0xFA, 0xC7, 0x18, 0x21, 0x09, 0x10,
0x88, 0x99, 0x93, 0x1A, 0x83, 0x11, 0xC2, 0x41,
0x00, 0x00, 0x00, 0x20, 0xC6, 0x21, 0xFF, 0x00,
0x67, 0x00, 0xE4, 0x08, 0x6F, 0x10, 0x3C, 0x00,
0xFD, 0x02, 0xB5, 0x3A, 0xC7, 0x44, 0x03, 0x84,
0x83, 0x24, 0x21, 0xB0, 0x21, 0x12, 0x21, 0x02,
0x02, 0x00, 0x02, 0x40, 0x3C, 0x00, 0xF8, 0x00,
0xD8, 0x24, 0x4C, 0x92, 0xEC, 0x00, 0xCC, 0x12,
0xFF, 0x00, 0xFF, 0xF3, 0x1C, 0x14, 0x0C, 0x04,
0x00, 0x0C, 0x04, 0x24, 0x00, 0x24, 0x10, 0x30,
0x00, 0x00, 0x10, 0x04, 0xE3, 0x00, 0xFB, 0x00,
0xF3, 0x08, 0xDB, 0x20, 0xDB, 0x04, 0xCF, 0x00,
0xFF, 0x00, 0xEC, 0x3E, 0xC1, 0x01, 0x01, 0x8E,
0x8F, 0x10, 0x0F, 0x90, 0x0F, 0x90, 0x0D, 0x09,
0x00, 0x00, 0x20, 0x01, 0x7E, 0x00, 0xF1, 0x0E,
0xE0, 0x10, 0x60, 0x10, 0x60, 0x10, 0x79, 0x82,
0xFF, 0x00, 0x7F, 0xFC, 0x03, 0x82, 0x01, 0x9E,
0x13, 0x80, 0x03, 0x80, 0x03, 0x9C, 0x0F, 0x90,
0x00, 0x00, 0x02, 0x00, 0x7C, 0x80, 0x60, 0x9C,
0x60, 0x9C, 0x7C, 0x80, 0x60, 0x9C, 0x70, 0x80,
0xFF, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF,
0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00,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0x00, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03,
0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x03, 0xFC,
0xFC, 0x03, 0xFF, 0x00, 0x03, 0xFC, 0x00, 0x03,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF,
};

View File

@ -0,0 +1,446 @@
static const uint16_t palette[] = {
0x7C1A, 0x0000, 0x0011, 0x3DEF, 0x6318, 0x7FFF, 0x1EBA, 0x19AF,
0x1EAF, 0x4648, 0x7FC0, 0x2507, 0x1484, 0x5129, 0x5010, 0x2095,
};
static const uint16_t tilemap[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0001, 0x0002, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x4002, 0x4001, 0x0000,
0x0000, 0x0004, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x4004, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0007, 0x0008, 0x0008,
0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
0x0008, 0x0008, 0x4007, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x000A, 0x000B, 0x400A, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x800A, 0x000C, 0xC00A, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x0006, 0x0005, 0x0005, 0x0005, 0x0009, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC009, 0x0005, 0x0005, 0x0005, 0xC006, 0x0000,
0x0000, 0x000D, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x000E,
0x000F, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016,
0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E,
0x001F, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x400D, 0x0000,
0x0000, 0x0020, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0021,
0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029,
0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031,
0x0032, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x4020, 0x0000,
0x0000, 0x0033, 0x0034, 0x0035, 0x0036, 0x0005, 0x0005, 0x0037,
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
0x0040, 0x0005, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046,
0x0047, 0x0005, 0x0005, 0x4036, 0x4035, 0x4034, 0x4033, 0x0000,
0x0000, 0x0000, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D,
0x004E, 0x004E, 0x004F, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050,
0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x404F, 0x004E, 0x004E,
0x404D, 0x004C, 0x404B, 0x404A, 0x4049, 0x4048, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};
const uint8_t tiles[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08,
0x01, 0x11, 0x06, 0x26, 0x04, 0x24, 0x08, 0x48,
0x00, 0x00, 0x01, 0x01, 0x07, 0x07, 0x0F, 0x0F,
0x1E, 0x1F, 0x39, 0x3F, 0x3B, 0x3F, 0x77, 0x7F,
0x00, 0x7F, 0x00, 0x80, 0x00, 0x00, 0x7F, 0x7F,
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xFF,
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x08, 0x48, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x77, 0x7F, 0x6F, 0x7F, 0x6F, 0x7F, 0x6F, 0x7F,
0x6F, 0x7F, 0x6F, 0x7F, 0x6F, 0x7F, 0x6F, 0x7F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x6F, 0x7F, 0x6F, 0x7F, 0x6F, 0x7F, 0x6F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, 0x9C, 0x80, 0x1C, 0x04, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE1, 0x3F, 0xE3, 0x7F, 0xE3, 0xFF, 0xF7, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xF0, 0x80, 0x78, 0x08, 0x78, 0x48, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0F, 0xFF, 0x87, 0xFF, 0x87, 0xFF, 0xEF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xC0, 0x00, 0x3C, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3F, 0xFF, 0x03, 0x3F, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1C, 0x1C, 0x03, 0x03, 0x00, 0xE0, 0x00, 0x1C,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE3, 0xFF, 0xFC, 0xFF, 0x1F, 0xFF, 0x03, 0x1F,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFC, 0xFC, 0x03, 0x03, 0x00, 0x00,
0x00, 0xFC, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0x03, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF,
0x03, 0xFF, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x3F, 0x3F,
0x00, 0x00, 0x00, 0xC0, 0x00, 0x3F, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0xFF, 0xC0, 0xFF,
0xFF, 0xFF, 0x3F, 0xFF, 0x00, 0x3F, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0,
0x3F, 0x3F, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x3F,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0xFF,
0xC0, 0xFF, 0xFF, 0xFF, 0x3F, 0xFF, 0x00, 0x3F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF
};

View File

@ -0,0 +1,558 @@
static const uint16_t palette[] = {
0x0000, 0x0011, 0x18C6, 0x001A, 0x318C, 0x39CE, 0x5294, 0x5AD6,
0x739C, 0x45A8, 0x4520, 0x18A5, 0x4A32, 0x2033, 0x20EC, 0x0000,
};
static const uint16_t tilemap[] = {
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
0x0001, 0x0003, 0x0004, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005,
0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x4004, 0x4003, 0x0001,
0x0001, 0x0006, 0x0007, 0x0007, 0x0007, 0x0008, 0x0009, 0x000A,
0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011, 0x0012,
0x0013, 0x0014, 0x0015, 0x000E, 0x0016, 0x0017, 0x0018, 0x0019,
0x001A, 0x001B, 0x001C, 0x0007, 0x0007, 0x0007, 0x4006, 0x0001,
0x0001, 0x001D, 0x001E, 0x001E, 0x001E, 0x001F, 0x0020, 0x0021,
0x0022, 0x0023, 0x0024, 0x0025, 0x4024, 0x0026, 0x0025, 0x0025,
0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E,
0x002F, 0x0030, 0x0031, 0x001E, 0x001E, 0x001E, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0034, 0x0035, 0x4034, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x8034, 0x0036, 0xC034, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0xC01D, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0x0037, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0032, 0x0038, 0x0001,
0x0001, 0x001D, 0x0032, 0x0032, 0x0032, 0x0033, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xC033, 0x0032, 0x0032, 0x0039, 0x003A, 0x0001,
0x0001, 0x003B, 0x003C, 0x0032, 0x0032, 0xC03C, 0x003D, 0x003D,
0x003D, 0x003D, 0x003D, 0x003D, 0x003D, 0x003D, 0x003D, 0x003D,
0x003D, 0x003D, 0x003D, 0x003D, 0x003D, 0x003D, 0x003D, 0x003D,
0x003D, 0x003D, 0x003E, 0x003F, 0x0040, 0x0041, 0x0001, 0x0001,
0x0001, 0x0042, 0x0043, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044,
0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044,
0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044,
0x0044, 0x0044, 0x0045, 0x0046, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D,
0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B,
0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
0x0001, 0x0001, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x006A, 0x006B, 0x0001, 0x006C, 0x0001, 0x0001,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
};
const uint8_t tiles[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0x01, 0xFE, 0x06, 0xF9, 0x08, 0xF7,
0x11, 0xEF, 0x22, 0xDB, 0x20, 0xDB, 0x40, 0xB7,
0xFF, 0x00, 0xFF, 0x00, 0xFE, 0x00, 0xF8, 0x00,
0xF1, 0x00, 0xE6, 0x04, 0xE4, 0x00, 0xC8, 0x00,
0x7F, 0x80, 0x80, 0x7F, 0x00, 0xFF, 0x7F, 0xFF,
0x80, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0x80, 0x00, 0x00, 0x00, 0x7F, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0xB7, 0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF,
0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF,
0xC8, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00,
0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x03, 0xFF, 0x02, 0xFF,
0x02, 0xFF, 0x02, 0xFF, 0x02, 0xFF, 0x02, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00,
0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0xC1, 0xDD, 0x00, 0xC9,
0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x00, 0xC9,
0x00, 0x00, 0x00, 0x00, 0xE3, 0x00, 0x36, 0x22,
0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x36, 0x22,
0x00, 0xFF, 0x00, 0xFF, 0xC7, 0xDF, 0x01, 0xCF,
0x11, 0xFF, 0x11, 0xFF, 0x11, 0xFF, 0x01, 0xCF,
0x00, 0x00, 0x00, 0x00, 0xE7, 0x00, 0x31, 0x20,
0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x31, 0x20,
0x00, 0xFF, 0x00, 0xFF, 0xC2, 0xFF, 0x03, 0xFF,
0x02, 0xFE, 0x02, 0xFE, 0x02, 0xFF, 0x02, 0xFF,
0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x03, 0x00,
0x03, 0x01, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x08, 0xFF, 0x18, 0xFF,
0x08, 0x4E, 0x08, 0x4E, 0x09, 0x1F, 0x08, 0x1C,
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00,
0xB9, 0x10, 0xB9, 0xA1, 0xE9, 0xA0, 0xEB, 0x41,
0x00, 0xFF, 0x00, 0xFF, 0x4F, 0xFF, 0x02, 0x1F,
0x02, 0x4F, 0x02, 0x4F, 0xF2, 0xFF, 0x02, 0xE7,
0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0xE2, 0xA0,
0xB2, 0xA0, 0xB2, 0x10, 0xF2, 0x00, 0x1A, 0x10,
0x00, 0xFF, 0x00, 0xFF, 0xBC, 0xFD, 0x22, 0xFB,
0x22, 0xFB, 0x3C, 0xFD, 0x24, 0xFF, 0x26, 0xF9,
0x00, 0x00, 0x00, 0x00, 0xBE, 0x00, 0x26, 0x00,
0x26, 0x00, 0x3E, 0x00, 0x24, 0x00, 0x26, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x50, 0xFF, 0x49, 0xEF,
0x49, 0xF0, 0x46, 0xFF, 0x49, 0xF0, 0x49, 0xEF,
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x59, 0x00,
0x4F, 0x06, 0x46, 0x00, 0x4F, 0x06, 0x59, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x88, 0xFF, 0x00, 0x72,
0x00, 0xF2, 0x05, 0xFF, 0x00, 0xF8, 0x00, 0x78,
0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x8D, 0x08,
0x0D, 0x05, 0x05, 0x00, 0x07, 0x05, 0x87, 0x02,
0x00, 0xFF, 0x00, 0xFF, 0x8A, 0xFF, 0x02, 0x27,
0x02, 0x27, 0x52, 0xFF, 0x02, 0x8F, 0x02, 0x8F,
0x00, 0x00, 0x00, 0x00, 0x8A, 0x00, 0xDA, 0x88,
0xDA, 0x50, 0x52, 0x00, 0x72, 0x50, 0x72, 0x20,
0x00, 0xFF, 0x00, 0xFF, 0xFA, 0xFF, 0x22, 0xFF,
0x22, 0xFF, 0x23, 0xFF, 0x22, 0xFF, 0x22, 0xFF,
0x00, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x22, 0x00,
0x22, 0x00, 0x23, 0x00, 0x22, 0x00, 0x22, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x20, 0xFF, 0x20, 0xFF,
0x20, 0xFF, 0xE0, 0xFF, 0x20, 0xFF, 0x20, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00,
0x20, 0x00, 0xE0, 0x00, 0x20, 0x00, 0x20, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x33, 0x37, 0x00, 0x77,
0x80, 0xFF, 0x20, 0x27, 0x08, 0xFF, 0x00, 0x77,
0x00, 0x00, 0x00, 0x00, 0xFB, 0x40, 0x88, 0x88,
0x80, 0x00, 0xF8, 0x50, 0x08, 0x00, 0x88, 0x88,
0x00, 0xFF, 0x00, 0xFF, 0xEF, 0xFF, 0x88, 0xFF,
0x88, 0xFF, 0x8F, 0xFF, 0x88, 0xFF, 0x88, 0xFF,
0x00, 0x00, 0x00, 0x00, 0xEF, 0x00, 0x88, 0x00,
0x88, 0x00, 0x8F, 0x00, 0x88, 0x00, 0x88, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0xF9, 0xFD, 0x80, 0xF9,
0x84, 0xFF, 0xF4, 0xFF, 0x84, 0xFF, 0x80, 0xF9,
0x00, 0x00, 0x00, 0x00, 0xFB, 0x00, 0x86, 0x02,
0x84, 0x00, 0xF4, 0x00, 0x84, 0x00, 0x86, 0x02,
0x00, 0xFF, 0x00, 0xFF, 0xC0, 0xDF, 0x00, 0xCF,
0x10, 0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x00, 0xCF,
0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x30, 0x20,
0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x30, 0x20,
0x00, 0xFF, 0x00, 0xFF, 0x30, 0x36, 0x00, 0x74,
0x82, 0xFF, 0x22, 0x27, 0x0A, 0xFF, 0x00, 0x74,
0x00, 0x00, 0x00, 0x00, 0xF9, 0x40, 0x8B, 0x89,
0x82, 0x00, 0xFA, 0x50, 0x0A, 0x00, 0x8B, 0x89,
0x00, 0xFF, 0x00, 0xFF, 0xE2, 0xEF, 0x02, 0xE7,
0x0A, 0xFF, 0x0A, 0xFF, 0x0A, 0xFF, 0x00, 0xE4,
0x00, 0x00, 0x00, 0x00, 0xF2, 0x00, 0x1A, 0x10,
0x0A, 0x00, 0x0A, 0x00, 0x0A, 0x00, 0x1B, 0x12,
0x00, 0xFF, 0x00, 0xFF, 0x14, 0xFF, 0x16, 0xFF,
0x14, 0xFC, 0x15, 0xFE, 0x14, 0xFF, 0x04, 0xCF,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x16, 0x00,
0x17, 0x01, 0x15, 0x00, 0x14, 0x00, 0x34, 0x10,
0x00, 0xFF, 0x00, 0xFF, 0x2F, 0xFF, 0x28, 0xFF,
0x28, 0xFF, 0xA8, 0x7F, 0x28, 0x3F, 0x68, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x2F, 0x00, 0x28, 0x00,
0x28, 0x00, 0xA8, 0x00, 0xE8, 0x80, 0x68, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0x3F,
0x40, 0xFF, 0x40, 0xFF, 0x40, 0xFF, 0x00, 0x3F,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xC0, 0x80,
0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0xC0, 0x80,
0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF,
0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF,
0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00,
0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0xFF,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xC1, 0xDD, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xE3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xC1, 0xDF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x02, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x4A, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x0A, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x22, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x82, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x20, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x60, 0x67, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xF8, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x8F, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x8F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xA2, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xF9, 0xFD, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xC0, 0xDF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x60, 0x66, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xF9, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xE0, 0xEE, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xF1, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xC4, 0xDF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0xE4, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x2F, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0xFF,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF,
0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF,
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x3C, 0xFF,
0x7E, 0xFF, 0xE7, 0xE7, 0xFF, 0x7E, 0xFF, 0x7E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x7E,
0x81, 0xC3, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00,
0xFF, 0x7E, 0xFF, 0x3C, 0xFF, 0x00, 0x7E, 0x81,
0x3C, 0xC3, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0xC3, 0x81,
0x7E, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xF7, 0x00, 0xF7, 0x00, 0xF7, 0x00, 0xF7,
0x00, 0xF7, 0x00, 0xED, 0x00, 0xED, 0x00, 0xED,
0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00,
0x09, 0x00, 0x11, 0x02, 0x11, 0x02, 0x11, 0x02,
0x00, 0xED, 0x00, 0xDB, 0x00, 0xDB, 0x00, 0xDB,
0x00, 0xB7, 0x00, 0xB7, 0x00, 0x6F, 0x00, 0x6F,
0x11, 0x02, 0x23, 0x04, 0x23, 0x04, 0x23, 0x04,
0x47, 0x08, 0x47, 0x08, 0x8F, 0x10, 0x8F, 0x10,
0x00, 0xFE, 0x00, 0xFD, 0x00, 0xFB, 0x00, 0xF7,
0x00, 0xEE, 0x00, 0xDD, 0x00, 0xBB, 0x00, 0x77,
0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00,
0x10, 0x01, 0x21, 0x02, 0x43, 0x04, 0x87, 0x08,
0x00, 0xDF, 0x00, 0xBF, 0x00, 0xBF, 0x00, 0x7F,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x1F, 0x20, 0x3F, 0x40, 0x3F, 0x40, 0x7F, 0x80,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0xEF, 0x00, 0xEF, 0x00, 0xEF, 0x00, 0xB7,
0x00, 0xB7, 0x00, 0xDB, 0x00, 0xDD, 0x00, 0xEE,
0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x88, 0x40,
0x88, 0x40, 0xC4, 0x20, 0xC2, 0x20, 0xE1, 0x10,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x7F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFC,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFC, 0x00, 0xE3, 0x00, 0x1F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x00, 0x1C, 0x00, 0xE0, 0x00,
0x00, 0xFE, 0x00, 0xFD, 0x00, 0xF3, 0x00, 0xEF,
0x00, 0x1C, 0x00, 0xF3, 0x00, 0xEF, 0x00, 0x1F,
0x01, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x10, 0x00,
0xE0, 0x03, 0x03, 0x0C, 0x0F, 0x10, 0x1F, 0xE0,
0x00, 0xEF, 0x00, 0xDF, 0x00, 0xBF, 0x00, 0x7F,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x0F, 0x10, 0x1F, 0x20, 0x3F, 0x40, 0x7F, 0x80,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0xF7, 0x00, 0xF9, 0x00, 0xFE, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xF0, 0x08, 0xF8, 0x06, 0xFE, 0x01, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x80, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0x80,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x7F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7F,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x03, 0x00, 0xFF, 0x00, 0xFC, 0x00, 0x03,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFC, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0xFC,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0xFC, 0x00, 0xE3, 0x00, 0x1F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FF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x80, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0x3E, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0xC1, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xE0, 0x1F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
};

View File

@ -86,6 +86,10 @@ void GB_update_mbc_mappings(GB_gameboy_t *gb)
case GB_MBC3: case GB_MBC3:
gb->mbc_rom_bank = gb->mbc3.rom_bank; gb->mbc_rom_bank = gb->mbc3.rom_bank;
gb->mbc_ram_bank = gb->mbc3.ram_bank; gb->mbc_ram_bank = gb->mbc3.ram_bank;
if (!gb->is_mbc30) {
gb->mbc_rom_bank &= 0x7F;
gb->mbc_ram_bank &= 0x3;
}
if (gb->mbc_rom_bank == 0) { if (gb->mbc_rom_bank == 0) {
gb->mbc_rom_bank = 1; gb->mbc_rom_bank = 1;
} }
@ -128,7 +132,7 @@ void GB_configure_cart(GB_gameboy_t *gb)
gb->mbc_ram_size = 0x200; gb->mbc_ram_size = 0x200;
} }
else { else {
static const int ram_sizes[256] = {0, 0x800, 0x2000, 0x8000, 0x20000, 0x10000}; static const unsigned ram_sizes[256] = {0, 0x800, 0x2000, 0x8000, 0x20000, 0x10000};
gb->mbc_ram_size = ram_sizes[gb->rom[0x149]]; gb->mbc_ram_size = ram_sizes[gb->rom[0x149]];
} }
gb->mbc_ram = malloc(gb->mbc_ram_size); gb->mbc_ram = malloc(gb->mbc_ram_size);
@ -147,6 +151,13 @@ void GB_configure_cart(GB_gameboy_t *gb)
} }
} }
/* Detect MBC30 */
if (gb->cartridge_type->mbc_type == GB_MBC3) {
if (gb->rom_size > 0x200000 || gb->mbc_ram_size > 0x8000) {
gb->is_mbc30 = true;
}
}
/* Set MBC5's bank to 1 correctly */ /* Set MBC5's bank to 1 correctly */
if (gb->cartridge_type->mbc_type == GB_MBC5) { if (gb->cartridge_type->mbc_type == GB_MBC5) {
gb->mbc5.rom_bank_low = 1; gb->mbc5.rom_bank_low = 1;

View File

@ -277,7 +277,7 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
case GB_MODEL_SGB_PAL_NO_SFC: case GB_MODEL_SGB_PAL_NO_SFC:
case GB_MODEL_SGB2: case GB_MODEL_SGB2:
case GB_MODEL_SGB2_NO_SFC: case GB_MODEL_SGB2_NO_SFC:
; break;
} }
} }
@ -295,11 +295,11 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
return gb->io_registers[GB_IO_TAC] | 0xF8; return gb->io_registers[GB_IO_TAC] | 0xF8;
case GB_IO_STAT: case GB_IO_STAT:
return gb->io_registers[GB_IO_STAT] | 0x80; return gb->io_registers[GB_IO_STAT] | 0x80;
case GB_IO_DMG_EMULATION_INDICATION: case GB_IO_OPRI:
if (!gb->cgb_mode) { if (!GB_is_cgb(gb)) {
return 0xFF; return 0xFF;
} }
return gb->io_registers[GB_IO_DMG_EMULATION_INDICATION] | 0xFE; return gb->io_registers[GB_IO_OPRI] | 0xFE;
case GB_IO_PCM_12: case GB_IO_PCM_12:
if (!GB_is_cgb(gb)) return 0xFF; if (!GB_is_cgb(gb)) return 0xFF;
@ -435,12 +435,12 @@ uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr)
if (is_addr_in_dma_use(gb, addr)) { if (is_addr_in_dma_use(gb, addr)) {
addr = gb->dma_current_src; addr = gb->dma_current_src;
} }
uint8_t data = read_map[addr >> 12](gb, addr);
GB_apply_cheat(gb, addr, &data);
if (gb->read_memory_callback) { if (gb->read_memory_callback) {
uint8_t data = read_map[addr >> 12](gb, addr);
data = gb->read_memory_callback(gb, addr, data); data = gb->read_memory_callback(gb, addr, data);
return data;
} }
return read_map[addr >> 12](gb, addr); return data;
} }
static void write_mbc(GB_gameboy_t *gb, uint16_t addr, uint8_t value) static void write_mbc(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
@ -456,9 +456,9 @@ static void write_mbc(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
} }
break; break;
case GB_MBC2: case GB_MBC2:
switch (addr & 0xF000) { switch (addr & 0x4100) {
case 0x0000: case 0x1000: if (!(addr & 0x100)) gb->mbc_ram_enable = (value & 0xF) == 0xA; break; case 0x0000: gb->mbc_ram_enable = (value & 0xF) == 0xA; break;
case 0x2000: case 0x3000: if ( addr & 0x100) gb->mbc2.rom_bank = value; break; case 0x0100: gb->mbc2.rom_bank = value; break;
} }
break; break;
case GB_MBC3: case GB_MBC3:
@ -642,24 +642,34 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
if (addr < 0xFF80) { if (addr < 0xFF80) {
/* Hardware registers */ /* Hardware registers */
switch (addr & 0xFF) { switch (addr & 0xFF) {
case GB_IO_WY:
if (value == gb->current_line) {
gb->wy_triggered = true;
}
case GB_IO_WX: case GB_IO_WX:
GB_window_related_write(gb, addr & 0xFF, value);
break;
case GB_IO_IF: case GB_IO_IF:
case GB_IO_SCX: case GB_IO_SCX:
case GB_IO_SCY: case GB_IO_SCY:
case GB_IO_BGP: case GB_IO_BGP:
case GB_IO_OBP0: case GB_IO_OBP0:
case GB_IO_OBP1: case GB_IO_OBP1:
case GB_IO_WY:
case GB_IO_SB: case GB_IO_SB:
case GB_IO_DMG_EMULATION_INDICATION:
case GB_IO_UNKNOWN2: case GB_IO_UNKNOWN2:
case GB_IO_UNKNOWN3: case GB_IO_UNKNOWN3:
case GB_IO_UNKNOWN4: case GB_IO_UNKNOWN4:
case GB_IO_UNKNOWN5: case GB_IO_UNKNOWN5:
gb->io_registers[addr & 0xFF] = value; gb->io_registers[addr & 0xFF] = value;
return; return;
case GB_IO_OPRI:
if ((!gb->boot_rom_finished || (gb->io_registers[GB_IO_KEY0] & 8)) && GB_is_cgb(gb)) {
gb->io_registers[addr & 0xFF] = value;
gb->object_priority = (value & 1) ? GB_OBJECT_PRIORITY_X : GB_OBJECT_PRIORITY_INDEX;
}
else if (gb->cgb_mode) {
gb->io_registers[addr & 0xFF] = value;
}
return;
case GB_IO_LYC: case GB_IO_LYC:
/* TODO: Probably completely wrong in double speed mode */ /* TODO: Probably completely wrong in double speed mode */
@ -728,8 +738,19 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
GB_timing_sync(gb); GB_timing_sync(gb);
GB_lcd_off(gb); GB_lcd_off(gb);
} }
/* Writing to LCDC might enable to disable the window, so we write it via GB_window_related_write */ /* Handle disabling objects while already fetching an object */
GB_window_related_write(gb, addr & 0xFF, value); if ((gb->io_registers[GB_IO_LCDC] & 2) && !(value & 2)) {
if (gb->during_object_fetch) {
gb->cycles_for_line += gb->display_cycles;
gb->display_cycles = 0;
gb->object_fetch_aborted = true;
}
}
gb->io_registers[GB_IO_LCDC] = value;
if (!(value & 0x20)) {
gb->wx_triggered = false;
gb->wx166_glitch = false;
}
return; return;
case GB_IO_STAT: case GB_IO_STAT:
@ -756,18 +777,19 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
} }
else if ((gb->io_registers[GB_IO_JOYP] & 0x30) != (value & 0x30)) { else if ((gb->io_registers[GB_IO_JOYP] & 0x30) != (value & 0x30)) {
GB_sgb_write(gb, value); GB_sgb_write(gb, value);
gb->io_registers[GB_IO_JOYP] = value & 0xF0; gb->io_registers[GB_IO_JOYP] = (value & 0xF0) | (gb->io_registers[GB_IO_JOYP] & 0x0F);
GB_update_joyp(gb); GB_update_joyp(gb);
} }
return; return;
case GB_IO_BIOS: case GB_IO_BANK:
gb->boot_rom_finished = true; gb->boot_rom_finished = true;
return; return;
case GB_IO_DMG_EMULATION: case GB_IO_KEY0:
if (GB_is_cgb(gb) && !gb->boot_rom_finished) { if (GB_is_cgb(gb) && !gb->boot_rom_finished) {
gb->cgb_mode = !(value & 0xC); /* The real "contents" of this register aren't quite known yet. */ gb->cgb_mode = !(value & 0xC); /* The real "contents" of this register aren't quite known yet. */
gb->io_registers[GB_IO_KEY0] = value;
} }
return; return;

View File

@ -180,6 +180,28 @@ static bool verify_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t *save)
return true; return true;
} }
static void sanitize_state(GB_gameboy_t *gb)
{
for (unsigned i = 0; i < 32; i++) {
GB_palette_changed(gb, false, i * 2);
GB_palette_changed(gb, true, i * 2);
}
gb->bg_fifo.read_end &= 0xF;
gb->bg_fifo.write_end &= 0xF;
gb->oam_fifo.read_end &= 0xF;
gb->oam_fifo.write_end &= 0xF;
gb->object_low_line_address &= gb->vram_size & ~1;
gb->fetcher_x &= 0x1f;
if (gb->lcd_x > gb->position_in_line) {
gb->lcd_x = gb->position_in_line;
}
if (gb->object_priority == GB_OBJECT_PRIORITY_UNDEFINED) {
gb->object_priority = gb->cgb_mode? GB_OBJECT_PRIORITY_INDEX : GB_OBJECT_PRIORITY_X;
}
}
#define READ_SECTION(gb, f, section) read_section(f, GB_GET_SECTION(gb, section), GB_SECTION_SIZE(section)) #define READ_SECTION(gb, f, section) read_section(f, GB_GET_SECTION(gb, section), GB_SECTION_SIZE(section))
int GB_load_state(GB_gameboy_t *gb, const char *path) int GB_load_state(GB_gameboy_t *gb, const char *path)
@ -252,15 +274,7 @@ int GB_load_state(GB_gameboy_t *gb, const char *path)
errno = 0; errno = 0;
for (unsigned i = 0; i < 32; i++) { sanitize_state(gb);
GB_palette_changed(gb, false, i * 2);
GB_palette_changed(gb, true, i * 2);
}
gb->bg_fifo.read_end &= 0xF;
gb->bg_fifo.write_end &= 0xF;
gb->oam_fifo.read_end &= 0xF;
gb->oam_fifo.write_end &= 0xF;
error: error:
fclose(f); fclose(f);
@ -343,7 +357,7 @@ int GB_load_state_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t le
return -1; return -1;
} }
if (buffer_read(gb->vram,gb->vram_size, &buffer, &length) != gb->vram_size) { if (buffer_read(gb->vram, gb->vram_size, &buffer, &length) != gb->vram_size) {
return -1; return -1;
} }
@ -353,15 +367,7 @@ int GB_load_state_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t le
memcpy(gb, &save, sizeof(save)); memcpy(gb, &save, sizeof(save));
for (unsigned i = 0; i < 32; i++) { sanitize_state(gb);
GB_palette_changed(gb, false, i * 2);
GB_palette_changed(gb, true, i * 2);
}
gb->bg_fifo.read_end &= 0xF;
gb->bg_fifo.write_end &= 0xF;
gb->oam_fifo.read_end &= 0xF;
gb->oam_fifo.write_end &= 0xF;
return 0; return 0;
} }

View File

@ -17,6 +17,7 @@ enum {
ATTR_BLK = 0x04, ATTR_BLK = 0x04,
ATTR_LIN = 0x05, ATTR_LIN = 0x05,
ATTR_DIV = 0x06, ATTR_DIV = 0x06,
ATTR_CHR = 0x07,
PAL_SET = 0x0A, PAL_SET = 0x0A,
PAL_TRN = 0x0B, PAL_TRN = 0x0B,
DATA_SND = 0x0F, DATA_SND = 0x0F,
@ -150,7 +151,7 @@ static void command_ready(GB_gameboy_t *gb)
0xE content bytes. The last command, FB, is padded with zeros, so information past the header is not sent. */ 0xE content bytes. The last command, FB, is padded with zeros, so information past the header is not sent. */
if ((gb->sgb->command[0] & 0xF1) == 0xF1) { if ((gb->sgb->command[0] & 0xF1) == 0xF1) {
if(gb->boot_rom_finished) return; if (gb->boot_rom_finished) return;
uint8_t checksum = 0; uint8_t checksum = 0;
for (unsigned i = 2; i < 0x10; i++) { for (unsigned i = 2; i < 0x10; i++) {
@ -246,7 +247,7 @@ static void command_ready(GB_gameboy_t *gb)
gb->sgb->attribute_map[x + 20 * y] = inside_palette; gb->sgb->attribute_map[x + 20 * y] = inside_palette;
} }
} }
else if(middle) { else if (middle) {
gb->sgb->attribute_map[x + 20 * y] = middle_palette; gb->sgb->attribute_map[x + 20 * y] = middle_palette;
} }
} }
@ -254,6 +255,52 @@ static void command_ready(GB_gameboy_t *gb)
} }
break; break;
} }
case ATTR_CHR: {
struct __attribute__((packed)) {
uint8_t x, y;
uint16_t length;
uint8_t direction;
uint8_t data[];
} *command = (void *)(gb->sgb->command + 1);
uint16_t count = command->length;
#ifdef GB_BIG_ENDIAN
count = __builtin_bswap16(count);
#endif
uint8_t x = command->x;
uint8_t y = command->y;
if (x >= 20 || y >= 18 || (count + 3) / 4 > sizeof(gb->sgb->command) - sizeof(*command) - 1) {
/* TODO: Verify with the SFC BIOS */
break;
}
for (unsigned i = 0; i < count; i++) {
uint8_t palette = (command->data[i / 4] >> (((~i) & 3) << 1)) & 3;
gb->sgb->attribute_map[x + 20 * y] = palette;
if (command->direction) {
y++;
if (y == 18) {
x++;
y = 0;
if (x == 20) {
x = 0;
}
}
}
else {
x++;
if (x == 20) {
y++;
x = 0;
if (y == 18) {
y = 0;
}
}
}
}
break;
}
case ATTR_LIN: { case ATTR_LIN: {
struct { struct {
uint8_t count; uint8_t count;
@ -474,7 +521,7 @@ void GB_sgb_write(GB_gameboy_t *gb, uint8_t value)
static uint32_t convert_rgb15(GB_gameboy_t *gb, uint16_t color) static uint32_t convert_rgb15(GB_gameboy_t *gb, uint16_t color)
{ {
return GB_convert_rgb15(gb, color); return GB_convert_rgb15(gb, color, false);
} }
static uint32_t convert_rgb15_with_fade(GB_gameboy_t *gb, uint16_t color, uint8_t fade) static uint32_t convert_rgb15_with_fade(GB_gameboy_t *gb, uint16_t color, uint8_t fade)
@ -489,14 +536,17 @@ static uint32_t convert_rgb15_with_fade(GB_gameboy_t *gb, uint16_t color, uint8_
color = r | (g << 5) | (b << 10); color = r | (g << 5) | (b << 10);
return GB_convert_rgb15(gb, color); return GB_convert_rgb15(gb, color, false);
} }
#include <stdio.h> #include <stdio.h>
static void render_boot_animation (GB_gameboy_t *gb) static void render_boot_animation (GB_gameboy_t *gb)
{ {
#include "sgb_animation_logo.inc" #include "graphics/sgb_animation_logo.inc"
uint32_t *output = &gb->screen[48 + 40 * 256]; uint32_t *output = gb->screen;
if (gb->border_mode != GB_BORDER_NEVER) {
output += 48 + 40 * 256;
}
uint8_t *input = animation_logo; uint8_t *input = animation_logo;
unsigned fade_blue = 0; unsigned fade_blue = 0;
unsigned fade_red = 0; unsigned fade_red = 0;
@ -544,7 +594,9 @@ static void render_boot_animation (GB_gameboy_t *gb)
input++; input++;
} }
} }
output += 256 - 160; if (gb->border_mode != GB_BORDER_NEVER) {
output += 256 - 160;
}
} }
} }
@ -557,14 +609,6 @@ void GB_sgb_render(GB_gameboy_t *gb)
if (gb->sgb->intro_animation < INTRO_ANIMATION_LENGTH) gb->sgb->intro_animation++; if (gb->sgb->intro_animation < INTRO_ANIMATION_LENGTH) gb->sgb->intro_animation++;
if (!gb->screen || !gb->rgb_encode_callback) return;
if (gb->sgb->mask_mode != MASK_FREEZE) {
memcpy(gb->sgb->effective_screen_buffer,
gb->sgb->screen_buffer,
sizeof(gb->sgb->effective_screen_buffer));
}
if (gb->sgb->vram_transfer_countdown) { if (gb->sgb->vram_transfer_countdown) {
if (--gb->sgb->vram_transfer_countdown == 0) { if (--gb->sgb->vram_transfer_countdown == 0) {
if (gb->sgb->transfer_dest == TRANSFER_LOW_TILES || gb->sgb->transfer_dest == TRANSFER_HIGH_TILES) { if (gb->sgb->transfer_dest == TRANSFER_LOW_TILES || gb->sgb->transfer_dest == TRANSFER_HIGH_TILES) {
@ -626,16 +670,27 @@ void GB_sgb_render(GB_gameboy_t *gb)
} }
} }
if (!gb->screen || !gb->rgb_encode_callback || gb->disable_rendering) return;
uint32_t colors[4 * 4]; uint32_t colors[4 * 4];
for (unsigned i = 0; i < 4 * 4; i++) { for (unsigned i = 0; i < 4 * 4; i++) {
colors[i] = convert_rgb15(gb, gb->sgb->effective_palettes[i]); colors[i] = convert_rgb15(gb, gb->sgb->effective_palettes[i]);
} }
if (gb->sgb->mask_mode != MASK_FREEZE) {
memcpy(gb->sgb->effective_screen_buffer,
gb->sgb->screen_buffer,
sizeof(gb->sgb->effective_screen_buffer));
}
if (gb->sgb->intro_animation < INTRO_ANIMATION_LENGTH) { if (gb->sgb->intro_animation < INTRO_ANIMATION_LENGTH) {
render_boot_animation(gb); render_boot_animation(gb);
} }
else { else {
uint32_t *output = &gb->screen[48 + 40 * 256]; uint32_t *output = gb->screen;
if (gb->border_mode != GB_BORDER_NEVER) {
output += 48 + 40 * 256;
}
uint8_t *input = gb->sgb->effective_screen_buffer; uint8_t *input = gb->sgb->effective_screen_buffer;
switch ((mask_mode_t) gb->sgb->mask_mode) { switch ((mask_mode_t) gb->sgb->mask_mode) {
case MASK_DISABLED: case MASK_DISABLED:
@ -645,7 +700,9 @@ void GB_sgb_render(GB_gameboy_t *gb)
uint8_t palette = gb->sgb->attribute_map[x / 8 + y / 8 * 20] & 3; uint8_t palette = gb->sgb->attribute_map[x / 8 + y / 8 * 20] & 3;
*(output++) = colors[(*(input++) & 3) + palette * 4]; *(output++) = colors[(*(input++) & 3) + palette * 4];
} }
output += 256 - 160; if (gb->border_mode != GB_BORDER_NEVER) {
output += 256 - 160;
}
} }
break; break;
} }
@ -656,7 +713,9 @@ void GB_sgb_render(GB_gameboy_t *gb)
for (unsigned x = 0; x < 160; x++) { for (unsigned x = 0; x < 160; x++) {
*(output++) = black; *(output++) = black;
} }
output += 256 - 160; if (gb->border_mode != GB_BORDER_NEVER) {
output += 256 - 160;
}
} }
break; break;
} }
@ -666,7 +725,9 @@ void GB_sgb_render(GB_gameboy_t *gb)
for (unsigned x = 0; x < 160; x++) { for (unsigned x = 0; x < 160; x++) {
*(output++) = colors[0]; *(output++) = colors[0];
} }
output += 256 - 160; if (gb->border_mode != GB_BORDER_NEVER) {
output += 256 - 160;
}
} }
break; break;
} }
@ -703,6 +764,9 @@ void GB_sgb_render(GB_gameboy_t *gb)
if (tile_x >= 6 && tile_x < 26 && tile_y >= 5 && tile_y < 23) { if (tile_x >= 6 && tile_x < 26 && tile_y >= 5 && tile_y < 23) {
gb_area = true; gb_area = true;
} }
else if (gb->border_mode == GB_BORDER_NEVER) {
continue;
}
uint16_t tile = gb->sgb->border.map[tile_x + tile_y * 32]; uint16_t tile = gb->sgb->border.map[tile_x + tile_y * 32];
uint8_t flip_x = (tile & 0x4000)? 0x7 : 0; uint8_t flip_x = (tile & 0x4000)? 0x7 : 0;
uint8_t flip_y = (tile & 0x8000)? 0x7 : 0; uint8_t flip_y = (tile & 0x8000)? 0x7 : 0;
@ -710,12 +774,19 @@ void GB_sgb_render(GB_gameboy_t *gb)
for (unsigned y = 0; y < 8; y++) { for (unsigned y = 0; y < 8; y++) {
for (unsigned x = 0; x < 8; x++) { for (unsigned x = 0; x < 8; x++) {
uint8_t color = gb->sgb->border.tiles[(tile & 0xFF) * 64 + (x ^ flip_x) + (y ^ flip_y) * 8] & 0xF; uint8_t color = gb->sgb->border.tiles[(tile & 0xFF) * 64 + (x ^ flip_x) + (y ^ flip_y) * 8] & 0xF;
if (color == 0) { uint32_t *output = gb->screen;
if (gb_area) continue; if (gb->border_mode == GB_BORDER_NEVER) {
gb->screen[tile_x * 8 + x + (tile_y * 8 + y) * 0x100] = colors[0]; output += (tile_x - 6) * 8 + x + ((tile_y - 5) * 8 + y) * 160;
} }
else { else {
gb->screen[tile_x * 8 + x + (tile_y * 8 + y) * 0x100] = border_colors[color + palette * 16]; output += tile_x * 8 + x + (tile_y * 8 + y) * 256;
}
if (color == 0) {
if (gb_area) continue;
*output = colors[0];
}
else {
*output = border_colors[color + palette * 16];
} }
} }
} }
@ -726,12 +797,12 @@ void GB_sgb_render(GB_gameboy_t *gb)
void GB_sgb_load_default_data(GB_gameboy_t *gb) void GB_sgb_load_default_data(GB_gameboy_t *gb)
{ {
#include "sgb_border.inc" #include "graphics/sgb_border.inc"
memcpy(gb->sgb->border.map, tilemap, sizeof(tilemap)); memcpy(gb->sgb->border.map, tilemap, sizeof(tilemap));
memcpy(gb->sgb->border.palette, palette, sizeof(palette)); memcpy(gb->sgb->border.palette, palette, sizeof(palette));
/* Expend tileset */ /* Expand tileset */
for (unsigned tile = 0; tile < sizeof(tiles) / 32; tile++) { for (unsigned tile = 0; tile < sizeof(tiles) / 32; tile++) {
for (unsigned y = 0; y < 8; y++) { for (unsigned y = 0; y < 8; y++) {
for (unsigned x = 0; x < 8; x++) { for (unsigned x = 0; x < 8; x++) {

View File

@ -5,6 +5,16 @@
#include <stdbool.h> #include <stdbool.h>
typedef struct GB_sgb_s GB_sgb_t; typedef struct GB_sgb_s GB_sgb_t;
typedef struct {
uint8_t tiles[0x100 * 8 * 8]; /* High nibble not used*/
union {
struct {
uint16_t map[32 * 32];
uint16_t palette[16 * 4];
};
uint16_t raw_data[0x440];
};
} GB_sgb_border_t;
#ifdef GB_INTERNAL #ifdef GB_INTERNAL
struct GB_sgb_s { struct GB_sgb_s {
@ -29,16 +39,7 @@ struct GB_sgb_s {
uint8_t vram_transfer_countdown, transfer_dest; uint8_t vram_transfer_countdown, transfer_dest;
/* Border */ /* Border */
struct { GB_sgb_border_t border, pending_border;
uint8_t tiles[0x100 * 8 * 8]; /* High nibble not used*/
union {
struct {
uint16_t map[32 * 32];
uint16_t palette[16 * 4];
};
uint16_t raw_data[0x440];
};
} border, pending_border;
uint8_t border_animation; uint8_t border_animation;
/* Colorization */ /* Colorization */

View File

@ -18,6 +18,9 @@ typedef enum {
GB_CONFLICT_STAT_DMG, GB_CONFLICT_STAT_DMG,
GB_CONFLICT_PALETTE_DMG, GB_CONFLICT_PALETTE_DMG,
GB_CONFLICT_PALETTE_CGB, GB_CONFLICT_PALETTE_CGB,
GB_CONFLICT_DMG_LCDC,
GB_CONFLICT_SGB_LCDC,
GB_CONFLICT_WX,
} GB_conflict_t; } GB_conflict_t;
/* Todo: How does double speed mode affect these? */ /* Todo: How does double speed mode affect these? */
@ -29,7 +32,6 @@ static const GB_conflict_t cgb_conflict_map[0x80] = {
[GB_IO_OBP0] = GB_CONFLICT_PALETTE_CGB, [GB_IO_OBP0] = GB_CONFLICT_PALETTE_CGB,
[GB_IO_OBP1] = GB_CONFLICT_PALETTE_CGB, [GB_IO_OBP1] = GB_CONFLICT_PALETTE_CGB,
/* Todo: most values not verified, and probably differ between revisions */ /* Todo: most values not verified, and probably differ between revisions */
}; };
@ -37,17 +39,17 @@ static const GB_conflict_t cgb_conflict_map[0x80] = {
static const GB_conflict_t dmg_conflict_map[0x80] = { static const GB_conflict_t dmg_conflict_map[0x80] = {
[GB_IO_IF] = GB_CONFLICT_WRITE_CPU, [GB_IO_IF] = GB_CONFLICT_WRITE_CPU,
[GB_IO_LYC] = GB_CONFLICT_READ_OLD, [GB_IO_LYC] = GB_CONFLICT_READ_OLD,
[GB_IO_LCDC] = GB_CONFLICT_READ_NEW, [GB_IO_LCDC] = GB_CONFLICT_DMG_LCDC,
[GB_IO_SCY] = GB_CONFLICT_READ_NEW, [GB_IO_SCY] = GB_CONFLICT_READ_NEW,
[GB_IO_STAT] = GB_CONFLICT_STAT_DMG, [GB_IO_STAT] = GB_CONFLICT_STAT_DMG,
[GB_IO_BGP] = GB_CONFLICT_PALETTE_DMG, [GB_IO_BGP] = GB_CONFLICT_PALETTE_DMG,
[GB_IO_OBP0] = GB_CONFLICT_PALETTE_DMG, [GB_IO_OBP0] = GB_CONFLICT_PALETTE_DMG,
[GB_IO_OBP1] = GB_CONFLICT_PALETTE_DMG, [GB_IO_OBP1] = GB_CONFLICT_PALETTE_DMG,
[GB_IO_WY] = GB_CONFLICT_READ_OLD,
[GB_IO_WX] = GB_CONFLICT_WX,
/* Todo: these were not verified at all */ /* Todo: these were not verified at all */
[GB_IO_WY] = GB_CONFLICT_READ_NEW,
[GB_IO_WX] = GB_CONFLICT_READ_NEW,
[GB_IO_SCX] = GB_CONFLICT_READ_NEW, [GB_IO_SCX] = GB_CONFLICT_READ_NEW,
}; };
@ -55,17 +57,17 @@ static const GB_conflict_t dmg_conflict_map[0x80] = {
static const GB_conflict_t sgb_conflict_map[0x80] = { static const GB_conflict_t sgb_conflict_map[0x80] = {
[GB_IO_IF] = GB_CONFLICT_WRITE_CPU, [GB_IO_IF] = GB_CONFLICT_WRITE_CPU,
[GB_IO_LYC] = GB_CONFLICT_READ_OLD, [GB_IO_LYC] = GB_CONFLICT_READ_OLD,
[GB_IO_LCDC] = GB_CONFLICT_READ_NEW, [GB_IO_LCDC] = GB_CONFLICT_SGB_LCDC,
[GB_IO_SCY] = GB_CONFLICT_READ_NEW, [GB_IO_SCY] = GB_CONFLICT_READ_NEW,
[GB_IO_STAT] = GB_CONFLICT_STAT_DMG, [GB_IO_STAT] = GB_CONFLICT_STAT_DMG,
[GB_IO_BGP] = GB_CONFLICT_READ_NEW, [GB_IO_BGP] = GB_CONFLICT_READ_NEW,
[GB_IO_OBP0] = GB_CONFLICT_READ_NEW, [GB_IO_OBP0] = GB_CONFLICT_READ_NEW,
[GB_IO_OBP1] = GB_CONFLICT_READ_NEW, [GB_IO_OBP1] = GB_CONFLICT_READ_NEW,
[GB_IO_WY] = GB_CONFLICT_READ_OLD,
[GB_IO_WX] = GB_CONFLICT_WX,
/* Todo: these were not verified at all */ /* Todo: these were not verified at all */
[GB_IO_WY] = GB_CONFLICT_READ_NEW,
[GB_IO_WX] = GB_CONFLICT_READ_NEW,
[GB_IO_SCX] = GB_CONFLICT_READ_NEW, [GB_IO_SCX] = GB_CONFLICT_READ_NEW,
}; };
@ -192,6 +194,53 @@ static void cycle_write(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
gb->pending_cycles = 6; gb->pending_cycles = 6;
return; return;
} }
case GB_CONFLICT_DMG_LCDC: {
/* Similar to the palette registers, these interact directly with the LCD, so they appear to be affected by it. Both my DMG (B, blob) and Game Boy Light behave this way though.
Additionally, LCDC.1 is very nasty because on the it is read both by the FIFO when popping pixels,
and the sprite-fetching state machine, and both behave differently when it comes to access conflicts.
Hacks ahead.
*/
uint8_t old_value = GB_read_memory(gb, addr);
GB_advance_cycles(gb, gb->pending_cycles - 2);
if (/* gb->model != GB_MODEL_MGB && */ gb->position_in_line == 0 && (old_value & 2) && !(value & 2)) {
old_value &= ~2;
}
GB_write_memory(gb, addr, old_value | (value & 1));
GB_advance_cycles(gb, 1);
GB_write_memory(gb, addr, value);
gb->pending_cycles = 5;
return;
}
case GB_CONFLICT_SGB_LCDC: {
/* Simplified version of the above */
uint8_t old_value = GB_read_memory(gb, addr);
GB_advance_cycles(gb, gb->pending_cycles - 2);
/* Hack to force aborting object fetch */
GB_write_memory(gb, addr, value);
GB_write_memory(gb, addr, old_value);
GB_advance_cycles(gb, 1);
GB_write_memory(gb, addr, value);
gb->pending_cycles = 5;
return;
}
case GB_CONFLICT_WX:
GB_advance_cycles(gb, gb->pending_cycles);
GB_write_memory(gb, addr, value);
gb->wx_just_changed = true;
GB_advance_cycles(gb, 1);
gb->wx_just_changed = false;
gb->pending_cycles = 3;
return;
} }
} }
@ -236,6 +285,26 @@ static void nop(GB_gameboy_t *gb, uint8_t opcode)
{ {
} }
static void enter_stop_mode(GB_gameboy_t *gb)
{
gb->stopped = true;
gb->oam_ppu_blocked = !gb->oam_read_blocked;
gb->vram_ppu_blocked = !gb->vram_read_blocked;
gb->cgb_palettes_ppu_blocked = !gb->cgb_palettes_blocked;
}
static void leave_stop_mode(GB_gameboy_t *gb)
{
/* The CPU takes more time to wake up then the other components */
for (unsigned i = 0x200; i--;) {
GB_advance_cycles(gb, 0x10);
}
gb->stopped = false;
gb->oam_ppu_blocked = false;
gb->vram_ppu_blocked = false;
gb->cgb_palettes_ppu_blocked = false;
}
static void stop(GB_gameboy_t *gb, uint8_t opcode) static void stop(GB_gameboy_t *gb, uint8_t opcode)
{ {
if (gb->io_registers[GB_IO_KEY1] & 0x1) { if (gb->io_registers[GB_IO_KEY1] & 0x1) {
@ -252,9 +321,8 @@ static void stop(GB_gameboy_t *gb, uint8_t opcode)
gb->cgb_double_speed ^= true; gb->cgb_double_speed ^= true;
gb->io_registers[GB_IO_KEY1] = 0; gb->io_registers[GB_IO_KEY1] = 0;
for (unsigned i = 0x800; i--;) { enter_stop_mode(gb);
GB_advance_cycles(gb, 0x40); leave_stop_mode(gb);
}
if (!needs_alignment) { if (!needs_alignment) {
GB_advance_cycles(gb, 0x4); GB_advance_cycles(gb, 0x4);
@ -270,7 +338,7 @@ static void stop(GB_gameboy_t *gb, uint8_t opcode)
gb->halted = true; gb->halted = true;
} }
else { else {
gb->stopped = true; enter_stop_mode(gb);
} }
} }
@ -384,7 +452,7 @@ static void ld_da16_sp(GB_gameboy_t *gb, uint8_t opcode)
addr = cycle_read_inc_oam_bug(gb, gb->pc++); addr = cycle_read_inc_oam_bug(gb, gb->pc++);
addr |= cycle_read_inc_oam_bug(gb, gb->pc++) << 8; addr |= cycle_read_inc_oam_bug(gb, gb->pc++) << 8;
cycle_write(gb, addr, gb->registers[GB_REGISTER_SP] & 0xFF); cycle_write(gb, addr, gb->registers[GB_REGISTER_SP] & 0xFF);
cycle_write(gb, addr+1, gb->registers[GB_REGISTER_SP] >> 8); cycle_write(gb, addr + 1, gb->registers[GB_REGISTER_SP] >> 8);
} }
static void add_hl_rr(GB_gameboy_t *gb, uint8_t opcode) static void add_hl_rr(GB_gameboy_t *gb, uint8_t opcode)
@ -403,7 +471,7 @@ static void add_hl_rr(GB_gameboy_t *gb, uint8_t opcode)
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if ( ((unsigned long) hl + (unsigned long) rr) & 0x10000) { if ( ((unsigned) hl + (unsigned) rr) & 0x10000) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -734,7 +802,7 @@ static void add_a_r(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) > 0x0F) { if ((a & 0xF) + (value & 0xF) > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if (((unsigned long) a) + ((unsigned long) value) > 0xFF) { if (((unsigned) a) + ((unsigned) value) > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -753,7 +821,7 @@ static void adc_a_r(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) + carry > 0x0F) { if ((a & 0xF) + (value & 0xF) + carry > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if (((unsigned long) a) + ((unsigned long) value) + carry > 0xFF) { if (((unsigned) a) + ((unsigned) value) + carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -789,7 +857,7 @@ static void sbc_a_r(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) < (value & 0xF) + carry) { if ((a & 0xF) < (value & 0xF) + carry) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if (((unsigned long) a) - ((unsigned long) value) - carry > 0xFF) { if (((unsigned) a) - ((unsigned) value) - carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -933,7 +1001,7 @@ static void add_a_d8(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) > 0x0F) { if ((a & 0xF) + (value & 0xF) > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if (((unsigned long) a) + ((unsigned long) value) > 0xFF) { if (((unsigned) a) + ((unsigned) value) > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -952,7 +1020,7 @@ static void adc_a_d8(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) + carry > 0x0F) { if ((a & 0xF) + (value & 0xF) + carry > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if (((unsigned long) a) + ((unsigned long) value) + carry > 0xFF) { if (((unsigned) a) + ((unsigned) value) + carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -988,7 +1056,7 @@ static void sbc_a_d8(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) < (value & 0xF) + carry) { if ((a & 0xF) < (value & 0xF) + carry) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
} }
if (((unsigned long) a) - ((unsigned long) value) - carry > 0xFF) { if (((unsigned) a) - ((unsigned) value) - carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG; gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
} }
} }
@ -1154,7 +1222,7 @@ static void ld_a_da16(GB_gameboy_t *gb, uint8_t opcode)
uint16_t addr; uint16_t addr;
gb->registers[GB_REGISTER_AF] &= 0xFF; gb->registers[GB_REGISTER_AF] &= 0xFF;
addr = cycle_read_inc_oam_bug(gb, gb->pc++); addr = cycle_read_inc_oam_bug(gb, gb->pc++);
addr |= cycle_read_inc_oam_bug(gb, gb->pc++) << 8 ; addr |= cycle_read_inc_oam_bug(gb, gb->pc++) << 8;
gb->registers[GB_REGISTER_AF] |= cycle_read(gb, addr) << 8; gb->registers[GB_REGISTER_AF] |= cycle_read(gb, addr) << 8;
} }
@ -1342,10 +1410,10 @@ static void bit_r(GB_gameboy_t *gb, uint8_t opcode)
} }
} }
else if ((opcode & 0xC0) == 0x80) { /* res */ else if ((opcode & 0xC0) == 0x80) { /* res */
set_src_value(gb, opcode, value & ~bit) ; set_src_value(gb, opcode, value & ~bit);
} }
else if ((opcode & 0xC0) == 0xC0) { /* set */ else if ((opcode & 0xC0) == 0xC0) { /* set */
set_src_value(gb, opcode, value | bit) ; set_src_value(gb, opcode, value | bit);
} }
} }
@ -1429,11 +1497,7 @@ void GB_cpu_run(GB_gameboy_t *gb)
GB_timing_sync(gb); GB_timing_sync(gb);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
if ((gb->io_registers[GB_IO_JOYP] & 0xF) != 0xF) { if ((gb->io_registers[GB_IO_JOYP] & 0xF) != 0xF) {
gb->stopped = false; leave_stop_mode(gb);
/* The CPU takes more time to wake up then the other components */
for (unsigned i = 0x800; i--;) {
GB_advance_cycles(gb, 0x40);
}
GB_advance_cycles(gb, 8); GB_advance_cycles(gb, 8);
} }
return; return;
@ -1454,19 +1518,19 @@ void GB_cpu_run(GB_gameboy_t *gb)
} }
gb->just_halted = false; gb->just_halted = false;
bool effecitve_ime = gb->ime; bool effective_ime = gb->ime;
if (gb->ime_toggle) { if (gb->ime_toggle) {
gb->ime = !gb->ime; gb->ime = !gb->ime;
gb->ime_toggle = false; gb->ime_toggle = false;
} }
/* Wake up from HALT mode without calling interrupt code. */ /* Wake up from HALT mode without calling interrupt code. */
if (gb->halted && !effecitve_ime && interrupt_queue) { if (gb->halted && !effective_ime && interrupt_queue) {
gb->halted = false; gb->halted = false;
} }
/* Call interrupt */ /* Call interrupt */
else if (effecitve_ime && interrupt_queue) { else if (effective_ime && interrupt_queue) {
gb->halted = false; gb->halted = false;
uint16_t call_addr = gb->pc; uint16_t call_addr = gb->pc;
@ -1503,7 +1567,7 @@ void GB_cpu_run(GB_gameboy_t *gb)
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
} }
/* Run mode */ /* Run mode */
else if(!gb->halted) { else if (!gb->halted) {
gb->last_opcode_read = cycle_read_inc_oam_bug(gb, gb->pc++); gb->last_opcode_read = cycle_read_inc_oam_bug(gb, gb->pc++);
if (gb->halt_bug) { if (gb->halt_bug) {
gb->pc--; gb->pc--;
@ -1512,10 +1576,11 @@ void GB_cpu_run(GB_gameboy_t *gb)
opcodes[gb->last_opcode_read](gb, gb->last_opcode_read); opcodes[gb->last_opcode_read](gb, gb->last_opcode_read);
} }
flush_pending_cycles(gb);
if (gb->hdma_starting) { if (gb->hdma_starting) {
gb->hdma_starting = false; gb->hdma_starting = false;
gb->hdma_on = true; gb->hdma_on = true;
gb->hdma_cycles = -8; gb->hdma_cycles = -8;
} }
flush_pending_cycles(gb);
} }

View File

@ -97,7 +97,8 @@ static void rla(GB_gameboy_t *gb, uint8_t opcode, uint16_t *pc)
GB_log(gb, "RLA\n"); GB_log(gb, "RLA\n");
} }
static void ld_da16_sp(GB_gameboy_t *gb, uint8_t opcode, uint16_t *pc){ static void ld_da16_sp(GB_gameboy_t *gb, uint8_t opcode, uint16_t *pc)
{
uint16_t addr; uint16_t addr;
(*pc)++; (*pc)++;
addr = GB_read_memory(gb, (*pc)++); addr = GB_read_memory(gb, (*pc)++);

View File

@ -71,9 +71,9 @@ void GB_map_free(GB_symbol_map_t *map)
free(map); free(map);
} }
static int hash_name(const char *name) static unsigned hash_name(const char *name)
{ {
int r = 0; unsigned r = 0;
while (*name) { while (*name) {
r <<= 1; r <<= 1;
if (r & 0x400) { if (r & 0x400) {
@ -87,7 +87,7 @@ static int hash_name(const char *name)
void GB_reversed_map_add_symbol(GB_reversed_symbol_map_t *map, uint16_t bank, GB_bank_symbol_t *bank_symbol) void GB_reversed_map_add_symbol(GB_reversed_symbol_map_t *map, uint16_t bank, GB_bank_symbol_t *bank_symbol)
{ {
int hash = hash_name(bank_symbol->name); unsigned hash = hash_name(bank_symbol->name);
GB_symbol_t *symbol = malloc(sizeof(*symbol)); GB_symbol_t *symbol = malloc(sizeof(*symbol));
symbol->name = bank_symbol->name; symbol->name = bank_symbol->name;
symbol->addr = bank_symbol->addr; symbol->addr = bank_symbol->addr;
@ -98,7 +98,7 @@ void GB_reversed_map_add_symbol(GB_reversed_symbol_map_t *map, uint16_t bank, GB
const GB_symbol_t *GB_reversed_map_find_symbol(GB_reversed_symbol_map_t *map, const char *name) const GB_symbol_t *GB_reversed_map_find_symbol(GB_reversed_symbol_map_t *map, const char *name)
{ {
int hash = hash_name(name); unsigned hash = hash_name(name);
GB_symbol_t *symbol = map->buckets[hash]; GB_symbol_t *symbol = map->buckets[hash];
while (symbol) { while (symbol) {

View File

@ -10,7 +10,7 @@
static const unsigned GB_TAC_TRIGGER_BITS[] = {512, 8, 32, 128}; static const unsigned GB_TAC_TRIGGER_BITS[] = {512, 8, 32, 128};
#ifndef DISABLE_TIMEKEEPING #ifndef GB_DISABLE_TIMEKEEPING
static int64_t get_nanoseconds(void) static int64_t get_nanoseconds(void)
{ {
#ifndef _WIN32 #ifndef _WIN32
@ -139,6 +139,11 @@ static void GB_set_internal_div_counter(GB_gameboy_t *gb, uint32_t value)
static void GB_timers_run(GB_gameboy_t *gb, uint8_t cycles) static void GB_timers_run(GB_gameboy_t *gb, uint8_t cycles)
{ {
if (gb->stopped) {
gb->apu.apu_cycles += 4 << !gb->cgb_double_speed;
return;
}
GB_STATE_MACHINE(gb, div, cycles, 1) { GB_STATE_MACHINE(gb, div, cycles, 1) {
GB_STATE(gb, div, 1); GB_STATE(gb, div, 1);
GB_STATE(gb, div, 2); GB_STATE(gb, div, 2);
@ -213,8 +218,8 @@ void GB_advance_cycles(GB_gameboy_t *gb, uint8_t cycles)
// Affected by speed boost // Affected by speed boost
gb->dma_cycles += cycles; gb->dma_cycles += cycles;
GB_timers_run(gb, cycles);
if (!gb->stopped) { if (!gb->stopped) {
GB_timers_run(gb, cycles);
advance_serial(gb, cycles); // TODO: Verify what happens in STOP mode advance_serial(gb, cycles); // TODO: Verify what happens in STOP mode
} }
@ -277,19 +282,14 @@ void GB_rtc_run(GB_gameboy_t *gb)
time_t current_time = time(NULL); time_t current_time = time(NULL);
while (gb->last_rtc_second < current_time) { while (gb->last_rtc_second < current_time) {
gb->last_rtc_second++; gb->last_rtc_second++;
if (++gb->rtc_real.seconds == 60) if (++gb->rtc_real.seconds == 60) {
{
gb->rtc_real.seconds = 0; gb->rtc_real.seconds = 0;
if (++gb->rtc_real.minutes == 60) if (++gb->rtc_real.minutes == 60) {
{
gb->rtc_real.minutes = 0; gb->rtc_real.minutes = 0;
if (++gb->rtc_real.hours == 24) if (++gb->rtc_real.hours == 24) {
{
gb->rtc_real.hours = 0; gb->rtc_real.hours = 0;
if (++gb->rtc_real.days == 0) if (++gb->rtc_real.days == 0) {
{ if (gb->rtc_real.high & 1) { /* Bit 8 of days*/
if (gb->rtc_real.high & 1) /* Bit 8 of days*/
{
gb->rtc_real.high |= 0x80; /* Overflow bit */ gb->rtc_real.high |= 0x80; /* Overflow bit */
} }
gb->rtc_real.high ^= 1; gb->rtc_real.high ^= 1;

View File

@ -432,7 +432,7 @@ static double distanceMod1(double a, double b) {
// Compute the vertical offset // Compute the vertical offset
CGFloat textYOffset = (glyphCount == 1 ? 4 : 5); CGFloat textYOffset = (glyphCount == 1 ? 4 : 5);
// LOL // LOL
if ([_label isEqualToString:@"6"] || [_label isEqualToString:@"7"] == 7) textYOffset -= 1; if ([_label isEqualToString:@"6"]) textYOffset -= 1;
// Apply this text matrix // Apply this text matrix

View File

@ -37,6 +37,7 @@ endif
VERSION := 0.12.3 VERSION := 0.12.3
export VERSION export VERSION
CONF ?= debug CONF ?= debug
SDL_AUDIO_DRIVER ?= sdl
BIN := build/bin BIN := build/bin
OBJ := build/obj OBJ := build/obj
@ -87,8 +88,19 @@ ifeq ($(PLATFORM),Darwin)
OPEN_DIALOG = OpenDialog/cocoa.m OPEN_DIALOG = OpenDialog/cocoa.m
endif endif
# These must come before the -Wno- flags
WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option
WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-strict-aliasing -Wno-multichar -Wno-int-in-bool-context
# Only add this flag if the compiler supports it
ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0)
WARNINGS += -Wpartial-availability
endif
CFLAGS += $(WARNINGS)
CFLAGS += -std=gnu11 -D_GNU_SOURCE -DVERSION="$(VERSION)" -I. -D_USE_MATH_DEFINES
CFLAGS += -Werror -Wall -Wno-unused-result -Wno-strict-aliasing -Wno-unknown-warning -Wno-unknown-warning-option -Wno-multichar -Wno-int-in-bool-context -std=gnu11 -D_GNU_SOURCE -DVERSION="$(VERSION)" -I. -D_USE_MATH_DEFINES
ifeq (,$(PKG_CONFIG)) ifeq (,$(PKG_CONFIG))
SDL_CFLAGS := $(shell sdl2-config --cflags) SDL_CFLAGS := $(shell sdl2-config --cflags)
SDL_LDFLAGS := $(shell sdl2-config --libs) SDL_LDFLAGS := $(shell sdl2-config --libs)
@ -116,7 +128,6 @@ SYSROOT := $(shell xcodebuild -sdk macosx -version Path 2> $(NULL))
CFLAGS += -F/Library/Frameworks -mmacosx-version-min=10.9 CFLAGS += -F/Library/Frameworks -mmacosx-version-min=10.9
OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT) OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT)
LDFLAGS += -framework AppKit -framework PreferencePanes -framework Carbon -framework QuartzCore -weak_framework Metal -weak_framework MetalKit -mmacosx-version-min=10.9 LDFLAGS += -framework AppKit -framework PreferencePanes -framework Carbon -framework QuartzCore -weak_framework Metal -weak_framework MetalKit -mmacosx-version-min=10.9
SDL_LDFLAGS := -F/Library/Frameworks -framework SDL2
GL_LDFLAGS := -framework OpenGL GL_LDFLAGS := -framework OpenGL
endif endif
CFLAGS += -Wno-deprecated-declarations CFLAGS += -Wno-deprecated-declarations
@ -137,6 +148,7 @@ endif
ifneq ($(PLATFORM),windows32) ifneq ($(PLATFORM),windows32)
LDFLAGS += -flto LDFLAGS += -flto
CFLAGS += -flto CFLAGS += -flto
LDFLAGS += -Wno-lto-type-mismatch # For GCC's LTO
endif endif
else else
@ -163,7 +175,7 @@ all: cocoa sdl tester libretro
# Get a list of our source files and their respective object file targets # Get a list of our source files and their respective object file targets
CORE_SOURCES := $(shell ls Core/*.c) CORE_SOURCES := $(shell ls Core/*.c)
SDL_SOURCES := $(shell ls SDL/*.c) $(OPEN_DIALOG) SDL_SOURCES := $(shell ls SDL/*.c) $(OPEN_DIALOG) SDL/audio/$(SDL_AUDIO_DRIVER).c
TESTER_SOURCES := $(shell ls Tester/*.c) TESTER_SOURCES := $(shell ls Tester/*.c)
ifeq ($(PLATFORM),Darwin) ifeq ($(PLATFORM),Darwin)
@ -333,7 +345,11 @@ $(BIN)/tester/sameboy_tester.exe: $(CORE_OBJECTS) $(SDL_OBJECTS)
-@$(MKDIR) -p $(dir $@) -@$(MKDIR) -p $(dir $@)
$(CC) $^ -o $@ $(LDFLAGS) -Wl,/subsystem:console $(CC) $^ -o $@ $(LDFLAGS) -Wl,/subsystem:console
$(BIN)/SDL/%.bin $(BIN)/tester/%.bin: $(BOOTROMS_DIR)/%.bin $(BIN)/SDL/%.bin: $(BOOTROMS_DIR)/%.bin
-@$(MKDIR) -p $(dir $@)
cp -f $^ $@
$(BIN)/tester/%.bin: $(BOOTROMS_DIR)/%.bin
-@$(MKDIR) -p $(dir $@) -@$(MKDIR) -p $(dir $@)
cp -f $^ $@ cp -f $^ $@
@ -382,10 +398,10 @@ $(BIN)/BootROMs/%.bin: BootROMs/%.asm $(OBJ)/BootROMs/SameBoyLogo.pb8
# Libretro Core (uses its own build system) # Libretro Core (uses its own build system)
libretro: libretro:
$(MAKE) -C libretro CFLAGS="$(WARNINGS)" $(MAKE) -C libretro
# Clean # Clean
clean: clean:
rm -rf build rm -rf build
.PHONY: libretro .PHONY: libretro tester

View File

@ -41,10 +41,10 @@
00:FF49 IO_OBP1 00:FF49 IO_OBP1
00:FF4A IO_WY 00:FF4A IO_WY
00:FF4B IO_WX 00:FF4B IO_WX
00:FF4C IO_DMG_EMULATION 00:FF4C IO_KEY0
00:FF4D IO_KEY1 00:FF4D IO_KEY1
00:FF4F IO_VBK 00:FF4F IO_VBK
00:FF50 IO_BIOS 00:FF50 IO_BANK
00:FF51 IO_HDMA1 00:FF51 IO_HDMA1
00:FF52 IO_HDMA2 00:FF52 IO_HDMA2
00:FF53 IO_HDMA3 00:FF53 IO_HDMA3
@ -55,7 +55,7 @@
00:FF69 IO_BGPD 00:FF69 IO_BGPD
00:FF6A IO_OBPI 00:FF6A IO_OBPI
00:FF6B IO_OBPD 00:FF6B IO_OBPD
00:FF6C IO_DMG_EMULATION_INDICATION 00:FF6C IO_OPRI
00:FF70 IO_SVBK 00:FF70 IO_SVBK
00:FF72 IO_UNKNOWN2 00:FF72 IO_UNKNOWN2
00:FF73 IO_UNKNOWN3 00:FF73 IO_UNKNOWN3

View File

@ -8,7 +8,7 @@ char *do_open_rom_dialog(void)
NSWindow *key = [NSApp keyWindow]; NSWindow *key = [NSApp keyWindow];
NSOpenPanel *dialog = [NSOpenPanel openPanel]; NSOpenPanel *dialog = [NSOpenPanel openPanel];
dialog.title = @"Open ROM"; dialog.title = @"Open ROM";
dialog.allowedFileTypes = @[@"gb", @"gbc", @"sgb"]; dialog.allowedFileTypes = @[@"gb", @"gbc", @"sgb", @"isx"];
[dialog runModal]; [dialog runModal];
[key makeKeyAndOrderFront:nil]; [key makeKeyAndOrderFront:nil];
NSString *ret = [[[dialog URLs] firstObject] path]; NSString *ret = [[[dialog URLs] firstObject] path];

View File

@ -82,14 +82,14 @@ char *do_open_rom_dialog(void)
gtk_file_filter_add_pattern(filter, "*.gb"); gtk_file_filter_add_pattern(filter, "*.gb");
gtk_file_filter_add_pattern(filter, "*.gbc"); gtk_file_filter_add_pattern(filter, "*.gbc");
gtk_file_filter_add_pattern(filter, "*.sgb"); gtk_file_filter_add_pattern(filter, "*.sgb");
gtk_file_filter_add_pattern(filter, "*.isx");
gtk_file_filter_set_name(filter, "Game Boy ROMs"); gtk_file_filter_set_name(filter, "Game Boy ROMs");
gtk_file_chooser_add_filter(dialog, filter); gtk_file_chooser_add_filter(dialog, filter);
int res = gtk_dialog_run (dialog); int res = gtk_dialog_run (dialog);
char *ret = NULL; char *ret = NULL;
if (res == GTK_RESPONSE_ACCEPT) if (res == GTK_RESPONSE_ACCEPT) {
{
char *filename; char *filename;
filename = gtk_file_chooser_get_filename(dialog); filename = gtk_file_chooser_get_filename(dialog);
ret = strdup(filename); ret = strdup(filename);

View File

@ -10,15 +10,14 @@ char *do_open_rom_dialog(void)
dialog.lStructSize = sizeof(dialog); dialog.lStructSize = sizeof(dialog);
dialog.lpstrFile = filename; dialog.lpstrFile = filename;
dialog.nMaxFile = sizeof(filename); dialog.nMaxFile = sizeof(filename);
dialog.lpstrFilter = L"Game Boy ROMs\0*.gb;*.gbc;*.sgb\0All files\0*.*\0\0"; dialog.lpstrFilter = L"Game Boy ROMs\0*.gb;*.gbc;*.sgb;*.isx\0All files\0*.*\0\0";
dialog.nFilterIndex = 1; dialog.nFilterIndex = 1;
dialog.lpstrFileTitle = NULL; dialog.lpstrFileTitle = NULL;
dialog.nMaxFileTitle = 0; dialog.nMaxFileTitle = 0;
dialog.lpstrInitialDir = NULL; dialog.lpstrInitialDir = NULL;
dialog.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; dialog.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileNameW(&dialog) == TRUE) if (GetOpenFileNameW(&dialog) == TRUE) {
{
char *ret = malloc(MAX_PATH * 4); char *ret = malloc(MAX_PATH * 4);
WideCharToMultiByte(CP_UTF8, 0, filename, sizeof(filename), ret, MAX_PATH * 4, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, filename, sizeof(filename), ret, MAX_PATH * 4, NULL, NULL);
return ret; return ret;

View File

@ -13,6 +13,7 @@
<array> <array>
<string>com.github.liji32.sameboy.gb</string> <string>com.github.liji32.sameboy.gb</string>
<string>com.github.liji32.sameboy.gbc</string> <string>com.github.liji32.sameboy.gbc</string>
<string>com.github.liji32.sameboy.isx</string>
</array> </array>
</dict> </dict>
</array> </array>

View File

@ -79,7 +79,7 @@ static OSStatus render(CGContextRef cgContext, CFURLRef url, bool showBorder)
} }
/* Mask it with the template (The middle part of the template image is transparent) */ /* Mask it with the template (The middle part of the template image is transparent) */
[effectiveTemplate drawInRect:(NSRect){{0,0},template.size}]; [effectiveTemplate drawInRect:(NSRect){{0, 0}, template.size}];
} }
CGColorSpaceRelease(colorSpaceRef); CGColorSpaceRelease(colorSpaceRef);

View File

@ -2,6 +2,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <ctype.h>
#include <Core/gb.h> #include <Core/gb.h>
#include "get_image_for_rom.h" #include "get_image_for_rom.h"
@ -60,7 +61,22 @@ int get_image_for_rom(const char *filename, const char *boot_path, uint32_t *out
GB_set_log_callback(&gb, log_callback); GB_set_log_callback(&gb, log_callback);
GB_set_color_correction_mode(&gb, GB_COLOR_CORRECTION_EMULATE_HARDWARE); GB_set_color_correction_mode(&gb, GB_COLOR_CORRECTION_EMULATE_HARDWARE);
if (GB_load_rom(&gb, filename)) { size_t length = strlen(filename);
char extension[4] = {0,};
if (length > 4) {
if (filename[length - 4] == '.') {
extension[0] = tolower(filename[length - 3]);
extension[1] = tolower(filename[length - 2]);
extension[2] = tolower(filename[length - 1]);
}
}
if (strcmp(extension, "isx") == 0) {
if (GB_load_isx(&gb, filename)) {
GB_free(&gb);
return 1;
}
}
else if (GB_load_rom(&gb, filename)) {
GB_free(&gb); GB_free(&gb);
return 1; return 1;
} }

View File

@ -43,8 +43,8 @@ typedef struct __QuickLookGeneratorPluginType
QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID); QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID);
void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance); void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance);
HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); HRESULT QuickLookGeneratorQueryInterface(void *thisInstance, REFIID iid, LPVOID *ppv);
void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator, CFUUIDRef typeID);
ULONG QuickLookGeneratorPluginAddRef(void *thisInstance); ULONG QuickLookGeneratorPluginAddRef(void *thisInstance);
ULONG QuickLookGeneratorPluginRelease(void *thisInstance); ULONG QuickLookGeneratorPluginRelease(void *thisInstance);
@ -77,11 +77,11 @@ QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFact
QuickLookGeneratorPluginType *theNewInstance; QuickLookGeneratorPluginType *theNewInstance;
theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType)); theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType));
memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType)); memset(theNewInstance, 0, sizeof(QuickLookGeneratorPluginType));
/* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */ /* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */
theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct)); theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct));
memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct)); memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl, sizeof(QLGeneratorInterfaceStruct));
/* Retain and keep an open instance refcount for each factory. */ /* Retain and keep an open instance refcount for each factory. */
theNewInstance->factoryID = CFRetain(inFactoryID); theNewInstance->factoryID = CFRetain(inFactoryID);
@ -110,7 +110,7 @@ void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInsta
/* Free the instance structure */ /* Free the instance structure */
free(thisInstance); free(thisInstance);
if (theFactoryID){ if (theFactoryID) {
CFPlugInRemoveInstanceForFactory(theFactoryID); CFPlugInRemoveInstanceForFactory(theFactoryID);
CFRelease(theFactoryID); CFRelease(theFactoryID);
} }
@ -121,13 +121,13 @@ void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInsta
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Implementation of the IUnknown QueryInterface function. // Implementation of the IUnknown QueryInterface function.
// //
HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) HRESULT QuickLookGeneratorQueryInterface(void *thisInstance, REFIID iid, LPVOID *ppv)
{ {
CFUUIDRef interfaceID; CFUUIDRef interfaceID;
interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, iid);
if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){ if (CFEqual(interfaceID, kQLGeneratorCallbacksInterfaceID)) {
/* If the Right interface was requested, bump the ref count, /* If the Right interface was requested, bump the ref count,
* set the ppv parameter equal to the instance, and * set the ppv parameter equal to the instance, and
* return good status. * return good status.
@ -138,7 +138,8 @@ HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *p
*ppv = thisInstance; *ppv = thisInstance;
CFRelease(interfaceID); CFRelease(interfaceID);
return S_OK; return S_OK;
}else{ }
else {
/* Requested interface unknown, bail with error. */ /* Requested interface unknown, bail with error. */
*ppv = NULL; *ppv = NULL;
CFRelease(interfaceID); CFRelease(interfaceID);
@ -168,10 +169,11 @@ ULONG QuickLookGeneratorPluginAddRef(void *thisInstance)
ULONG QuickLookGeneratorPluginRelease(void *thisInstance) ULONG QuickLookGeneratorPluginRelease(void *thisInstance)
{ {
((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1; ((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1;
if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){ if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0) {
DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance ); DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance );
return 0; return 0;
}else{ }
else {
return ((QuickLookGeneratorPluginType*) thisInstance )->refCount; return ((QuickLookGeneratorPluginType*) thisInstance )->refCount;
} }
} }
@ -179,7 +181,7 @@ ULONG QuickLookGeneratorPluginRelease(void *thisInstance)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// QuickLookGeneratorPluginFactory // QuickLookGeneratorPluginFactory
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator, CFUUIDRef typeID)
{ {
QuickLookGeneratorPluginType *result; QuickLookGeneratorPluginType *result;
CFUUIDRef uuid; CFUUIDRef uuid;
@ -187,8 +189,8 @@ void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID)
/* If correct type is being requested, allocate an /* If correct type is being requested, allocate an
* instance of kQLGeneratorTypeID and return the IUnknown interface. * instance of kQLGeneratorTypeID and return the IUnknown interface.
*/ */
if (CFEqual(typeID,kQLGeneratorTypeID)){ if (CFEqual(typeID, kQLGeneratorTypeID)) {
uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); uuid = CFUUIDCreateFromString(kCFAllocatorDefault, CFSTR(PLUGIN_ID));
result = AllocQuickLookGeneratorPluginType(uuid); result = AllocQuickLookGeneratorPluginType(uuid);
CFRelease(uuid); CFRelease(uuid);
return result; return result;

View File

@ -38,7 +38,7 @@ SameBoy requires the following tools and libraries to build:
* clang * clang
* make * make
* Cocoa port: OS X SDK and Xcode command line tools * Cocoa port: OS X SDK and Xcode command line tools
* SDL port: SDL2.framework (OS X) or libsdl2 (Other platforms) * SDL port: libsdl2
* [rgbds](https://github.com/bentley/rgbds/releases/), for boot ROM compilation * [rgbds](https://github.com/bentley/rgbds/releases/), for boot ROM compilation
On Windows, SameBoy also requires: On Windows, SameBoy also requires:

16
SDL/audio/audio.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef sdl_audio_h
#define sdl_audio_h
#include <stdbool.h>
#include <stddef.h>
#include <Core/gb.h>
bool GB_audio_is_playing(void);
void GB_audio_set_paused(bool paused);
void GB_audio_clear_queue(void);
unsigned GB_audio_get_frequency(void);
size_t GB_audio_get_queue_length(void);
void GB_audio_queue_sample(GB_sample_t *sample);
void GB_audio_init(void);
#endif /* sdl_audio_h */

87
SDL/audio/sdl.c Normal file
View File

@ -0,0 +1,87 @@
#include "audio.h"
#include <SDL.h>
#ifndef _WIN32
#define AUDIO_FREQUENCY 96000
#include <unistd.h>
#else
#include <Windows.h>
/* Windows (well, at least my VM) can't handle 96KHz sound well :( */
/* felsqualle says: For SDL 2.0.6+ using the WASAPI driver, the highest freq.
we can get is 48000. 96000 also works, but always has some faint crackling in
the audio, no matter how high or low I set the buffer length...
Not quite satisfied with that solution, because acc. to SDL2 docs,
96k + WASAPI *should* work. */
#define AUDIO_FREQUENCY 48000
#endif
/* Compatibility with older SDL versions */
#ifndef SDL_AUDIO_ALLOW_SAMPLES_CHANGE
#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0
#endif
static SDL_AudioDeviceID device_id;
static SDL_AudioSpec want_aspec, have_aspec;
bool GB_audio_is_playing(void)
{
return SDL_GetAudioDeviceStatus(device_id) == SDL_AUDIO_PLAYING;
}
void GB_audio_set_paused(bool paused)
{
GB_audio_clear_queue();
SDL_PauseAudioDevice(device_id, paused);
}
void GB_audio_clear_queue(void)
{
SDL_ClearQueuedAudio(device_id);
}
unsigned GB_audio_get_frequency(void)
{
return have_aspec.freq;
}
size_t GB_audio_get_queue_length(void)
{
return SDL_GetQueuedAudioSize(device_id);
}
void GB_audio_queue_sample(GB_sample_t *sample)
{
SDL_QueueAudio(device_id, sample, sizeof(*sample));
}
void GB_audio_init(void)
{
/* Configure Audio */
memset(&want_aspec, 0, sizeof(want_aspec));
want_aspec.freq = AUDIO_FREQUENCY;
want_aspec.format = AUDIO_S16SYS;
want_aspec.channels = 2;
want_aspec.samples = 512;
SDL_version _sdl_version;
SDL_GetVersion(&_sdl_version);
unsigned sdl_version = _sdl_version.major * 1000 + _sdl_version.minor * 100 + _sdl_version.patch;
#ifndef _WIN32
/* SDL 2.0.5 on macOS and Linux introduced a bug where certain combinations of buffer lengths and frequencies
fail to produce audio correctly. */
if (sdl_version >= 2005) {
want_aspec.samples = 2048;
}
#else
if (sdl_version < 2006) {
/* Since WASAPI audio was introduced in SDL 2.0.6, we have to lower the audio frequency
to 44100 because otherwise we would get garbled audio output.*/
want_aspec.freq = 44100;
}
#endif
device_id = SDL_OpenAudioDevice(0, 0, &want_aspec, &have_aspec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_SAMPLES_CHANGE);
}

202
SDL/gui.c
View File

@ -46,9 +46,22 @@ void render_texture(void *pixels, void *previous)
} }
glClearColor(0, 0, 0, 1); glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
GB_frame_blending_mode_t mode = configuration.blending_mode;
if (!previous) {
mode = GB_FRAME_BLENDING_MODE_DISABLED;
}
else if (mode == GB_FRAME_BLENDING_MODE_ACCURATE) {
if (GB_is_sgb(&gb)) {
mode = GB_FRAME_BLENDING_MODE_SIMPLE;
}
else {
mode = GB_is_odd_frame(&gb)? GB_FRAME_BLENDING_MODE_ACCURATE_ODD : GB_FRAME_BLENDING_MODE_ACCURATE_EVEN;
}
}
render_bitmap_with_shader(&shader, _pixels, previous, render_bitmap_with_shader(&shader, _pixels, previous,
GB_get_screen_width(&gb), GB_get_screen_height(&gb), GB_get_screen_width(&gb), GB_get_screen_height(&gb),
rect.x, rect.y, rect.w, rect.h); rect.x, rect.y, rect.w, rect.h,
mode);
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
} }
} }
@ -91,9 +104,10 @@ configuration_t configuration =
.color_correction_mode = GB_COLOR_CORRECTION_EMULATE_HARDWARE, .color_correction_mode = GB_COLOR_CORRECTION_EMULATE_HARDWARE,
.highpass_mode = GB_HIGHPASS_ACCURATE, .highpass_mode = GB_HIGHPASS_ACCURATE,
.scaling_mode = GB_SDL_SCALING_INTEGER_FACTOR, .scaling_mode = GB_SDL_SCALING_INTEGER_FACTOR,
.blend_frames = true, .blending_mode = GB_FRAME_BLENDING_MODE_ACCURATE,
.rewind_length = 60 * 2, .rewind_length = 60 * 2,
.model = MODEL_CGB .model = MODEL_CGB,
.volume = 100,
}; };
@ -128,8 +142,8 @@ void update_viewport(void)
double y_factor = win_height / (double) GB_get_screen_height(&gb); double y_factor = win_height / (double) GB_get_screen_height(&gb);
if (configuration.scaling_mode == GB_SDL_SCALING_INTEGER_FACTOR) { if (configuration.scaling_mode == GB_SDL_SCALING_INTEGER_FACTOR) {
x_factor = (int)(x_factor); x_factor = (unsigned)(x_factor);
y_factor = (int)(y_factor); y_factor = (unsigned)(y_factor);
} }
if (configuration.scaling_mode != GB_SDL_SCALING_ENTIRE_WINDOW) { if (configuration.scaling_mode != GB_SDL_SCALING_ENTIRE_WINDOW) {
@ -175,9 +189,12 @@ static void draw_char(uint32_t *buffer, unsigned width, unsigned height, unsigne
} }
} }
static unsigned scroll = 0;
static void draw_unbordered_text(uint32_t *buffer, unsigned width, unsigned height, unsigned x, unsigned y, const char *string, uint32_t color) static void draw_unbordered_text(uint32_t *buffer, unsigned width, unsigned height, unsigned x, unsigned y, const char *string, uint32_t color)
{ {
y -= scroll;
unsigned orig_x = x; unsigned orig_x = x;
unsigned y_offset = (GB_get_screen_height(&gb) - 144) / 2;
while (*string) { while (*string) {
if (*string == '\n') { if (*string == '\n') {
x = orig_x; x = orig_x;
@ -186,7 +203,7 @@ static void draw_unbordered_text(uint32_t *buffer, unsigned width, unsigned heig
continue; continue;
} }
if (x > width - GLYPH_WIDTH || y == 0 || y > height - GLYPH_HEIGHT) { if (x > width - GLYPH_WIDTH || y == 0 || y - y_offset > 144 - GLYPH_HEIGHT) {
break; break;
} }
@ -297,6 +314,7 @@ static void return_to_root_menu(unsigned index)
{ {
current_menu = root_menu; current_menu = root_menu;
current_selection = 0; current_selection = 0;
scroll = 0;
} }
static void cycle_model(unsigned index) static void cycle_model(unsigned index)
@ -320,7 +338,7 @@ static void cycle_model_backwards(unsigned index)
const char *current_model_string(unsigned index) const char *current_model_string(unsigned index)
{ {
return (const char *[]){"Game Boy", "Game Boy Color", "Game Boy Advance" , "Super Game Boy"} return (const char *[]){"Game Boy", "Game Boy Color", "Game Boy Advance", "Super Game Boy"}
[configuration.model]; [configuration.model];
} }
@ -407,6 +425,7 @@ static void enter_emulation_menu(unsigned index)
{ {
current_menu = emulation_menu; current_menu = emulation_menu;
current_selection = 0; current_selection = 0;
scroll = 0;
} }
const char *current_scaling_mode(unsigned index) const char *current_scaling_mode(unsigned index)
@ -417,10 +436,22 @@ const char *current_scaling_mode(unsigned index)
const char *current_color_correction_mode(unsigned index) const char *current_color_correction_mode(unsigned index)
{ {
return (const char *[]){"Disabled", "Correct Color Curves", "Emulate Hardware", "Preserve Brightness"} return (const char *[]){"Disabled", "Correct Color Curves", "Emulate Hardware", "Preserve Brightness", "Reduce Contrast"}
[configuration.color_correction_mode]; [configuration.color_correction_mode];
} }
const char *current_palette(unsigned index)
{
return (const char *[]){"Greyscale", "Lime (Game Boy)", "Olive (Pocket)", "Teal (Light)"}
[configuration.dmg_palette];
}
const char *current_border_mode(unsigned index)
{
return (const char *[]){"SGB Only", "Never", "Always"}
[configuration.border_mode];
}
void cycle_scaling(unsigned index) void cycle_scaling(unsigned index)
{ {
configuration.scaling_mode++; configuration.scaling_mode++;
@ -445,7 +476,7 @@ void cycle_scaling_backwards(unsigned index)
static void cycle_color_correction(unsigned index) static void cycle_color_correction(unsigned index)
{ {
if (configuration.color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) { if (configuration.color_correction_mode == GB_COLOR_CORRECTION_REDUCE_CONTRAST) {
configuration.color_correction_mode = GB_COLOR_CORRECTION_DISABLED; configuration.color_correction_mode = GB_COLOR_CORRECTION_DISABLED;
} }
else { else {
@ -456,13 +487,53 @@ static void cycle_color_correction(unsigned index)
static void cycle_color_correction_backwards(unsigned index) static void cycle_color_correction_backwards(unsigned index)
{ {
if (configuration.color_correction_mode == GB_COLOR_CORRECTION_DISABLED) { if (configuration.color_correction_mode == GB_COLOR_CORRECTION_DISABLED) {
configuration.color_correction_mode = GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS; configuration.color_correction_mode = GB_COLOR_CORRECTION_REDUCE_CONTRAST;
} }
else { else {
configuration.color_correction_mode--; configuration.color_correction_mode--;
} }
} }
static void cycle_palette(unsigned index)
{
if (configuration.dmg_palette == 3) {
configuration.dmg_palette = 0;
}
else {
configuration.dmg_palette++;
}
}
static void cycle_palette_backwards(unsigned index)
{
if (configuration.dmg_palette == 0) {
configuration.dmg_palette = 3;
}
else {
configuration.dmg_palette--;
}
}
static void cycle_border_mode(unsigned index)
{
if (configuration.border_mode == GB_BORDER_ALWAYS) {
configuration.border_mode = GB_BORDER_SGB;
}
else {
configuration.border_mode++;
}
}
static void cycle_border_mode_backwards(unsigned index)
{
if (configuration.border_mode == GB_BORDER_SGB) {
configuration.border_mode = GB_BORDER_ALWAYS;
}
else {
configuration.border_mode--;
}
}
struct shader_name { struct shader_name {
const char *file_name; const char *file_name;
const char *display_name; const char *display_name;
@ -471,6 +542,7 @@ struct shader_name {
{"NearestNeighbor", "Nearest Neighbor"}, {"NearestNeighbor", "Nearest Neighbor"},
{"Bilinear", "Bilinear"}, {"Bilinear", "Bilinear"},
{"SmoothBilinear", "Smooth Bilinear"}, {"SmoothBilinear", "Smooth Bilinear"},
{"MonoLCD", "Monochrome LCD"},
{"LCD", "LCD Display"}, {"LCD", "LCD Display"},
{"CRT", "CRT Display"}, {"CRT", "CRT Display"},
{"Scale2x", "Scale2x"}, {"Scale2x", "Scale2x"},
@ -542,21 +614,39 @@ const char *current_filter_name(unsigned index)
return shaders[i].display_name; return shaders[i].display_name;
} }
static void toggle_blend_frames(unsigned index) static void cycle_blending_mode(unsigned index)
{ {
configuration.blend_frames ^= true; if (configuration.blending_mode == GB_FRAME_BLENDING_MODE_ACCURATE) {
configuration.blending_mode = GB_FRAME_BLENDING_MODE_DISABLED;
}
else {
configuration.blending_mode++;
}
} }
const char *blend_frames_string(unsigned index) static void cycle_blending_mode_backwards(unsigned index)
{ {
return configuration.blend_frames? "Enabled" : "Disabled"; if (configuration.blending_mode == GB_FRAME_BLENDING_MODE_DISABLED) {
configuration.blending_mode = GB_FRAME_BLENDING_MODE_ACCURATE;
}
else {
configuration.blending_mode--;
}
}
const char *blending_mode_string(unsigned index)
{
return (const char *[]){"Disabled", "Simple", "Accurate"}
[configuration.blending_mode];
} }
static const struct menu_item graphics_menu[] = { static const struct menu_item graphics_menu[] = {
{"Scaling Mode:", cycle_scaling, current_scaling_mode, cycle_scaling_backwards}, {"Scaling Mode:", cycle_scaling, current_scaling_mode, cycle_scaling_backwards},
{"Scaling Filter:", cycle_filter, current_filter_name, cycle_filter_backwards}, {"Scaling Filter:", cycle_filter, current_filter_name, cycle_filter_backwards},
{"Color Correction:", cycle_color_correction, current_color_correction_mode, cycle_color_correction_backwards}, {"Color Correction:", cycle_color_correction, current_color_correction_mode, cycle_color_correction_backwards},
{"Blend Frames:", toggle_blend_frames, blend_frames_string, toggle_blend_frames}, {"Frame Blending:", cycle_blending_mode, blending_mode_string, cycle_blending_mode_backwards},
{"Mono Palette:", cycle_palette, current_palette, cycle_palette_backwards},
{"Display Border:", cycle_border_mode, current_border_mode, cycle_border_mode_backwards},
{"Back", return_to_root_menu}, {"Back", return_to_root_menu},
{NULL,} {NULL,}
}; };
@ -565,6 +655,7 @@ static void enter_graphics_menu(unsigned index)
{ {
current_menu = graphics_menu; current_menu = graphics_menu;
current_selection = 0; current_selection = 0;
scroll = 0;
} }
const char *highpass_filter_string(unsigned index) const char *highpass_filter_string(unsigned index)
@ -591,8 +682,32 @@ void cycle_highpass_filter_backwards(unsigned index)
} }
} }
const char *volume_string(unsigned index)
{
static char ret[5];
sprintf(ret, "%d%%", configuration.volume);
return ret;
}
void increase_volume(unsigned index)
{
configuration.volume += 5;
if (configuration.volume > 100) {
configuration.volume = 100;
}
}
void decrease_volume(unsigned index)
{
configuration.volume -= 5;
if (configuration.volume > 100) {
configuration.volume = 0;
}
}
static const struct menu_item audio_menu[] = { static const struct menu_item audio_menu[] = {
{"Highpass Filter:", cycle_highpass_filter, highpass_filter_string, cycle_highpass_filter_backwards}, {"Highpass Filter:", cycle_highpass_filter, highpass_filter_string, cycle_highpass_filter_backwards},
{"Volume:", increase_volume, volume_string, decrease_volume},
{"Back", return_to_root_menu}, {"Back", return_to_root_menu},
{NULL,} {NULL,}
}; };
@ -601,6 +716,7 @@ static void enter_audio_menu(unsigned index)
{ {
current_menu = audio_menu; current_menu = audio_menu;
current_selection = 0; current_selection = 0;
scroll = 0;
} }
static void modify_key(unsigned index) static void modify_key(unsigned index)
@ -608,7 +724,6 @@ static void modify_key(unsigned index)
gui_state = WAITING_FOR_KEY; gui_state = WAITING_FOR_KEY;
} }
static void enter_controls_menu_2(unsigned index);
static const char *key_name(unsigned index); static const char *key_name(unsigned index);
static const struct menu_item controls_menu[] = { static const struct menu_item controls_menu[] = {
@ -620,12 +735,6 @@ static const struct menu_item controls_menu[] = {
{"B:", modify_key, key_name,}, {"B:", modify_key, key_name,},
{"Select:", modify_key, key_name,}, {"Select:", modify_key, key_name,},
{"Start:", modify_key, key_name,}, {"Start:", modify_key, key_name,},
{"Next Page", enter_controls_menu_2},
{"Back", return_to_root_menu},
{NULL,}
};
static const struct menu_item controls_menu_2[] = {
{"Turbo:", modify_key, key_name,}, {"Turbo:", modify_key, key_name,},
{"Rewind:", modify_key, key_name,}, {"Rewind:", modify_key, key_name,},
{"Slow-Motion:", modify_key, key_name,}, {"Slow-Motion:", modify_key, key_name,},
@ -635,11 +744,11 @@ static const struct menu_item controls_menu_2[] = {
static const char *key_name(unsigned index) static const char *key_name(unsigned index)
{ {
if (current_menu == controls_menu_2) { if (index >= 8) {
if (index == 0) { if (index == 8) {
return SDL_GetScancodeName(configuration.keys[8]); return SDL_GetScancodeName(configuration.keys[8]);
} }
return SDL_GetScancodeName(configuration.keys_2[index - 1]); return SDL_GetScancodeName(configuration.keys_2[index - 9]);
} }
return SDL_GetScancodeName(configuration.keys[index]); return SDL_GetScancodeName(configuration.keys[index]);
} }
@ -648,12 +757,7 @@ static void enter_controls_menu(unsigned index)
{ {
current_menu = controls_menu; current_menu = controls_menu;
current_selection = 0; current_selection = 0;
} scroll = 0;
static void enter_controls_menu_2(unsigned index)
{
current_menu = controls_menu_2;
current_selection = 0;
} }
static unsigned joypad_index = 0; static unsigned joypad_index = 0;
@ -696,7 +800,7 @@ static void cycle_joypads(unsigned index)
SDL_JoystickClose(joystick); SDL_JoystickClose(joystick);
joystick = NULL; joystick = NULL;
} }
if ((controller = SDL_GameControllerOpen(joypad_index))){ if ((controller = SDL_GameControllerOpen(joypad_index))) {
joystick = SDL_GameControllerGetJoystick(controller); joystick = SDL_GameControllerGetJoystick(controller);
} }
else { else {
@ -718,7 +822,7 @@ static void cycle_joypads_backwards(unsigned index)
SDL_JoystickClose(joystick); SDL_JoystickClose(joystick);
joystick = NULL; joystick = NULL;
} }
if ((controller = SDL_GameControllerOpen(joypad_index))){ if ((controller = SDL_GameControllerOpen(joypad_index))) {
joystick = SDL_GameControllerGetJoystick(controller); joystick = SDL_GameControllerGetJoystick(controller);
} }
else { else {
@ -744,6 +848,7 @@ static void enter_joypad_menu(unsigned index)
{ {
current_menu = joypad_menu; current_menu = joypad_menu;
current_selection = 0; current_selection = 0;
scroll = 0;
} }
joypad_button_t get_joypad_button(uint8_t physical_button) joypad_button_t get_joypad_button(uint8_t physical_button)
@ -781,7 +886,7 @@ void connect_joypad(void)
} }
} }
else if (!joystick && SDL_NumJoysticks()) { else if (!joystick && SDL_NumJoysticks()) {
if ((controller = SDL_GameControllerOpen(0))){ if ((controller = SDL_GameControllerOpen(0))) {
joystick = SDL_GameControllerGetJoystick(controller); joystick = SDL_GameControllerGetJoystick(controller);
} }
else { else {
@ -826,6 +931,7 @@ void run_gui(bool is_running)
bool should_render = true; bool should_render = true;
current_menu = root_menu = is_running? paused_menu : nonpaused_menu; current_menu = root_menu = is_running? paused_menu : nonpaused_menu;
current_selection = 0; current_selection = 0;
scroll = 0;
do { do {
/* Convert Joypad and mouse events (We only generate down events) */ /* Convert Joypad and mouse events (We only generate down events) */
if (gui_state != WAITING_FOR_KEY && gui_state != WAITING_FOR_JBUTTON) { if (gui_state != WAITING_FOR_KEY && gui_state != WAITING_FOR_JBUTTON) {
@ -850,6 +956,7 @@ void run_gui(bool is_running)
y = y * 8 / 7; y = y * 8 / 7;
y -= 144 / 16; y -= 144 / 16;
} }
y += scroll;
if (x < 0 || x >= 160 || y < 24) { if (x < 0 || x >= 160 || y < 24) {
continue; continue;
@ -1058,6 +1165,7 @@ void run_gui(bool is_running)
gui_state = SHOWING_DROP_MESSAGE; gui_state = SHOWING_DROP_MESSAGE;
} }
current_selection = 0; current_selection = 0;
scroll = 0;
current_menu = root_menu; current_menu = root_menu;
should_render = true; should_render = true;
} }
@ -1106,12 +1214,12 @@ void run_gui(bool is_running)
should_render = true; should_render = true;
} }
else if (gui_state == WAITING_FOR_KEY) { else if (gui_state == WAITING_FOR_KEY) {
if (current_menu == controls_menu_2) { if (current_selection >= 8) {
if (current_selection == 0) { if (current_selection == 8) {
configuration.keys[8] = event.key.keysym.scancode; configuration.keys[8] = event.key.keysym.scancode;
} }
else { else {
configuration.keys_2[current_selection - 1] = event.key.keysym.scancode; configuration.keys_2[current_selection - 9] = event.key.keysym.scancode;
} }
} }
else { else {
@ -1125,6 +1233,7 @@ void run_gui(bool is_running)
if (should_render) { if (should_render) {
should_render = false; should_render = false;
rerender:
if (width == 160 && height == 144) { if (width == 160 && height == 144) {
memcpy(pixels, converted_background->pixels, sizeof(pixels)); memcpy(pixels, converted_background->pixels, sizeof(pixels));
} }
@ -1144,9 +1253,19 @@ void run_gui(bool is_running)
draw_text_centered(pixels, width, height, 8 + y_offset, "SameBoy", gui_palette_native[3], gui_palette_native[0], false); draw_text_centered(pixels, width, height, 8 + y_offset, "SameBoy", gui_palette_native[3], gui_palette_native[0], false);
unsigned i = 0, y = 24; unsigned i = 0, y = 24;
for (const struct menu_item *item = current_menu; item->string; item++, i++) { for (const struct menu_item *item = current_menu; item->string; item++, i++) {
if (i == current_selection) {
if (y < scroll) {
scroll = y - 4;
goto rerender;
}
}
if (i == current_selection && i == 0 && scroll != 0) {
scroll = 0;
goto rerender;
}
if (item->value_getter && !item->backwards_handler) { if (item->value_getter && !item->backwards_handler) {
char line[25]; char line[25];
snprintf(line, sizeof(line), "%s%*s", item->string, 24 - (int)strlen(item->string), item->value_getter(i)); snprintf(line, sizeof(line), "%s%*s", item->string, 24 - (unsigned)strlen(item->string), item->value_getter(i));
draw_text_centered(pixels, width, height, y + y_offset, line, gui_palette_native[3], gui_palette_native[0], draw_text_centered(pixels, width, height, y + y_offset, line, gui_palette_native[3], gui_palette_native[0],
i == current_selection ? DECORATION_SELECTION : DECORATION_NONE); i == current_selection ? DECORATION_SELECTION : DECORATION_NONE);
y += 12; y += 12;
@ -1162,6 +1281,13 @@ void run_gui(bool is_running)
y += 12; y += 12;
} }
} }
if (i == current_selection) {
if (y > scroll + 144) {
scroll = y - 144;
goto rerender;
}
}
} }
break; break;
case SHOWING_HELP: case SHOWING_HELP:

View File

@ -70,7 +70,7 @@ typedef struct {
SDL_Scancode keys[9]; SDL_Scancode keys[9];
GB_color_correction_mode_t color_correction_mode; GB_color_correction_mode_t color_correction_mode;
enum scaling_mode scaling_mode; enum scaling_mode scaling_mode;
bool blend_frames; uint8_t blending_mode;
GB_highpass_mode_t highpass_mode; GB_highpass_mode_t highpass_mode;
@ -100,6 +100,11 @@ typedef struct {
SGB_2, SGB_2,
SGB_MAX SGB_MAX
} sgb_revision; } sgb_revision;
/* v0.13 */
uint8_t dmg_palette;
GB_border_mode_t border_mode;
uint8_t volume;
} configuration_t; } configuration_t;
extern configuration_t configuration; extern configuration_t configuration;

View File

@ -1,32 +1,19 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <ctype.h>
#include <OpenDialog/open_dialog.h> #include <OpenDialog/open_dialog.h>
#include <SDL.h> #include <SDL.h>
#include <Core/gb.h> #include <Core/gb.h>
#include "utils.h" #include "utils.h"
#include "gui.h" #include "gui.h"
#include "shader.h" #include "shader.h"
#include "audio/audio.h"
#ifndef _WIN32 #ifndef _WIN32
#define AUDIO_FREQUENCY 96000 #include <unistd.h>
#else #else
#include <Windows.h> #include <Windows.h>
/* Windows (well, at least my VM) can't handle 96KHz sound well :( */
/* felsqualle says: For SDL 2.0.6+ using the WASAPI driver, the highest freq.
we can get is 48000. 96000 also works, but always has some faint crackling in
the audio, no matter how high or low I set the buffer length...
Not quite satisfied with that solution, because acc. to SDL2 docs,
96k + WASAPI *should* work. */
#define AUDIO_FREQUENCY 48000
#endif
/* Compatibility with older SDL versions */
#ifndef SDL_AUDIO_ALLOW_SAMPLES_CHANGE
#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0
#endif #endif
GB_gameboy_t gb; GB_gameboy_t gb;
@ -40,7 +27,6 @@ static char *filename = NULL;
static typeof(free) *free_function = NULL; static typeof(free) *free_function = NULL;
static char *battery_save_path_ptr; static char *battery_save_path_ptr;
SDL_AudioDeviceID device_id;
void set_filename(const char *new_filename, typeof(free) *new_free_function) void set_filename(const char *new_filename, typeof(free) *new_free_function)
{ {
@ -51,8 +37,6 @@ void set_filename(const char *new_filename, typeof(free) *new_free_function)
free_function = new_free_function; free_function = new_free_function;
} }
static SDL_AudioSpec want_aspec, have_aspec;
static char *captured_log = NULL; static char *captured_log = NULL;
static void log_capture_callback(GB_gameboy_t *gb, const char *string, GB_log_attributes attributes) static void log_capture_callback(GB_gameboy_t *gb, const char *string, GB_log_attributes attributes)
@ -92,27 +76,62 @@ static const char *end_capturing_logs(bool show_popup, bool should_exit)
return captured_log; return captured_log;
} }
static void update_palette(void)
{
switch (configuration.dmg_palette) {
case 1:
GB_set_palette(&gb, &GB_PALETTE_DMG);
break;
case 2:
GB_set_palette(&gb, &GB_PALETTE_MGB);
break;
case 3:
GB_set_palette(&gb, &GB_PALETTE_GBL);
break;
default:
GB_set_palette(&gb, &GB_PALETTE_GREY);
}
}
static void screen_size_changed(void)
{
SDL_DestroyTexture(texture);
texture = SDL_CreateTexture(renderer, SDL_GetWindowPixelFormat(window), SDL_TEXTUREACCESS_STREAMING,
GB_get_screen_width(&gb), GB_get_screen_height(&gb));
SDL_SetWindowMinimumSize(window, GB_get_screen_width(&gb), GB_get_screen_height(&gb));
update_viewport();
}
static void open_menu(void) static void open_menu(void)
{ {
bool audio_playing = SDL_GetAudioDeviceStatus(device_id) == SDL_AUDIO_PLAYING; bool audio_playing = GB_audio_is_playing();
if (audio_playing) { if (audio_playing) {
SDL_PauseAudioDevice(device_id, 1); GB_audio_set_paused(true);
} }
size_t previous_width = GB_get_screen_width(&gb);
run_gui(true); run_gui(true);
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
if (audio_playing) { if (audio_playing) {
SDL_ClearQueuedAudio(device_id); GB_audio_set_paused(false);
SDL_PauseAudioDevice(device_id, 0);
} }
GB_set_color_correction_mode(&gb, configuration.color_correction_mode); GB_set_color_correction_mode(&gb, configuration.color_correction_mode);
GB_set_border_mode(&gb, configuration.border_mode);
update_palette();
GB_set_highpass_filter_mode(&gb, configuration.highpass_mode); GB_set_highpass_filter_mode(&gb, configuration.highpass_mode);
if (previous_width != GB_get_screen_width(&gb)) {
screen_size_changed();
}
} }
static void handle_events(GB_gameboy_t *gb) static void handle_events(GB_gameboy_t *gb)
{ {
SDL_Event event; SDL_Event event;
while (SDL_PollEvent(&event)) while (SDL_PollEvent(&event)) {
{
switch (event.type) { switch (event.type) {
case SDL_QUIT: case SDL_QUIT:
pending_command = GB_SDL_QUIT_COMMAND; pending_command = GB_SDL_QUIT_COMMAND;
@ -138,7 +157,7 @@ static void handle_events(GB_gameboy_t *gb)
GB_set_key_state(gb, (GB_key_t) button, event.type == SDL_JOYBUTTONDOWN); GB_set_key_state(gb, (GB_key_t) button, event.type == SDL_JOYBUTTONDOWN);
} }
else if (button == JOYPAD_BUTTON_TURBO) { else if (button == JOYPAD_BUTTON_TURBO) {
SDL_ClearQueuedAudio(device_id); GB_audio_clear_queue();
turbo_down = event.type == SDL_JOYBUTTONDOWN; turbo_down = event.type == SDL_JOYBUTTONDOWN;
GB_set_turbo_mode(gb, turbo_down, turbo_down && rewind_down); GB_set_turbo_mode(gb, turbo_down, turbo_down && rewind_down);
} }
@ -256,14 +275,7 @@ static void handle_events(GB_gameboy_t *gb)
break; break;
} }
#endif #endif
bool audio_playing = SDL_GetAudioDeviceStatus(device_id) == SDL_AUDIO_PLAYING; GB_audio_set_paused(GB_audio_is_playing());
if (audio_playing) {
SDL_PauseAudioDevice(device_id, 1);
}
else if (!audio_playing) {
SDL_ClearQueuedAudio(device_id);
SDL_PauseAudioDevice(device_id, 0);
}
} }
break; break;
@ -298,7 +310,7 @@ static void handle_events(GB_gameboy_t *gb)
case SDL_KEYUP: // Fallthrough case SDL_KEYUP: // Fallthrough
if (event.key.keysym.scancode == configuration.keys[8]) { if (event.key.keysym.scancode == configuration.keys[8]) {
turbo_down = event.type == SDL_KEYDOWN; turbo_down = event.type == SDL_KEYDOWN;
SDL_ClearQueuedAudio(device_id); GB_audio_clear_queue();
GB_set_turbo_mode(gb, turbo_down, turbo_down && rewind_down); GB_set_turbo_mode(gb, turbo_down, turbo_down && rewind_down);
} }
else if (event.key.keysym.scancode == configuration.keys_2[0]) { else if (event.key.keysym.scancode == configuration.keys_2[0]) {
@ -335,7 +347,7 @@ static void vblank(GB_gameboy_t *gb)
clock_mutliplier += 1.0/16; clock_mutliplier += 1.0/16;
GB_set_clock_multiplier(gb, clock_mutliplier); GB_set_clock_multiplier(gb, clock_mutliplier);
} }
if (configuration.blend_frames) { if (configuration.blending_mode) {
render_texture(active_pixel_buffer, previous_pixel_buffer); render_texture(active_pixel_buffer, previous_pixel_buffer);
uint32_t *temp = active_pixel_buffer; uint32_t *temp = active_pixel_buffer;
active_pixel_buffer = previous_pixel_buffer; active_pixel_buffer = previous_pixel_buffer;
@ -371,19 +383,24 @@ static void gb_audio_callback(GB_gameboy_t *gb, GB_sample_t *sample)
if (turbo_down) { if (turbo_down) {
static unsigned skip = 0; static unsigned skip = 0;
skip++; skip++;
if (skip == have_aspec.freq / 8) { if (skip == GB_audio_get_frequency() / 8) {
skip = 0; skip = 0;
} }
if (skip > have_aspec.freq / 16) { if (skip > GB_audio_get_frequency() / 16) {
return; return;
} }
} }
if (SDL_GetQueuedAudioSize(device_id) / sizeof(*sample) > have_aspec.freq / 4) { if (GB_audio_get_queue_length() / sizeof(*sample) > GB_audio_get_frequency() / 4) {
return; return;
} }
SDL_QueueAudio(device_id, sample, sizeof(*sample)); if (configuration.volume != 100) {
sample->left = sample->left * configuration.volume / 100;
sample->right = sample->right * configuration.volume / 100;
}
GB_audio_queue_sample(sample);
} }
@ -424,6 +441,24 @@ static bool handle_pending_command(void)
return false; return false;
} }
static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type)
{
bool error = false;
start_capturing_logs();
static const char *const names[] = {
[GB_BOOT_ROM_DMG0] = "dmg0_boot.bin",
[GB_BOOT_ROM_DMG] = "dmg_boot.bin",
[GB_BOOT_ROM_MGB] = "mgb_boot.bin",
[GB_BOOT_ROM_SGB] = "sgb_boot.bin",
[GB_BOOT_ROM_SGB2] = "sgb2_boot.bin",
[GB_BOOT_ROM_CGB0] = "cgb0_boot.bin",
[GB_BOOT_ROM_CGB] = "cgb_boot.bin",
[GB_BOOT_ROM_AGB] = "agb_boot.bin",
};
GB_load_boot_rom(gb, resource_path(names[type]));
end_capturing_logs(true, error);
}
static void run(void) static void run(void)
{ {
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
@ -449,39 +484,47 @@ restart:
else { else {
GB_init(&gb, model); GB_init(&gb, model);
GB_set_boot_rom_load_callback(&gb, load_boot_rom);
GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank); GB_set_vblank_callback(&gb, (GB_vblank_callback_t) vblank);
GB_set_pixels_output(&gb, active_pixel_buffer); GB_set_pixels_output(&gb, active_pixel_buffer);
GB_set_rgb_encode_callback(&gb, rgb_encode); GB_set_rgb_encode_callback(&gb, rgb_encode);
GB_set_sample_rate(&gb, have_aspec.freq); GB_set_sample_rate(&gb, GB_audio_get_frequency());
GB_set_color_correction_mode(&gb, configuration.color_correction_mode); GB_set_color_correction_mode(&gb, configuration.color_correction_mode);
update_palette();
if ((unsigned)configuration.border_mode <= GB_BORDER_ALWAYS) {
GB_set_border_mode(&gb, configuration.border_mode);
}
GB_set_highpass_filter_mode(&gb, configuration.highpass_mode); GB_set_highpass_filter_mode(&gb, configuration.highpass_mode);
GB_set_rewind_length(&gb, configuration.rewind_length); GB_set_rewind_length(&gb, configuration.rewind_length);
GB_set_update_input_hint_callback(&gb, handle_events); GB_set_update_input_hint_callback(&gb, handle_events);
GB_apu_set_sample_callback(&gb, gb_audio_callback); GB_apu_set_sample_callback(&gb, gb_audio_callback);
} }
SDL_DestroyTexture(texture);
texture = SDL_CreateTexture(renderer, SDL_GetWindowPixelFormat(window), SDL_TEXTUREACCESS_STREAMING,
GB_get_screen_width(&gb), GB_get_screen_height(&gb));
SDL_SetWindowMinimumSize(window, GB_get_screen_width(&gb), GB_get_screen_height(&gb));
bool error = false; bool error = false;
GB_debugger_clear_symbols(&gb);
start_capturing_logs(); start_capturing_logs();
const char * const boot_roms[] = {"dmg_boot.bin", "cgb_boot.bin", "agb_boot.bin", "sgb_boot.bin"};
const char *boot_rom = boot_roms[configuration.model];
if (configuration.model == MODEL_SGB && configuration.sgb_revision == SGB_2) {
boot_rom = "sgb2_boot.bin";
}
error = GB_load_boot_rom(&gb, resource_path(boot_rom));
end_capturing_logs(true, error);
start_capturing_logs();
error = GB_load_rom(&gb, filename);
end_capturing_logs(true, error);
size_t path_length = strlen(filename); size_t path_length = strlen(filename);
char extension[4] = {0,};
if (path_length > 4) {
if (filename[path_length - 4] == '.') {
extension[0] = tolower(filename[path_length - 3]);
extension[1] = tolower(filename[path_length - 2]);
extension[2] = tolower(filename[path_length - 1]);
}
}
if (strcmp(extension, "isx") == 0) {
error = GB_load_isx(&gb, filename);
/* Configure battery */
char battery_save_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .sav + NULL */
replace_extension(filename, path_length, battery_save_path, ".ram");
battery_save_path_ptr = battery_save_path;
GB_load_battery(&gb, battery_save_path);
}
else {
GB_load_rom(&gb, filename);
}
end_capturing_logs(true, error);
/* Configure battery */ /* Configure battery */
char battery_save_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .sav + NULL */ char battery_save_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .sav + NULL */
@ -496,7 +539,7 @@ restart:
replace_extension(filename, path_length, symbols_path, ".sym"); replace_extension(filename, path_length, symbols_path, ".sym");
GB_debugger_load_symbol_file(&gb, symbols_path); GB_debugger_load_symbol_file(&gb, symbols_path);
update_viewport(); screen_size_changed();
/* Run emulation */ /* Run emulation */
while (true) { while (true) {
@ -553,7 +596,7 @@ static bool get_arg_flag(const char *flag, int *argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef _WIN32 #ifdef _WIN32
SetProcessDPIAware(); SetProcessDPIAware();
#endif #endif
#define str(x) #x #define str(x) #x
#define xstr(x) str(x) #define xstr(x) str(x)
@ -606,40 +649,16 @@ int main(int argc, char **argv)
pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888); pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
} }
GB_audio_init();
/* Configure Audio */
memset(&want_aspec, 0, sizeof(want_aspec));
want_aspec.freq = AUDIO_FREQUENCY;
want_aspec.format = AUDIO_S16SYS;
want_aspec.channels = 2;
want_aspec.samples = 512;
SDL_version _sdl_version;
SDL_GetVersion(&_sdl_version);
unsigned sdl_version = _sdl_version.major * 1000 + _sdl_version.minor * 100 + _sdl_version.patch;
#ifndef _WIN32
/* SDL 2.0.5 on macOS and Linux introduced a bug where certain combinations of buffer lengths and frequencies
fail to produce audio correctly. */
if (sdl_version >= 2005) {
want_aspec.samples = 2048;
}
#else
if (sdl_version < 2006) {
/* Since WASAPI audio was introduced in SDL 2.0.6, we have to lower the audio frequency
to 44100 because otherwise we would get garbled audio output.*/
want_aspec.freq = 44100;
}
#endif
device_id = SDL_OpenAudioDevice(0, 0, &want_aspec, &have_aspec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_SAMPLES_CHANGE);
/* Start Audio */
SDL_EventState(SDL_DROPFILE, SDL_ENABLE); SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
char *prefs_dir = SDL_GetPrefPath("", "SameBoy"); strcpy(prefs_path, resource_path("prefs.bin"));
snprintf(prefs_path, sizeof(prefs_path) - 1, "%sprefs.bin", prefs_dir); if (access(prefs_path, R_OK | W_OK) != 0) {
SDL_free(prefs_dir); char *prefs_dir = SDL_GetPrefPath("", "SameBoy");
snprintf(prefs_path, sizeof(prefs_path) - 1, "%sprefs.bin", prefs_dir);
SDL_free(prefs_dir);
}
FILE *prefs_file = fopen(prefs_path, "rb"); FILE *prefs_file = fopen(prefs_path, "rb");
if (prefs_file) { if (prefs_file) {
@ -663,7 +682,7 @@ int main(int argc, char **argv)
else { else {
connect_joypad(); connect_joypad();
} }
SDL_PauseAudioDevice(device_id, 0); GB_audio_set_paused(false);
run(); // Never returns run(); // Never returns
return 0; return 0;
} }

View File

@ -10,7 +10,7 @@
#define GL_COMPAT_WRAPPER(func) \ #define GL_COMPAT_WRAPPER(func) \
({ extern typeof(func) *GL_COMPAT_NAME(func); \ ({ extern typeof(func) *GL_COMPAT_NAME(func); \
if(!GL_COMPAT_NAME(func)) GL_COMPAT_NAME(func) = SDL_GL_GetProcAddress(#func); \ if (!GL_COMPAT_NAME(func)) GL_COMPAT_NAME(func) = SDL_GL_GetProcAddress(#func); \
GL_COMPAT_NAME(func); \ GL_COMPAT_NAME(func); \
}) })

View File

@ -75,7 +75,7 @@ bool init_shader_with_name(shader_t *shader, const char *name)
static char master_shader_code[0x801] = {0,}; static char master_shader_code[0x801] = {0,};
static char shader_code[0x10001] = {0,}; static char shader_code[0x10001] = {0,};
static char final_shader_code[0x10801] = {0,}; static char final_shader_code[0x10801] = {0,};
static signed long filter_token_location = 0; static ssize_t filter_token_location = 0;
if (!master_shader_code[0]) { if (!master_shader_code[0]) {
FILE *master_shader_f = fopen(resource_path("Shaders/MasterShader.fsh"), "r"); FILE *master_shader_f = fopen(resource_path("Shaders/MasterShader.fsh"), "r");
@ -130,7 +130,7 @@ bool init_shader_with_name(shader_t *shader, const char *name)
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
shader->previous_texture_uniform = glGetUniformLocation(shader->program, "previous_image"); shader->previous_texture_uniform = glGetUniformLocation(shader->program, "previous_image");
shader->mix_previous_uniform = glGetUniformLocation(shader->program, "mix_previous"); shader->blending_mode_uniform = glGetUniformLocation(shader->program, "frame_blending_mode");
// Program // Program
@ -164,7 +164,8 @@ bool init_shader_with_name(shader_t *shader, const char *name)
void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous, void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous,
unsigned source_width, unsigned source_height, unsigned source_width, unsigned source_height,
unsigned x, unsigned y, unsigned w, unsigned h) unsigned x, unsigned y, unsigned w, unsigned h,
GB_frame_blending_mode_t blending_mode)
{ {
glUseProgram(shader->program); glUseProgram(shader->program);
glUniform2f(shader->origin_uniform, x, y); glUniform2f(shader->origin_uniform, x, y);
@ -173,7 +174,7 @@ void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous,
glBindTexture(GL_TEXTURE_2D, shader->texture); glBindTexture(GL_TEXTURE_2D, shader->texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, source_width, source_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, source_width, source_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
glUniform1i(shader->texture_uniform, 0); glUniform1i(shader->texture_uniform, 0);
glUniform1i(shader->mix_previous_uniform, previous != NULL); glUniform1i(shader->blending_mode_uniform, previous? blending_mode : GB_FRAME_BLENDING_MODE_DISABLED);
if (previous) { if (previous) {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, shader->previous_texture); glBindTexture(GL_TEXTURE_2D, shader->previous_texture);

View File

@ -8,7 +8,7 @@ typedef struct shader_s {
GLuint origin_uniform; GLuint origin_uniform;
GLuint texture_uniform; GLuint texture_uniform;
GLuint previous_texture_uniform; GLuint previous_texture_uniform;
GLuint mix_previous_uniform; GLuint blending_mode_uniform;
GLuint position_attribute; GLuint position_attribute;
GLuint texture; GLuint texture;
@ -16,10 +16,19 @@ typedef struct shader_s {
GLuint program; GLuint program;
} shader_t; } shader_t;
typedef enum {
GB_FRAME_BLENDING_MODE_DISABLED,
GB_FRAME_BLENDING_MODE_SIMPLE,
GB_FRAME_BLENDING_MODE_ACCURATE,
GB_FRAME_BLENDING_MODE_ACCURATE_EVEN = GB_FRAME_BLENDING_MODE_ACCURATE,
GB_FRAME_BLENDING_MODE_ACCURATE_ODD,
} GB_frame_blending_mode_t;
bool init_shader_with_name(shader_t *shader, const char *name); bool init_shader_with_name(shader_t *shader, const char *name);
void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous, void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous,
unsigned source_width, unsigned source_height, unsigned source_width, unsigned source_height,
unsigned x, unsigned y, unsigned w, unsigned h); unsigned x, unsigned y, unsigned w, unsigned h,
GB_frame_blending_mode_t blending_mode);
void free_shader(struct shader_s *shader); void free_shader(struct shader_s *shader);
#endif /* shader_h */ #endif /* shader_h */

View File

@ -158,6 +158,8 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
ret *= output_resolution.y - pixel_position.y; ret *= output_resolution.y - pixel_position.y;
} }
// Gamma correction
ret = pow(ret, vec4(0.72));
return ret; return ret;
} }

View File

@ -1,7 +1,7 @@
#version 150 #version 150
uniform sampler2D image; uniform sampler2D image;
uniform sampler2D previous_image; uniform sampler2D previous_image;
uniform bool mix_previous; uniform int frame_blending_mode;
uniform vec2 output_resolution; uniform vec2 output_resolution;
uniform vec2 origin; uniform vec2 origin;
@ -15,6 +15,15 @@ out vec4 frag_color;
#line 1 #line 1
{filter} {filter}
#define BLEND_BIAS (1.0/3.0)
#define DISABLED 0
#define SIMPLE 1
#define ACCURATE 2
#define ACCURATE_EVEN ACCURATE
#define ACCURATE_ODD 3
void main() void main()
{ {
vec2 position = gl_FragCoord.xy - origin; vec2 position = gl_FragCoord.xy - origin;
@ -22,11 +31,34 @@ void main()
position.y = 1 - position.y; position.y = 1 - position.y;
vec2 input_resolution = textureSize(image, 0); vec2 input_resolution = textureSize(image, 0);
if (mix_previous) { float ratio;
frag_color = mix(scale(image, position, input_resolution, output_resolution), switch (frame_blending_mode) {
scale(previous_image, position, input_resolution, output_resolution), 0.5); default:
} case DISABLED:
else { frag_color = scale(image, position, input_resolution, output_resolution);
frag_color = scale(image, position, input_resolution, output_resolution); return;
case SIMPLE:
ratio = 0.5;
break;
case ACCURATE_EVEN:
if ((int(position.y * input_resolution.y) & 1) == 0) {
ratio = BLEND_BIAS;
}
else {
ratio = 1 - BLEND_BIAS;
}
break;
case ACCURATE_ODD:
if ((int(position.y * input_resolution.y) & 1) == 0) {
ratio = 1 - BLEND_BIAS;
}
else {
ratio = BLEND_BIAS;
}
break;
} }
frag_color = mix(scale(image, position, input_resolution, output_resolution),
scale(previous_image, position, input_resolution, output_resolution), ratio);
} }

View File

@ -42,19 +42,52 @@ static inline float4 texture(texture2d<half> texture, float2 pos)
#line 1 #line 1
{filter} {filter}
#define BLEND_BIAS (1.0/3.0)
enum frame_blending_mode {
DISABLED,
SIMPLE,
ACCURATE,
ACCURATE_EVEN = ACCURATE,
ACCURATE_ODD,
};
fragment float4 fragment_shader(rasterizer_data in [[stage_in]], fragment float4 fragment_shader(rasterizer_data in [[stage_in]],
texture2d<half> image [[ texture(0) ]], texture2d<half> image [[ texture(0) ]],
texture2d<half> previous_image [[ texture(1) ]], texture2d<half> previous_image [[ texture(1) ]],
constant bool *mix_previous [[ buffer(0) ]], constant enum frame_blending_mode *frame_blending_mode [[ buffer(0) ]],
constant float2 *output_resolution [[ buffer(1) ]]) constant float2 *output_resolution [[ buffer(1) ]])
{ {
float2 input_resolution = float2(image.get_width(), image.get_height()); float2 input_resolution = float2(image.get_width(), image.get_height());
in.texcoords.y = 1 - in.texcoords.y; in.texcoords.y = 1 - in.texcoords.y;
if (*mix_previous) { float ratio;
return mix(scale(image, in.texcoords, input_resolution, *output_resolution), switch (*frame_blending_mode) {
scale(previous_image, in.texcoords, input_resolution, *output_resolution), 0.5); default:
case DISABLED:
return scale(image, in.texcoords, input_resolution, *output_resolution);
case SIMPLE:
ratio = 0.5;
break;
case ACCURATE_EVEN:
if (((int)(in.texcoords.y * input_resolution.y) & 1) == 0) {
ratio = BLEND_BIAS;
}
else {
ratio = 1 - BLEND_BIAS;
}
break;
case ACCURATE_ODD:
if (((int)(in.texcoords.y * input_resolution.y) & 1) == 0) {
ratio = 1 - BLEND_BIAS;
}
else {
ratio = BLEND_BIAS;
}
break;
} }
return scale(image, in.texcoords, input_resolution, *output_resolution);
return mix(scale(image, in.texcoords, input_resolution, *output_resolution),
scale(previous_image, in.texcoords, input_resolution, *output_resolution), ratio);
} }

50
Shaders/MonoLCD.fsh Normal file
View File

@ -0,0 +1,50 @@
#define SCANLINE_DEPTH 0.25
#define BLOOM 0.4
STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution)
{
vec2 pixel = position * input_resolution - vec2(0.5, 0.5);
vec4 q11 = texture(image, (floor(pixel) + 0.5) / input_resolution);
vec4 q12 = texture(image, (vec2(floor(pixel.x), ceil(pixel.y)) + 0.5) / input_resolution);
vec4 q21 = texture(image, (vec2(ceil(pixel.x), floor(pixel.y)) + 0.5) / input_resolution);
vec4 q22 = texture(image, (ceil(pixel) + 0.5) / input_resolution);
vec2 s = smoothstep(0., 1., fract(pixel));
vec4 r1 = mix(q11, q21, s.x);
vec4 r2 = mix(q12, q22, s.x);
vec2 pos = fract(position * input_resolution);
vec2 sub_pos = fract(position * input_resolution * 6);
float multiplier = 1.0;
if (pos.y < 1.0 / 6.0) {
multiplier *= sub_pos.y * SCANLINE_DEPTH + (1 - SCANLINE_DEPTH);
}
else if (pos.y > 5.0 / 6.0) {
multiplier *= (1.0 - sub_pos.y) * SCANLINE_DEPTH + (1 - SCANLINE_DEPTH);
}
if (pos.x < 1.0 / 6.0) {
multiplier *= sub_pos.x * SCANLINE_DEPTH + (1 - SCANLINE_DEPTH);
}
else if (pos.x > 5.0 / 6.0) {
multiplier *= (1.0 - sub_pos.x) * SCANLINE_DEPTH + (1 - SCANLINE_DEPTH);
}
vec4 pre_shadow = mix(texture(image, position) * multiplier, mix(r1, r2, s.y), BLOOM);
pixel += vec2(-0.6, -0.8);
q11 = texture(image, (floor(pixel) + 0.5) / input_resolution);
q12 = texture(image, (vec2(floor(pixel.x), ceil(pixel.y)) + 0.5) / input_resolution);
q21 = texture(image, (vec2(ceil(pixel.x), floor(pixel.y)) + 0.5) / input_resolution);
q22 = texture(image, (ceil(pixel) + 0.5) / input_resolution);
r1 = mix(q11, q21, fract(pixel.x));
r2 = mix(q12, q22, fract(pixel.x));
vec4 shadow = mix(r1, r2, fract(pixel.y));
return mix(min(shadow, pre_shadow), pre_shadow, 0.75);
}

View File

@ -73,38 +73,38 @@ static void handle_buttons(GB_gameboy_t *gb)
frames) % combo_length + (start_is_bad? 20 : 0) ) { frames) % combo_length + (start_is_bad? 20 : 0) ) {
case 0: case 0:
if (!limit_start || frames < 20 * 60) { if (!limit_start || frames < 20 * 60) {
gb->keys[0][push_right? 0 : 7] = true; // Start (Or right) down GB_set_key_state(gb, push_right? GB_KEY_RIGHT: GB_KEY_START, true);
} }
if (pointer_control) { if (pointer_control) {
gb->keys[0][1] = true; // left GB_set_key_state(gb, GB_KEY_LEFT, true);
gb->keys[0][2] = true; // up GB_set_key_state(gb, GB_KEY_UP, true);
} }
break; break;
case 10: case 10:
gb->keys[0][push_right? 0 : 7] = false; // Start (Or right) up GB_set_key_state(gb, push_right? GB_KEY_RIGHT: GB_KEY_START, false);
if (pointer_control) { if (pointer_control) {
gb->keys[0][1] = false; // left GB_set_key_state(gb, GB_KEY_LEFT, false);
gb->keys[0][2] = false; // up GB_set_key_state(gb, GB_KEY_UP, false);
} }
break; break;
case 20: case 20:
gb->keys[0][b_is_confirm? 5: 4] = true; // A down (or B) GB_set_key_state(gb, b_is_confirm? GB_KEY_B: GB_KEY_A, true);
break; break;
case 30: case 30:
gb->keys[0][b_is_confirm? 5: 4] = false; // A up (or B) GB_set_key_state(gb, b_is_confirm? GB_KEY_B: GB_KEY_A, false);
break; break;
case 40: case 40:
if (push_a_twice) { if (push_a_twice) {
gb->keys[0][b_is_confirm? 5: 4] = true; // A down (or B) GB_set_key_state(gb, b_is_confirm? GB_KEY_B: GB_KEY_A, true);
} }
else if (gb->boot_rom_finished) { else if (gb->boot_rom_finished) {
gb->keys[0][3] = true; // D-Pad Down down GB_set_key_state(gb, GB_KEY_DOWN, true);
} }
break; break;
case 50: case 50:
gb->keys[0][b_is_confirm? 5: 4] = false; // A down (or B) GB_set_key_state(gb, b_is_confirm? GB_KEY_B: GB_KEY_A, false);
gb->keys[0][3] = false; // D-Pad Down up GB_set_key_state(gb, GB_KEY_DOWN, false);
break; break;
} }
} }
@ -174,12 +174,12 @@ static const char *executable_folder(void)
} }
/* Ugly unportable code! :( */ /* Ugly unportable code! :( */
#ifdef __APPLE__ #ifdef __APPLE__
unsigned int length = sizeof(path) - 1; uint32_t length = sizeof(path) - 1;
_NSGetExecutablePath(&path[0], &length); _NSGetExecutablePath(&path[0], &length);
#else #else
#ifdef __linux__ #ifdef __linux__
ssize_t length = readlink("/proc/self/exe", &path[0], sizeof(path) - 1); size_t __attribute__((unused)) length = readlink("/proc/self/exe", &path[0], sizeof(path) - 1);
assert (length != -1); assert(length != -1);
#else #else
#ifdef _WIN32 #ifdef _WIN32
HMODULE hModule = GetModuleHandle(NULL); HMODULE hModule = GetModuleHandle(NULL);
@ -300,7 +300,7 @@ int main(int argc, char **argv)
if (max_forks > 1) { if (max_forks > 1) {
while (current_forks >= max_forks) { while (current_forks >= max_forks) {
int wait_out; int wait_out;
while(wait(&wait_out) == -1); while (wait(&wait_out) == -1);
current_forks--; current_forks--;
} }
@ -323,15 +323,15 @@ int main(int argc, char **argv)
if (dmg) { if (dmg) {
GB_init(&gb, GB_MODEL_DMG_B); GB_init(&gb, GB_MODEL_DMG_B);
if (GB_load_boot_rom(&gb, boot_rom_path? boot_rom_path : executable_relative_path("dmg_boot.bin"))) { if (GB_load_boot_rom(&gb, boot_rom_path ?: executable_relative_path("dmg_boot.bin"))) {
perror("Failed to load boot ROM"); fprintf(stderr, "Failed to load boot ROM from '%s'\n", boot_rom_path ?: executable_relative_path("dmg_boot.bin"));
exit(1); exit(1);
} }
} }
else { else {
GB_init(&gb, GB_MODEL_CGB_E); GB_init(&gb, GB_MODEL_CGB_E);
if (GB_load_boot_rom(&gb, boot_rom_path? boot_rom_path : executable_relative_path("cgb_boot.bin"))) { if (GB_load_boot_rom(&gb, boot_rom_path ?: executable_relative_path("cgb_boot.bin"))) {
perror("Failed to load boot ROM"); fprintf(stderr, "Failed to load boot ROM from '%s'\n", boot_rom_path ?: executable_relative_path("cgb_boot.bin"));
exit(1); exit(1);
} }
} }
@ -433,7 +433,7 @@ int main(int argc, char **argv)
} }
#ifndef _WIN32 #ifndef _WIN32
int wait_out; int wait_out;
while(wait(&wait_out) != -1); while (wait(&wait_out) != -1);
#endif #endif
return 0; return 0;
} }

View File

@ -2,6 +2,10 @@
#include_next <stdio.h> #include_next <stdio.h>
#include <stdlib.h> #include <stdlib.h>
int access(const char *filename, int mode);
#define R_OK 2
#define W_OK 4
#ifndef __MINGW32__ #ifndef __MINGW32__
#ifndef __LIBRETRO__ #ifndef __LIBRETRO__
static inline int vasprintf(char **str, const char *fmt, va_list args) static inline int vasprintf(char **str, const char *fmt, va_list args)
@ -20,7 +24,8 @@ static inline int vasprintf(char **str, const char *fmt, va_list args)
#endif #endif
/* This code is public domain -- Will Hartung 4/9/09 */ /* This code is public domain -- Will Hartung 4/9/09 */
static inline size_t getline(char **lineptr, size_t *n, FILE *stream) { static inline size_t getline(char **lineptr, size_t *n, FILE *stream)
{
char *bufptr = NULL; char *bufptr = NULL;
char *p = bufptr; char *p = bufptr;
size_t size; size_t size;

View File

@ -1,6 +1,7 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <winnls.h> #include <winnls.h>
#include <io.h>
FILE *fopen(const char *filename, const char *mode) FILE *fopen(const char *filename, const char *mode)
{ {
@ -12,3 +13,12 @@ FILE *fopen(const char *filename, const char *mode)
return _wfopen(w_filename, w_mode); return _wfopen(w_filename, w_mode);
} }
int access(const char *filename, int mode)
{
wchar_t w_filename[MAX_PATH] = {0,};
MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename) / sizeof(w_filename[0]));
return _waccess(w_filename, mode);
}

View File

@ -4,4 +4,4 @@ When building on macOS, the build system will make a native Cocoa app by default
# Attempting to build the SDL frontend on macOS fails on linking # Attempting to build the SDL frontend on macOS fails on linking
SameBoy on macOS expects you to have the SDL2 framework installed as a framework. You can find the SDL2 binaries on the [SDL homepage](https://www.libsdl.org/download-2.0.php). Mount the DMG and copy SDL2.framework to `/Library/Frameworks/`. SameBoy on macOS expects you to have SDL2 installed via Brew, and not as a framework. Older versions expected it to be installed as a framework, but this is no longer the case.

View File

@ -1,6 +1,8 @@
STATIC_LINKING := 0 STATIC_LINKING := 0
AR := ar AR := ar
CFLAGS := -Wall $(CFLAGS)
GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)" GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown") ifneq ($(GIT_VERSION)," unknown")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
@ -93,7 +95,7 @@ else ifeq ($(platform), linux-portable)
else ifeq ($(platform), switch) else ifeq ($(platform), switch)
TARGET := $(TARGET_NAME)_libretro_$(platform).a TARGET := $(TARGET_NAME)_libretro_$(platform).a
include $(LIBTRANSISTOR_HOME)/libtransistor.mk include $(LIBTRANSISTOR_HOME)/libtransistor.mk
CFLAGS += -Wl,-q -Wall -O3 -fno-short-enums -fno-optimize-sibling-calls CFLAGS += -Wl,-q -O3 -fno-short-enums -fno-optimize-sibling-calls
STATIC_LINKING=1 STATIC_LINKING=1
# Nintendo WiiU # Nintendo WiiU
else ifeq ($(platform), wiiu) else ifeq ($(platform), wiiu)
@ -141,7 +143,7 @@ else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_vita.a TARGET := $(TARGET_NAME)_vita.a
CC = arm-vita-eabi-gcc CC = arm-vita-eabi-gcc
AR = arm-vita-eabi-ar AR = arm-vita-eabi-ar
CFLAGS += -Wl,-q -Wall -O3 -fno-short-enums -fno-optimize-sibling-calls CFLAGS += -Wl,-q -O3 -fno-short-enums -fno-optimize-sibling-calls
STATIC_LINKING = 1 STATIC_LINKING = 1
# Windows MSVC 2017 all architectures # Windows MSVC 2017 all architectures
@ -260,7 +262,7 @@ endif
include Makefile.common include Makefile.common
OBJECTS := $(patsubst %.c,$(CORE_DIR)/build/obj/%_libretro.c.o,$(SOURCES_C)) OBJECTS := $(patsubst $(CORE_DIR)/%.c,$(CORE_DIR)/build/obj/%_libretro.c.o,$(SOURCES_C))
OBJOUT = -o OBJOUT = -o
LINKOUT = -o LINKOUT = -o
@ -278,7 +280,7 @@ else
LD = $(CC) LD = $(CC)
endif endif
CFLAGS += -Wall -D__LIBRETRO__ $(fpic) $(INCFLAGS) -std=gnu11 -D_GNU_SOURCE -D_USE_MATH_DEFINES CFLAGS += -D__LIBRETRO__ $(fpic) $(INCFLAGS) -std=gnu11 -D_GNU_SOURCE -D_USE_MATH_DEFINES
all: $(TARGET) all: $(TARGET)
@ -306,7 +308,7 @@ else
$(LD) $(fpic) $(SHARED) $(INCFLAGS) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS) $(LD) $(fpic) $(SHARED) $(INCFLAGS) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS)
endif endif
$(CORE_DIR)/build/obj/%_libretro.c.o: %.c $(CORE_DIR)/build/obj/%_libretro.c.o: $(CORE_DIR)/%.c
-@$(MKDIR) -p $(dir $@) -@$(MKDIR) -p $(dir $@)
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS) $(fpic) -DGB_INTERNAL $(CC) -c $(OBJOUT)$@ $< $(CFLAGS) $(fpic) -DGB_INTERNAL

View File

@ -20,7 +20,7 @@ SOURCES_C := $(CORE_DIR)/Core/gb.c \
$(CORE_DIR)/libretro/sgb2_boot.c \ $(CORE_DIR)/libretro/sgb2_boot.c \
$(CORE_DIR)/libretro/libretro.c $(CORE_DIR)/libretro/libretro.c
CFLAGS += -DDISABLE_TIMEKEEPING -DDISABLE_REWIND -DDISABLE_DEBUGGER CFLAGS += -DGB_DISABLE_TIMEKEEPING -DGB_DISABLE_REWIND -DGB_DISABLE_DEBUGGER -DGB_DISABLE_CHEATS
SOURCES_CXX := SOURCES_CXX :=

View File

@ -200,14 +200,14 @@ static bool serial_end2(GB_gameboy_t *gb)
static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b) static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
{ {
return r<<16|g<<8|b; return r <<16 | g <<8 | b;
} }
static retro_environment_t environ_cb; static retro_environment_t environ_cb;
/* variables for single cart mode */ /* variables for single cart mode */
static const struct retro_variable vars_single[] = { static const struct retro_variable vars_single[] = {
{ "sameboy_color_correction_mode", "Color correction; off|correct curves|emulate hardware|preserve brightness" }, { "sameboy_color_correction_mode", "Color correction; off|correct curves|emulate hardware|preserve brightness|reduce contrast" },
{ "sameboy_high_pass_filter_mode", "High-pass filter; off|accurate|remove dc offset" }, { "sameboy_high_pass_filter_mode", "High-pass filter; off|accurate|remove dc offset" },
{ "sameboy_model", "Emulated model; Auto|Game Boy|Game Boy Color|Game Boy Advance|Super Game Boy|Super Game Boy 2" }, { "sameboy_model", "Emulated model; Auto|Game Boy|Game Boy Color|Game Boy Advance|Super Game Boy|Super Game Boy 2" },
{ "sameboy_border", "Super Game Boy border; enabled|disabled" }, { "sameboy_border", "Super Game Boy border; enabled|disabled" },
@ -328,15 +328,13 @@ static struct retro_input_descriptor descriptors_4p[] = {
static void set_link_cable_state(bool state) static void set_link_cable_state(bool state)
{ {
if (state && emulated_devices == 2) if (state && emulated_devices == 2) {
{
GB_set_serial_transfer_bit_start_callback(&gameboy[0], serial_start1); GB_set_serial_transfer_bit_start_callback(&gameboy[0], serial_start1);
GB_set_serial_transfer_bit_end_callback(&gameboy[0], serial_end1); GB_set_serial_transfer_bit_end_callback(&gameboy[0], serial_end1);
GB_set_serial_transfer_bit_start_callback(&gameboy[1], serial_start2); GB_set_serial_transfer_bit_start_callback(&gameboy[1], serial_start2);
GB_set_serial_transfer_bit_end_callback(&gameboy[1], serial_end2); GB_set_serial_transfer_bit_end_callback(&gameboy[1], serial_end2);
} }
else if (!state) else if (!state) {
{
GB_set_serial_transfer_bit_start_callback(&gameboy[0], NULL); GB_set_serial_transfer_bit_start_callback(&gameboy[0], NULL);
GB_set_serial_transfer_bit_end_callback(&gameboy[0], NULL); GB_set_serial_transfer_bit_end_callback(&gameboy[0], NULL);
GB_set_serial_transfer_bit_start_callback(&gameboy[1], NULL); GB_set_serial_transfer_bit_start_callback(&gameboy[1], NULL);
@ -382,8 +380,7 @@ static void init_for_current_model(unsigned id)
/* todo: attempt to make these more generic */ /* todo: attempt to make these more generic */
GB_set_vblank_callback(&gameboy[0], (GB_vblank_callback_t) vblank1); GB_set_vblank_callback(&gameboy[0], (GB_vblank_callback_t) vblank1);
if (emulated_devices == 2) if (emulated_devices == 2) {
{
GB_set_vblank_callback(&gameboy[1], (GB_vblank_callback_t) vblank2); GB_set_vblank_callback(&gameboy[1], (GB_vblank_callback_t) vblank2);
if (link_cable_emulation) if (link_cable_emulation)
set_link_cable_state(true); set_link_cable_state(true);
@ -435,17 +432,17 @@ static void init_for_current_model(unsigned id)
descs[8].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_OAM, &size, &bank); descs[8].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_OAM, &size, &bank);
descs[8].start = 0xFE00; descs[8].start = 0xFE00;
descs[8].len = 0x00A0; descs[8].len = 0x00A0;
descs[8].select= 0xFFFFFF00; descs[8].select = 0xFFFFFF00;
descs[9].ptr = descs[2].ptr + 0x2000; /* GBC RAM bank 2 */ descs[9].ptr = descs[2].ptr + 0x2000; /* GBC RAM bank 2 */
descs[9].start = 0x10000; descs[9].start = 0x10000;
descs[9].len = GB_is_cgb(&gameboy[i]) ? 0x6000 : 0; /* 0x1000 per bank (2-7), unmapped on GB */ descs[9].len = GB_is_cgb(&gameboy[i]) ? 0x6000 : 0; /* 0x1000 per bank (2-7), unmapped on GB */
descs[9].select= 0xFFFF0000; descs[9].select = 0xFFFF0000;
descs[10].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_IO, &size, &bank); descs[10].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_IO, &size, &bank);
descs[10].start = 0xFF00; descs[10].start = 0xFF00;
descs[10].len = 0x0080; descs[10].len = 0x0080;
descs[10].select= 0xFFFFFF00; descs[10].select = 0xFFFFFF00;
struct retro_memory_map mmaps; struct retro_memory_map mmaps;
mmaps.descriptors = descs; mmaps.descriptors = descs;
@ -453,8 +450,7 @@ static void init_for_current_model(unsigned id)
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &mmaps); environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &mmaps);
/* Let's be extremely nitpicky about how devices and descriptors are set */ /* Let's be extremely nitpicky about how devices and descriptors are set */
if (emulated_devices == 1 && (model[0] == MODEL_SGB || model[0] == MODEL_SGB2)) if (emulated_devices == 1 && (model[0] == MODEL_SGB || model[0] == MODEL_SGB2)) {
{
static const struct retro_controller_info ports[] = { static const struct retro_controller_info ports[] = {
{ controllers_sgb, 1 }, { controllers_sgb, 1 },
{ controllers_sgb, 1 }, { controllers_sgb, 1 },
@ -465,8 +461,7 @@ static void init_for_current_model(unsigned id)
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports); environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descriptors_4p); environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descriptors_4p);
} }
else if (emulated_devices == 1) else if (emulated_devices == 1) {
{
static const struct retro_controller_info ports[] = { static const struct retro_controller_info ports[] = {
{ controllers, 1 }, { controllers, 1 },
{ NULL, 0 }, { NULL, 0 },
@ -474,8 +469,7 @@ static void init_for_current_model(unsigned id)
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports); environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descriptors_1p); environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descriptors_1p);
} }
else else {
{
static const struct retro_controller_info ports[] = { static const struct retro_controller_info ports[] = {
{ controllers, 1 }, { controllers, 1 },
{ controllers, 1 }, { controllers, 1 },
@ -490,12 +484,10 @@ static void init_for_current_model(unsigned id)
static void check_variables() static void check_variables()
{ {
struct retro_variable var = {0}; struct retro_variable var = {0};
if (emulated_devices == 1) if (emulated_devices == 1) {
{
var.key = "sameboy_color_correction_mode"; var.key = "sameboy_color_correction_mode";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED);
else if (strcmp(var.value, "correct curves") == 0) else if (strcmp(var.value, "correct curves") == 0)
@ -504,12 +496,13 @@ static void check_variables()
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE);
else if (strcmp(var.value, "preserve brightness") == 0) else if (strcmp(var.value, "preserve brightness") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS);
else if (strcmp(var.value, "reduce_contrast") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
} }
var.key = "sameboy_high_pass_filter_mode"; var.key = "sameboy_high_pass_filter_mode";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_OFF); GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_OFF);
else if (strcmp(var.value, "accurate") == 0) else if (strcmp(var.value, "accurate") == 0)
@ -520,8 +513,7 @@ static void check_variables()
var.key = "sameboy_model"; var.key = "sameboy_model";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
enum model new_model = model[0]; enum model new_model = model[0];
if (strcmp(var.value, "Game Boy") == 0) if (strcmp(var.value, "Game Boy") == 0)
new_model = MODEL_DMG; new_model = MODEL_DMG;
@ -536,8 +528,7 @@ static void check_variables()
else else
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
if (new_model != model[0]) if (new_model != model[0]) {
{
geometry_updated = true; geometry_updated = true;
model[0] = new_model; model[0] = new_model;
init_for_current_model(0); init_for_current_model(0);
@ -546,20 +537,17 @@ static void check_variables()
var.key = "sameboy_border"; var.key = "sameboy_border";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "enabled") == 0) if (strcmp(var.value, "enabled") == 0)
sgb_border = 1; sgb_border = 1;
else if (strcmp(var.value, "disabled") == 0) else if (strcmp(var.value, "disabled") == 0)
sgb_border = 0; sgb_border = 0;
} }
} }
else else {
{
var.key = "sameboy_color_correction_mode_1"; var.key = "sameboy_color_correction_mode_1";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED);
else if (strcmp(var.value, "correct curves") == 0) else if (strcmp(var.value, "correct curves") == 0)
@ -568,12 +556,13 @@ static void check_variables()
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE);
else if (strcmp(var.value, "preserve brightness") == 0) else if (strcmp(var.value, "preserve brightness") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS);
else if (strcmp(var.value, "reduce_contrast") == 0)
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
} }
var.key = "sameboy_color_correction_mode_2"; var.key = "sameboy_color_correction_mode_2";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_DISABLED); GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_DISABLED);
else if (strcmp(var.value, "correct curves") == 0) else if (strcmp(var.value, "correct curves") == 0)
@ -582,12 +571,14 @@ static void check_variables()
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_EMULATE_HARDWARE); GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_EMULATE_HARDWARE);
else if (strcmp(var.value, "preserve brightness") == 0) else if (strcmp(var.value, "preserve brightness") == 0)
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS);
else if (strcmp(var.value, "reduce_contrast") == 0)
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
} }
var.key = "sameboy_high_pass_filter_mode_1"; var.key = "sameboy_high_pass_filter_mode_1";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_OFF); GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_OFF);
else if (strcmp(var.value, "accurate") == 0) else if (strcmp(var.value, "accurate") == 0)
@ -598,8 +589,7 @@ static void check_variables()
var.key = "sameboy_high_pass_filter_mode_2"; var.key = "sameboy_high_pass_filter_mode_2";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "off") == 0) if (strcmp(var.value, "off") == 0)
GB_set_highpass_filter_mode(&gameboy[1], GB_HIGHPASS_OFF); GB_set_highpass_filter_mode(&gameboy[1], GB_HIGHPASS_OFF);
else if (strcmp(var.value, "accurate") == 0) else if (strcmp(var.value, "accurate") == 0)
@ -610,8 +600,7 @@ static void check_variables()
var.key = "sameboy_model_1"; var.key = "sameboy_model_1";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
enum model new_model = model[0]; enum model new_model = model[0];
if (strcmp(var.value, "Game Boy") == 0) if (strcmp(var.value, "Game Boy") == 0)
new_model = MODEL_DMG; new_model = MODEL_DMG;
@ -626,8 +615,7 @@ static void check_variables()
else else
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
if (model[0] != new_model) if (model[0] != new_model) {
{
model[0] = new_model; model[0] = new_model;
init_for_current_model(0); init_for_current_model(0);
} }
@ -635,8 +623,7 @@ static void check_variables()
var.key = "sameboy_model_2"; var.key = "sameboy_model_2";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
enum model new_model = model[1]; enum model new_model = model[1];
if (strcmp(var.value, "Game Boy") == 0) if (strcmp(var.value, "Game Boy") == 0)
new_model = MODEL_DMG; new_model = MODEL_DMG;
@ -651,8 +638,7 @@ static void check_variables()
else else
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
if (model[1] != new_model) if (model[1] != new_model) {
{
model[1] = new_model; model[1] = new_model;
init_for_current_model(1); init_for_current_model(1);
} }
@ -660,8 +646,7 @@ static void check_variables()
var.key = "sameboy_screen_layout"; var.key = "sameboy_screen_layout";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "top-down") == 0) if (strcmp(var.value, "top-down") == 0)
screen_layout = LAYOUT_TOP_DOWN; screen_layout = LAYOUT_TOP_DOWN;
else else
@ -672,8 +657,7 @@ static void check_variables()
var.key = "sameboy_link"; var.key = "sameboy_link";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
bool tmp = link_cable_emulation; bool tmp = link_cable_emulation;
if (strcmp(var.value, "enabled") == 0) if (strcmp(var.value, "enabled") == 0)
link_cable_emulation = true; link_cable_emulation = true;
@ -687,8 +671,7 @@ static void check_variables()
var.key = "sameboy_audio_output"; var.key = "sameboy_audio_output";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
{
if (strcmp(var.value, "Game Boy #1") == 0) if (strcmp(var.value, "Game Boy #1") == 0)
audio_out = GB_1; audio_out = GB_1;
else else
@ -753,28 +736,25 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
struct retro_game_geometry geom; struct retro_game_geometry geom;
struct retro_system_timing timing = { GB_get_usual_frame_rate(&gameboy[0]), AUDIO_FREQUENCY }; struct retro_system_timing timing = { GB_get_usual_frame_rate(&gameboy[0]), AUDIO_FREQUENCY };
if (emulated_devices == 2) if (emulated_devices == 2) {
{
if (screen_layout == LAYOUT_TOP_DOWN) { if (screen_layout == LAYOUT_TOP_DOWN) {
geom.base_width = VIDEO_WIDTH; geom.base_width = VIDEO_WIDTH;
geom.base_height = VIDEO_HEIGHT * emulated_devices; geom.base_height = VIDEO_HEIGHT * emulated_devices;
geom.aspect_ratio = (double)VIDEO_WIDTH / (emulated_devices * VIDEO_HEIGHT); geom.aspect_ratio = (double)VIDEO_WIDTH / (emulated_devices * VIDEO_HEIGHT);
}else if (screen_layout == LAYOUT_LEFT_RIGHT) { }
else if (screen_layout == LAYOUT_LEFT_RIGHT) {
geom.base_width = VIDEO_WIDTH * emulated_devices; geom.base_width = VIDEO_WIDTH * emulated_devices;
geom.base_height = VIDEO_HEIGHT; geom.base_height = VIDEO_HEIGHT;
geom.aspect_ratio = ((double)VIDEO_WIDTH * emulated_devices) / VIDEO_HEIGHT; geom.aspect_ratio = ((double)VIDEO_WIDTH * emulated_devices) / VIDEO_HEIGHT;
} }
} }
else else {
{ if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2) {
if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2)
{
geom.base_width = SGB_VIDEO_WIDTH; geom.base_width = SGB_VIDEO_WIDTH;
geom.base_height = SGB_VIDEO_HEIGHT; geom.base_height = SGB_VIDEO_HEIGHT;
geom.aspect_ratio = (double)SGB_VIDEO_WIDTH / SGB_VIDEO_HEIGHT; geom.aspect_ratio = (double)SGB_VIDEO_WIDTH / SGB_VIDEO_HEIGHT;
} }
else else {
{
geom.base_width = VIDEO_WIDTH; geom.base_width = VIDEO_WIDTH;
geom.base_height = VIDEO_HEIGHT; geom.base_height = VIDEO_HEIGHT;
geom.aspect_ratio = (double)VIDEO_WIDTH / VIDEO_HEIGHT; geom.aspect_ratio = (double)VIDEO_WIDTH / VIDEO_HEIGHT;
@ -848,13 +828,11 @@ void retro_run(void)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
check_variables(); check_variables();
if (emulated_devices == 2) if (emulated_devices == 2) {
{
GB_update_keys_status(&gameboy[0], 0); GB_update_keys_status(&gameboy[0], 0);
GB_update_keys_status(&gameboy[1], 1); GB_update_keys_status(&gameboy[1], 1);
} }
else if (emulated_devices == 1 && (model[0] == MODEL_SGB || model[0] == MODEL_SGB2)) else if (emulated_devices == 1 && (model[0] == MODEL_SGB || model[0] == MODEL_SGB2)) {
{
for (unsigned i = 0; i < 4; i++) for (unsigned i = 0; i < 4; i++)
GB_update_keys_status(&gameboy[0], i); GB_update_keys_status(&gameboy[0], i);
} }
@ -863,8 +841,7 @@ void retro_run(void)
vblank1_occurred = vblank2_occurred = false; vblank1_occurred = vblank2_occurred = false;
signed delta = 0; signed delta = 0;
if (emulated_devices == 2) if (emulated_devices == 2) {
{
while (!vblank1_occurred || !vblank2_occurred) { while (!vblank1_occurred || !vblank2_occurred) {
if (delta >= 0) { if (delta >= 0) {
delta -= GB_run(&gameboy[0]); delta -= GB_run(&gameboy[0]);
@ -874,16 +851,15 @@ void retro_run(void)
} }
} }
} }
else else {
{
GB_run_frame(&gameboy[0]); GB_run_frame(&gameboy[0]);
} }
if (emulated_devices == 2) if (emulated_devices == 2) {
{
if (screen_layout == LAYOUT_TOP_DOWN) { if (screen_layout == LAYOUT_TOP_DOWN) {
video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT * emulated_devices, VIDEO_WIDTH * sizeof(uint32_t)); video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT * emulated_devices, VIDEO_WIDTH * sizeof(uint32_t));
}else if (screen_layout == LAYOUT_LEFT_RIGHT) { }
else if (screen_layout == LAYOUT_LEFT_RIGHT) {
/* use slow memcpy method for now */ /* use slow memcpy method for now */
for (int index = 0; index < emulated_devices; index++) { for (int index = 0; index < emulated_devices; index++) {
for (int y = 0; y < VIDEO_HEIGHT; y++) { for (int y = 0; y < VIDEO_HEIGHT; y++) {
@ -896,8 +872,7 @@ void retro_run(void)
video_cb(frame_buf_copy, VIDEO_WIDTH * emulated_devices, VIDEO_HEIGHT, VIDEO_WIDTH * emulated_devices * sizeof(uint32_t)); video_cb(frame_buf_copy, VIDEO_WIDTH * emulated_devices, VIDEO_HEIGHT, VIDEO_WIDTH * emulated_devices * sizeof(uint32_t));
} }
} }
else else {
{
if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2) { if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2) {
if (sgb_border == 1) if (sgb_border == 1)
video_cb(frame_buf, SGB_VIDEO_WIDTH, SGB_VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t)); video_cb(frame_buf, SGB_VIDEO_WIDTH, SGB_VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t));
@ -920,12 +895,11 @@ bool retro_load_game(const struct retro_game_info *info)
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars_single); environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars_single);
check_variables(); check_variables();
frame_buf = (uint32_t*)malloc(SGB_VIDEO_PIXELS* emulated_devices * sizeof(uint32_t)); frame_buf = (uint32_t*)malloc(SGB_VIDEO_PIXELS *emulated_devices * sizeof(uint32_t));
memset(frame_buf, 0, SGB_VIDEO_PIXELS * emulated_devices * sizeof(uint32_t)); memset(frame_buf, 0, SGB_VIDEO_PIXELS * emulated_devices * sizeof(uint32_t));
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
{
log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported\n"); log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported\n");
return false; return false;
} }
@ -933,11 +907,9 @@ bool retro_load_game(const struct retro_game_info *info)
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG; auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG;
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path); snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
for (int i = 0; i < emulated_devices; i++) for (int i = 0; i < emulated_devices; i++) {
{
init_for_current_model(i); init_for_current_model(i);
if (GB_load_rom(&gameboy[i],info->path)) if (GB_load_rom(&gameboy[i], info->path)) {
{
log_cb(RETRO_LOG_INFO, "Failed to load ROM at %s\n", info->path); log_cb(RETRO_LOG_INFO, "Failed to load ROM at %s\n", info->path);
return false; return false;
} }
@ -984,8 +956,7 @@ bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
memset(frame_buf_copy, 0, emulated_devices * SGB_VIDEO_PIXELS * sizeof(uint32_t)); memset(frame_buf_copy, 0, emulated_devices * SGB_VIDEO_PIXELS * sizeof(uint32_t));
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
{
log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported\n"); log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported\n");
return false; return false;
} }
@ -993,11 +964,9 @@ bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG; auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB : MODEL_DMG;
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path); snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
for (int i = 0; i < emulated_devices; i++) for (int i = 0; i < emulated_devices; i++) {
{
init_for_current_model(i); init_for_current_model(i);
if (GB_load_rom(&gameboy[i], info[i].path)) if (GB_load_rom(&gameboy[i], info[i].path)) {
{
log_cb(RETRO_LOG_INFO, "Failed to load ROM\n"); log_cb(RETRO_LOG_INFO, "Failed to load ROM\n");
return false; return false;
} }
@ -1063,8 +1032,7 @@ bool retro_serialize(void *data, size_t size)
bool retro_unserialize(const void *data, size_t size) bool retro_unserialize(const void *data, size_t size)
{ {
for (int i = 0; i < emulated_devices; i++) for (int i = 0; i < emulated_devices; i++) {
{
size_t state_size = GB_get_save_state_size(&gameboy[i]); size_t state_size = GB_get_save_state_size(&gameboy[i]);
if (state_size > size) { if (state_size > size) {
return false; return false;
@ -1085,10 +1053,8 @@ bool retro_unserialize(const void *data, size_t size)
void *retro_get_memory_data(unsigned type) void *retro_get_memory_data(unsigned type)
{ {
void *data = NULL; void *data = NULL;
if (emulated_devices == 1) if (emulated_devices == 1) {
{ switch (type) {
switch(type)
{
case RETRO_MEMORY_SYSTEM_RAM: case RETRO_MEMORY_SYSTEM_RAM:
data = gameboy[0].ram; data = gameboy[0].ram;
break; break;
@ -1102,7 +1068,7 @@ void *retro_get_memory_data(unsigned type)
data = gameboy[0].vram; data = gameboy[0].vram;
break; break;
case RETRO_MEMORY_RTC: case RETRO_MEMORY_RTC:
if(gameboy[0].cartridge_type->has_battery) if (gameboy[0].cartridge_type->has_battery)
data = GB_GET_SECTION(&gameboy[0], rtc); data = GB_GET_SECTION(&gameboy[0], rtc);
else else
data = NULL; data = NULL;
@ -1111,10 +1077,8 @@ void *retro_get_memory_data(unsigned type)
break; break;
} }
} }
else else {
{ switch (type) {
switch (type)
{
case RETRO_MEMORY_GAMEBOY_1_SRAM: case RETRO_MEMORY_GAMEBOY_1_SRAM:
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0) if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0)
data = gameboy[0].mbc_ram; data = gameboy[0].mbc_ram;
@ -1128,13 +1092,13 @@ void *retro_get_memory_data(unsigned type)
data = NULL; data = NULL;
break; break;
case RETRO_MEMORY_GAMEBOY_1_RTC: case RETRO_MEMORY_GAMEBOY_1_RTC:
if(gameboy[0].cartridge_type->has_battery) if (gameboy[0].cartridge_type->has_battery)
data = GB_GET_SECTION(&gameboy[0], rtc); data = GB_GET_SECTION(&gameboy[0], rtc);
else else
data = NULL; data = NULL;
break; break;
case RETRO_MEMORY_GAMEBOY_2_RTC: case RETRO_MEMORY_GAMEBOY_2_RTC:
if(gameboy[1].cartridge_type->has_battery) if (gameboy[1].cartridge_type->has_battery)
data = GB_GET_SECTION(&gameboy[1], rtc); data = GB_GET_SECTION(&gameboy[1], rtc);
else else
data = NULL; data = NULL;
@ -1150,10 +1114,8 @@ void *retro_get_memory_data(unsigned type)
size_t retro_get_memory_size(unsigned type) size_t retro_get_memory_size(unsigned type)
{ {
size_t size = 0; size_t size = 0;
if (emulated_devices == 1) if (emulated_devices == 1) {
{ switch (type) {
switch(type)
{
case RETRO_MEMORY_SYSTEM_RAM: case RETRO_MEMORY_SYSTEM_RAM:
size = gameboy[0].ram_size; size = gameboy[0].ram_size;
break; break;
@ -1167,7 +1129,7 @@ size_t retro_get_memory_size(unsigned type)
size = gameboy[0].vram_size; size = gameboy[0].vram_size;
break; break;
case RETRO_MEMORY_RTC: case RETRO_MEMORY_RTC:
if(gameboy[0].cartridge_type->has_battery) if (gameboy[0].cartridge_type->has_battery)
size = GB_SECTION_SIZE(rtc); size = GB_SECTION_SIZE(rtc);
else else
size = 0; size = 0;
@ -1176,10 +1138,8 @@ size_t retro_get_memory_size(unsigned type)
break; break;
} }
} }
else else {
{ switch (type) {
switch (type)
{
case RETRO_MEMORY_GAMEBOY_1_SRAM: case RETRO_MEMORY_GAMEBOY_1_SRAM:
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0) if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0)
size = gameboy[0].mbc_ram_size; size = gameboy[0].mbc_ram_size;
@ -1193,11 +1153,11 @@ size_t retro_get_memory_size(unsigned type)
size = 0; size = 0;
break; break;
case RETRO_MEMORY_GAMEBOY_1_RTC: case RETRO_MEMORY_GAMEBOY_1_RTC:
if(gameboy[0].cartridge_type->has_battery) if (gameboy[0].cartridge_type->has_battery)
size = GB_SECTION_SIZE(rtc); size = GB_SECTION_SIZE(rtc);
break; break;
case RETRO_MEMORY_GAMEBOY_2_RTC: case RETRO_MEMORY_GAMEBOY_2_RTC:
if(gameboy[1].cartridge_type->has_battery) if (gameboy[1].cartridge_type->has_battery)
size = GB_SECTION_SIZE(rtc); size = GB_SECTION_SIZE(rtc);
break; break;
default: default: