diff --git a/menu.c b/menu.c index 1cbbdb7..f145705 100644 --- a/menu.c +++ b/menu.c @@ -139,6 +139,7 @@ void SelectFile(char* pFileExt, unsigned char Options, unsigned char MenuSelect, void HandleUI(void) { + char *p; unsigned char i, c, up, down, select, menu, right, left, plus, minus; unsigned long len; static hardfileTYPE t_hardfile[2]; // temporary copy of former hardfile configuration @@ -298,7 +299,7 @@ void HandleUI(void) else if(user_io_core_type() == CORE_TYPE_MIST) menustate = MENU_MIST_MAIN1; else - menustate = MENU_DUMMY_MAIN1; + menustate = MENU_8BIT_MAIN1; menusub = 0; OsdClear(); @@ -307,30 +308,57 @@ void HandleUI(void) break; /******************************************************************/ - /* dummy main menu */ + /* 8 bit main menu */ /******************************************************************/ - case MENU_DUMMY_MAIN1 : + case MENU_8BIT_MAIN1 : menumask=0; - OsdSetTitle("Menu", 0); + // string at first index is the core name + p = user_io_8bit_get_string(0); + if(!p || !strlen(p)) OsdSetTitle("8BIT", 0); + else OsdSetTitle(p, 0); - OsdWrite(0, "", 0,0); - OsdWrite(1, " Dummy menu test", 0,0); + // check if there's a file type supported + p = user_io_8bit_get_string(1); + if(p && strlen(p)) { + menumask = (menumask << 1) | 1; + strcpy(s, " Load *."); + strcat(s, p); + OsdWrite(0, s, menusub==0, 0); + } else + OsdWrite(0, " no file", 0,1); + + OsdWrite(1, " 8 bit menu test", 0,0); OsdWrite(2, "", 0,0); OsdWrite(3, "", 0,0); OsdWrite(4, "", 0,0); OsdWrite(5, "", 0,0); OsdWrite(6, "", 0,0); OsdWrite(7, "", 0,0); - menustate = MENU_DUMMY_MAIN2; - parentstate=MENU_DUMMY_MAIN1; + menustate = MENU_8BIT_MAIN2; + parentstate=MENU_8BIT_MAIN1; break; - case MENU_DUMMY_MAIN2 : + case MENU_8BIT_MAIN2 : // menu key closes menu if (menu) menustate = MENU_NONE1; + if(select) { + switch(menusub) { + case 0: { + p = user_io_8bit_get_string(1); + strcat(p, " "); // expand short extensions to 3 bytes + p[3] = 0; + SelectFile(p, SCAN_DIR | SCAN_LFN, MENU_8BIT_MAIN_FILE_SELECTED, MENU_8BIT_MAIN1); + } + } + } break; + + case MENU_8BIT_MAIN_FILE_SELECTED : // file successfully selected + iprintf("selecte file %s\n", file.name); + menustate = MENU_8BIT_MAIN1; + break; /******************************************************************/ /* mist main menu */ diff --git a/menu.h b/menu.h index d184104..b938eec 100644 --- a/menu.h +++ b/menu.h @@ -86,8 +86,9 @@ enum MENU MENU_MIST_VIDEO_ADJUST2, // Dummy menu entries - MENU_DUMMY_MAIN1, - MENU_DUMMY_MAIN2, + MENU_8BIT_MAIN1, + MENU_8BIT_MAIN2, + MENU_8BIT_MAIN_FILE_SELECTED, }; // UI strings, used by boot messages diff --git a/usb/hid.c b/usb/hid.c index 643e6e5..018c49c 100644 --- a/usb/hid.c +++ b/usb/hid.c @@ -365,8 +365,8 @@ static uint8_t usb_hid_poll(usb_device_t *dev) { uint8_t jmap = 0; uint8_t ax; - // hid_debugf("Joystick data:"); - // hexdump(buf, read, 0); + // hid_debugf("Joystick data:"); + // hexdump(buf, read, 0); // currently only byte sized axes are allowed ax = buf[conf->joystick.axis_byte_offset[0]]; @@ -389,6 +389,8 @@ static uint8_t usb_hid_poll(usb_device_t *dev) { // check if joystick state has changed if(jmap != info->iface_info[i].jmap) { + // iprintf("jmap changed to %x\n", jmap); + // and feed into joystick input system user_io_joystick(ax, jmap); info->iface_info[i].jmap = jmap; diff --git a/user_io.c b/user_io.c index 614cc6a..931e74c 100644 --- a/user_io.c +++ b/user_io.c @@ -288,6 +288,48 @@ static void kbd_fifo_poll() { kbd_fifo_r = (kbd_fifo_r + 1)&(KBD_FIFO_SIZE-1); } +// 8 bit cores have a config string telling the firmware how +// to treat it +char *user_io_8bit_get_string(char index) { + unsigned char i, lidx = 0, j = 0; + static char buffer[16+1]; // max 16 bytes per config item + + // clear buffer + buffer[0] = 0; + + /* read status byte */ + EnableIO(); + SPI(UIO_GET_STRING); + + i = SPI(0); + // the first char returned will be 0xff if the core doesn't support + // config strings + if(i == 0xff) { + DisableIO(); + return NULL; + } + + iprintf("String: "); + + while ((i != 0) && (i!=0xff)) { + if(i == ';') { + if(lidx == index) buffer[j++] = 0; + lidx++; + } else { + if(lidx == index) + buffer[j++] = i; + } + + iprintf("%c", i); + i = SPI(0); + } + + DisableIO(); + iprintf("\n"); + + return buffer; +} + void user_io_poll() { if((core_type != CORE_TYPE_MINIMIG) && (core_type != CORE_TYPE_PACE) && diff --git a/user_io.h b/user_io.h index e0dd6ac..1c393b2 100644 --- a/user_io.h +++ b/user_io.h @@ -37,6 +37,8 @@ #define UIO_JOYSTICK5 0x12 // -"- #define UIO_JOYSTICK6 0x13 // -"- +#define UIO_GET_STRING 0x14 + // codes as used by 8bit (atari 800, zx81) #define UIO_GET_STATUS 0x50 #define UIO_SECTOR_SND 0x51 @@ -72,6 +74,7 @@ char user_io_button_dip_switch1(); char user_io_user_button(); void user_io_osd_key_enable(char); void user_io_serial_tx(char *, uint16_t); +char *user_io_8bit_get_string(char); // io controllers interface for FPGA ethernet emulation using usb ethernet // devices attached to the io controller (ethernec emulation)