1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-01-13 15:17:43 +00:00

Added display of USB raw status in joystick test screen.

Added override of core name from HDL version string ("V0;<text>").
This commit is contained in:
Newsdee 2016-06-05 14:49:15 +08:00
parent 92f3c5a9b5
commit 5ac081e365
5 changed files with 109 additions and 50 deletions

124
menu.c
View File

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#include "AT91SAM7S256.h" //#include "AT91SAM7S256.h"
//#include "stdbool.h" //#include "stdbool.h"
#include <stdlib.h> #include <stdlib.h>
#include <inttypes.h>
#include "stdio.h" #include "stdio.h"
#include "string.h" #include "string.h"
#include "errors.h" #include "errors.h"
@ -47,8 +48,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "archie.h" #include "archie.h"
#include "usb/joymapping.h" #include "usb/joymapping.h"
// test features // test features (not used right now)
#define ALLOW_TEST_MENU 1 //remove to disable in prod version // #define ALLOW_TEST_MENU 0 //remove to disable in prod version
// other constants // other constants
@ -220,6 +221,28 @@ static void substrcpy(char *d, char *s, char idx) {
#define HELPTEXT_DELAY 10000 #define HELPTEXT_DELAY 10000
#define FRAME_DELAY 150 #define FRAME_DELAY 150
//assumes big endian
void siprintbinary(char* buffer, size_t const size, void const * const ptr)
{
unsigned char *b = (unsigned char*) ptr;
unsigned char byte;
int i, j;
siprintf(buffer, "%*s", size-1, "");
for (i=size-1;i>=0;i--)
{
for (j=0;j<8;j++)
{
byte = (b[i] >> j) & 1;
if(byte)
strcat(buffer, "1");
else
strcat(buffer, "0");
}
}
return;
}
void HandleUI(void) void HandleUI(void)
{ {
char *p; char *p;
@ -235,11 +258,11 @@ void HandleUI(void)
/* check joystick status */ /* check joystick status */
char joy_0 = 0; char joy_0 = 0;
uint16_t joy_usb=0;
char joy_string[16]; char joy_string[16];
char joy_string2[32]; char joy_string2[32];
char joy_string3[16]; char binary_string[9]="00000000";
/* build USB id key */ /* build USB id key */
unsigned int usb_vid = OsdUsbVidGet(); unsigned int usb_vid = OsdUsbVidGet();
unsigned int usb_pid = OsdUsbPidGet(); unsigned int usb_pid = OsdUsbPidGet();
@ -590,6 +613,22 @@ void HandleUI(void)
menumask = (menumask << 1) | 1; menumask = (menumask << 1) | 1;
entry++; entry++;
} }
// check for 'V'ersion strings
if(p && (p[0] == 'V')) {
// p[1] is not used but kept for future use
char x = p[1];
// get version string
substrcpy(s, p, 2);
char l = strlen(s);
s[0] = ' ';
substrcpy(s+1, p, 1);
OsdCoreNameSet(s);
}
i++; i++;
} while(p); } while(p);
@ -766,7 +805,7 @@ void HandleUI(void)
ScrollText(5," MiST by Till Harbaum, based on Minimig and other projects. MiST hardware and software is distributed under the terms of the GNU General Public License version 3. MiST FPGA cores are the work of their respective authors under individual licensing.",0,0,0); ScrollText(5," MiST by Till Harbaum, based on Minimig and other projects. MiST hardware and software is distributed under the terms of the GNU General Public License version 3. MiST FPGA cores are the work of their respective authors under individual licensing.",0,0,0);
// menu key closes menu // menu key closes menu
if (menu) if (menu)
menustate = MENU_NONE1; menustate = MENU_NONE1;
if(select) { if(select) {
//iprintf("Selected", 0); //iprintf("Selected", 0);
@ -805,17 +844,20 @@ void HandleUI(void)
case MENU_8BIT_TEST2: case MENU_8BIT_TEST2:
memset(joy_string, '\0', sizeof(joy_string)); memset(joy_string, '\0', sizeof(joy_string));
memset(joy_string2, '\0', sizeof(joy_string2)); memset(joy_string2, '\0', sizeof(joy_string2));
memset(joy_string3, '\0', sizeof(joy_string3));
joy_0 = OsdJoyGet(); joy_0 = OsdJoyGet();
strcat(joy_string, " "); strcat(joy_string, " ");
strcat(joy_string2, " " ); strcat(joy_string2, " " );
strcat(joy_string3, " " );
if(joy_0 & JOY_UP) strcat(joy_string, "\x12"); if(joy_0 & JOY_UP) strcat(joy_string, "\x12");
if(joy_0 & JOY_DOWN) strcat(joy_string3, "\x13");
if(joy_0 & JOY_LEFT) if(joy_0 & JOY_LEFT)
strcat(joy_string2, "< \x14 "); if(joy_0 & JOY_DOWN)
strcat(joy_string2, "< \x13 ");
else
strcat(joy_string2, "< \x14 ");
else else
strcat(joy_string2, " \x14 "); if (joy_0 & JOY_DOWN)
strcat(joy_string2, " \x13 ");
else
strcat(joy_string2, " \x14 ");
if(joy_0 & JOY_RIGHT) if(joy_0 & JOY_RIGHT)
strcat(joy_string2, "> "); //"\x16 "); strcat(joy_string2, "> "); //"\x16 ");
else else
@ -831,51 +873,51 @@ void HandleUI(void)
if (joy_0!=0) { if (joy_0!=0) {
OsdWrite(3, joy_string, 0, 0); OsdWrite(3, joy_string, 0, 0);
OsdWrite(4, joy_string2, 0, 0); OsdWrite(4, joy_string2, 0, 0);
OsdWrite(5, joy_string3, 0, 0); OsdWrite(5, " ", 0, 0);
} else { } else {
OsdWrite(3, "", 0, 0); OsdWrite(3, "", 0, 0);
OsdWrite(4, JOY_NO_INPUT, 0, 0); OsdWrite(4, JOY_NO_INPUT, 0, 0);
OsdWrite(5, "", 0, 0); OsdWrite(5, "", 0, 0);
} }
// Disallow to allow testing output
//if (menu) // display raw USB input
// menustate = MENU_NONE1; joy_0 = OsdUsbJoyGet();
siprintf(s, " USB: ");
siprintbinary(binary_string, sizeof(joy_0), &joy_0);
strcat(s, binary_string);
strcat(s, " ");
joy_0 = OsdUsbJoyGetExtra();
siprintbinary(binary_string, sizeof(joy_0), &joy_0);
strcat(s, binary_string);
OsdWrite(6, s, 0,0);
/* // allow allow exit when hitting space
if(select) { if(c==KEY_SPACE) {
//iprintf("Selected", 0); menustate = MENU_8BIT_SYSTEM1;
if (menusub==1) { menusub = 0;
menustate = MENU_8BIT_SYSTEM1; }
menusub = 0;
}
}*/
if(c==KEY_SPACE) {
menustate = MENU_8BIT_SYSTEM1;
menusub = 0;
}
//} //}
break; break;
/******************************************************************/ /******************************************************************/
/* mist main menu */ /* mist main menu */
/******************************************************************/ /******************************************************************/
case MENU_MIST_MAIN1 : case MENU_MIST_MAIN1 :
menumask=0xff; menumask=0xff;
OsdSetTitle("Mist", 0); OsdSetTitle("Mist", 0);
// most important: main page has setup for floppy A: and screen // most important: main page has setup for floppy A: and screen
strcpy(s, " A: "); strcpy(s, " A: ");
strcat(s, tos_get_disk_name(0)); strcat(s, tos_get_disk_name(0));
if(tos_system_ctrl() & TOS_CONTROL_FDC_WR_PROT_A) strcat(s, " \x17"); if(tos_system_ctrl() & TOS_CONTROL_FDC_WR_PROT_A) strcat(s, " \x17");
OsdWrite(0, s, menusub == 0,0); OsdWrite(0, s, menusub == 0,0);
strcpy(s, " Screen: "); strcpy(s, " Screen: ");
if(tos_system_ctrl() & TOS_CONTROL_VIDEO_COLOR) strcat(s, "Color"); if(tos_system_ctrl() & TOS_CONTROL_VIDEO_COLOR) strcat(s, "Color");
else strcat(s, "Mono"); else strcat(s, "Mono");
OsdWrite(1, s, menusub == 1,0); OsdWrite(1, s, menusub == 1,0);
/* everything else is in submenus */ /* everything else is in submenus */
OsdWrite(2, " Storage \x16", menusub == 2,0); OsdWrite(2, " Storage \x16", menusub == 2,0);

8
menu.h
View File

@ -97,10 +97,10 @@ enum MENU
MENU_8BIT_MAIN_IMAGE_SELECTED, MENU_8BIT_MAIN_IMAGE_SELECTED,
MENU_8BIT_SYSTEM1, MENU_8BIT_SYSTEM1,
MENU_8BIT_SYSTEM2, MENU_8BIT_SYSTEM2,
MENU_8BIT_ABOUT1, MENU_8BIT_ABOUT1,
MENU_8BIT_ABOUT2, MENU_8BIT_ABOUT2,
MENU_8BIT_TEST1, MENU_8BIT_TEST1,
MENU_8BIT_TEST2 MENU_8BIT_TEST2
}; };
// UI strings, used by boot messages // UI strings, used by boot messages

15
osd.c
View File

@ -726,16 +726,27 @@ unsigned char OsdKeyGet() {
/* latest joystick state */ /* latest joystick state */
static unsigned char osd_joy; static unsigned char osd_joy;
void OsdJoySet(unsigned char c) { void OsdJoySet(unsigned char c) {
//iprintf("OSD joy: %x\n", c); //iprintf("OSD joy: %x\n", c);
osd_joy = c; osd_joy = c;
} }
unsigned char OsdJoyGet() { unsigned char OsdJoyGet() {
return osd_joy; return osd_joy;
} }
static uint8_t raw_usb_joy; // four directions and 4 buttons
static uint8_t raw_usb_joy_extra; // eight extra buttons
void OsdUsbJoySet(uint8_t usbjoy, uint8_t usbextra) {
raw_usb_joy = usbjoy;
raw_usb_joy_extra = usbextra;
}
uint8_t OsdUsbJoyGet() {
return raw_usb_joy;
}
uint8_t OsdUsbJoyGetExtra() {
return raw_usb_joy_extra;
}
/* connected HID information */ /* connected HID information */
static unsigned int usb_vid; static unsigned int usb_vid;
static unsigned int usb_pid; static unsigned int usb_pid;

6
osd.h
View File

@ -95,6 +95,8 @@
#define OSD_ARROW_LEFT 1 #define OSD_ARROW_LEFT 1
#define OSD_ARROW_RIGHT 2 #define OSD_ARROW_RIGHT 2
#include <inttypes.h>
/*functions*/ /*functions*/
void OsdSetTitle(char *s,int arrow); // arrow > 0 = display right arrow in bottom right, < 0 = display left arrow void OsdSetTitle(char *s,int arrow); // arrow > 0 = display right arrow in bottom right, < 0 = display left arrow
void OsdWrite(unsigned char n, char *s, unsigned char inver, unsigned char stipple); void OsdWrite(unsigned char n, char *s, unsigned char inver, unsigned char stipple);
@ -133,6 +135,10 @@ unsigned char OsdKeyGet();
void OsdJoySet(unsigned char); void OsdJoySet(unsigned char);
unsigned char OsdJoyGet(); unsigned char OsdJoyGet();
void OsdUsbJoySet(uint8_t usbjoy, uint8_t usbextra);
uint8_t OsdUsbJoyGet();
uint8_t OsdUsbJoyGetExtra();
void OsdUsbIdSet(unsigned int vid, unsigned int pid); void OsdUsbIdSet(unsigned int vid, unsigned int pid);
unsigned int OsdUsbVidGet(); unsigned int OsdUsbVidGet();
unsigned int OsdUsbPidGet(); unsigned int OsdUsbPidGet();

View File

@ -734,10 +734,10 @@ static void usb_process_iface (usb_hid_iface_info_t *iface,
jmap |= btn << JOY_BTN_SHIFT; // add buttons jmap |= btn << JOY_BTN_SHIFT; // add buttons
// report joystick 1 to OSD // report joystick 1 to OSD
if ( iface->jindex==0) if ( iface->jindex==0) {
OsdUsbIdSet( conf->joystick_mouse.vid, conf->joystick_mouse.pid ); OsdUsbIdSet( conf->joystick_mouse.vid, conf->joystick_mouse.pid );
OsdUsbJoySet( jmap, btn_extra );
}
// map virtual joypad // map virtual joypad
uint16_t vjoy = jmap; uint16_t vjoy = jmap;
vjoy |= btn_extra << 8; vjoy |= btn_extra << 8;