diff --git a/menu.cpp b/menu.cpp index 2377cc0..06313d4 100644 --- a/menu.cpp +++ b/menu.cpp @@ -2253,10 +2253,12 @@ void HandleUI(void) /* minimig main menu */ /******************************************************************/ case MENU_MAIN1: - menumask = 0x1FF0; // b01110000 Floppy turbo, Harddisk options & Exit. + menumask = 0xFF0; // b01110000 Floppy turbo, Harddisk options & Exit. OsdSetTitle("Minimig", OSD_ARROW_RIGHT | OSD_ARROW_LEFT); helptext = helptexts[HELPTEXT_MAIN]; + OsdWrite(0, "", 0, 0); + // floppy drive info // We display a line for each drive that's active // in the config file, but grey out any that the FPGA doesn't think are active. @@ -2264,7 +2266,7 @@ void HandleUI(void) for (int i = 0; i < 4; i++) { if (i == config.floppy.drives + 1) - OsdWrite(i, " KP +/- to add/remove drives", 0, 1); + OsdWrite(i+1, " KP +/- to add/remove drives", 0, 1); else { strcpy(s, " dfx: "); @@ -2304,25 +2306,24 @@ void HandleUI(void) } else strcpy(s, ""); - OsdWrite(i, s, menusub == i, (i>drives) || (i>config.floppy.drives)); + OsdWrite(i+1, s, menusub == i, (i>drives) || (i>config.floppy.drives)); } } sprintf(s, " Floppy disk turbo : %s", config.floppy.speed ? "on" : "off"); - OsdWrite(4, s, menusub == 4, 0); - OsdWrite(5, "", 0, 0); + OsdWrite(5, s, menusub == 4, 0); + OsdWrite(6, "", 0, 0); - OsdWrite(6, " Hard disks", menusub == 5, 0); - OsdWrite(7, " Chipset", menusub == 6, 0); - OsdWrite(8, " Memory", menusub == 7, 0); - OsdWrite(9, " Audio & Video", menusub == 8, 0); - OsdWrite(10, "", 0, 0); + OsdWrite(7, " Hard disks", menusub == 5, 0); + OsdWrite(8, " Chipset", menusub == 6, 0); + OsdWrite(9, " Memory", menusub == 7, 0); + OsdWrite(10, " Audio & Video", menusub == 8, 0); + OsdWrite(11, "", 0, 0); - OsdWrite(11, " Save configuration", menusub == 9, 0); - OsdWrite(12, " Load configuration", menusub == 10, 0); - OsdWrite(13, "", 0, 0); - OsdWrite(14, user_io_minimig_get_adjust() ? " Finish screen adjusting" : " Adjust screen position", menusub == 11, 0); + OsdWrite(12, " Save configuration", menusub == 9, 0); + OsdWrite(13, " Load configuration", menusub == 10, 0); + OsdWrite(14, "", 0, 0); - OsdWrite(15, STD_EXIT, menusub == 12, 0); + OsdWrite(15, STD_EXIT, menusub == 11, 0); menustate = MENU_MAIN2; parentstate = MENU_MAIN1; @@ -2396,11 +2397,6 @@ void HandleUI(void) menustate = MENU_LOADCONFIG_1; } else if (menusub == 11) - { - menustate = MENU_NONE1; - user_io_minimig_set_adjust(!user_io_minimig_get_adjust()); - } - else if (menusub == 12) menustate = MENU_NONE1; } else if (c == KEY_BACKSPACE) // eject all floppies @@ -2702,24 +2698,24 @@ void HandleUI(void) OsdSetTitle("Chipset", OSD_ARROW_LEFT | OSD_ARROW_RIGHT); OsdWrite(0, "", 0, 0); - strcpy(s, " CPU : "); + strcpy(s, " CPU : "); strcat(s, config_cpu_msg[config.cpu & 0x03]); OsdWrite(1, s, menusub == 0, 0); - strcpy(s, " Turbo : "); + strcpy(s, " Turbo : "); strcat(s, config_turbo_msg[(config.cpu >> 2) & 0x03]); OsdWrite(2, s, menusub == 1, 0); OsdWrite(3, "", 0, 0); - strcpy(s, " Video : "); + strcpy(s, " Video : "); strcat(s, config.chipset & CONFIG_NTSC ? "NTSC" : "PAL"); OsdWrite(4, s, menusub == 2, 0); - strcpy(s, " Chipset : "); + strcpy(s, " Chipset : "); strcat(s, config_chipset_msg[(config.chipset >> 2) & 7]); OsdWrite(5, s, menusub == 3, 0); OsdWrite(6, "", 0, 0); - strcpy(s, " CD32Pad : "); + strcpy(s, " CD32Pad : "); strcat(s, config_cd32pad_msg[(config.autofire >> 2) & 1]); OsdWrite(7, s, menusub == 4, 0); - strcpy(s, " Joy Swap : "); + strcpy(s, " Joy Swap : "); strcat(s, (config.autofire & 0x8)? "ON" : "OFF"); OsdWrite(8, s, menusub == 5, 0); for (int i = 9; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0); @@ -2834,23 +2830,23 @@ void HandleUI(void) OsdSetTitle("Memory", OSD_ARROW_LEFT | OSD_ARROW_RIGHT); OsdWrite(0, "", 0, 0); - strcpy(s, " CHIP : "); + strcpy(s, " CHIP : "); strcat(s, config_memory_chip_msg[config.memory & 0x03]); OsdWrite(1, s, menusub == 0, 0); - strcpy(s, " SLOW : "); + strcpy(s, " SLOW : "); strcat(s, config_memory_slow_msg[config.memory >> 2 & 0x03]); OsdWrite(2, s, menusub == 1, 0); - strcpy(s, " FAST : "); + strcpy(s, " FAST : "); strcat(s, config_memory_fast_msg[config.memory >> 4 & 0x03]); OsdWrite(3, s, menusub == 2, 0); OsdWrite(4, "", 0, 0); - strcpy(s, " ROM : "); - strncat(s, config.kickstart, 25); + strcpy(s, " ROM : "); + strncat(s, config.kickstart, 24); OsdWrite(5, s, menusub == 3, 0); - strcpy(s, " HRTmon: "); + strcpy(s, " HRTmon : "); strcat(s, (config.memory & 0x40) ? "enabled " : "disabled"); OsdWrite(6, s, menusub == 4, 0); @@ -3079,27 +3075,35 @@ void HandleUI(void) /* video settings menu */ /******************************************************************/ case MENU_SETTINGS_VIDEO1: - menumask = 0x1f; + menumask = 0x3f; parentstate = menustate; helptext = 0; // helptexts[HELPTEXT_VIDEO]; OsdSetTitle("Video", OSD_ARROW_LEFT | OSD_ARROW_RIGHT); OsdWrite(0, "", 0, 0); - strcpy(s, " Scanlines : "); + strcpy(s, " Scanlines : "); strcat(s, config_scanlines_msg[config.scanlines & 0x3]); OsdWrite(1, s, menusub == 0, 0); - strcpy(s, " Video area by : "); + strcpy(s, " Video area by : "); strcat(s, config_blank_msg[(config.scanlines >> 6) & 3]); OsdWrite(2, s, menusub == 1, 0); - strcpy(s, " Aspect Ratio : "); + strcpy(s, " Aspect Ratio : "); strcat(s, config_ar_msg[(config.scanlines >> 4) & 1]); OsdWrite(3, s, menusub == 2, 0); OsdWrite(4, "", 0, 0); - strcpy(s, " Stereo mix : "); + strcpy(s, " Stereo mix : "); strcat(s, config_stereo_msg[config.audio & 3]); OsdWrite(5, s, menusub == 3, 0); - for (int i = 6; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0); - OsdWrite(OsdGetSize() - 1, STD_EXIT, menusub == 4, 0); + OsdWrite(6, "", 0, 0); + OsdWrite(7, "", 0, 0); + OsdWrite(8, user_io_minimig_get_adjust() ? " Finish screen adjustment" : " Adjust screen position", menusub == 4, 0); + OsdWrite(9, "", 0, 0); + OsdWrite(10, "", 0, 0); + OsdWrite(11, "", 0, 0); + OsdWrite(12, "", 0, 0); + OsdWrite(13, "", 0, 0); + OsdWrite(14, "", 0, 0); + OsdWrite(OsdGetSize() - 1, STD_EXIT, menusub == 5, 0); menustate = MENU_SETTINGS_VIDEO2; break; @@ -3135,6 +3139,11 @@ void HandleUI(void) ConfigAudio(config.audio); } else if (menusub == 4) + { + menustate = MENU_NONE1; + user_io_minimig_set_adjust(!user_io_minimig_get_adjust()); + } + else if (menusub == 5) { menustate = MENU_MAIN1; menusub = 8; diff --git a/releases/MiSTer_20181213 b/releases/MiSTer_20181213 new file mode 100644 index 0000000..c9858b7 Binary files /dev/null and b/releases/MiSTer_20181213 differ diff --git a/support/snes/snes.cpp b/support/snes/snes.cpp index 0f897e8..85616f1 100644 --- a/support/snes/snes.cpp +++ b/support/snes/snes.cpp @@ -126,35 +126,113 @@ static uint32_t find_header(const uint8_t *data, uint32_t size) uint8_t* snes_get_header(fileTYPE *f) { memset(hdr, 0, sizeof(hdr)); - uint8_t *buf = (uint8_t*)malloc(f->size); - if (buf) + uint32_t size = f->size; + uint8_t *prebuf = (uint8_t*)malloc(size); + if (prebuf) { FileSeekLBA(f, 0); - if (FileReadAdv(f, buf, f->size)) + if (FileReadAdv(f, prebuf, size)) { - uint32_t addr = find_header(buf, f->size); + uint8_t *buf = prebuf; + + if (size & 512) + { + buf += 512; + size -= 512; + } + + *(uint32_t*)(&hdr[8]) = size; + + uint32_t addr = find_header(buf, size); if (addr) { - uint8_t romsz = buf[addr + RomSize]; uint8_t ramsz = buf[addr + RamSize]; - if (romsz >= 0x10) romsz = 0; if (ramsz >= 0x08) ramsz = 0; - hdr[0] = (ramsz << 4) | romsz; - hdr[1] = (addr == 0x00ffc0) ? 1 : (addr == 0x40ffc0) ? 5 : 0; //LHRom type + //Rom type: 0-Low, 1-High, 2-ExHigh + hdr[1] = (addr == 0x00ffc0) ? 1 : (addr == 0x40ffc0) ? 2 : 0; - hdr[2] = buf[addr + RomType]; + //DSPn types 8..B + if ((buf[addr + Mapper] == 0x20 || buf[addr + Mapper] == 0x21) && buf[addr + RomType] == 0x03) + { //DSP1 + hdr[1] |= 0x80; + } + else if (buf[addr + Mapper] == 0x30 && buf[addr + RomType] == 0x05 && buf[addr + Company] != 0xb2) + { //DSP1 + hdr[1] |= 0x80; + } + else if (buf[addr + Mapper] == 0x31 && (buf[addr + RomType] == 0x03 || buf[addr + RomType] == 0x05)) + { //DSP1 + hdr[1] |= 0x80; + } + else if (buf[addr + Mapper] == 0x20 && buf[addr + RomType] == 0x05) + { //DSP2 + hdr[1] |= 0x90; + } + else if (buf[addr + Mapper] == 0x30 && buf[addr + RomType] == 0x05 && buf[addr + Company] == 0xb2) + { //DSP3 + hdr[1] |= 0xA0; + } + else if (buf[addr + Mapper] == 0x30 && buf[addr + RomType] == 0x03) + { //DSP4 + hdr[1] |= 0xB0; + } + //CX4 4 + if (buf[addr + Mapper] == 0x20 && buf[addr + RomType] == 0xf3) + { + hdr[1] |= 0x40; + } + + //SDD1 5 + if (buf[addr + Mapper] == 0x32 && (buf[addr + RomType] == 0x43 || buf[addr + RomType] == 0x45)) + { + hdr[1] |= 0x50; + } + + //SA1 6 + if (buf[addr + Mapper] == 0x23 && (buf[addr + RomType] == 0x32 || buf[addr + RomType] == 0x34 || buf[addr + RomType] == 0x35)) + { + hdr[1] |= 0x60; + } + + //GSU 7 + if (buf[addr + Mapper] == 0x20 && (buf[addr + RomType] == 0x13 || buf[addr + RomType] == 0x14 || buf[addr + RomType] == 0x15 || buf[addr + RomType] == 0x1a)) + { + ramsz = buf[addr - 3]; + if (ramsz == 0xFF) ramsz = 5; //StarFox + if (ramsz > 6) ramsz = 6; + hdr[1] |= 0x70; + } + + //1..3,C..F - reserved for other mappers. + + hdr[2] = 0; + + //PAL Regions if ((buf[addr + CartRegion] >= 0x02 && buf[addr + CartRegion] <= 0x0C) || buf[addr + CartRegion] == 0x11) - { //PAL Regions + { hdr[3] |= 1; } - *(uint32_t*)(&hdr[4]) = addr; + //re-calc rom size + uint8_t romsz = 15; + size--; + if (!(size & 0xFF000000)) + { + while (!(size & 0x1000000)) + { + romsz--; + size <<= 1; + } + } + hdr[0] = (ramsz << 4) | romsz; + printf("Size from header: 0x%X, calculated size: 0x%X\n", buf[addr + RomSize], romsz); } + *(uint32_t*)(&hdr[4]) = addr; } FileSeekLBA(f, 0); - free(buf); + free(prebuf); } return hdr; } diff --git a/user_io.cpp b/user_io.cpp index 55d2a27..c46d5b3 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -1213,7 +1213,7 @@ static void send_pcolchr(const char* name, unsigned char index, int type) int user_io_file_tx(const char* name, unsigned char index, char opensave, char mute, char composite) { fileTYPE f = { 0 }; - static uint8_t buf[1024]; + static uint8_t buf[4096]; if (!FileOpen(&f, name, mute)) return 0; @@ -1261,7 +1261,7 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m } else { - if (is_snes_core()) + if (is_snes_core() && bytes2send) { printf("Load SNES ROM.\n"); uint8_t* buf = snes_get_header(&f); @@ -1270,15 +1270,21 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m spi8(UIO_FILE_TX_DAT); spi_write(buf, 512, fio_size); DisableFpga(); + + if (bytes2send & 512) + { + bytes2send -= 512; + FileReadSec(&f, buf); + } } while (bytes2send) { printf("."); - uint16_t chunk = (bytes2send > 512) ? 512 : bytes2send; + uint16_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send; - FileReadSec(&f, buf); + FileReadAdv(&f, buf, chunk); EnableFpga(); spi8(UIO_FILE_TX_DAT); @@ -3086,7 +3092,7 @@ static uint32_t show_video_info(int force) } adjust_vsize(0); - return 0; + return ret; } int hasAPI1_5()