mirror of https://github.com/bsnes-emu/bsnes.git
Fixing inconsistent style
This commit is contained in:
parent
d38fd41b0e
commit
0cf168f32b
|
@ -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);
|
||||||
|
|
|
@ -150,7 +150,8 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
||||||
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];
|
||||||
|
@ -470,7 +471,8 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowControllerDidLoadNib:(NSWindowController *)aController {
|
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
||||||
|
{
|
||||||
[super windowControllerDidLoadNib:aController];
|
[super windowControllerDidLoadNib:aController];
|
||||||
// Interface Builder bug?
|
// Interface Builder bug?
|
||||||
[self.consoleWindow setContentSize:self.consoleWindow.minSize];
|
[self.consoleWindow setContentSize:self.consoleWindow.minSize];
|
||||||
|
@ -625,11 +627,13 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
||||||
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";
|
||||||
|
@ -837,7 +841,8 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
||||||
[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;
|
||||||
|
@ -1681,11 +1686,13 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
||||||
return 600;
|
return 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)splitView:(GBSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex {
|
- (CGFloat)splitView:(GBSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex
|
||||||
|
{
|
||||||
return splitView.frame.size.width - 321;
|
return splitView.frame.size.width - 321;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)splitView:(GBSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view {
|
- (BOOL)splitView:(GBSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view
|
||||||
|
{
|
||||||
if ([[splitView arrangedSubviews] lastObject] == view) {
|
if ([[splitView arrangedSubviews] lastObject] == view) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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"]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
NSColor *_dividerColor;
|
NSColor *_dividerColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDividerColor:(NSColor *)color {
|
- (void)setDividerColor:(NSColor *)color
|
||||||
|
{
|
||||||
_dividerColor = color;
|
_dividerColor = color;
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor *)dividerColor {
|
- (NSColor *)dividerColor
|
||||||
|
{
|
||||||
if (_dividerColor) {
|
if (_dividerColor) {
|
||||||
return _dividerColor;
|
return _dividerColor;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +24,8 @@
|
||||||
{
|
{
|
||||||
if (@available(macOS 10.11, *)) {
|
if (@available(macOS 10.11, *)) {
|
||||||
return [super arrangedSubviews];
|
return [super arrangedSubviews];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return [self subviews];
|
return [self subviews];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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];
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,8 +114,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];
|
||||||
|
@ -124,8 +123,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];
|
||||||
|
|
|
@ -159,8 +159,7 @@ 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];
|
*(GB_frame_blending_mode_t *)[frame_blending_mode_buffer contents] = [self frameBlendingMode];
|
||||||
*(vector_float2 *)[output_resolution_buffer contents] = output_resolution;
|
*(vector_float2 *)[output_resolution_buffer contents] = output_resolution;
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,8 @@ AddHIDElements(CFArrayRef array, recDevice *pDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) {
|
ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem)
|
||||||
|
{
|
||||||
while (listitem) {
|
while (listitem) {
|
||||||
if (listitem->cookie == cookie) {
|
if (listitem->cookie == cookie) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -431,7 +432,8 @@ AddHIDElement(const void *value, void *parameter)
|
||||||
}
|
}
|
||||||
if (elementPrevious) {
|
if (elementPrevious) {
|
||||||
elementPrevious->pNext = element;
|
elementPrevious->pNext = element;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
*headElement = element;
|
*headElement = element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +521,8 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
|
||||||
*guid16++ = 0;
|
*guid16++ = 0;
|
||||||
*guid16++ = version;
|
*guid16++ = version;
|
||||||
*guid16++ = 0;
|
*guid16++ = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
*guid16++ = BUS_BLUETOOTH;
|
*guid16++ = BUS_BLUETOOTH;
|
||||||
*guid16++ = 0;
|
*guid16++ = 0;
|
||||||
strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4);
|
strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4);
|
||||||
|
@ -582,7 +585,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||||
value = GetHIDElementState(device, element) - element->min;
|
value = GetHIDElementState(device, element) - element->min;
|
||||||
if (range == 4) { /* 4 position hatswitch - scale up value */
|
if (range == 4) { /* 4 position hatswitch - scale up value */
|
||||||
value *= 2;
|
value *= 2;
|
||||||
} else if (range != 8) { /* Neither a 4 nor 8 positions - fall back to default position (centered) */
|
}
|
||||||
|
else if (range != 8) { /* Neither a 4 nor 8 positions - fall back to default position (centered) */
|
||||||
value = -1;
|
value = -1;
|
||||||
}
|
}
|
||||||
if ((unsigned)value >= 8) {
|
if ((unsigned)value >= 8) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char * argv[])
|
||||||
|
{
|
||||||
return NSApplicationMain(argc, argv);
|
return NSApplicationMain(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,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);
|
||||||
}
|
}
|
||||||
|
@ -380,8 +382,7 @@ 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,};
|
||||||
|
@ -487,8 +488,7 @@ 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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)++);
|
||||||
|
|
|
@ -274,19 +274,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;
|
||||||
|
|
|
@ -88,8 +88,7 @@ char *do_open_rom_dialog(void)
|
||||||
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);
|
||||||
|
|
|
@ -17,8 +17,7 @@ char *do_open_rom_dialog(void)
|
||||||
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;
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -171,7 +172,8 @@ ULONG QuickLookGeneratorPluginRelease(void *thisInstance)
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,8 +149,7 @@ static void open_menu(void)
|
||||||
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;
|
||||||
|
|
|
@ -24,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;
|
||||||
|
|
|
@ -323,15 +323,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);
|
||||||
|
@ -375,8 +373,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);
|
||||||
|
@ -446,8 +443,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 },
|
||||||
|
@ -458,8 +454,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 },
|
||||||
|
@ -467,8 +462,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 },
|
||||||
|
@ -483,12 +477,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)
|
||||||
|
@ -503,8 +495,7 @@ static void check_variables()
|
||||||
|
|
||||||
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)
|
||||||
|
@ -515,8 +506,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;
|
||||||
|
@ -531,8 +521,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);
|
||||||
|
@ -541,20 +530,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)
|
||||||
|
@ -569,8 +555,7 @@ static void check_variables()
|
||||||
|
|
||||||
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)
|
||||||
|
@ -586,8 +571,7 @@ static void check_variables()
|
||||||
|
|
||||||
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 +582,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 +593,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 +608,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 +616,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 +631,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 +639,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 +650,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 +664,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 +729,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 +821,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 +834,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 +844,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 +865,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));
|
||||||
|
@ -924,8 +892,7 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||||
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 +900,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 +949,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 +957,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 +1025,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 +1046,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;
|
||||||
|
@ -1111,10 +1070,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;
|
||||||
|
@ -1150,10 +1107,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;
|
||||||
|
@ -1176,10 +1131,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;
|
||||||
|
|
Loading…
Reference in New Issue