fix build

This commit is contained in:
condret 2024-10-27 19:50:48 +01:00
parent ca3b4e4168
commit 13685b7903
3 changed files with 12 additions and 8 deletions

View File

@ -1,7 +1,7 @@
LDFLAGS = $(shell pkg-config --libs sdl2 r_util r_io) LDFLAGS = $(shell pkg-config --libs sdl2 r_util r_io)
CFLAGS = -Wall -I include/ $(shell pkg-config --cflags sdl2 r_util r_io) CFLAGS = -Wall -I include/ $(shell pkg-config --cflags sdl2 r_util r_io)
all: sdl/pixbuf.o io/timers.o io/mbc1.o io/mbc2.o io/joypad.o all: sdl/pixbuf.o io/timers.o io/mbc1.o io/mbc2.o io/joypad.o io/dma.o
sdl/pixbuf.o: sdl/pixbuf.o:
gcc -c sdl/pixbuf.c -o sdl/pixbuf.o $(CFLAGS) gcc -c sdl/pixbuf.c -o sdl/pixbuf.o $(CFLAGS)
@ -18,5 +18,8 @@ io/mbc2.o:
io/joypad.o: io/joypad.o:
gcc -c io/joypad.c -o io/joypad.o $(CFLAGS) gcc -c io/joypad.c -o io/joypad.o $(CFLAGS)
io/dma.o:
gcc -c io/dma.c -o io/dma.o $(CFLAGS)
clean: clean:
rm sdl/*.o && rm io/*.o rm sdl/*.o && rm io/*.o

View File

@ -18,7 +18,7 @@ static ut64 __bus_lseek(RIO* io, RIODesc *desc, ut64 offset, int whence) {
break; break;
case R_IO_SEEK_END: case R_IO_SEEK_END:
seek = 0xff80; seek = 0xff80;
break break;
} }
dma->seek = (dma->seek & (~0xffff)) | seek; dma->seek = (dma->seek & (~0xffff)) | seek;
return seek; return seek;
@ -31,7 +31,7 @@ static bool __bus_check(RIO *io, const char *pathname, bool many) {
static int __bus_read(RIO *io, RIODesc *desc, ut8 *buf, int len) { static int __bus_read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
GBDMA *dma = desc->data; GBDMA *dma = desc->data;
ut64 seek = dma->seek & 0xffff; ut64 seek = dma->seek & 0xffff;
if (timers->seek > 0xff7f || len < 1) { if (dma->seek > 0xff7f || len < 1) {
return 0; return 0;
} }
len = R_MIN (len, 0xff80 - seek); len = R_MIN (len, 0xff80 - seek);
@ -41,7 +41,7 @@ static int __bus_read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
#if 1 #if 1
if (len != _len) { if (len != _len) {
ut64 vseek = r_io_p2v (io, seek + _len); ut64 vseek = r_io_p2v (io, seek + _len);
r_io_bank_read_at (io, dma->default_bank_id, &buf[_len], len - _len) r_io_bank_read_at (io, dma->default_bank_id, vseek, &buf[_len], len - _len);
} }
#endif #endif
seek += len; seek += len;
@ -52,7 +52,7 @@ static int __bus_read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
static int __bus_write(RIO *io, RIODesc *desc, const ut8 *buf, int len) { static int __bus_write(RIO *io, RIODesc *desc, const ut8 *buf, int len) {
GBDMA *dma = desc->data; GBDMA *dma = desc->data;
ut64 seek = dma->seek & 0xffff; ut64 seek = dma->seek & 0xffff;
if (timers->seek > 0xff7f || len < 1) { if (dma->seek > 0xff7f || len < 1) {
return 0; return 0;
} }
len = R_MIN (len, 0xff80 - seek); len = R_MIN (len, 0xff80 - seek);
@ -177,7 +177,7 @@ GBDMA *gb_dma_open (RIO *io, bool cgb) {
return NULL; return NULL;
} }
dma->default_bank_id = io->bank; dma->default_bank_id = io->bank;
RIOBank *bank = r_io_bank_new (io, "dma bus"); RIOBank *bank = r_io_bank_new ("dma bus");
if (!bank) { if (!bank) {
free (dma); free (dma);
return NULL; return NULL;
@ -202,7 +202,7 @@ GBDMA *gb_dma_open (RIO *io, bool cgb) {
sprintf (uri, "gb_dma_bus://%p", dma); sprintf (uri, "gb_dma_bus://%p", dma);
desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_dma_bus, uri, R_PERM_RWX, 0); desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_dma_bus, uri, R_PERM_RWX, 0);
if (!desc) { if (!desc) {
r_io_fd_close (dma->dma_fd); r_io_fd_close (io, dma->dma_fd);
r_io_bank_free (bank); r_io_bank_free (bank);
free (dma); free (dma);
return NULL; return NULL;

View File

@ -45,7 +45,8 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
#if 0 #if 0
joypad->data = buf[0] & 0xf; joypad->data = buf[0] & 0xf;
#else #else
buf[0] = joypad->data & 0x3f buf[0] = joypad->data & 0x3f;
#endif
joypad->odata |= 0x40; joypad->odata |= 0x40;
return 1; return 1;
} }