Kaynağa Gözat

Add stubs for PSG.

master
Ben Kurtovic 8 yıl önce
ebeveyn
işleme
34c9e778b5
6 değiştirilmiş dosya ile 77 ekleme ve 7 silme
  1. +4
    -2
      src/gamegear.c
  2. +3
    -1
      src/gamegear.h
  3. +3
    -3
      src/io.c
  4. +3
    -1
      src/io.h
  5. +43
    -0
      src/psg.c
  6. +21
    -0
      src/psg.h

+ 4
- 2
src/gamegear.c Dosyayı Görüntüle

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

#include <stdlib.h>
@@ -24,7 +24,8 @@ GameGear* gamegear_create()
GameGear *gg = cr_malloc(sizeof(GameGear));
mmu_init(&gg->mmu);
vdp_init(&gg->vdp);
io_init(&gg->io, &gg->vdp);
psg_init(&gg->psg);
io_init(&gg->io, &gg->vdp, &gg->psg);
z80_init(&gg->cpu, &gg->mmu, &gg->io);

gg->powered = false;
@@ -42,6 +43,7 @@ void gamegear_destroy(GameGear *gg)
{
mmu_free(&gg->mmu);
vdp_free(&gg->vdp);
psg_free(&gg->psg);
free(gg);
}



+ 3
- 1
src/gamegear.h Dosyayı Görüntüle

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

#pragma once
@@ -8,6 +8,7 @@

#include "io.h"
#include "mmu.h"
#include "psg.h"
#include "rom.h"
#include "z80.h"

@@ -23,6 +24,7 @@ typedef struct GameGear {
Z80 cpu;
MMU mmu;
VDP vdp;
PSG psg;
IO io;
bool powered;
GGFrameCallback callback;


+ 3
- 3
src/io.c Dosyayı Görüntüle

@@ -6,9 +6,10 @@
/*
Initialize an IO object.
*/
void io_init(IO *io, VDP *vdp)
void io_init(IO *io, VDP *vdp, PSG *psg)
{
io->vdp = vdp;
io->psg = psg;
}

/*
@@ -72,8 +73,7 @@ void io_port_write(IO *io, uint8_t port, uint8_t value)
// TODO: Write to I/O control register
goto except;
} else if (port <= 0x7F) {
// TODO: Write to the SN76489 PSG
goto except;
psg_write(io->psg, value);
} else if (port <= 0xBF && !(port % 2)) {
vdp_write_data(io->vdp, value);
} else if (port <= 0xBF) {


+ 3
- 1
src/io.h Dosyayı Görüntüle

@@ -6,19 +6,21 @@
#include <stdbool.h>
#include <stdint.h>

#include "psg.h"
#include "vdp.h"

/* Structs */

typedef struct {
VDP *vdp;
PSG *psg;
bool except;
uint8_t exc_port;
} IO;

/* Functions */

void io_init(IO*, VDP*);
void io_init(IO*, VDP*, PSG*);
void io_power(IO*);
bool io_check_irq(IO*);
uint8_t io_port_read(IO*, uint8_t);


+ 43
- 0
src/psg.c Dosyayı Görüntüle

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

#include "psg.h"
#include "util.h"

/*
Initialize the SN76489 Programmable Sound Generator (PSG).
*/
void psg_init(PSG *psg)
{
// TODO
(void) psg;
}

/*
Free memory previously allocated by the PSG.
*/
void psg_free(PSG *psg)
{
// TODO
(void) psg;
}

/*
Power on the PSG, setting up initial state.
*/
void psg_power(PSG *psg)
{
psg->tone1 = psg->tone2 = psg->tone3 = 0x0000;
psg->vol1 = psg->vol2 = psg->vol3 = 0x0F;
psg->noise = 0x00;
}

/*
Write a byte of input to the PSG.
*/
void psg_write(PSG *psg, uint8_t byte)
{
// TODO
(void) psg;
TRACE("PSG ignoring write: 0x%02X", byte)
}

+ 21
- 0
src/psg.h Dosyayı Görüntüle

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

#pragma once

#include <stdint.h>

/* Structs */

typedef struct {
uint16_t tone1, tone2, tone3;
uint8_t vol1, vol2, vol3;
uint8_t noise;
} PSG;

/* Functions */

void psg_init(PSG*);
void psg_free(PSG*);
void psg_power(PSG*);
void psg_write(PSG*, uint8_t);

Yükleniyor…
İptal
Kaydet