Bläddra i källkod

Add IOManager, which manages emulation rather than the GG itself.

master
Ben Kurtovic 9 år sedan
förälder
incheckning
88e36ebd13
5 ändrade filer med 52 tillägg och 7 borttagningar
  1. +2
    -1
      crater.c
  2. +15
    -5
      src/gamegear.c
  3. +4
    -1
      src/gamegear.h
  4. +21
    -0
      src/iomanager.c
  5. +10
    -0
      src/iomanager.h

+ 2
- 1
crater.c Visa fil

@@ -8,6 +8,7 @@
#include "src/config.h"
#include "src/disassembler.h"
#include "src/gamegear.h"
#include "src/iomanager.h"
#include "src/logging.h"
#include "src/rom.h"

@@ -48,7 +49,7 @@ int main(int argc, char *argv[])

printf("crater: emulating: %s\n", rom->name);
gamegear_load(gg, rom);
gamegear_power(gg);
iomanager_emulate(gg);

gamegear_destroy(gg);
rom_close(rom);


+ 15
- 5
src/gamegear.c Visa fil

@@ -1,6 +1,8 @@
/* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
Released under the terms of the MIT License. See LICENSE for details. */

#include <stdlib.h>

#include "gamegear.h"
#include "logging.h"

@@ -24,7 +26,7 @@ GameGear* gamegear_create()

Does *not* destroy any loaded ROM objects.
*/
void gamegear_destroy(GameGear* gg)
void gamegear_destroy(GameGear *gg)
{
free(gg);
}
@@ -34,17 +36,25 @@ void gamegear_destroy(GameGear* gg)

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;
}

/*
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
gg->state = state;
}

+ 4
- 1
src/gamegear.h Visa fil

@@ -3,12 +3,15 @@

#pragma once

#include <stdbool.h>

#include "rom.h"

/* Structs */

typedef struct {
ROM *rom;
bool state;
} GameGear;

/* Functions */
@@ -16,4 +19,4 @@ typedef struct {
GameGear* gamegear_create();
void gamegear_destroy(GameGear*);
void gamegear_load(GameGear*, ROM*);
void gamegear_power(GameGear*);
void gamegear_power(GameGear*, bool);

+ 21
- 0
src/iomanager.c Visa fil

@@ -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);
}

+ 10
- 0
src/iomanager.h Visa fil

@@ -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*);

Laddar…
Avbryt
Spara