@@ -8,6 +8,7 @@ | |||||
#include "src/config.h" | #include "src/config.h" | ||||
#include "src/disassembler.h" | #include "src/disassembler.h" | ||||
#include "src/gamegear.h" | #include "src/gamegear.h" | ||||
#include "src/iomanager.h" | |||||
#include "src/logging.h" | #include "src/logging.h" | ||||
#include "src/rom.h" | #include "src/rom.h" | ||||
@@ -48,7 +49,7 @@ int main(int argc, char *argv[]) | |||||
printf("crater: emulating: %s\n", rom->name); | printf("crater: emulating: %s\n", rom->name); | ||||
gamegear_load(gg, rom); | gamegear_load(gg, rom); | ||||
gamegear_power(gg); | |||||
iomanager_emulate(gg); | |||||
gamegear_destroy(gg); | gamegear_destroy(gg); | ||||
rom_close(rom); | rom_close(rom); | ||||
@@ -1,6 +1,8 @@ | |||||
/* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | ||||
Released under the terms of the MIT License. See LICENSE for details. */ | Released under the terms of the MIT License. See LICENSE for details. */ | ||||
#include <stdlib.h> | |||||
#include "gamegear.h" | #include "gamegear.h" | ||||
#include "logging.h" | #include "logging.h" | ||||
@@ -24,7 +26,7 @@ GameGear* gamegear_create() | |||||
Does *not* destroy any loaded ROM objects. | Does *not* destroy any loaded ROM objects. | ||||
*/ | */ | ||||
void gamegear_destroy(GameGear* gg) | |||||
void gamegear_destroy(GameGear *gg) | |||||
{ | { | ||||
free(gg); | free(gg); | ||||
} | } | ||||
@@ -34,17 +36,25 @@ void gamegear_destroy(GameGear* gg) | |||||
Does *not* steal the reference to the ROM object. | Does *not* steal the reference to the ROM object. | ||||
*/ | */ | ||||
void gamegear_load(GameGear* gg, ROM* rom) | |||||
void gamegear_load(GameGear *gg, ROM *rom) | |||||
{ | { | ||||
gg->rom = rom; | gg->rom = rom; | ||||
} | } | ||||
/* | /* | ||||
Powers a GameGear object, beginning emulation. | |||||
Set the GameGear object's power state (true = on; false = off). | |||||
Powering on the GameGear executes boot code (e.g. clearing memory and | |||||
setting initial register values) and starts the clock. Powering it off | |||||
stops the clock. | |||||
This function call blocks until the GameGear is powered off. | |||||
Setting the power state to its current value has no effect. | |||||
*/ | */ | ||||
void gamegear_power(GameGear* gg) | |||||
void gamegear_power(GameGear *gg, bool state) | |||||
{ | { | ||||
if (gg->state == state) | |||||
return; | |||||
// TODO | // TODO | ||||
gg->state = state; | |||||
} | } |
@@ -3,12 +3,15 @@ | |||||
#pragma once | #pragma once | ||||
#include <stdbool.h> | |||||
#include "rom.h" | #include "rom.h" | ||||
/* Structs */ | /* Structs */ | ||||
typedef struct { | typedef struct { | ||||
ROM *rom; | ROM *rom; | ||||
bool state; | |||||
} GameGear; | } GameGear; | ||||
/* Functions */ | /* Functions */ | ||||
@@ -16,4 +19,4 @@ typedef struct { | |||||
GameGear* gamegear_create(); | GameGear* gamegear_create(); | ||||
void gamegear_destroy(GameGear*); | void gamegear_destroy(GameGear*); | ||||
void gamegear_load(GameGear*, ROM*); | void gamegear_load(GameGear*, ROM*); | ||||
void gamegear_power(GameGear*); | |||||
void gamegear_power(GameGear*, bool); |
@@ -0,0 +1,21 @@ | |||||
/* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
Released under the terms of the MIT License. See LICENSE for details. */ | |||||
#include "iomanager.h" | |||||
#include "logging.h" | |||||
/* | |||||
Emulate a Game Gear. Handle I/O with the host computer. | |||||
Block until emulation is finished. | |||||
*/ | |||||
void iomanager_emulate(GameGear *gg) | |||||
{ | |||||
DEBUG("IOManager powering GameGear") | |||||
gamegear_power(gg, true); | |||||
// TODO | |||||
DEBUG("IOManager unpowering GameGear") | |||||
gamegear_power(gg, false); | |||||
} |
@@ -0,0 +1,10 @@ | |||||
/* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
Released under the terms of the MIT License. See LICENSE for details. */ | |||||
#pragma once | |||||
#include "gamegear.h" | |||||
/* Functions */ | |||||
void iomanager_emulate(GameGear*); |