From 7d5787601423329ba1a767b30dc5bc4f57e088c4 Mon Sep 17 00:00:00 2001 From: harbaum Date: Mon, 17 Feb 2014 14:18:00 +0000 Subject: [PATCH] Introduced 8 bit mode --- Makefile | 1 + keycodes.h | 30 ------------------- osd.c | 86 ------------------------------------------------------ user_io.c | 47 ++++++++++++++++++++++++----- user_io.h | 9 +++--- 5 files changed, 45 insertions(+), 128 deletions(-) diff --git a/Makefile b/Makefile index 5b9217e..a16af8e 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ TODAY = `date +"%m/%d/%y"` PRJ = firmware SRC = Cstartup_SAM7.c fat.c fdd.c firmware.c fpga.c hardware.c hdd.c main.c menu.c mmc.c osd.c syscalls.c user_io.c boot_print.c boot_logo.c rafile.c config.c tos.c ikbd.c SRC += usb/max3421e.c usb/usb.c usb/hub.c usb/hid.c usb/timer.c +SRC += cdc_enumerate.c cdc_control.c OBJ = $(SRC:.c=.o) DEP = $(SRC:.c=.d) diff --git a/keycodes.h b/keycodes.h index 4436542..a2dc1ad 100644 --- a/keycodes.h +++ b/keycodes.h @@ -262,33 +262,3 @@ const unsigned short usb2atari[] = { MISS // 6f: F20 }; -#if 0 - // #define KEY_UPSTROKE 0x80 -#define KEY_MENU 0x69 -#define KEY_PGUP 0x6C -#define KEY_PGDN 0x6D -#define KEY_HOME 0x6A -#define KEY_ESC 0x45 -#define KEY_ENTER 0x44 -#define KEY_BACK 0x41 -#define KEY_SPACE 0x40 -#define KEY_UP 0x4C -#define KEY_DOWN 0x4D -#define KEY_LEFT 0x4F -#define KEY_RIGHT 0x4E -#define KEY_F1 0x50 -#define KEY_F2 0x51 -#define KEY_F3 0x52 -#define KEY_F4 0x53 -#define KEY_F5 0x54 -#define KEY_F6 0x55 -#define KEY_F7 0x56 -#define KEY_F8 0x57 -#define KEY_F9 0x58 -#define KEY_F10 0x59 -#define KEY_CTRL 0x63 -#define KEY_LALT 0x64 -#define KEY_KPPLUS 0x5E -#define KEY_KPMINUS 0x4A -#define KEY_KP0 0x0F -#endif diff --git a/osd.c b/osd.c index 19568bc..1395807 100644 --- a/osd.c +++ b/osd.c @@ -453,92 +453,6 @@ void OsdDrawLogo(unsigned char n, char row,char superimpose) } -void OsdWriteDoubleSize(unsigned char n, char *s, unsigned char pass) -{ - unsigned short i; - unsigned char b; - const unsigned char *p; - int linelimit=OSDLINELEN; - - // select OSD SPI device - EnableOsd(); - - // select buffer and line to write to - SPI(OSDCMDWRITE | n); - - i = 0; - // send all characters in string to OSD - while (1) - { - if(i==0) // Render sidestripe - { - p = &titlebuffer[(7-n)*8]; - SPI(0xff); - SPI(0xff); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(255^*p); SPI(255^*p++); - SPI(0xff); - SPI(0xff); - SPI(0x00); - SPI(0x00); - i += 22; - } - else - { - b = *s++; - - if (b == 0) // end of string - break; - - else if(i<(linelimit-16)) // normal character - { - int c; - p = &charfont[b][0]; - if(pass) // Draw the bottom half.. - { - int j; - for(j=0;j<8;++j) - { - c=*p++; - c=(c&0xf0)>>4; - c=(c&0x08)<<1 | c; // ....ABCD => ...AABCD - c=(c&0x1c)<<1 | (c & 0x07); // ...AABCD => ..AABBCD - c=(c&0x3e)<<1 | (c & 0x03); // ..AABBCD => .AABBCCD - c=c<<1 | (c&0x01); // .AABBCCD => AABBCCDD - SPI(c); SPI(c); - } - } - else // Draw the top half... - { - int j; - for(j=0;j<8;++j) - { - c=*p++; - c=c&0xf; - c=(c&0x08)<<1 | c; // ....ABCD => ...AABCD - c=(c&0x1c)<<1 | (c & 0x07); // ...AABCD => ..AABBCD - c=(c&0x3e)<<1 | (c & 0x03); // ..AABBCD => .AABBCCD - c=c<<1 | (c&0x01); // .AABBCCD => AABBCCDD - SPI(c); SPI(c); - } - } - i += 16; - } - } - } - for (; i < linelimit; i++) // clear end of line - SPI(0); - - // deselect OSD SPI device - DisableOsd(); -} - // write a null-terminated string to the OSD buffer starting at line void OSD_PrintText(unsigned char line, char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert) { diff --git a/user_io.c b/user_io.c index 61a42b9..c363de6 100644 --- a/user_io.c +++ b/user_io.c @@ -25,6 +25,9 @@ AT91PS_PMC a_pPMC = AT91C_BASE_PMC; static char caps_lock_toggle = 0; +// a 128 bit (16 bytes) bitmap containing a single bit for every possible key +static unsigned char keymap[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + static void PollOneAdc() { static unsigned char adc_cnt = 0xff; @@ -101,7 +104,8 @@ void user_io_detect_core_type() { if((core_type != CORE_TYPE_DUMB) && (core_type != CORE_TYPE_MINIMIG) && (core_type != CORE_TYPE_PACE) && - (core_type != CORE_TYPE_MIST)) + (core_type != CORE_TYPE_MIST) && + (core_type != CORE_TYPE_8BIT)) core_type = CORE_TYPE_UNKNOWN; switch(core_type) { @@ -124,17 +128,25 @@ void user_io_detect_core_type() { case CORE_TYPE_MIST: puts("Identified MiST core"); break; + + case CORE_TYPE_8BIT: + puts("Identified 8BIT core"); + break; } } void user_io_joystick(unsigned char joystick, unsigned char map) { - if(core_type == CORE_TYPE_MINIMIG || core_type == CORE_TYPE_PACE) { + // most cores process joystick events themselves + if((core_type == CORE_TYPE_MINIMIG) || + (core_type == CORE_TYPE_PACE) || + (core_type == CORE_TYPE_8BIT)) { EnableIO(); SPI(UIO_JOYSTICK0 + joystick); SPI(map); DisableIO(); } + // atari ST handles joystick through the ikbd emulated by the io controller if(core_type == CORE_TYPE_MIST) ikbd_joystick(joystick, map); } @@ -149,7 +161,8 @@ void user_io_serial_tx(char chr) { void user_io_poll() { if((core_type != CORE_TYPE_MINIMIG) && (core_type != CORE_TYPE_PACE) && - (core_type != CORE_TYPE_MIST)) { + (core_type != CORE_TYPE_MIST) && + (core_type != CORE_TYPE_8BIT)) { return; // no user io for the installed core } @@ -157,7 +170,7 @@ void user_io_poll() { ikbd_poll(); #if 1 - // check for inout data on usart + // check for input data on usart USART_Poll(); unsigned char c = 0; @@ -281,6 +294,20 @@ static void send_keycode(unsigned short code) { if(core_type == CORE_TYPE_MIST) ikbd_keyboard(code); + + if(core_type == CORE_TYPE_8BIT) { + char i; + unsigned char idx = (code>>3)&15; // keymap byte index 0..15 + unsigned char bit = 1 << (code & 7); // keymap bit index 0..7 + if(code & 0x80) keymap[idx] &= ~bit; + else keymap[idx] |= bit; + + // send 128 bit keymap on every key event + EnableIO(); + SPI(UIO_KEYBOARD); + for(i=0;i<16;i++) SPI(keymap[i]); + DisableIO(); + } } void user_io_mouse(unsigned char b, char x, char y) { @@ -322,7 +349,10 @@ unsigned short keycode(unsigned char in) { if(core_type == CORE_TYPE_MINIMIG) return usb2ami[in]; - if(core_type == CORE_TYPE_MIST) + // atari st and the 8 bit core (currently only used for atari 800) + // use the same key codes + if((core_type == CORE_TYPE_MIST) || + (core_type == CORE_TYPE_8BIT)) return usb2atari[in]; return MISS; @@ -347,7 +377,7 @@ unsigned char modifier_keycode(unsigned char index) { return amiga_modifier[index]; } - if(core_type == CORE_TYPE_MIST) { + if((core_type == CORE_TYPE_MIST)||(core_type == CORE_TYPE_8BIT)) { static const unsigned char atari_modifier[] = { 0x1d, 0x2a, 0x38, MISS, 0x1d, 0x36, 0x38, MISS }; return atari_modifier[index]; @@ -374,12 +404,13 @@ static char key_used_by_osd(unsigned short s) { // in atari mode eat all keys if the OSD is online, // else none as it's up to the core to forward keys // to the OSD - return (core_type == CORE_TYPE_MIST); + return(core_type == CORE_TYPE_MIST); } void user_io_kbd(unsigned char m, unsigned char *k) { if((core_type == CORE_TYPE_MINIMIG) || - (core_type == CORE_TYPE_MIST)) { + (core_type == CORE_TYPE_MIST) || + (core_type == CORE_TYPE_8BIT)) { static unsigned char modifier = 0, pressed[6] = { 0,0,0,0,0,0 }; int i, j; diff --git a/user_io.h b/user_io.h index 0a12a7b..941a7c9 100644 --- a/user_io.h +++ b/user_io.h @@ -37,10 +37,11 @@ // core type value should be unlikely to be returned by broken cores #define CORE_TYPE_UNKNOWN 0x55 -#define CORE_TYPE_DUMB 0xa0 -#define CORE_TYPE_MINIMIG 0xa1 -#define CORE_TYPE_PACE 0xa2 -#define CORE_TYPE_MIST 0xa3 +#define CORE_TYPE_DUMB 0xa0 // core without any io controller interaction +#define CORE_TYPE_MINIMIG 0xa1 // minimig amiga core +#define CORE_TYPE_PACE 0xa2 // core from pacedev.net (joystick only) +#define CORE_TYPE_MIST 0xa3 // mist atari st core +#define CORE_TYPE_8BIT 0xa4 // atari 800/c64 like core void user_io_init(); void user_io_detect_core_type();