Add more mappings

This commit is contained in:
condret 2024-11-19 04:15:35 +01:00
parent 9d578edf4d
commit b80f301c0e
2 changed files with 20 additions and 1 deletions

11
gb/gb.c
View File

@ -10,6 +10,15 @@ bool gb_init(GB *gb, SDL_Renderer *renderer) {
gb->io->overlay = false;
gb->io->cachemode = false;
gb->io->p_cache = 0;
//initialize hram
if (!r_io_open_at (gb->io, "malloc://0x7f", R_PERM_RWX, 0, 0xff80)) {
goto fail_anal;
}
//initialize wram
RIODesc *wram = r_io_open_at (gb->io, "malloc://0x2000", R_PERM_RWX, 0, 0xc000);
if (!wram || !r_io_map_add (gb->io, wram->fd, R_PERM_RWX, 0, 0xe000, 0x1e00)) {
goto fail_anal;
}
gb->anal = r_anal_new ();
if (!gb->anal) {
goto fail_anal;
@ -62,3 +71,5 @@ void gb_fini(GB *gb) {
r_io_free (gb->io);
gb[0] = (const GB){0};
}
//void gb_load_cartridge

View File

@ -111,10 +111,18 @@ GBPPU *gb_ppu_open (RIO *io, SDL_Renderer *renderer) {
free (ppu);
return NULL;
}
RIOMap *vram = r_io_map_add (io, ppu->vram_fd, R_PERM_RWX, 0ULL, 0x8000, 0x2000);
if (!vram) {
r_io_fd_close (io, ppu->vram_fd);
free (ppu);
return NULL;
}
ppu->vram_mapid = vram->id;
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) {
if (!desc || !r_io_map_add (io, desc->fd, R_PERM_RWX, 0ULL, 0xff40, 0x6) ||
!r_io_map_add (io, desc->fd, R_PERM_RWX, 0x6, 0xff47, 0x5)) {
r_io_fd_close (io, ppu->vram_fd);
free (ppu);
return NULL;