Kaynağa Gözat

Stub out some GG methods; minor cleanup.

master
Ben Kurtovic 9 yıl önce
ebeveyn
işleme
96e2a3f1d5
10 değiştirilmiş dosya ile 96 ekleme ve 18 silme
  1. +6
    -2
      crater.c
  2. +1
    -0
      src/assembler.h
  3. +1
    -0
      src/config.h
  4. +1
    -0
      src/disassembler.h
  5. +50
    -0
      src/gamegear.c
  6. +19
    -0
      src/gamegear.h
  7. +12
    -14
      src/logging.h
  8. +2
    -1
      src/rom.c
  9. +2
    -0
      src/rom.h
  10. +2
    -1
      src/util.h

+ 6
- 2
crater.c Dosyayı Görüntüle

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

@@ -43,10 +44,13 @@ int main(int argc, char *argv[])
ERROR("couldn't load ROM image '%s': %s", config->rom_path, errmsg)
retval = EXIT_FAILURE;
} else {
printf("crater: emulating: %s\n", rom->name);
GameGear *gg = gamegear_create();

// TODO: emulate game here...
printf("crater: emulating: %s\n", rom->name);
gamegear_load(gg, rom);
gamegear_power(gg);

gamegear_destroy(gg);
rom_close(rom);
}
}


+ 1
- 0
src/assembler.h Dosyayı Görüntüle

@@ -2,6 +2,7 @@
Released under the terms of the MIT License. See LICENSE for details. */

#pragma once

#include <stdbool.h>

/* Structs */


+ 1
- 0
src/config.h Dosyayı Görüntüle

@@ -2,6 +2,7 @@
Released under the terms of the MIT License. See LICENSE for details. */

#pragma once

#include <stdbool.h>

#define CONFIG_OK 0


+ 1
- 0
src/disassembler.h Dosyayı Görüntüle

@@ -2,6 +2,7 @@
Released under the terms of the MIT License. See LICENSE for details. */

#pragma once

#include <stdbool.h>

/* Structs */


+ 50
- 0
src/gamegear.c Dosyayı Görüntüle

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

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

/*
Create and return a pointer to a new GameGear object.

If memory could not be allocated, OUT_OF_MEMORY() is triggered.
*/
GameGear* gamegear_create()
{
GameGear *gg = malloc(sizeof(GameGear));
if (!gg)
OUT_OF_MEMORY()

gg->rom = NULL;
return gg;
}

/*
Destroy a previously-allocated GameGear object.

Does *not* destroy any loaded ROM objects.
*/
void gamegear_destroy(GameGear* gg)
{
free(gg);
}

/*
Load a ROM image into the GameGear object.

Does *not* steal the reference to the ROM object.
*/
void gamegear_load(GameGear* gg, ROM* rom)
{
gg->rom = rom;
}

/*
Powers a GameGear object, beginning emulation.

This function call blocks until the GameGear is powered off.
*/
void gamegear_power(GameGear* gg)
{
// TODO
}

+ 19
- 0
src/gamegear.h Dosyayı Görüntüle

@@ -0,0 +1,19 @@
/* 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 "rom.h"

/* Structs */

typedef struct {
ROM *rom;
} GameGear;

/* Functions */

GameGear* gamegear_create();
void gamegear_destroy(GameGear*);
void gamegear_load(GameGear*, ROM*);
void gamegear_power(GameGear*);

+ 12
- 14
src/logging.h Dosyayı Görüntüle

@@ -10,29 +10,27 @@

/* Internal usage only */

#define LOG_MSG(level, extra, after, ...) { \
fprintf(stderr, level ": " __VA_ARGS__); \
extra; \
fprintf(stderr, "\n"); \
after; \
#define LOG_MSG(dest, level, extra, after, ...) { \
fprintf(dest, level ": " __VA_ARGS__); \
extra; \
fprintf(dest, "\n"); \
after; \
}
#define PRINT_ERRNO() fprintf(stderr, ": %s", strerror(errno))

/* Public logging macros */

#define FATAL(...) LOG_MSG("Error", {}, exit(EXIT_FAILURE), __VA_ARGS__)
#define FATAL_ERRNO(...) LOG_MSG("Error", PRINT_ERRNO(), exit(EXIT_FAILURE), __VA_ARGS__)
#define ERROR(...) LOG_MSG("Error", {}, {}, __VA_ARGS__)
#define ERROR_ERRNO(...) LOG_MSG("Error", PRINT_ERRNO(), {}, __VA_ARGS__)
#define WARN(...) LOG_MSG("Warning", {}, {}, __VA_ARGS__)
#define WARN_ERRNO(...) LOG_MSG("Warning", PRINT_ERRNO(), {}, __VA_ARGS__)
#define FATAL(...) LOG_MSG(stderr, "Error", {}, exit(EXIT_FAILURE), __VA_ARGS__)
#define FATAL_ERRNO(...) LOG_MSG(stderr, "Error", PRINT_ERRNO(), exit(EXIT_FAILURE), __VA_ARGS__)
#define ERROR(...) LOG_MSG(stderr, "Error", {}, {}, __VA_ARGS__)
#define ERROR_ERRNO(...) LOG_MSG(stderr, "Error", PRINT_ERRNO(), {}, __VA_ARGS__)
#define WARN(...) LOG_MSG(stderr, "Warning", {}, {}, __VA_ARGS__)
#define WARN_ERRNO(...) LOG_MSG(stderr, "Warning", PRINT_ERRNO(), {}, __VA_ARGS__)

#ifdef DEBUG_MODE
#define DEBUG(...) LOG_MSG("[DEBUG]", {}, {}, __VA_ARGS__)
#define DEBUG_ERRNO(...) LOG_MSG("[DEBUG]", PRINT_ERRNO(), {}, __VA_ARGS__)
#define DEBUG(...) LOG_MSG(stdout, "[DEBUG]", {}, {}, __VA_ARGS__)
#else
#define DEBUG(...) {}
#define DEBUG_ERRNO(...) {}
#endif

#define OUT_OF_MEMORY() FATAL("couldn't allocate enough memory")

+ 2
- 1
src/rom.c Dosyayı Görüntüle

@@ -220,7 +220,8 @@ void rom_close(ROM *rom)

NULL is returned if the region code is invalid.

Region code information is taken from http://www.smspower.org/Development/ROMHeader.
Region code information is taken from:
http://www.smspower.org/Development/ROMHeader
*/
const char* rom_region(const ROM *rom)
{


+ 2
- 0
src/rom.h Dosyayı Görüntüle

@@ -2,7 +2,9 @@
Released under the terms of the MIT License. See LICENSE for details. */

#pragma once

#include <stdint.h>
#include <stdlib.h>

/* Error strings */



+ 2
- 1
src/util.h Dosyayı Görüntüle

@@ -2,7 +2,8 @@
Released under the terms of the MIT License. See LICENSE for details. */

#pragma once
#include "stdint.h"

#include <stdint.h>

/* Functions */



Yükleniyor…
İptal
Kaydet