more ppu
This commit is contained in:
parent
b2ebb5472f
commit
6167122d8e
|
@ -116,9 +116,9 @@ typedef struct gameboy_t {
|
||||||
int cartrigde_fd;
|
int cartrigde_fd;
|
||||||
} GB;
|
} GB;
|
||||||
|
|
||||||
GBPPU *gb_ppu_open (RIO *io);
|
GBPPU *gb_ppu_open (RIO *io, SDL_Renderer *renderer);
|
||||||
void gb_ppu_update (GB *gb, ut32 cycles);
|
void gb_ppu_update (GB *gb, ut32 cycles);
|
||||||
void gb_ppu_close (GBPPU *ppu);
|
void gb_ppu_close (GBPPU *ppu, RIO *io);
|
||||||
|
|
||||||
extern RIOPlugin r_io_plugin_gb_timers;
|
extern RIOPlugin r_io_plugin_gb_timers;
|
||||||
extern RIOPlugin r_io_plugin_gb_mbc1;
|
extern RIOPlugin r_io_plugin_gb_mbc1;
|
||||||
|
|
8
io/dma.c
8
io/dma.c
|
@ -189,15 +189,15 @@ GBDMA *gb_dma_open (RIO *io) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dma->dma_bank_id = bank->id;
|
dma->dma_bank_id = bank->id;
|
||||||
char uri[64];
|
// strcpy (uri, "malloc://0xa0");
|
||||||
memset (uri, 0x00, sizeof (char) * 64);
|
dma->oam_fd = r_io_fd_open (io, "malloc://0xa0", R_PERM_RWX, 0);
|
||||||
strcpy (uri, "malloc://0xa0");
|
|
||||||
dma->oam_fd = r_io_fd_open (io, uri, R_PERM_RWX, 0);
|
|
||||||
if (dma->oam_fd < 0) {
|
if (dma->oam_fd < 0) {
|
||||||
r_io_bank_free (bank);
|
r_io_bank_free (bank);
|
||||||
free (dma);
|
free (dma);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
char uri[64];
|
||||||
|
memset (uri, 0x00, sizeof (char) * 64);
|
||||||
sprintf (uri, "gb_dma://%p", dma);
|
sprintf (uri, "gb_dma://%p", dma);
|
||||||
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_dma,
|
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_dma,
|
||||||
uri, R_PERM_RWX, 0);
|
uri, R_PERM_RWX, 0);
|
||||||
|
|
43
io/ppu.c
43
io/ppu.c
|
@ -1,8 +1,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gb.h>
|
|
||||||
#include <r_io.h>
|
#include <r_io.h>
|
||||||
#include <r_util.h>
|
#include <r_util.h>
|
||||||
|
#include <gb.h>
|
||||||
|
#include <ragb_sdl.h>
|
||||||
|
|
||||||
RIOPlugin r_io_plugin_gb_ppu;
|
RIOPlugin r_io_plugin_gb_ppu;
|
||||||
|
|
||||||
|
@ -93,3 +94,43 @@ RIOPlugin r_io_plugin_gb_ppu = {
|
||||||
.seek = __lseek,
|
.seek = __lseek,
|
||||||
.write = __write,
|
.write = __write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GBPPU *gb_ppu_open (RIO *io, SDL_Renderer *renderer) {
|
||||||
|
GBPPU *ppu = R_NEW0 (GBPPU);
|
||||||
|
if (!ppu) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ppu->vram_fd = r_io_fd_open (io, "malloc//:0x2000", R_PERM_RWX, 0);
|
||||||
|
if (ppu->vram_fd < 0) {
|
||||||
|
free (ppu);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
char uri[64];
|
||||||
|
sprintf (uri, "gb_ppu://%p", ppu);
|
||||||
|
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_ppu, uri, R_PERM_RWX, 0);
|
||||||
|
if (!desc) {
|
||||||
|
r_io_fd_close (io, ppu->vram_fd);
|
||||||
|
free (ppu);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ppu->reg_fd = desc->fd;
|
||||||
|
ppu->pixbuf = gb_pix_buf_new (renderer, 160, 144);
|
||||||
|
if (!ppu->pixbuf) {
|
||||||
|
r_io_desc_close (desc);
|
||||||
|
r_io_fd_close (io, ppu->vram_fd);
|
||||||
|
free (ppu);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return ppu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gb_ppu_update (GB *gb, ut32 cycles) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void gb_ppu_close (GBPPU *ppu, RIO *io) {
|
||||||
|
r_io_fd_close (ppu->vram_fd);
|
||||||
|
r_io_fd_close (ppu->reg_fd);
|
||||||
|
gb_pix_buf_free (ppu->pixbuf);
|
||||||
|
free (ppu);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user