Sfoglia il codice sorgente

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

master
Ben Kurtovic 9 anni fa
parent
commit
88e36ebd13
5 ha cambiato i file con 52 aggiunte e 7 eliminazioni
  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 Vedi File

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


+ 15
- 5
src/gamegear.c Vedi File

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

+ 4
- 1
src/gamegear.h Vedi File

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

+ 21
- 0
src/iomanager.c Vedi File

@@ -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 Vedi File

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

Caricamento…
Annulla
Salva