Skip to content

Commit

Permalink
gba: add goomba emulator autoloading for gb/gbc roms.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorgelig committed Dec 17, 2019
1 parent 66f96a4 commit 7080eb1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 38 deletions.
9 changes: 1 addition & 8 deletions cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,8 @@ static void cheats_send()

user_io_set_index(255);

// prepare transmission
user_io_set_download(1);

EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(buff, pos ? pos : 2, fpga_get_fio_size());
DisableFpga();

// signal end of transmission
user_io_file_tx_write(buff, pos ? pos : 2);
user_io_set_download(0);
}

Expand Down
6 changes: 1 addition & 5 deletions support/arcade/romutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ static int file_tx_start(unsigned char index)

static int file_tx_data(const uint8_t *buf, uint16_t chunk, struct MD5Context *md5context)
{
EnableFpga();
spi8(UIO_FILE_TX_DAT);

spi_write(buf, chunk, user_io_get_width());
DisableFpga();
user_io_file_tx_write(buf, chunk);

if (md5context) MD5Update(md5context, buf, chunk);
#if DEBUG_ROM_BINARY
Expand Down
9 changes: 1 addition & 8 deletions support/megacd/megacd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,8 @@ int mcd_send_data(uint8_t* buf, int len, uint8_t index) {
// set index byte
user_io_set_index(index);

// prepare transmission of new file
user_io_set_download(1);

EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(buf, len, 1);
DisableFpga();

// signal end of transmission
user_io_file_tx_write(buf, len);
user_io_set_download(0);
return 1;
}
Expand Down
54 changes: 37 additions & 17 deletions user_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,14 +1552,9 @@ static void send_pcolchr(const char* name, unsigned char index, int type)
//hexdump(col_attr, sizeof(col_attr));

user_io_set_index(index);
user_io_set_download(1);

EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(col_attr, type ? 1024 : 1025, fio_size);
DisableFpga();

// signal end of transmission
user_io_set_download(1);
user_io_file_tx_write(col_attr, type ? 1024 : 1025);
user_io_set_download(0);
}
}
Expand Down Expand Up @@ -1619,6 +1614,14 @@ static void tx_progress(const char* name, unsigned int progress)
InfoMessage(progress_buf, 2000, "Loading");
}

void user_io_file_tx_write(const uint8_t *addr, uint16_t len)
{
EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(addr, len, fio_size);
DisableFpga();
}

int user_io_file_tx(const char* name, unsigned char index, char opensave, char mute, char composite)
{
fileTYPE f = {};
Expand Down Expand Up @@ -1661,10 +1664,7 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m
printf("Load SNES ROM.\n");
uint8_t* buf = snes_get_header(&f);
hexdump(buf, 16, 0);
EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(buf, 512, fio_size);
DisableFpga();
user_io_file_tx_write(buf, 512);

//strip original SNES ROM header if present (not used)
if (bytes2send & 512)
Expand All @@ -1682,16 +1682,36 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m
int progress = -1;
if (use_progress) MenuHide();

while (bytes2send)
int dosend = 1;
if (!strcasecmp(core_name, "GBA") && ((index >> 6) == 1 || (index >> 6) == 2))
{
fileTYPE fg = {};
if (!FileOpen(&fg, user_io_make_filepath(HomeDir, "goomba.rom")))
{
dosend = 0;
Info("Cannot open goomba.rom!");
sleep(1);
}
else
{
uint32_t sz = fg.size;
while (sz)
{
uint16_t chunk = (sz > sizeof(buf)) ? sizeof(buf) : sz;
FileReadAdv(&fg, buf, chunk);
user_io_file_tx_write(buf, chunk);
sz -= chunk;
}
FileClose(&fg);
}
}

while (dosend && bytes2send)
{
uint16_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;

FileReadAdv(&f, buf, chunk);

EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(buf, chunk, fio_size);
DisableFpga();
user_io_file_tx_write(buf, chunk);

if (use_progress)
{
Expand Down
1 change: 1 addition & 0 deletions user_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void user_io_read_confstr();
char *user_io_get_confstr(int index);
uint32_t user_io_8bit_set_status(uint32_t, uint32_t, int ex = 0);
int user_io_file_tx(const char* name, unsigned char index = 0, char opensave = 0, char mute = 0, char composite = 0);
void user_io_file_tx_write(const uint8_t *addr, uint16_t len);
int user_io_get_width();

uint32_t user_io_get_file_crc();
Expand Down

0 comments on commit 7080eb1

Please sign in to comment.