diff --git a/Makefile b/Makefile index a05d28a..cfa11d3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ LDFLAGS = $(shell pkg-config --libs 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: gcc -c sdl/pixbuf.c -o sdl/pixbuf.o $(CFLAGS) @@ -18,5 +18,8 @@ io/mbc2.o: io/joypad.o: gcc -c io/joypad.c -o io/joypad.o $(CFLAGS) +io/dma.o: + gcc -c io/dma.c -o io/dma.o $(CFLAGS) + clean: rm sdl/*.o && rm io/*.o diff --git a/io/dma.c b/io/dma.c index 3b219d5..5dd8040 100644 --- a/io/dma.c +++ b/io/dma.c @@ -18,7 +18,7 @@ static ut64 __bus_lseek(RIO* io, RIODesc *desc, ut64 offset, int whence) { break; case R_IO_SEEK_END: seek = 0xff80; - break + break; } dma->seek = (dma->seek & (~0xffff)) | 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) { GBDMA *dma = desc->data; ut64 seek = dma->seek & 0xffff; - if (timers->seek > 0xff7f || len < 1) { + if (dma->seek > 0xff7f || len < 1) { return 0; } 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 (len != _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 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) { GBDMA *dma = desc->data; ut64 seek = dma->seek & 0xffff; - if (timers->seek > 0xff7f || len < 1) { + if (dma->seek > 0xff7f || len < 1) { return 0; } len = R_MIN (len, 0xff80 - seek); @@ -177,7 +177,7 @@ GBDMA *gb_dma_open (RIO *io, bool cgb) { return NULL; } 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) { free (dma); return NULL; @@ -202,7 +202,7 @@ GBDMA *gb_dma_open (RIO *io, bool cgb) { 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); if (!desc) { - r_io_fd_close (dma->dma_fd); + r_io_fd_close (io, dma->dma_fd); r_io_bank_free (bank); free (dma); return NULL; diff --git a/io/joypad.c b/io/joypad.c index 518efda..ae4ffa0 100644 --- a/io/joypad.c +++ b/io/joypad.c @@ -45,7 +45,8 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) { #if 0 joypad->data = buf[0] & 0xf; #else - buf[0] = joypad->data & 0x3f + buf[0] = joypad->data & 0x3f; +#endif joypad->odata |= 0x40; return 1; }