adapted keyboard layout for picomputer
This commit is contained in:
parent
2e8ec725aa
commit
feb2b6d7fa
39 changed files with 953 additions and 459 deletions
BIN
MCUME_pico/.DS_Store
vendored
Normal file
BIN
MCUME_pico/.DS_Store
vendored
Normal file
Binary file not shown.
|
|
@ -280,10 +280,10 @@ target_link_libraries(mcume pico_multicore
|
||||||
IF (NOT DEFINED N_SD_CARDS)
|
IF (NOT DEFINED N_SD_CARDS)
|
||||||
SET(N_SD_CARDS 1)
|
SET(N_SD_CARDS 1)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
target_compile_definitions(mcume PUBLIC DEBUG N_SD_CARDS=${N_SD_CARDS})
|
target_compile_definitions(mcume PUBLIC N_SD_CARDS=${N_SD_CARDS})
|
||||||
|
|
||||||
|
|
||||||
#pico_enable_stdio_uart(mcume 0)
|
pico_enable_stdio_uart(mcume 0)
|
||||||
pico_enable_stdio_usb(mcume 1)
|
pico_enable_stdio_usb(mcume 0)
|
||||||
|
|
||||||
pico_add_extra_outputs(mcume)
|
pico_add_extra_outputs(mcume)
|
||||||
|
|
|
||||||
BIN
MCUME_pico/bin/PICOMPUTER/.DS_Store
vendored
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -500,7 +500,7 @@ void at5_Step(void)
|
||||||
else which=&cont1;
|
else which=&cont1;
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
if (j & MASK_KEY_USER1)
|
if (j & MASK_KEY_USER2)
|
||||||
which->key[12] = 1;
|
which->key[12] = 1;
|
||||||
else
|
else
|
||||||
which->key[12] = 0;
|
which->key[12] = 0;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -205,7 +204,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -278,10 +277,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -291,20 +289,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -322,8 +311,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -348,9 +346,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -359,10 +354,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,6 +367,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -440,31 +444,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -480,9 +508,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ const unsigned short key_map2[] = {
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
BIN
MCUME_pico/pico64/.DS_Store
vendored
Normal file
BIN
MCUME_pico/pico64/.DS_Store
vendored
Normal file
Binary file not shown.
|
|
@ -161,7 +161,7 @@ uint8_t cia1PORTA(void) {
|
||||||
|
|
||||||
v = ~cpu.cia1.R[0x02] | (cpu.cia1.R[0x00] & cpu.cia1.R[0x02]);
|
v = ~cpu.cia1.R[0x02] | (cpu.cia1.R[0x00] & cpu.cia1.R[0x02]);
|
||||||
int keys = 0;
|
int keys = 0;
|
||||||
if (!oskbActive) keys = emu_ReadKeys();
|
if (!oskbActive) keys = emu_GetPad();
|
||||||
if (!cpu.swapJoysticks) {
|
if (!cpu.swapJoysticks) {
|
||||||
if (keys & MASK_JOY2_BTN) v &= 0xEF;
|
if (keys & MASK_JOY2_BTN) v &= 0xEF;
|
||||||
if (keys & MASK_JOY2_UP) v &= 0xFE;
|
if (keys & MASK_JOY2_UP) v &= 0xFE;
|
||||||
|
|
@ -210,7 +210,7 @@ uint8_t cia1PORTB(void) {
|
||||||
|
|
||||||
v = ~cpu.cia1.R[0x03] | (cpu.cia1.R[0x00] & cpu.cia1.R[0x02]) ;
|
v = ~cpu.cia1.R[0x03] | (cpu.cia1.R[0x00] & cpu.cia1.R[0x02]) ;
|
||||||
int keys = 0;
|
int keys = 0;
|
||||||
if (!oskbActive) keys = emu_ReadKeys();
|
if (!oskbActive) keys = emu_GetPad();
|
||||||
if (!cpu.swapJoysticks) {
|
if (!cpu.swapJoysticks) {
|
||||||
if (keys & MASK_JOY1_BTN) v &= 0xEF;
|
if (keys & MASK_JOY1_BTN) v &= 0xEF;
|
||||||
if (keys & MASK_JOY1_UP) v &= 0xFE;
|
if (keys & MASK_JOY1_UP) v &= 0xFE;
|
||||||
|
|
@ -301,6 +301,7 @@ int emu_oskbActive(void) {
|
||||||
return (oskbActive?1:0);
|
return (oskbActive?1:0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PICOMPUTER
|
||||||
void emu_DrawVsync(void)
|
void emu_DrawVsync(void)
|
||||||
{
|
{
|
||||||
char sel[2]={0,0};
|
char sel[2]={0,0};
|
||||||
|
|
@ -314,11 +315,51 @@ void emu_DrawVsync(void)
|
||||||
}
|
}
|
||||||
//skip += 1;
|
//skip += 1;
|
||||||
//skip &= VID_FRAME_SKIP;
|
//skip &= VID_FRAME_SKIP;
|
||||||
//tft.waitSync();
|
#ifdef USE_VGA
|
||||||
|
tft.waitSync();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define DEBUG 1
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
static const char * digits = "0123456789ABCDEF";
|
||||||
|
static char buf[5] = {0,0,0,0,0};
|
||||||
|
#endif
|
||||||
|
|
||||||
void c64_Input(int bClick) {
|
void c64_Input(int bClick) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
/*
|
||||||
|
buf[2] = 0;
|
||||||
|
int key = emu_ReadI2CKeyboard2(0);
|
||||||
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
|
buf[1] = digits[key&0xf];
|
||||||
|
tft.drawText(4*8,16*4,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
key = emu_ReadI2CKeyboard2(1);
|
||||||
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
|
buf[1] = digits[key&0xf];
|
||||||
|
tft.drawText(4*8,16*5,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
key = emu_ReadI2CKeyboard2(2);
|
||||||
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
|
buf[1] = digits[key&0xf];
|
||||||
|
tft.drawText(4*8,16*6,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
key = emu_ReadI2CKeyboard2(3);
|
||||||
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
|
buf[1] = digits[key&0xf];
|
||||||
|
tft.drawText(4*8,16*7,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
key = emu_ReadI2CKeyboard2(4);
|
||||||
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
|
buf[1] = digits[key&0xf];
|
||||||
|
tft.drawText(4*8,16*8,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
key = emu_ReadI2CKeyboard2(5);
|
||||||
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
|
buf[1] = digits[key&0xf];
|
||||||
|
tft.drawText(4*8,16*9,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PICOMPUTER
|
||||||
if (oskbActive) {
|
if (oskbActive) {
|
||||||
if (bClick & MASK_JOY2_BTN) {
|
if (bClick & MASK_JOY2_BTN) {
|
||||||
if (oskbXPos == 10) textkey[0] = 13;
|
if (oskbXPos == 10) textkey[0] = 13;
|
||||||
|
|
@ -334,8 +375,9 @@ void c64_Input(int bClick) {
|
||||||
if (bClick & MASK_JOY2_UP) oskbYPos = 0;
|
if (bClick & MASK_JOY2_UP) oskbYPos = 0;
|
||||||
if (bClick & MASK_JOY2_DOWN) oskbYPos = 1;
|
if (bClick & MASK_JOY2_DOWN) oskbYPos = 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (nbkeys == 0) {
|
if (nbkeys == 0) {
|
||||||
|
#ifndef PICOMPUTER
|
||||||
if (bClick & MASK_KEY_USER2) {
|
if (bClick & MASK_KEY_USER2) {
|
||||||
if (!oskbActive) {
|
if (!oskbActive) {
|
||||||
oskbActive = true;
|
oskbActive = true;
|
||||||
|
|
@ -344,7 +386,9 @@ void c64_Input(int bClick) {
|
||||||
oskbActive = false;
|
oskbActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bClick & MASK_KEY_USER1) {
|
else
|
||||||
|
#endif
|
||||||
|
if (bClick & MASK_KEY_USER1) {
|
||||||
if (firsttime) {
|
if (firsttime) {
|
||||||
firsttime = false;
|
firsttime = false;
|
||||||
textseq = textload;
|
textseq = textload;
|
||||||
|
|
@ -359,6 +403,13 @@ void c64_Input(int bClick) {
|
||||||
{
|
{
|
||||||
int hk = emu_ReadI2CKeyboard();
|
int hk = emu_ReadI2CKeyboard();
|
||||||
if ( (hk != 0) && (res == false) ) {
|
if ( (hk != 0) && (res == false) ) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
buf[3] = 0;
|
||||||
|
buf[0] = digits[(hk>>8)&0xf];
|
||||||
|
buf[1] = digits[(hk>>4)&0xf];
|
||||||
|
buf[2] = digits[hk&0xf];
|
||||||
|
tft.drawText(0,0,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
|
#endif
|
||||||
setKey(ascii2scan[hk],true);
|
setKey(ascii2scan[hk],true);
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -203,7 +202,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -276,10 +275,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -289,20 +287,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -320,8 +309,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -346,9 +344,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -357,10 +352,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -368,6 +365,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -438,31 +442,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -478,9 +506,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,23 +31,32 @@
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
|
||||||
const unsigned short key_map1[] = {
|
const unsigned short key_map1[] = {
|
||||||
'Q','W','E','R','T','Y','U','I','O','P','0',
|
'Q','W','E','R','T','Y','U','I','O','P',157,
|
||||||
0,'A','S','D','F','G','H','J','K','L',0xD,
|
0,'A','S','D','F','G','H','J','K','L',0x0D,
|
||||||
0,'Z','X','C','V','B','N','M',',',' ',
|
0,'Z','X','C','V','B','N','M',',',' ',
|
||||||
0,0,0,0
|
145,157,29,17
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned short key_map2[] = {
|
const unsigned short key_map2[] = {
|
||||||
'1','2','3','4','5','6','7','8','9','0',0,
|
'1','2','3','4','5','6','7','8','9','0',0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,
|
0, '"','$',',','.','!','+','-','/','*','%',
|
||||||
|
0, 0,0,0,0,133,134,135,136,139, // not usable except last ones F1,F2,F3,F4,F7
|
||||||
|
0,0,0,0
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
const unsigned short key_map3[] = {
|
||||||
|
133,134,135,136,137,138,139,140,0,0,0, // function keys
|
||||||
|
0, 0,0,0,0,0,0,0,0,0,0,
|
||||||
0, 0,0,0,0,0,0,0,0,0,
|
0, 0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0
|
0,0,0,0
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -110,6 +119,7 @@ extern int emu_GetPad(void);
|
||||||
extern int emu_ReadAnalogJoyX(int min, int max);
|
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||||
extern int emu_ReadI2CKeyboard(void);
|
extern int emu_ReadI2CKeyboard(void);
|
||||||
|
extern unsigned char emu_ReadI2CKeyboard2(int row);
|
||||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||||
extern int emu_oskbActive(void);
|
extern int emu_oskbActive(void);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ int main(void) {
|
||||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||||
tft.startDMA();
|
tft.startDMA();
|
||||||
struct repeating_timer timer;
|
struct repeating_timer timer;
|
||||||
add_repeating_timer_ms(50, repeating_timer_callback, NULL, &timer);
|
add_repeating_timer_ms(25, repeating_timer_callback, NULL, &timer);
|
||||||
}
|
}
|
||||||
tft.waitSync();
|
tft.waitSync();
|
||||||
}
|
}
|
||||||
|
|
@ -86,12 +86,14 @@ void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void emu_DrawVsync(void)
|
#ifdef PICOMPUTER
|
||||||
//{
|
void emu_DrawVsync(void)
|
||||||
// skip += 1;
|
{
|
||||||
// skip &= VID_FRAME_SKIP;
|
skip += 1;
|
||||||
// //tft.waitSync();
|
skip &= VID_FRAME_SKIP;
|
||||||
//}
|
//tft.waitSync();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +110,7 @@ void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||||
{
|
{
|
||||||
if (skip == 0) {
|
if (skip == 0) {
|
||||||
#ifdef USE_VGA
|
#ifdef USE_VGA
|
||||||
tft.writeLine(width,height,line, VBuf);
|
tft.writeLine(width,height,line, VBuf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,6 +120,8 @@ void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||||
if (skip == 0) {
|
if (skip == 0) {
|
||||||
#ifdef USE_VGA
|
#ifdef USE_VGA
|
||||||
tft.writeLine16(width,height,line, VBuf);
|
tft.writeLine16(width,height,line, VBuf);
|
||||||
|
#else
|
||||||
|
tft.writeLine(width,height,line, VBuf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
MCUME_pico/pico64/reSID/.DS_Store
vendored
Normal file
BIN
MCUME_pico/pico64/reSID/.DS_Store
vendored
Normal file
Binary file not shown.
|
|
@ -1275,7 +1275,7 @@ typedef void (*modes_t)( tpixel *p, const tpixel *pe, uint16_t *spl, const uint1
|
||||||
const modes_t modes[8] = {mode0, mode1, mode2, mode3, mode4, mode5, mode6, mode7};
|
const modes_t modes[8] = {mode0, mode1, mode2, mode3, mode4, mode5, mode6, mode7};
|
||||||
|
|
||||||
|
|
||||||
//static tpixel linebuffer[SCREEN_WIDTH];
|
static tpixel linebuffer[SCREEN_WIDTH];
|
||||||
|
|
||||||
void vic_do(void) {
|
void vic_do(void) {
|
||||||
|
|
||||||
|
|
@ -1396,9 +1396,11 @@ void vic_do(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//max_x = (!cpu.vic.CSEL) ? 40:38;
|
//max_x = (!cpu.vic.CSEL) ? 40:38;
|
||||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH;
|
#ifdef USE_VGA
|
||||||
//p = &linebuffer[0]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
|
||||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE));
|
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE));
|
||||||
|
#else
|
||||||
|
p = &linebuffer[0];
|
||||||
|
#endif
|
||||||
pe = p + SCREEN_WIDTH;
|
pe = p + SCREEN_WIDTH;
|
||||||
//Left Screenborder: Cycle 10
|
//Left Screenborder: Cycle 10
|
||||||
spl = &cpu.vic.spriteLine[24];
|
spl = &cpu.vic.spriteLine[24];
|
||||||
|
|
@ -1561,10 +1563,11 @@ g-Zugriff
|
||||||
if (!cpu.vic.CSEL) {
|
if (!cpu.vic.CSEL) {
|
||||||
cpu_clock(1);
|
cpu_clock(1);
|
||||||
uint16_t col = cpu.vic.colors[0];
|
uint16_t col = cpu.vic.colors[0];
|
||||||
//p = &screen[r - FIRSTDISPLAYLINE][0];
|
#ifdef USE_VGA
|
||||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + BORDER_LEFT;
|
|
||||||
//p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
|
||||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + BORDER_LEFT;
|
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + BORDER_LEFT;
|
||||||
|
#else
|
||||||
|
p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
||||||
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
// Sprites im Rand
|
// Sprites im Rand
|
||||||
uint16_t sprite;
|
uint16_t sprite;
|
||||||
|
|
@ -1586,11 +1589,12 @@ g-Zugriff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Rand rechts:
|
//Rand rechts:
|
||||||
//p = &screen[r - FIRSTDISPLAYLINE][SCREEN_WIDTH - 9];
|
#ifdef USE_VGA
|
||||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||||
//p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
#else
|
||||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||||
pe = p + 9;
|
#endif
|
||||||
|
pe = p + 9;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Sprites im Rand
|
// Sprites im Rand
|
||||||
|
|
@ -1609,7 +1613,14 @@ g-Zugriff
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
#ifdef USE_VGA
|
||||||
|
//emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
||||||
|
#else
|
||||||
|
emu_DrawLine16(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
||||||
|
//memset(&linebuffer[0],0,320*2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Rechter Rand nach CSEL, im Textbereich
|
//Rechter Rand nach CSEL, im Textbereich
|
||||||
|
|
|
||||||
|
|
@ -288,13 +288,13 @@ void at8_Step(void)
|
||||||
else which=&cont1;
|
else which=&cont1;
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
if (j & MASK_KEY_USER1)
|
if (j & MASK_KEY_USER2)
|
||||||
INPUT_key_consol &= ~0x01;
|
INPUT_key_consol &= ~0x01;
|
||||||
else
|
else
|
||||||
INPUT_key_consol |= 0x01;
|
INPUT_key_consol |= 0x01;
|
||||||
|
|
||||||
// Select
|
// Select
|
||||||
if (j & MASK_KEY_USER2)
|
if (j & MASK_KEY_USER1)
|
||||||
INPUT_key_consol &= ~0x02;
|
INPUT_key_consol &= ~0x02;
|
||||||
else
|
else
|
||||||
INPUT_key_consol |= 0x02;
|
INPUT_key_consol |= 0x02;
|
||||||
|
|
@ -308,7 +308,10 @@ void at8_Step(void)
|
||||||
if (k != 0) {
|
if (k != 0) {
|
||||||
INPUT_key_code = k-1;
|
INPUT_key_code = k-1;
|
||||||
}
|
}
|
||||||
else if (hk != 0) {
|
else {
|
||||||
|
INPUT_key_code = AKEY_NONE;
|
||||||
|
}
|
||||||
|
if (hk != 0) {
|
||||||
INPUT_key_code = hk-1;
|
INPUT_key_code = hk-1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -138,7 +137,6 @@ void emu_Free(void * pt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_ReadAnalogJoyX(int min, int max)
|
int emu_ReadAnalogJoyX(int min, int max)
|
||||||
{
|
{
|
||||||
adc_select_input(0);
|
adc_select_input(0);
|
||||||
|
|
@ -204,7 +202,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -277,10 +275,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -290,20 +287,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -321,8 +309,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -347,9 +344,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -358,10 +352,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -369,6 +365,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -439,31 +442,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -479,9 +506,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,17 +42,17 @@ const unsigned short key_map1[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned short key_map2[] = {
|
const unsigned short key_map2[] = {
|
||||||
0x1F+1,0x1F ,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x34+1, // Digits
|
0x1F+1,0x1F,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x34+1, // Digits
|
||||||
0x2C+1,0x07+1,0x22+1,0x26+1,0x02+1,0x06+1,0x36+1,0x37+1,0x0F+1,0x0E + 1,0x06+1, // various
|
0x2C+1,0x07+1,0x22+1,0x26+1,0x02+1,0x06+1,0x36+1,0x37+1,0x0F+1,0x0E + 1,0x06+1, // various
|
||||||
//0x07+1=*, 0x22+1=.,0x26+1=/, 0x02+1=;, 0x06+1=+, 0x36+1=<, 0x37+1=>, 0x0F+1==, 0x0E+1=-, 0x06+1=+
|
//0x07+1=*, 0x22+1=.,0x26+1=/, 0x02+1=;, 0x06+1=+, 0x36+1=<, 0x37+1=>, 0x0F+1==, 0x0E+1=-, 0x06+1=+
|
||||||
0, 0,0,0,0,0,0,0,0,0,
|
0, 0,0,0,0,0,3,4,19,20,
|
||||||
0,0,0,0
|
0,0,0,0
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,26 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
TFT_T_DMA tft;
|
TFT_T_DMA tft;
|
||||||
|
|
||||||
|
volatile bool vbl=true;
|
||||||
static int skip=0;
|
static int skip=0;
|
||||||
|
|
||||||
|
bool repeating_timer_callback(struct repeating_timer *t) {
|
||||||
|
if (vbl) {
|
||||||
|
vbl = false;
|
||||||
|
} else {
|
||||||
|
vbl = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// vreg_set_voltage(VREG_VOLTAGE_1_05);
|
vreg_set_voltage(VREG_VOLTAGE_1_05);
|
||||||
// set_sys_clock_khz(125000, true);
|
// set_sys_clock_khz(125000, true);
|
||||||
// set_sys_clock_khz(150000, true);
|
// set_sys_clock_khz(150000, true);
|
||||||
// set_sys_clock_khz(133000, true);
|
// set_sys_clock_khz(133000, true);
|
||||||
// set_sys_clock_khz(200000, true);
|
// set_sys_clock_khz(200000, true);
|
||||||
// set_sys_clock_khz(225000, true);
|
// set_sys_clock_khz(225000, true);
|
||||||
// set_sys_clock_khz(250000, true);
|
set_sys_clock_khz(250000, true);
|
||||||
|
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
#ifdef USE_VGA
|
#ifdef USE_VGA
|
||||||
|
|
@ -51,7 +61,9 @@ int main(void) {
|
||||||
emu_start();
|
emu_start();
|
||||||
emu_Init(filename);
|
emu_Init(filename);
|
||||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||||
tft.startDMA();
|
tft.startDMA();
|
||||||
|
struct repeating_timer timer;
|
||||||
|
add_repeating_timer_ms(15, repeating_timer_callback, NULL, &timer);
|
||||||
}
|
}
|
||||||
tft.waitSync();
|
tft.waitSync();
|
||||||
}
|
}
|
||||||
|
|
@ -82,9 +94,14 @@ void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int
|
||||||
|
|
||||||
void emu_DrawVsync(void)
|
void emu_DrawVsync(void)
|
||||||
{
|
{
|
||||||
|
volatile bool vb=vbl;
|
||||||
skip += 1;
|
skip += 1;
|
||||||
skip &= VID_FRAME_SKIP;
|
skip &= VID_FRAME_SKIP;
|
||||||
|
#ifdef USE_VGA
|
||||||
//tft.waitSync();
|
//tft.waitSync();
|
||||||
|
#else
|
||||||
|
//while (vbl==vb) {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -137,9 +136,6 @@ void emu_Free(void * pt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_ReadAnalogJoyX(int min, int max)
|
int emu_ReadAnalogJoyX(int min, int max)
|
||||||
{
|
{
|
||||||
adc_select_input(0);
|
adc_select_input(0);
|
||||||
|
|
@ -205,7 +201,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -278,10 +274,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -291,20 +286,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -322,8 +308,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -348,9 +343,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -359,10 +351,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,6 +364,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -440,31 +441,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -480,8 +505,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const unsigned short key_map1[] = {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const unsigned short key_map1[] = {
|
const unsigned short key_map1[] = {
|
||||||
20,26,8,21,23,28,25,12,18,19,'0',
|
20,26,8,21,23,28,25,12,18,19,0,
|
||||||
0, 4, 9, 7,22, 4,11,13,14,15,40,
|
0, 4, 9, 7,22, 4,11,13,14,15,40,
|
||||||
0,6,27,29,224,5,17,16,225,44,
|
0,6,27,29,224,5,17,16,225,44,
|
||||||
0,0,0,0
|
0,0,0,0
|
||||||
|
|
@ -54,7 +54,7 @@ const unsigned short key_map2[] = {
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,7 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
static int keyMap;
|
static int keyMap;
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -203,7 +202,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -276,10 +275,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -289,20 +287,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -320,8 +309,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -346,9 +344,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -357,10 +352,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -368,6 +365,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -438,31 +442,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -478,9 +506,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ const unsigned short key_map2[] = {
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,14 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
||||||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
|
||||||
static bool i2cKeyboardPresent = false;
|
|
||||||
static unsigned short * keys;
|
|
||||||
static int keyMap;
|
static int keyMap;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
static int keypadval=0;
|
static unsigned short * keys;
|
||||||
|
static unsigned char keymatrix[6];
|
||||||
|
static int keymatrix_hitrow=-1;
|
||||||
|
static bool key_fn=false;
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -138,16 +141,10 @@ void emu_Free(void * pt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_ReadAnalogJoyX(int min, int max)
|
int emu_ReadAnalogJoyX(int min, int max)
|
||||||
{
|
{
|
||||||
#ifdef PIN_JOY2_A1X
|
|
||||||
adc_select_input(0);
|
adc_select_input(0);
|
||||||
int val = adc_read();
|
int val = adc_read();
|
||||||
#else
|
|
||||||
int val = 0;
|
|
||||||
#endif
|
|
||||||
#if INVX
|
#if INVX
|
||||||
val = 4095 - val;
|
val = 4095 - val;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -160,12 +157,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
||||||
|
|
||||||
int emu_ReadAnalogJoyY(int min, int max)
|
int emu_ReadAnalogJoyY(int min, int max)
|
||||||
{
|
{
|
||||||
#ifdef PIN_JOY2_A2Y
|
|
||||||
adc_select_input(1);
|
adc_select_input(1);
|
||||||
int val = adc_read();
|
int val = adc_read();
|
||||||
#else
|
|
||||||
int val = 0;
|
|
||||||
#endif
|
|
||||||
#if INVY
|
#if INVY
|
||||||
val = 4095 - val;
|
val = 4095 - val;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -182,7 +175,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
||||||
static uint16_t readAnalogJoystick(void)
|
static uint16_t readAnalogJoystick(void)
|
||||||
{
|
{
|
||||||
uint16_t joysval = 0;
|
uint16_t joysval = 0;
|
||||||
|
#ifdef PIN_JOY2_A1X
|
||||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||||
|
|
@ -190,10 +183,11 @@ static uint16_t readAnalogJoystick(void)
|
||||||
int yReading = emu_ReadAnalogJoyY(0,256);
|
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||||
|
#endif
|
||||||
#ifdef PIN_JOY2_BTN
|
#ifdef PIN_JOY2_BTN
|
||||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (joysval);
|
return (joysval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,7 +206,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -280,6 +274,58 @@ int emu_ReadKeys(void)
|
||||||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
keymatrix_hitrow = -1;
|
||||||
|
unsigned char row;
|
||||||
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
|
gpio_put(cols[i], 0);
|
||||||
|
row=0;
|
||||||
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
row |= (gpio_get(8) ? 0 : 0x02);
|
||||||
|
row |= (gpio_get(6) ? 0 : 0x04);
|
||||||
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
|
gpio_put(cols[i], 1);
|
||||||
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
|
|
||||||
|
keymatrix[i]=row;
|
||||||
|
if (row) keymatrix_hitrow=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
//6,9,15,8,7,22
|
||||||
|
#if INVX
|
||||||
|
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||||
|
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||||
|
#else
|
||||||
|
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||||
|
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||||
|
#endif
|
||||||
|
#if INVY
|
||||||
|
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||||
|
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||||
|
#else
|
||||||
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
||||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||||
|
|
@ -301,10 +347,35 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
|
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
if (key_fn) {
|
||||||
|
keys = (unsigned short *)key_map2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keys = (unsigned short *)key_map1;
|
||||||
|
}
|
||||||
|
if (keymatrix_hitrow >=0 ) {
|
||||||
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
|
if (match == matkeys[i]) {
|
||||||
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -362,8 +433,6 @@ void emu_InitJoysticks(void) {
|
||||||
yRef += adc_read();
|
yRef += adc_read();
|
||||||
sleep_ms(20);
|
sleep_ms(20);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if INVX
|
#if INVX
|
||||||
xRef = 4095 -xRef/10;
|
xRef = 4095 -xRef/10;
|
||||||
#else
|
#else
|
||||||
|
|
@ -373,12 +442,74 @@ void emu_InitJoysticks(void) {
|
||||||
yRef = 4095 -yRef/10;
|
yRef = 4095 -yRef/10;
|
||||||
#else
|
#else
|
||||||
yRef /= 10;
|
yRef /= 10;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
|
gpio_init(1);
|
||||||
|
gpio_init(2);
|
||||||
|
gpio_init(3);
|
||||||
|
gpio_init(4);
|
||||||
|
gpio_init(5);
|
||||||
|
gpio_init(14);
|
||||||
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
|
gpio_put(1, 1);
|
||||||
|
gpio_put(2, 1);
|
||||||
|
gpio_put(3, 1);
|
||||||
|
gpio_put(4, 1);
|
||||||
|
gpio_put(5, 1);
|
||||||
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
|
gpio_set_pulls(6,true,false);
|
||||||
|
gpio_set_dir(6,GPIO_IN);
|
||||||
|
gpio_set_pulls(9,true,false);
|
||||||
|
gpio_set_dir(9,GPIO_IN);
|
||||||
|
gpio_set_pulls(15,true,false);
|
||||||
|
gpio_set_dir(15,GPIO_IN);
|
||||||
|
gpio_set_pulls(8,true,false);
|
||||||
|
gpio_set_dir(8,GPIO_IN);
|
||||||
|
gpio_set_pulls(7,true,false);
|
||||||
|
gpio_set_dir(7,GPIO_IN);
|
||||||
|
gpio_set_pulls(22,true,false);
|
||||||
|
gpio_set_dir(22,GPIO_IN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -800,7 +931,6 @@ void emu_init(void)
|
||||||
|
|
||||||
void emu_start(void)
|
void emu_start(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
usbnavpad = 0;
|
usbnavpad = 0;
|
||||||
|
|
||||||
keys = (unsigned short *)key_map1;
|
keys = (unsigned short *)key_map1;
|
||||||
|
|
|
||||||
|
|
@ -27,37 +27,34 @@
|
||||||
#define ACTION_RUNTFT 129
|
#define ACTION_RUNTFT 129
|
||||||
#define ACTION_RUNVGA 130
|
#define ACTION_RUNVGA 130
|
||||||
|
|
||||||
|
|
||||||
#ifdef KEYMAP_PRESENT
|
#ifdef KEYMAP_PRESENT
|
||||||
|
#ifdef PICOMPUTER
|
||||||
#define TAREA_W_DEF 32
|
|
||||||
#define TAREA_H_DEF 32
|
|
||||||
#define TAREA_END 255
|
|
||||||
#define TAREA_NEW_ROW 254
|
|
||||||
#define TAREA_NEW_COL 253
|
|
||||||
#define TAREA_XY 252
|
|
||||||
#define TAREA_WH 251
|
|
||||||
|
|
||||||
#define KEYBOARD_X 104
|
|
||||||
#define KEYBOARD_Y 78
|
|
||||||
#define KEYBOARD_KEY_H 30
|
|
||||||
#define KEYBOARD_KEY_W 21
|
|
||||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
|
||||||
|
|
||||||
const unsigned short keysw[] = {
|
|
||||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
|
||||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
|
||||||
TAREA_NEW_ROW,40,40,
|
|
||||||
TAREA_END};
|
|
||||||
|
|
||||||
const unsigned short key_map1[] = {
|
const unsigned short key_map1[] = {
|
||||||
2,3};
|
0,2,3,0,0,0,0,0,0,0, 0,
|
||||||
|
0, 0,0,0,0,0,0,0,0,0,0,
|
||||||
#ifdef HAS_I2CKBD
|
0, 0,0,0,0,0,0,0,0,0, // not usable except last ones
|
||||||
const unsigned short i2ckeys[] = {
|
0,0,0,0
|
||||||
0X0080,0X0008};
|
};
|
||||||
#endif
|
|
||||||
|
const unsigned short key_map2[] = {
|
||||||
|
0,0,0,0,0,0,0,0,0,0, 0,
|
||||||
|
0, 0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0, 0,0,0,0,0,0,0,0,0, // not usable except last ones
|
||||||
|
0,0,0,0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const unsigned short matkeys[] = {
|
||||||
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MASK_JOY2_RIGHT 0x0001
|
#define MASK_JOY2_RIGHT 0x0001
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,7 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
static int keyMap;
|
static int keyMap;
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -201,7 +200,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -274,10 +273,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -287,20 +285,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -318,8 +307,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -344,9 +342,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -355,10 +350,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -366,6 +363,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -436,31 +440,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -476,9 +504,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ const unsigned short key_map2[] = {
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,7 @@ static unsigned char keymatrix[6];
|
||||||
static int keymatrix_hitrow=-1;
|
static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -203,7 +202,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -276,10 +275,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -289,20 +287,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -320,8 +309,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -346,9 +344,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -357,10 +352,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -368,6 +365,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -438,31 +442,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -478,8 +506,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const unsigned short key_map2[] = {
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ void keyjoy(void) {
|
||||||
riotRead[0x280]=(v1 << 4) | v2;
|
riotRead[0x280]=(v1 << 4) | v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int kswitches = 0;
|
||||||
|
|
||||||
void keycons(void) {
|
void keycons(void) {
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
|
|
@ -67,14 +68,42 @@ void keycons(void) {
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
int key = emu_ReadKeys();;
|
int key = emu_ReadKeys();;
|
||||||
int sw = emu_GetPad() & 0xff;
|
int sw = emu_GetPad() & 0xff;
|
||||||
|
int hk = emu_ReadI2CKeyboard();
|
||||||
|
|
||||||
|
kswitches = 0;
|
||||||
|
if (hk == 1) {
|
||||||
|
if (kswitches & 0x01)
|
||||||
|
kswitches &= ~0x01;
|
||||||
|
else
|
||||||
|
kswitches |= 0x01;
|
||||||
|
}
|
||||||
|
else if (hk == 2) {
|
||||||
|
if (kswitches & 0x02)
|
||||||
|
kswitches &= ~0x02;
|
||||||
|
else
|
||||||
|
kswitches |= 0x02;
|
||||||
|
}
|
||||||
|
else if (hk == 3) {
|
||||||
|
if (kswitches & 0x04)
|
||||||
|
kswitches &= ~0x04;
|
||||||
|
else
|
||||||
|
kswitches |= 0x04;
|
||||||
|
}
|
||||||
|
else if (hk == 4) {
|
||||||
|
if (kswitches & 0x08)
|
||||||
|
kswitches &= ~0x08;
|
||||||
|
else
|
||||||
|
kswitches |= 0x08;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// read the keyboard state. The return value (in keys) is a pointer to a
|
// read the keyboard state. The return value (in keys) is a pointer to a
|
||||||
// 256 byte buffer which holds the state of all the keyboard keys. If a
|
// 256 byte buffer which holds the state of all the keyboard keys. If a
|
||||||
// byte's upper bit is set to 1, the key is pressed.
|
// byte's upper bit is set to 1, the key is pressed.
|
||||||
|
|
||||||
riotRead[SWCHB] |= 0x03;
|
riotRead[SWCHB] |= 0x03;
|
||||||
|
|
||||||
if ( (key & MASK_KEY_USER3) | (sw == 2) ) //
|
if ( (key & MASK_KEY_USER3) /*|| (sw == 2)*/ || (kswitches & 0x04) ) //
|
||||||
nOptions_Color = !nOptions_Color;
|
nOptions_Color = !nOptions_Color;
|
||||||
|
|
||||||
if (!nOptions_Color)
|
if (!nOptions_Color)
|
||||||
|
|
@ -83,9 +112,9 @@ void keycons(void) {
|
||||||
riotRead[SWCHB] |= 0x08; /* Color */
|
riotRead[SWCHB] |= 0x08; /* Color */
|
||||||
|
|
||||||
|
|
||||||
if ( (key & MASK_KEY_USER1) | (sw == 4) )
|
if ( (key & MASK_KEY_USER1) /*|| (sw == 4)*/ || (kswitches & 0x02) )
|
||||||
riotRead[SWCHB] &= 0xFE; /* Reset */
|
riotRead[SWCHB] &= 0xFE; /* Reset */
|
||||||
if ( (key & MASK_KEY_USER2) | (sw == 3) )
|
if ( (key & MASK_KEY_USER2) /*|| (sw == 3)*/ || (kswitches & 0x01) )
|
||||||
riotRead[SWCHB] &= 0xFD; /* Select */
|
riotRead[SWCHB] &= 0xFD; /* Select */
|
||||||
|
|
||||||
if (nOptions_P1Diff) riotRead[SWCHB] &= 0xBF; /* P0 amateur */
|
if (nOptions_P1Diff) riotRead[SWCHB] &= 0xBF; /* P0 amateur */
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,7 @@ static int keymatrix_hitrow=-1;
|
||||||
static bool key_fn=false;
|
static bool key_fn=false;
|
||||||
#endif
|
#endif
|
||||||
static int keyMap;
|
static int keyMap;
|
||||||
|
|
||||||
static int keypadval=0;
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
|
|
@ -138,7 +137,6 @@ void emu_Free(void * pt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_ReadAnalogJoyX(int min, int max)
|
int emu_ReadAnalogJoyX(int min, int max)
|
||||||
{
|
{
|
||||||
adc_select_input(0);
|
adc_select_input(0);
|
||||||
|
|
@ -204,7 +202,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -277,10 +275,9 @@ int emu_ReadKeys(void)
|
||||||
unsigned char row;
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -290,20 +287,11 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
gpio_put(cols[i], 1);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
keymatrix[i]=row;
|
||||||
if (row) keymatrix_hitrow=i;
|
if (row) keymatrix_hitrow=i;
|
||||||
gpio_put(cols[i], 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
//6,9,15,8,7,22
|
||||||
|
|
@ -321,8 +309,17 @@ int emu_ReadKeys(void)
|
||||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
#endif
|
#endif
|
||||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN;
|
||||||
|
if ( key_fn ) retval |= MASK_KEY_USER2;
|
||||||
|
if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -347,9 +344,6 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
if ( keymatrix[0] & 0x02 ) {
|
|
||||||
key_fn = true;
|
|
||||||
}
|
|
||||||
if (key_fn) {
|
if (key_fn) {
|
||||||
keys = (unsigned short *)key_map2;
|
keys = (unsigned short *)key_map2;
|
||||||
}
|
}
|
||||||
|
|
@ -358,10 +352,12 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
}
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if ( (match == 0x002 ) ) return 0; // shift or fn
|
||||||
|
if (match < 0x100 ) match = match & ~0x002; // ignore shift key
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
key_fn = false;
|
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
// return (match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -369,6 +365,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -439,31 +442,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -479,7 +506,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
|
||||||
const unsigned short key_map1[] = {
|
const unsigned short key_map1[] = {
|
||||||
1,2,3,4,0,0,0,0,0,0,0,
|
0,1,2,3,4,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0, 0,0,0,0,0,0,0,0,0,
|
0, 0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0
|
0,0,0,0
|
||||||
|
|
@ -45,7 +45,7 @@ const unsigned short key_map2[] = {
|
||||||
const unsigned short matkeys[] = {
|
const unsigned short matkeys[] = {
|
||||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
0x002,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,21 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static unsigned short * keys;
|
|
||||||
static int keyMap;
|
static int keyMap;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
static int keypadval=0;
|
static unsigned short * keys;
|
||||||
|
static unsigned char keymatrix[6];
|
||||||
|
static int keymatrix_hitrow=-1;
|
||||||
|
static bool key_fn=false;
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool joySwapped = false;
|
static bool joySwapped = false;
|
||||||
static uint16_t bLastState;
|
static uint16_t bLastState;
|
||||||
static int xRef;
|
static int xRef;
|
||||||
static int yRef;
|
static int yRef;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
|
||||||
static unsigned char keymatrix[6];
|
|
||||||
static int keymatrix_hitrow = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void emu_printf(char * text)
|
void emu_printf(char * text)
|
||||||
{
|
{
|
||||||
|
|
@ -56,6 +56,8 @@ void emu_printh(int val)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_ReadAnalogJoyX(int min, int max)
|
int emu_ReadAnalogJoyX(int min, int max)
|
||||||
{
|
{
|
||||||
adc_select_input(0);
|
adc_select_input(0);
|
||||||
|
|
@ -121,7 +123,7 @@ int emu_SwapJoysticks(int statusOnly) {
|
||||||
|
|
||||||
int emu_GetPad(void)
|
int emu_GetPad(void)
|
||||||
{
|
{
|
||||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
return(bLastState/*|((joySwapped?1:0)<<7)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
int emu_ReadKeys(void)
|
int emu_ReadKeys(void)
|
||||||
|
|
@ -190,26 +192,13 @@ int emu_ReadKeys(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
gpio_put(14, 0);
|
|
||||||
|
|
||||||
//6,9,15,8,7,22
|
|
||||||
if ( !gpio_get(9) ) retval |= MASK_JOY2_LEFT;
|
|
||||||
if ( !gpio_get(9) ) retval |= MASK_JOY2_LEFT;
|
|
||||||
if ( !gpio_get(9) ) retval |= MASK_JOY2_LEFT;
|
|
||||||
if ( !gpio_get(8) ) retval |= MASK_JOY2_RIGHT;
|
|
||||||
if ( !gpio_get(6) ) retval |= MASK_JOY2_DOWN;
|
|
||||||
if ( !gpio_get(15) ) retval |= MASK_JOY2_UP;
|
|
||||||
if ( !gpio_get(7) ) retval |= MASK_JOY2_BTN;
|
|
||||||
if ( !gpio_get(22) ) retval |= MASK_KEY_USER1;
|
|
||||||
|
|
||||||
gpio_put(14, 1);
|
|
||||||
|
|
||||||
keymatrix_hitrow = -1;
|
keymatrix_hitrow = -1;
|
||||||
|
unsigned char row;
|
||||||
unsigned short cols[6]={1,2,3,4,5,14};
|
unsigned short cols[6]={1,2,3,4,5,14};
|
||||||
for (int i=0;i<6;i++){
|
for (int i=0;i<6;i++){
|
||||||
|
// gpio_set_dir(cols[i], GPIO_OUT);
|
||||||
gpio_put(cols[i], 0);
|
gpio_put(cols[i], 0);
|
||||||
unsigned char row=0;
|
row=0;
|
||||||
|
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
row |= (gpio_get(9) ? 0 : 0x01);
|
row |= (gpio_get(9) ? 0 : 0x01);
|
||||||
|
|
@ -219,21 +208,39 @@ int emu_ReadKeys(void)
|
||||||
row |= (gpio_get(15) ? 0 : 0x08);
|
row |= (gpio_get(15) ? 0 : 0x08);
|
||||||
row |= (gpio_get(7) ? 0 : 0x10);
|
row |= (gpio_get(7) ? 0 : 0x10);
|
||||||
row |= (gpio_get(22) ? 0 : 0x20);
|
row |= (gpio_get(22) ? 0 : 0x20);
|
||||||
/*
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(9) ) row |= 0x01;
|
|
||||||
if ( !gpio_get(8) ) row |= 0x02;
|
|
||||||
if ( !gpio_get(6) ) row |= 0x04;
|
|
||||||
if ( !gpio_get(15) ) row |= 0x08;
|
|
||||||
if ( !gpio_get(7) ) row |= 0x10;
|
|
||||||
if ( !gpio_get(22) ) row |= 0x20;
|
|
||||||
*/
|
|
||||||
keymatrix[i]=row;
|
|
||||||
if (row) keymatrix_hitrow=i;
|
|
||||||
gpio_put(cols[i], 1);
|
gpio_put(cols[i], 1);
|
||||||
|
// gpio_set_dir(cols[i], GPIO_IN);
|
||||||
|
|
||||||
|
keymatrix[i]=row;
|
||||||
|
if (row) keymatrix_hitrow=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//6,9,15,8,7,22
|
||||||
|
#if INVX
|
||||||
|
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||||
|
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||||
|
#else
|
||||||
|
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||||
|
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||||
|
#endif
|
||||||
|
#if INVY
|
||||||
|
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||||
|
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||||
|
#else
|
||||||
|
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||||
|
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||||
|
#endif
|
||||||
|
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||||
|
|
||||||
|
if ( keymatrix[0] & 0x02 ) {
|
||||||
|
key_fn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
key_fn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( key_fn ) retval |= MASK_JOY2_BTN;
|
||||||
|
//if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Serial.println(retval,HEX);
|
//Serial.println(retval,HEX);
|
||||||
|
|
@ -255,19 +262,18 @@ unsigned short emu_DebounceLocalKeys(void)
|
||||||
return (bClick);
|
return (bClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char emu_ReadI2CKeyboard2(int row) {
|
|
||||||
int retval=0;
|
|
||||||
#ifdef PICOMPUTER
|
|
||||||
retval = keymatrix[row];
|
|
||||||
#endif
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
int emu_ReadI2CKeyboard(void) {
|
int emu_ReadI2CKeyboard(void) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
if (key_fn) {
|
||||||
|
keys = (unsigned short *)key_map1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keys = (unsigned short *)key_map1;
|
||||||
|
}
|
||||||
if (keymatrix_hitrow >=0 ) {
|
if (keymatrix_hitrow >=0 ) {
|
||||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||||
|
if (match == 0x002 ) return 0;
|
||||||
for (int i=0; i<sizeof(matkeys); i++) {
|
for (int i=0; i<sizeof(matkeys); i++) {
|
||||||
if (match == matkeys[i]) {
|
if (match == matkeys[i]) {
|
||||||
return (keys[i]);
|
return (keys[i]);
|
||||||
|
|
@ -278,6 +284,13 @@ int emu_ReadI2CKeyboard(void) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||||
|
int retval=0;
|
||||||
|
#ifdef PICOMPUTER
|
||||||
|
retval = keymatrix[row];
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
void emu_InitJoysticks(void) {
|
void emu_InitJoysticks(void) {
|
||||||
|
|
||||||
// Second Joystick
|
// Second Joystick
|
||||||
|
|
@ -348,31 +361,55 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PICOMPUTER
|
#ifdef PICOMPUTER
|
||||||
|
// Output (rows)
|
||||||
gpio_init(1);
|
gpio_init(1);
|
||||||
gpio_init(2);
|
gpio_init(2);
|
||||||
gpio_init(3);
|
gpio_init(3);
|
||||||
gpio_init(4);
|
gpio_init(4);
|
||||||
gpio_init(5);
|
gpio_init(5);
|
||||||
gpio_init(14);
|
gpio_init(14);
|
||||||
|
|
||||||
gpio_init(6);
|
|
||||||
gpio_init(9);
|
|
||||||
gpio_init(15);
|
|
||||||
gpio_init(8);
|
|
||||||
gpio_init(7);
|
|
||||||
gpio_init(22);
|
|
||||||
gpio_set_dir(1, GPIO_OUT);
|
gpio_set_dir(1, GPIO_OUT);
|
||||||
gpio_set_dir(2, GPIO_OUT);
|
gpio_set_dir(2, GPIO_OUT);
|
||||||
gpio_set_dir(3, GPIO_OUT);
|
gpio_set_dir(3, GPIO_OUT);
|
||||||
gpio_set_dir(4, GPIO_OUT);
|
gpio_set_dir(4, GPIO_OUT);
|
||||||
gpio_set_dir(5, GPIO_OUT);
|
gpio_set_dir(5, GPIO_OUT);
|
||||||
gpio_set_dir(14, GPIO_OUT);
|
gpio_set_dir(14, GPIO_OUT);
|
||||||
|
|
||||||
gpio_put(1, 1);
|
gpio_put(1, 1);
|
||||||
gpio_put(2, 1);
|
gpio_put(2, 1);
|
||||||
gpio_put(3, 1);
|
gpio_put(3, 1);
|
||||||
gpio_put(4, 1);
|
gpio_put(4, 1);
|
||||||
gpio_put(5, 1);
|
gpio_put(5, 1);
|
||||||
gpio_put(14, 1);
|
gpio_put(14, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
gpio_put(1, 0);
|
||||||
|
gpio_put(2, 0);
|
||||||
|
gpio_put(3, 0);
|
||||||
|
gpio_put(4, 0);
|
||||||
|
gpio_put(5, 0);
|
||||||
|
gpio_put(14, 0);
|
||||||
|
gpio_set_pulls(1,true,true);
|
||||||
|
gpio_set_pulls(2,true,true);
|
||||||
|
gpio_set_pulls(3,true,true);
|
||||||
|
gpio_set_pulls(4,true,true);
|
||||||
|
gpio_set_pulls(5,true,true);
|
||||||
|
gpio_set_pulls(14,true,true);
|
||||||
|
gpio_set_dir(1, GPIO_IN);
|
||||||
|
gpio_set_dir(2, GPIO_IN);
|
||||||
|
gpio_set_dir(3, GPIO_IN);
|
||||||
|
gpio_set_dir(4, GPIO_IN);
|
||||||
|
gpio_set_dir(5, GPIO_IN);
|
||||||
|
gpio_set_dir(14, GPIO_IN);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Input pins (cols)
|
||||||
|
gpio_init(6);
|
||||||
|
gpio_init(9);
|
||||||
|
gpio_init(15);
|
||||||
|
gpio_init(8);
|
||||||
|
gpio_init(7);
|
||||||
|
gpio_init(22);
|
||||||
gpio_set_pulls(6,true,false);
|
gpio_set_pulls(6,true,false);
|
||||||
gpio_set_dir(6,GPIO_IN);
|
gpio_set_dir(6,GPIO_IN);
|
||||||
gpio_set_pulls(9,true,false);
|
gpio_set_pulls(9,true,false);
|
||||||
|
|
@ -388,9 +425,6 @@ void emu_InitJoysticks(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int emu_setKeymap(int index) {
|
int emu_setKeymap(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,12 @@ static int fb_width, fb_height;
|
||||||
|
|
||||||
static const char * digits = "0123456789ABCDEF";
|
static const char * digits = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
bool repeating_timer_callback(struct repeating_timer *t) {
|
||||||
|
uint16_t bClick = emu_DebounceLocalKeys();
|
||||||
|
//emu_Input(bClick);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
vreg_set_voltage(VREG_VOLTAGE_1_05);
|
vreg_set_voltage(VREG_VOLTAGE_1_05);
|
||||||
// set_sys_clock_khz(125000, true);
|
// set_sys_clock_khz(125000, true);
|
||||||
|
|
@ -41,13 +47,16 @@ int main(void) {
|
||||||
tft.begin();
|
tft.begin();
|
||||||
emu_init();
|
emu_init();
|
||||||
emu_start();
|
emu_start();
|
||||||
tft.startDMA();
|
//tft.startDMA();
|
||||||
tft.fillScreen(LIGHT_BLUE);
|
struct repeating_timer timer;
|
||||||
|
add_repeating_timer_ms(25, repeating_timer_callback, NULL, &timer);
|
||||||
|
|
||||||
|
tft.fillScreenNoDma(LIGHT_BLUE);
|
||||||
tft.get_frame_buffer_size(&fb_width, &fb_height);
|
tft.get_frame_buffer_size(&fb_width, &fb_height);
|
||||||
tft.drawRect((fb_width-320)/2,(fb_height-200)/2, 320,200, BLUE);
|
tft.drawRectNoDma((fb_width-320)/2,(fb_height-200)/2, 320,200, BLUE);
|
||||||
tft.drawText((fb_width-320)/2,(fb_height-200)/2+1*8," **** COMMODORE 64 BASIC V2 **** ",LIGHT_BLUE,BLUE,false);
|
tft.drawTextNoDma((fb_width-320)/2,(fb_height-200)/2+1*8," **** COMMODORE 64 BASIC V2 **** ",LIGHT_BLUE,BLUE,false);
|
||||||
tft.drawText((fb_width-320)/2,(fb_height-200)/2+3*8," 64K RAM SYSTEM 38911 BASIC BYTES FREE ",LIGHT_BLUE,BLUE,false);
|
tft.drawTextNoDma((fb_width-320)/2,(fb_height-200)/2+3*8," 64K RAM SYSTEM 38911 BASIC BYTES FREE ",LIGHT_BLUE,BLUE,false);
|
||||||
tft.drawText((fb_width-320)/2,(fb_height-200)/2+5*8,"READY.",LIGHT_BLUE,BLUE,false);
|
tft.drawTextNoDma((fb_width-320)/2,(fb_height-200)/2+5*8,"READY.",LIGHT_BLUE,BLUE,false);
|
||||||
|
|
||||||
char buf[4] = {32,32,32,0};
|
char buf[4] = {32,32,32,0};
|
||||||
uint sys_clk = clock_get_hz(clk_sys)/1000000;
|
uint sys_clk = clock_get_hz(clk_sys)/1000000;
|
||||||
|
|
@ -59,49 +68,49 @@ int main(void) {
|
||||||
buf[0] = digits[r1];
|
buf[0] = digits[r1];
|
||||||
buf[1] = digits[r2];
|
buf[1] = digits[r2];
|
||||||
buf[2] = digits[r3];
|
buf[2] = digits[r3];
|
||||||
tft.drawText(4*8,0,buf,BLUE,LIGHT_BLUE,false);
|
tft.drawTextNoDma(4*8,0,buf,BLUE,LIGHT_BLUE,false);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
uint16_t bClick = emu_ReadKeys();
|
uint16_t bClick = emu_GetPad();
|
||||||
char buf[5] = {0,0,0,0,0};
|
char buf[5] = {0,0,0,0,0};
|
||||||
buf[0] = digits[(bClick>>12)&0xf];
|
buf[0] = digits[(bClick>>12)&0xf];
|
||||||
buf[1] = digits[(bClick>>8)&0xf];
|
buf[1] = digits[(bClick>>8)&0xf];
|
||||||
buf[2] = digits[(bClick>>4)&0xf];
|
buf[2] = digits[(bClick>>4)&0xf];
|
||||||
buf[3] = digits[bClick&0xf];
|
buf[3] = digits[bClick&0xf];
|
||||||
tft.drawText(4*8,16,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
buf[3] = 0;
|
buf[3] = 0;
|
||||||
int key = emu_ReadI2CKeyboard();
|
int key = emu_ReadI2CKeyboard();
|
||||||
buf[0] = digits[(key>>8)&0xf];
|
buf[0] = digits[(key>>8)&0xf];
|
||||||
buf[1] = digits[(key>>4)&0xf];
|
buf[1] = digits[(key>>4)&0xf];
|
||||||
buf[2] = digits[key&0xf];
|
buf[2] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*2,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*2,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
/*
|
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
uint8_t key = emu_ReadI2CKeyboard2(0);
|
key = emu_ReadI2CKeyboard2(0);
|
||||||
buf[0] = digits[(key>>4)&0xf];
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
buf[1] = digits[key&0xf];
|
buf[1] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*2,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*4,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
key = emu_ReadI2CKeyboard2(1);
|
key = emu_ReadI2CKeyboard2(1);
|
||||||
buf[0] = digits[(key>>4)&0xf];
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
buf[1] = digits[key&0xf];
|
buf[1] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*3,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*5,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
key = emu_ReadI2CKeyboard2(2);
|
key = emu_ReadI2CKeyboard2(2);
|
||||||
buf[0] = digits[(key>>4)&0xf];
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
buf[1] = digits[key&0xf];
|
buf[1] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*4,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*6,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
key = emu_ReadI2CKeyboard2(3);
|
key = emu_ReadI2CKeyboard2(3);
|
||||||
buf[0] = digits[(key>>4)&0xf];
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
buf[1] = digits[key&0xf];
|
buf[1] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*5,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*7,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
key = emu_ReadI2CKeyboard2(4);
|
key = emu_ReadI2CKeyboard2(4);
|
||||||
buf[0] = digits[(key>>4)&0xf];
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
buf[1] = digits[key&0xf];
|
buf[1] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*6,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*8,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
key = emu_ReadI2CKeyboard2(5);
|
key = emu_ReadI2CKeyboard2(5);
|
||||||
buf[0] = digits[(key>>4)&0xf];
|
buf[0] = digits[(key>>4)&0xf];
|
||||||
buf[1] = digits[key&0xf];
|
buf[1] = digits[key&0xf];
|
||||||
tft.drawText(4*8,16*7,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
tft.drawTextNoDma(4*8,16*9,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||||
*/
|
|
||||||
sleep_ms(20);
|
sleep_ms(20);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue