add T41 VGA supprt for all emus except st and amiga
This commit is contained in:
parent
b11ae4b91b
commit
cb094fe973
342 changed files with 19766 additions and 232327 deletions
Binary file not shown.
|
|
@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) {
|
|||
void AudioPlaySystem::step(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -455,6 +455,13 @@ static void Initialise(void)
|
|||
cont2.analog_v = POT_CENTRE;
|
||||
}
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
|
||||
void at5_Init(void)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -593,9 +600,3 @@ void at5_Start(char * cartname)
|
|||
|
||||
emu_printf("init done");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1387,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#define CUSTOM_SND 1
|
||||
//#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
//#define TIMER_REND 1
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
// Title: < >
|
||||
|
|
@ -68,7 +65,7 @@ const unsigned short keysw[] = {
|
|||
// [START] 12 [ 3 ] 13 [ 2 ] 14 [ 1 ] 15
|
||||
|
||||
|
||||
const unsigned short keys[] = {
|
||||
const unsigned short key_map1[] = {
|
||||
12+1,8+1,4+1,
|
||||
0,
|
||||
15+1,14+1,13+1,
|
||||
|
|
@ -108,6 +105,9 @@ const unsigned short i2ckeys[] = {
|
|||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void * emu_Malloc(int size);
|
||||
|
|
@ -128,6 +128,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -141,6 +142,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -149,9 +153,11 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,21 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "atari5200.h"
|
||||
|
|
@ -36,7 +35,14 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -70,7 +76,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -82,7 +92,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -100,11 +114,43 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -154,8 +200,13 @@ void * emu_LineBuffer(int line)
|
|||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
tft.begin();
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_352x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
|
|
@ -173,6 +224,7 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
|
|
@ -185,6 +237,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -225,8 +278,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -234,6 +294,10 @@ AudioConnection patchCord1(mymixer, dac1);
|
|||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320 //640 //320
|
||||
#define TFT_REALWIDTH 320 //640 //320
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
|
@ -44,8 +44,8 @@ class TFT_T_DMA: public VGA_T4
|
|||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const vga_pixel *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const vga_pixel *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -50,13 +50,18 @@
|
|||
#define USBHOST (!PS2KEYBOARD)
|
||||
|
||||
|
||||
#include "tft_t_dma.h"
|
||||
extern TFT_T_DMA tft;
|
||||
|
||||
extern "C" {
|
||||
#include "emuapi.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
extern TFT_T_DMA tft;
|
||||
|
||||
|
||||
void initMachine();
|
||||
void resetMachine() __attribute__ ((noreturn));
|
||||
void resetExternal();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
extern "C" {
|
||||
#include "emuapi.h"
|
||||
#include "platform_config.h"
|
||||
}
|
||||
|
||||
#include "Teensy64.h"
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -251,7 +253,9 @@ void c64_Init(void)
|
|||
resetCia2();
|
||||
resetVic();
|
||||
cpu_reset();
|
||||
#ifdef HAS_SND
|
||||
emu_sndInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -307,6 +311,12 @@ void c64_Input(int bClick) {
|
|||
}
|
||||
}
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
#ifdef HAS_SND
|
||||
void SND_Process( void * stream, int len )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -454,6 +489,7 @@ int emu_ReadKeys(void)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
|
@ -491,7 +527,7 @@ int emu_ReadI2CKeyboard(void) {
|
|||
Serial.println(msg[6], BIN);
|
||||
*/
|
||||
unsigned short match = (~msg[hitindex])&0x00FF | (hitindex<<8);
|
||||
Serial.println(match,HEX);
|
||||
//Serial.println(match,HEX);
|
||||
for (i=0; i<sizeof(i2ckeys); i++) {
|
||||
if (match == i2ckeys[i]) {
|
||||
//Serial.println((int)keys[i]);
|
||||
|
|
@ -574,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -591,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -636,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -650,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -725,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -838,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -846,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1337,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1386,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1412,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
// Title: < >
|
||||
#define TITLE " NES Emulator "
|
||||
#define TITLE " C64 Emulator "
|
||||
#define ROMSDIR "c64"
|
||||
|
||||
#define emu_Init(ROM) {c64_Start(ROM); c64_Init(); }
|
||||
|
|
@ -51,7 +49,7 @@ const unsigned short keysw[] = {
|
|||
TAREA_NEW_ROW,40,40,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[] = {
|
||||
const unsigned short key_map1[] = {
|
||||
2,3};
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
|
|
@ -80,6 +78,7 @@ const unsigned short i2ckeys[] = {
|
|||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
|
|
@ -102,6 +101,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -115,6 +115,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -123,9 +126,10 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "patches.h"
|
||||
#include "emuapi.h"
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
#define DIRECTORY ROMSDIR + "/\0"
|
||||
|
|
@ -191,13 +192,17 @@ uint16_t addr,size;
|
|||
|
||||
Serial.println("loading");
|
||||
//printf("%s,%d,%d:", filename, device, secondaryAddress);
|
||||
#ifdef EXTERNAL_SD
|
||||
tft.stopDMA();
|
||||
//emu_resetSD();
|
||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||
#endif
|
||||
if (emu_FileOpen(filename) == 0) {
|
||||
//Serial.println("not found");
|
||||
cpu.pc = 0xf530; //Jump to $F530
|
||||
#ifdef EXTERNAL_SD
|
||||
tft.startDMA();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -214,8 +219,9 @@ uint16_t addr,size;
|
|||
cpu.y = 0x49; //Offset for "LOADING"
|
||||
cpu.pc = 0xF12B; //Print and return
|
||||
emu_printf("loaded");
|
||||
#ifdef EXTERNAL_SD
|
||||
tft.startDMA();
|
||||
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,22 @@
|
|||
|
||||
//#define OLD_LAYOUT 1
|
||||
|
||||
#define ILI9341 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
//#define INVX 1
|
||||
#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
//extern "C" {
|
||||
#include "keyboard_osd.h"
|
||||
|
||||
#include "c64.h"
|
||||
//}
|
||||
|
||||
#ifdef HAS_VGA
|
||||
#include <uVGA.h>
|
||||
|
|
@ -36,7 +34,13 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -47,17 +51,12 @@ volatile boolean vbl=true;
|
|||
static int skip=0;
|
||||
static elapsedMicros tius;
|
||||
|
||||
volatile int16_t mClick=0;
|
||||
static void vblCount() {
|
||||
if (vbl) {
|
||||
vbl = false;
|
||||
} else {
|
||||
vbl = true;
|
||||
}
|
||||
emu_Input(mClick);
|
||||
if (mClick) {
|
||||
mClick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
|
|
@ -75,19 +74,29 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
while (vbl==vb) {};
|
||||
}
|
||||
#endif
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
emu_Input(bClick);
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -105,12 +114,29 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
//if (skip==0) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
//}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
|
|
@ -120,7 +146,11 @@ void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
|||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -166,15 +196,23 @@ void * emu_LineBuffer(int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ****************************************************
|
||||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
|
||||
emu_init();
|
||||
}
|
||||
|
||||
|
||||
// ****************************************************
|
||||
// the loop() method runs continuously
|
||||
// ****************************************************
|
||||
|
|
@ -187,6 +225,7 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
|
|
@ -200,6 +239,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -226,11 +266,11 @@ void loop(void)
|
|||
#endif
|
||||
if ( (!virtualkeyboardIsActive()) || (vgaMode) ) {
|
||||
emu_Step();
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
if (bClick & MASK_KEY_USER1) {
|
||||
emu_Input(bClick);
|
||||
mClick = 1;
|
||||
}
|
||||
//delay(20);
|
||||
//uint16_t bClick = emu_DebounceLocalKeys();
|
||||
//if (bClick & MASK_KEY_USER1) {
|
||||
// emu_Input(bClick);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -243,8 +283,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -277,5 +324,3 @@ void emu_sndPlayBuzz(int size, int val) {
|
|||
//Serial.println(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensy64/vga_t_dma.h
Normal file
53
MCUME_teensy/teensy64/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -69,7 +69,11 @@
|
|||
#define BORDER_LEFT 0
|
||||
#define BORDER_RIGHT 0
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
typedef uint8_t tpixel;
|
||||
#else
|
||||
typedef uint16_t tpixel;
|
||||
#endif
|
||||
|
||||
#define MAXCYCLESSPRITES0_2 3
|
||||
#define MAXCYCLESSPRITES3_7 5
|
||||
|
|
@ -1270,7 +1274,8 @@ void mode7 (tpixel *p, const tpixel *pe, uint16_t *spl, const uint16_t vc) {
|
|||
typedef void (*modes_t)( tpixel *p, const tpixel *pe, uint16_t *spl, const uint16_t vc ); //Funktionspointer
|
||||
const modes_t modes[8] = {mode0, mode1, mode2, mode3, mode4, mode5, mode6, mode7};
|
||||
|
||||
static uint16_t linebuffer[SCREEN_WIDTH];
|
||||
|
||||
static tpixel linebuffer[SCREEN_WIDTH];
|
||||
|
||||
void vic_do(void) {
|
||||
|
||||
|
|
@ -1304,7 +1309,7 @@ void vic_do(void) {
|
|||
cpu.vic.denLatch = 0;
|
||||
//if (cpu.vic.rasterLine == LINECNT)
|
||||
//delay(50);
|
||||
//emu_DrawVsync();
|
||||
emu_DrawVsync();
|
||||
|
||||
} else cpu.vic.rasterLine++;
|
||||
|
||||
|
|
@ -1602,7 +1607,13 @@ g-Zugriff
|
|||
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
||||
#else
|
||||
emu_DrawLine16(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//Rechter Rand nach CSEL, im Textbereich
|
||||
cpu_clock(5);
|
||||
|
|
|
|||
|
|
@ -267,6 +267,11 @@ void at8_Init(void)
|
|||
Initialise();
|
||||
}
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void at8_Step(void)
|
||||
{
|
||||
|
|
@ -371,9 +376,3 @@ void at8_Start(char * cartname)
|
|||
|
||||
emu_printf("init done");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1387,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
|
|
@ -18,7 +16,7 @@
|
|||
#define emu_Input(x) {}
|
||||
|
||||
#define PALETTE_SIZE 256
|
||||
#define VID_FRAME_SKIP 0x3
|
||||
#define VID_FRAME_SKIP 0x0
|
||||
#define TFT_VBUFFER_YCROP 0
|
||||
#define SINGLELINE_RENDERING 1
|
||||
|
||||
|
|
@ -60,7 +58,7 @@ const unsigned short keysw[] = {
|
|||
TAREA_END};
|
||||
|
||||
|
||||
const unsigned short keys[] = {
|
||||
const unsigned short key_map1[] = {
|
||||
0x1C+1,0x1F+1,0x1F ,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x36+1,0x37+1,0,0,
|
||||
0x2C+1,0x2F+1,0x2F ,0x2A+1,0x28+1,0x2D+1,0x2B+1,0x0B+1,0x0D+1,0x08+1,0x0A+1,0x0E,0x0F+1,0x0C+1,
|
||||
0, 0x3F+1,0x3F ,0x3A+1,0x38+1,0x3D+1,0x39+1,0x01+1,0x05+1,0x00+1,0x02+1,0x06+1,0x07+1,0,
|
||||
|
|
@ -97,6 +95,9 @@ const unsigned short i2ckeys[] = {
|
|||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void * emu_Malloc(int size);
|
||||
|
|
@ -117,6 +118,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -130,6 +132,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -138,8 +143,10 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,22 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "atari800.h"
|
||||
|
|
@ -36,7 +35,14 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -70,7 +76,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -82,7 +92,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -100,11 +114,43 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -154,8 +200,13 @@ void * emu_LineBuffer(int line)
|
|||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
tft.begin();
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_352x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 255);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
|
|
@ -173,6 +224,7 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
|
|
@ -185,6 +237,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -217,6 +270,7 @@ void loop(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
|
|
@ -224,8 +278,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -233,6 +294,10 @@ AudioConnection patchCord1(mymixer, dac1);
|
|||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
// sgtl5000_1.enable();
|
||||
// sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
@ -258,7 +323,3 @@ void emu_sndPlayBuzz(int size, int val) {
|
|||
//Serial.println(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensy800/vga_t_dma.h
Normal file
53
MCUME_teensy/teensy800/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -4,13 +4,15 @@
|
|||
|
||||
// #define RAM_SIZE 0xF8000 // 512k //655360UL
|
||||
// #define NATIVE_RAM (0X28000) // 128k+32768 //231424UL
|
||||
#define RAM_SIZE 0x78000 // 512k //655360UL
|
||||
#define NATIVE_RAM (0X28000) // 128k+32768 //231424UL
|
||||
#define NATIVE_START 0UL
|
||||
|
||||
|
||||
#define RAM_SIZE 0x78000 // 512k //655360UL
|
||||
#define NATIVE_RAM (0X28000) // 128k+32768 //231424UL
|
||||
#define NATIVE_START 0UL
|
||||
|
||||
|
||||
|
||||
#define ROM_READ(a,b) a[b]
|
||||
#define ROM_READ(a,b) a[b]
|
||||
|
||||
|
||||
//#define INCLUDE_ROM_BASIC
|
||||
|
|
@ -152,4 +154,3 @@ union _bytewordregs_{
|
|||
uint16_t wordregs[8];
|
||||
uint8_t byteregs[8];
|
||||
} ;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
#define KEYMAP_PRESENT 1
|
||||
|
||||
//extern "C" {
|
||||
extern "C" {
|
||||
#include "emuapi.h"
|
||||
#include "iopins.h"
|
||||
//}
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1387,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#else
|
||||
#endif
|
||||
//#define HAS_SND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
//#define CUSTOM_SND 1
|
||||
#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
|
@ -60,7 +55,7 @@ const unsigned short keysw[]=
|
|||
//TAREA_NEW_ROW,18,18,18,18,18,18,18,18,18,18,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[]={
|
||||
const unsigned short key_map1[]={
|
||||
|
||||
59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
|
||||
109,110,111,112,106,107,108,17,18,19,
|
||||
|
|
@ -99,10 +94,16 @@ const unsigned short i2ckeys[] = {
|
|||
#define MASK_KEY_USER4 0x2000
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
|
||||
extern void * emu_Malloc(int size);
|
||||
extern void emu_Free(void * pt);
|
||||
|
||||
|
|
@ -121,6 +122,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -134,6 +136,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -142,9 +147,14 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,22 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T41 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
//#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
|
||||
//#define ILI9341 1
|
||||
#define ST7789 1
|
||||
#define SWAP_JOYSTICK 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
|
||||
extern "C" {
|
||||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
|
|
@ -33,7 +33,14 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -55,7 +62,6 @@ static void vblCount() {
|
|||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
//Serial.println("%d: %d %d %d\n", index, r,g,b);
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
|
|
@ -67,7 +73,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -79,7 +89,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -97,11 +111,28 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -112,7 +143,11 @@ void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
|||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -162,13 +197,18 @@ void * emu_LineBuffer(int line)
|
|||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
tft.begin();
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_640x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
}
|
||||
static unsigned char col=0;
|
||||
|
||||
// ****************************************************
|
||||
// the loop() method runs continuously
|
||||
// ****************************************************
|
||||
|
|
@ -181,7 +221,10 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||
tft.startDMA();
|
||||
}
|
||||
|
|
@ -191,6 +234,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -216,28 +260,41 @@ void loop(void)
|
|||
#endif
|
||||
if ( (!virtualkeyboardIsActive()) || (vgaMode) ) {
|
||||
emu_Step();
|
||||
//delay(20);
|
||||
//tft.fillScreen( RGBVAL16(0xff,col,0x00) );
|
||||
//if ((uint32_t)_pfbtft >= 0x20200000u) arm_dcache_flush(_pfbtft, CBALLOC);
|
||||
//col++;
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
emu_Input(bClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
#endif
|
||||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
@ -247,7 +304,6 @@ void emu_sndPlaySound(int chan, int volume, int freq)
|
|||
if (chan < 6) {
|
||||
mymixer.sound(chan, freq, volume);
|
||||
}
|
||||
|
||||
/*
|
||||
Serial.print(chan);
|
||||
Serial.print(":" );
|
||||
|
|
|
|||
|
|
@ -4,7 +4,13 @@
|
|||
#include "emu.h"
|
||||
#include "ps2.h"
|
||||
|
||||
#ifdef HAS_T41
|
||||
EXTMEM static unsigned char MemPool[8*1024*1024];
|
||||
#else
|
||||
static uint8_t LOMEM[NATIVE_RAM];
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t * RAM;
|
||||
uint8_t * LORAM;
|
||||
|
||||
|
|
@ -333,14 +339,15 @@ void installPalette(void) {
|
|||
|
||||
extern uint8_t vidmode, portram[0x400];
|
||||
|
||||
#define XRES 320
|
||||
#define XRES_MAX 640
|
||||
#define XRES_HI 640
|
||||
#define XRES_LO 320
|
||||
#define YRES 200
|
||||
|
||||
#include "font.h"
|
||||
|
||||
|
||||
static unsigned short line[XRES];
|
||||
|
||||
static unsigned short line[XRES_MAX];
|
||||
|
||||
void drawscreentext80(void) {
|
||||
uint16_t row, col, y, x, xpos;
|
||||
|
|
@ -360,23 +367,23 @@ void drawscreentext80(void) {
|
|||
fg = attrib & 0x0F;
|
||||
//if (y == 0) {printf("0x%02X",cc);}
|
||||
fontdata = ROM_READ(font, ((uint32_t)cc << 3) + (y&0x7));
|
||||
for (x=0; x<4; x++)
|
||||
for (x=0; x<8; x++)
|
||||
//for (x=0; x<4; x++)
|
||||
{
|
||||
if (fontdata & 1) {
|
||||
line[xpos++] = palettecga[fg];
|
||||
} else {
|
||||
line[xpos++] = palettecga[bg];
|
||||
}
|
||||
fontdata >>= 2;
|
||||
fontdata >>= 1;
|
||||
//fontdata >>= 2;
|
||||
}
|
||||
}
|
||||
|
||||
emu_DrawLine16(&line[0], XRES, YRES, y);
|
||||
emu_DrawLine16(&line[0], XRES_HI, YRES, y);
|
||||
}
|
||||
}
|
||||
|
||||
void drawscreenlorescga(void) {
|
||||
//uint16_t row;
|
||||
uint16_t y, x, xpos;
|
||||
uint8_t intensity, usepal;
|
||||
uint16_t color;
|
||||
|
|
@ -385,10 +392,8 @@ void drawscreenlorescga(void) {
|
|||
|
||||
for (y=0; y<(25*8); y++)
|
||||
{
|
||||
//row = y>>3;
|
||||
//uint8_t * vrampt=&VRAM[160*row];
|
||||
xpos = 0;
|
||||
for (x=0; x<XRES; x++)
|
||||
for (x=0; x<XRES_LO; x++)
|
||||
{
|
||||
int ychar = y;// >> 1;
|
||||
int xchar = x;// >> 1;
|
||||
|
|
@ -403,8 +408,7 @@ void drawscreenlorescga(void) {
|
|||
if (color == (usepal + intensity)) color = 0;
|
||||
line[xpos++] = palettecga[color];
|
||||
}
|
||||
|
||||
emu_DrawLine16(&line[0], XRES, YRES, y);
|
||||
emu_DrawLine16(&line[0], XRES_LO, YRES, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -415,7 +419,7 @@ void drawscreenhirescga(void) {
|
|||
for (y=0; y<(25*8); y++)
|
||||
{
|
||||
xpos = 0;
|
||||
for (x=0; x<XRES; x++)
|
||||
for (x=0; x<XRES_HI; x++)
|
||||
{
|
||||
int ychar = y >> 1;
|
||||
int xchar = x;
|
||||
|
|
@ -423,8 +427,7 @@ void drawscreenhirescga(void) {
|
|||
color = ((curchar >> (7-(x&7))) & 1) ? 15 : 0;
|
||||
line[xpos++] = palettecga[color];
|
||||
}
|
||||
|
||||
emu_DrawLine16(&line[0], XRES, YRES, y);
|
||||
emu_DrawLine16(&line[0], XRES_HI, YRES, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -457,9 +460,10 @@ static uint8_t nbkeys=0;
|
|||
static uint8_t kcnt=0;
|
||||
static int toggle=1;
|
||||
|
||||
//static char * seq="DIR\r";
|
||||
//static char * seq="CAT.EXE\r";
|
||||
static char * seq="PRINCE.BAT\r";
|
||||
static char * seq;
|
||||
static char * seq1="PRINCE.BAT\r";
|
||||
static char * seq2="CAT.EXE\r";
|
||||
static char * seq3="DIR\r";
|
||||
|
||||
static int mouse_x = 160;
|
||||
static int mouse_y = 100;
|
||||
|
|
@ -480,7 +484,6 @@ static void keyevent(int keysym, int isdown)
|
|||
if (!isdown) portram[0x60] |= 0x80;
|
||||
portram[0x64] |= 2;
|
||||
doirq(1);
|
||||
//vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -490,7 +493,13 @@ extern void apc_Input(int bClick) {
|
|||
|
||||
if (nbkeys == 0) {
|
||||
if (bClick & MASK_JOY2_BTN) {
|
||||
nbkeys = strlen(seq);
|
||||
nbkeys = strlen(seq1);
|
||||
seq=seq1;
|
||||
kcnt=0;
|
||||
}
|
||||
if (bClick & MASK_KEY_USER1) {
|
||||
nbkeys = strlen(seq2);
|
||||
seq=seq2;
|
||||
kcnt=0;
|
||||
}
|
||||
}
|
||||
|
|
@ -554,35 +563,23 @@ static void do_events(void)
|
|||
}
|
||||
else {
|
||||
if (( k & MASK_JOY1_RIGHT) || ( k & MASK_JOY2_RIGHT)) {
|
||||
if ( mouse_x < XRES ) {
|
||||
if ( mouse_x < XRES_HI ) {
|
||||
mouse_x += 1;
|
||||
//Serial.print("r");
|
||||
//IkbdMouseMotion ( mouse_x, mouse_y );
|
||||
//IkbdLoop();
|
||||
}
|
||||
}
|
||||
else if (( k & MASK_JOY1_LEFT) || ( k & MASK_JOY2_LEFT)) {
|
||||
if ( mouse_x > 1 ) {
|
||||
mouse_x -= 1;
|
||||
//Serial.print("l");
|
||||
//IkbdMouseMotion ( mouse_x, mouse_y );
|
||||
//IkbdLoop();
|
||||
}
|
||||
}
|
||||
else if (( k & MASK_JOY1_UP) || ( k & MASK_JOY2_UP)) {
|
||||
if ( mouse_y > 1 ) {
|
||||
mouse_y -= 1;
|
||||
//Serial.print("u");
|
||||
//IkbdMouseMotion ( mouse_x, mouse_y );
|
||||
//IkbdLoop();
|
||||
}
|
||||
}
|
||||
else if (( k & MASK_JOY1_DOWN) || ( k & MASK_JOY2_DOWN)) {
|
||||
if ( mouse_y < YRES ) {
|
||||
mouse_y += 1;
|
||||
//Serial.print("d");
|
||||
//IkbdMouseMotion ( mouse_x, mouse_y );
|
||||
//IkbdLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -591,15 +588,17 @@ static void do_events(void)
|
|||
mouseb=1;
|
||||
}
|
||||
if ( (mouseb != prev_mouseb) ){
|
||||
//if (mouseb) IkbdMousePress(2);
|
||||
//else IkbdMouseRelease(2);
|
||||
//Serial.println("btoggle");
|
||||
//IkbdLoop();
|
||||
prev_mouseb = mouseb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void apc_Step(void)
|
||||
{
|
||||
exec86(8000);
|
||||
|
|
@ -612,12 +611,18 @@ void apc_Step(void)
|
|||
|
||||
void apc_Init(void)
|
||||
{
|
||||
#ifdef HAS_T41
|
||||
LORAM = MemPool;
|
||||
RAM = MemPool + NATIVE_RAM;
|
||||
#else
|
||||
RAM = (uint8_t*) malloc(RAM_SIZE);
|
||||
if (!RAM) emu_printf("SPI RAM malloc failed");
|
||||
if (!RAM) emu_printf("RAM malloc failed");
|
||||
LORAM = &LOMEM[0];
|
||||
//LORAM = (uint8_t*)malloc(NATIVE_RAM);
|
||||
//if (!LORAM) emu_printf("LORAM malloc failed");
|
||||
|
||||
#endif
|
||||
|
||||
installPalette();
|
||||
init8253();
|
||||
reset86();
|
||||
|
|
@ -630,9 +635,3 @@ void apc_Start(char * filename)
|
|||
initDisk(filename);
|
||||
emu_printf("init done");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensy8086/vga_t_dma.h
Normal file
53
MCUME_teensy/teensy8086/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 640
|
||||
#define TFT_REALWIDTH 640
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -5,10 +5,20 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
//#include "logo.h"
|
||||
#include "logozx80kbd.h"
|
||||
#include "logozx81kbd.h"
|
||||
static const uint16_t * logo = logozx80kbd;
|
||||
#endif
|
||||
static const unsigned short * keysw = keyswzx80;
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -21,6 +31,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -86,7 +103,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -95,7 +112,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -115,14 +132,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
static const uint16_t * logo = logozx80kbd;
|
||||
static const unsigned short * keysw = keyswzx80;
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -248,7 +261,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -275,13 +288,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -403,6 +432,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -578,7 +613,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -595,7 +630,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -640,7 +675,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -655,11 +690,15 @@ void handleVirtualkeyboard() {
|
|||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
#ifndef HAS_T4_VGA
|
||||
logo = logozx81kbd;
|
||||
#endif
|
||||
keysw = keyswzx81;
|
||||
}
|
||||
else {
|
||||
#ifndef HAS_T4_VGA
|
||||
logo = logozx80kbd;
|
||||
#endif
|
||||
keysw = keyswzx80;
|
||||
}
|
||||
}
|
||||
|
|
@ -733,10 +772,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -846,7 +887,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -854,8 +895,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1345,11 +1388,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1394,7 +1564,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1420,5 +1594,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
//#define TIMER_REND 1
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
// Title: < >
|
||||
|
|
@ -62,7 +59,7 @@ const unsigned short keyswzx81[] = {
|
|||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[] = {
|
||||
const unsigned short key_map1[] = {
|
||||
30,31,32,33,34,35,36,37,38,39,
|
||||
20,26, 8,21,23,28,25,12,18,19,
|
||||
4, 9, 7,22, 4,11,13,14,15,40,
|
||||
|
|
@ -96,8 +93,10 @@ const unsigned short i2ckeys[] = {
|
|||
#define MASK_KEY_USER4 0x2000
|
||||
|
||||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void * emu_Malloc(int size);
|
||||
|
|
@ -118,6 +117,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -131,6 +131,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -139,10 +142,10 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,22 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
//#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "zx81.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_VGA
|
||||
#include <uVGA.h>
|
||||
uVGA uvga;
|
||||
|
|
@ -36,7 +36,14 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -70,7 +77,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -82,7 +93,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -100,11 +115,43 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -154,8 +201,13 @@ void * emu_LineBuffer(int line)
|
|||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
tft.begin();
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_352x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
|
|
@ -173,6 +225,7 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
|
|
@ -185,6 +238,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -217,6 +271,7 @@ void loop(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
|
|
@ -224,8 +279,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -233,6 +295,10 @@ AudioConnection patchCord1(mymixer, dac1);
|
|||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
@ -258,6 +324,3 @@ void emu_sndPlayBuzz(int size, int val) {
|
|||
//Serial.println(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -443,7 +446,7 @@ void TFT_T_DMA::startDMA(void) {
|
|||
digitalWrite(_cs, HIGH);
|
||||
SPI.begin();
|
||||
SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
|
||||
#ifdef TFT_DEBUG
|
||||
PRREG(LPSPI4_CCR);
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensy81/vga_t_dma.h
Normal file
53
MCUME_teensy/teensy81/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -200,6 +200,7 @@ void do_interrupt()
|
|||
|
||||
void bitbufBlit(unsigned char * buf)
|
||||
{
|
||||
emu_DrawVsync();
|
||||
memset( XBuf, 1, WIDTH*8 );
|
||||
buf = buf + (ZX_VID_MARGIN*(ZX_VID_FULLWIDTH/8));
|
||||
int y,x,i;
|
||||
|
|
@ -472,6 +473,13 @@ static void initmem()
|
|||
}
|
||||
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
|
||||
void z81_Init(void)
|
||||
{
|
||||
#if HAS_SND
|
||||
|
|
@ -517,7 +525,6 @@ void z81_Step(void)
|
|||
ExecZ80();
|
||||
sighandler(0);
|
||||
//if (strlen(tapename)) handleKeyBuf();
|
||||
emu_DrawVsync();
|
||||
updateKeyboard();
|
||||
Loop8910(&ay,20);
|
||||
}
|
||||
|
|
@ -558,4 +565,3 @@ void z81_Start(char * filename)
|
|||
ramsize = 56;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ static void do_events(void)
|
|||
|
||||
|
||||
if (hk != prev_hk) {
|
||||
prev_hk == hk;
|
||||
prev_hk = hk;
|
||||
if ( (hk != 0) && (hk != prev_key) ) {
|
||||
prev_key = hk;
|
||||
IkbdKeyPress ( hk );
|
||||
|
|
|
|||
|
|
@ -110,6 +110,12 @@ struct
|
|||
/***************************************
|
||||
* Exported procedures
|
||||
***************************************/
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void coc_Init(void)
|
||||
{
|
||||
int J;
|
||||
|
|
@ -894,5 +900,3 @@ void RefreshLine3(register byte Y)
|
|||
|
||||
RefreshBorder(Y);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const int16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const int16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1387,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
//#define TIMER_REND 1
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
// Title: < >
|
||||
|
|
@ -53,7 +50,7 @@ const unsigned short keysw[] = {
|
|||
TAREA_NEW_ROW,20,20,20,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[] = {
|
||||
const unsigned short key_map1[] = {
|
||||
2,3,4,
|
||||
5,6,7,
|
||||
8,9,10,
|
||||
|
|
@ -86,8 +83,10 @@ const unsigned short i2ckeys[] = {
|
|||
#define MASK_KEY_USER4 0x2000
|
||||
|
||||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void * emu_Malloc(int size);
|
||||
|
|
@ -108,6 +107,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -121,6 +121,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -129,9 +132,11 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,21 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
//#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "Colem.h"
|
||||
|
|
@ -36,7 +35,14 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -70,7 +76,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -82,7 +92,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -100,11 +114,43 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -154,8 +200,13 @@ void * emu_LineBuffer(int line)
|
|||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
tft.begin();
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_352x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
|
|
@ -173,6 +224,7 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
|
|
@ -185,6 +237,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -210,13 +263,14 @@ void loop(void)
|
|||
#endif
|
||||
if ( (!virtualkeyboardIsActive()) || (vgaMode) ) {
|
||||
emu_Step();
|
||||
delay(20);
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
emu_Input(bClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
|
|
@ -224,8 +278,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -233,6 +294,10 @@ AudioConnection patchCord1(mymixer, dac1);
|
|||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
50
MCUME_teensy/teensycolem/vga_t_dma.h
Normal file
50
MCUME_teensy/teensycolem/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 256
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 192
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "emuapi.h"
|
||||
#include "tft_t_dma.h"
|
||||
#include "psram_t.h"
|
||||
#include "iopins.h"
|
||||
|
||||
extern "C" {
|
||||
|
|
@ -10,6 +9,29 @@ extern "C" {
|
|||
#include "system.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T41
|
||||
|
||||
EXTMEM static unsigned char MemPool[8*1024*1024];
|
||||
|
||||
extern "C" uint8 read_rom(int address) {
|
||||
return (MemPool[address]);
|
||||
}
|
||||
|
||||
extern "C" uint8 readb_swap_rom(int address) {
|
||||
return (MemPool[address^1]);
|
||||
}
|
||||
|
||||
extern "C" uint16 readw_swap_rom(int address) {
|
||||
return ((MemPool[address+1]<<8) + MemPool[address]);
|
||||
}
|
||||
extern "C" void write_rom(int address, uint8 val) {
|
||||
MemPool[address]=val;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "psram_t.h"
|
||||
|
||||
PSRAM_T psram = PSRAM_T(PSRAM_CS, PSRAM_MOSI, PSRAM_SCLK, PSRAM_MISO);
|
||||
|
||||
extern "C" uint8 read_rom(int address) {
|
||||
|
|
@ -27,6 +49,8 @@ extern "C" void write_rom(int address, uint8 val) {
|
|||
psram.pswrite(address,val);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static uint8 romversion;
|
||||
extern "C" uint8 rom_version(void) {
|
||||
return romversion;
|
||||
|
|
@ -47,11 +71,18 @@ static deinterleave_block(int offset, int srcoffset)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void gen_Init(void)
|
||||
{
|
||||
emu_printf("Allocating MEM");
|
||||
#ifndef HAS_T41
|
||||
psram.begin();
|
||||
#endif
|
||||
mem_init();
|
||||
emu_printf("Allocating MEM done");
|
||||
}
|
||||
|
|
@ -167,7 +198,3 @@ audio_play_sample(stream, 0, len);
|
|||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1387,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
//#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
|
||||
#define EXTRA_HEAP 0x10 //0x9000
|
||||
#ifdef HAS_T4_VGA
|
||||
#define EXTRA_HEAP 0x10000
|
||||
#else
|
||||
#define EXTRA_HEAP 0x10
|
||||
#endif
|
||||
|
||||
// Title: < >
|
||||
#define TITLE " Genesis Emulator "
|
||||
|
|
@ -18,7 +20,7 @@
|
|||
#define emu_Step(x) {gen_Step();}
|
||||
#define emu_Input(x) {gen_Input(x);}
|
||||
|
||||
#define PALETTE_SIZE 2
|
||||
#define PALETTE_SIZE 1
|
||||
#define VID_FRAME_SKIP 0x0
|
||||
#define TFT_VBUFFER_YCROP 0
|
||||
#define SINGLELINE_RENDERING 1
|
||||
|
|
@ -57,7 +59,7 @@ const unsigned short keysw[]=
|
|||
//TAREA_NEW_ROW,18,18,18,18,18,18,18,18,18,18,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[]={
|
||||
const unsigned short key_map1[]={
|
||||
|
||||
59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
|
||||
109,110,111,112,106,107,108,17,18,19,
|
||||
|
|
@ -101,17 +103,17 @@ const unsigned short i2ckeys[] = {
|
|||
extern "C" {
|
||||
#endif
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
extern void * emu_Malloc(int size);
|
||||
extern void emu_Free(void * pt);
|
||||
|
||||
|
||||
extern int emu_FileOpen(char * filename);
|
||||
extern int emu_FileRead(char * buf, int size);
|
||||
extern unsigned char emu_FileGetc(void);
|
||||
extern int emu_FileTell(void);
|
||||
extern int emu_FileSeek(int seek);
|
||||
extern void emu_FileClose(void);
|
||||
extern int emu_FileSize(char * filename);
|
||||
|
|
@ -124,6 +126,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -137,6 +140,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -145,12 +151,14 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,22 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T41 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
//#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -240,7 +240,6 @@ Serial.printf("D") ; Serial.flush();
|
|||
|
||||
#include "emuapi.h"
|
||||
|
||||
|
||||
PSRAM_T::PSRAM_T(uint8_t cs, uint8_t mosi, uint8_t sclk, uint8_t miso)
|
||||
{
|
||||
}
|
||||
|
|
@ -386,4 +385,3 @@ uint16_t PSRAM_T::psread_w(uint32_t addr)
|
|||
psram_read_n(curPage,&(pages[top].page[0]),PAGE_SIZE);
|
||||
return (pages[top].page[offs+1]<<8) + pages[top].page[offs];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@
|
|||
|
||||
|
||||
#include "shared.h"
|
||||
#include "platform_config.h"
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#endif
|
||||
extern void emu_DrawLine16(unsigned short *src, int width , int height, int line);
|
||||
extern void emu_printf(char * text);
|
||||
|
||||
|
||||
#ifdef ALIGN_LONG
|
||||
|
||||
|
|
@ -14,6 +22,27 @@
|
|||
#undef READ_LONG
|
||||
#undef WRITE_LONG
|
||||
|
||||
|
||||
|
||||
if(reg[12] & 8)
|
||||
{
|
||||
int j;
|
||||
for(j = 0; j < 3; j += 1)
|
||||
{
|
||||
color = &vdp_palette[j][data];
|
||||
set_color((j << 6), color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color = &vdp_palette[1][data];
|
||||
set_color(0x00, color);
|
||||
set_color(0x40, color);
|
||||
set_color(0x80, color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ uint32 READ_LONG(void *address)
|
||||
{
|
||||
if ((uint32)address & 3)
|
||||
|
|
@ -155,6 +184,9 @@ static __inline__ void WRITE_LONG(void *address, uint32 data)
|
|||
|
||||
/* Pixel creation macros, input is four bits each */
|
||||
|
||||
/* 3:3:2 RGB */
|
||||
#define MAKE_PIXEL_8(r,g,b) ((r) << 5 | (g) << 2 | ((b) >> 1))
|
||||
|
||||
/* 5:6:5 RGB */
|
||||
#define MAKE_PIXEL_16(r,g,b) ((r) << 12 | (g) << 7 | (b) << 1)
|
||||
|
||||
|
|
@ -229,6 +261,7 @@ int render_init(void)
|
|||
pixel_16_lut[2][i] = MAKE_PIXEL_16(r|8,g|8,b|8);
|
||||
}
|
||||
|
||||
|
||||
/* Set up color update function */
|
||||
color_update = color_update_16;
|
||||
|
||||
|
|
@ -283,6 +316,7 @@ void render_reset(void)
|
|||
memset(ntb_buf, 0, sizeof(ntb_buf));
|
||||
memset(obj_buf, 0, sizeof(obj_buf));
|
||||
|
||||
//memset(&pixel_8, 0, sizeof(pixel_8));
|
||||
memset(&pixel_16, 0, sizeof(pixel_16));
|
||||
}
|
||||
|
||||
|
|
@ -363,12 +397,8 @@ void render_line(int line)
|
|||
|
||||
|
||||
int width = (reg[12] & 1) ? 320 : 256;
|
||||
|
||||
|
||||
|
||||
remap_16(lb+0x20, line_buf, pixel_16, width);
|
||||
emu_DrawLine16(line_buf, width ,256, line);
|
||||
//remap_16(lb+0x20, emu_LineBuffer(line), pixel_16, width);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Window rendering */
|
||||
|
|
@ -770,18 +800,6 @@ void window_clip(int line)
|
|||
/*--------------------------------------------------------------------------*/
|
||||
/* Remap functions */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
void remap_8(uint8 *src, uint8 *dst, uint8 *table, int length)
|
||||
{
|
||||
int count;
|
||||
for(count = 0; count < length; count += 1)
|
||||
{
|
||||
*dst++ = table[*src++];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void remap_16(uint8 *src, uint16 *dst, uint16 *table, int length)
|
||||
{
|
||||
int count;
|
||||
|
|
@ -808,6 +826,7 @@ void merge(uint8 *srca, uint8 *srcb, uint8 *dst, uint8 *table, int width)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void color_update_16(int index, uint16 data)
|
||||
{
|
||||
if(reg[12] & 8)
|
||||
|
|
@ -1044,4 +1063,3 @@ void render_obj_im2(int line, uint8 *buf, uint8 *table)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,4 +37,3 @@ void make_name_lut(void);
|
|||
void parse_satb(int line);
|
||||
|
||||
#endif /* _RENDER_H_ */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
|
||||
extern "C" {
|
||||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
|
|
@ -33,7 +34,14 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -55,7 +63,6 @@ static void vblCount() {
|
|||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
//Serial.println("%d: %d %d %d\n", index, r,g,b);
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
|
|
@ -67,7 +74,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -79,7 +90,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -97,11 +112,28 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -112,7 +144,11 @@ void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
|||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -162,14 +198,18 @@ void * emu_LineBuffer(int line)
|
|||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
tft.begin();
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
}
|
||||
|
||||
|
||||
// ****************************************************
|
||||
// the loop() method runs continuously
|
||||
// ****************************************************
|
||||
|
|
@ -182,7 +222,10 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||
tft.startDMA();
|
||||
}
|
||||
|
|
@ -192,6 +235,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -217,12 +261,14 @@ void loop(void)
|
|||
#endif
|
||||
if ( (!virtualkeyboardIsActive()) || (vgaMode) ) {
|
||||
emu_Step();
|
||||
uint16_t bClick = 0; //emu_DebounceLocalKeys();
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
emu_Input(bClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
|
|
@ -230,8 +276,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -239,6 +292,10 @@ AudioConnection patchCord1(mymixer, dac1);
|
|||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensygen/vga_t_dma.h
Normal file
53
MCUME_teensy/teensygen/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "emuapi.h"
|
||||
#include "tft_t_dma.h"
|
||||
#include "psram_t.h"
|
||||
#include "iopins.h"
|
||||
|
||||
|
|
@ -21,27 +20,39 @@ extern "C" {
|
|||
#include "loader.h"
|
||||
}
|
||||
|
||||
|
||||
static int rom_offset = 0;
|
||||
|
||||
PSRAM_T psram = PSRAM_T(PSRAM_CS, PSRAM_MOSI, PSRAM_SCLK, PSRAM_MISO);
|
||||
#ifdef HAS_T41
|
||||
EXTMEM static unsigned char MemPool[8*1024*1024];
|
||||
|
||||
extern "C" uint8 read_rom(int address) {
|
||||
return (MemPool[address+rom_offset]);
|
||||
}
|
||||
|
||||
extern "C" void write_rom(int address, uint8 val) {
|
||||
MemPool[address]=val;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "psram_t.h"
|
||||
|
||||
PSRAM_T psram = PSRAM_T(PSRAM_CS, PSRAM_MOSI, PSRAM_SCLK, PSRAM_MISO);
|
||||
|
||||
extern "C" uint8 read_rom(int address) {
|
||||
return (psram.psread(address+rom_offset));
|
||||
}
|
||||
|
||||
//extern "C" uint8 readb_swap_rom(int address) {
|
||||
// return(psram.psread(address^1));
|
||||
//}
|
||||
|
||||
//extern "C" uint16 readw_swap_rom(int address) {
|
||||
// return psram.psread_w(address);
|
||||
//}
|
||||
|
||||
extern "C" void write_rom(int address, uint8 val) {
|
||||
psram.pswrite(address,val);
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -49,7 +60,9 @@ extern "C" void write_rom(int address, uint8 val) {
|
|||
void gbe_Init(void)
|
||||
{
|
||||
emu_printf("Allocating MEM");
|
||||
#ifndef HAS_T41
|
||||
psram.begin();
|
||||
#endif
|
||||
mem_init();
|
||||
emu_printf("Allocating MEM done");
|
||||
}
|
||||
|
|
@ -98,8 +111,10 @@ void gbe_Start(char * Cartridge)
|
|||
cpu_reset();
|
||||
mbc_reset();
|
||||
#ifdef SOUND_PRESENT
|
||||
#ifdef HAS_SND
|
||||
sound_reset(22050);
|
||||
emu_sndInit();
|
||||
#endif
|
||||
#endif
|
||||
lcd_begin();
|
||||
emu_printf("init done");
|
||||
|
|
@ -151,7 +166,3 @@ void SND_Process(void *stream, int len) {
|
|||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -413,7 +448,7 @@ int emu_ReadKeys(void)
|
|||
if ( digitalRead(PIN_KEY_USER4) == LOW ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
// Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|| (retval & MASK_KEY_USER4 ) )
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1387,7 +1549,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1579,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
//#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
|
||||
#define EXTRA_HEAP 0x10 //0x9000
|
||||
|
|
@ -57,7 +55,7 @@ const unsigned short keysw[]=
|
|||
//TAREA_NEW_ROW,18,18,18,18,18,18,18,18,18,18,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[]={
|
||||
const unsigned short key_map1[]={
|
||||
|
||||
59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
|
||||
109,110,111,112,106,107,108,17,18,19,
|
||||
|
|
@ -101,17 +99,17 @@ const unsigned short i2ckeys[] = {
|
|||
extern "C" {
|
||||
#endif
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void emu_printh(int val);
|
||||
extern void * emu_Malloc(int size);
|
||||
extern void emu_Free(void * pt);
|
||||
|
||||
|
||||
extern int emu_FileOpen(char * filename);
|
||||
extern int emu_FileRead(char * buf, int size);
|
||||
extern unsigned char emu_FileGetc(void);
|
||||
extern int emu_FileTell(void);
|
||||
extern int emu_FileSeek(int seek);
|
||||
extern void emu_FileClose(void);
|
||||
extern int emu_FileSize(char * filename);
|
||||
|
|
@ -124,6 +122,7 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
|
|
@ -137,6 +136,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -145,12 +147,14 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,22 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T41 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
extern "C" {
|
||||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
|
||||
#include "keyboard_osd.h"
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
|
|
@ -33,7 +34,13 @@ uVGA uvga;
|
|||
uint8_t * VGA_frame_buffer;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
bool vgaMode = false;
|
||||
|
||||
|
|
@ -43,6 +50,9 @@ static IntervalTimer myTimer;
|
|||
volatile boolean vbl=true;
|
||||
static int skip=0;
|
||||
static elapsedMicros tius;
|
||||
volatile int16_t mClick=0;
|
||||
|
||||
|
||||
|
||||
static void vblCount() {
|
||||
if (vbl) {
|
||||
|
|
@ -67,7 +77,11 @@ void emu_DrawVsync(void)
|
|||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -79,7 +93,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,1,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,1,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
else {
|
||||
|
|
@ -97,11 +115,28 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
#endif
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -112,7 +147,11 @@ void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
|||
{
|
||||
if (!vgaMode) {
|
||||
if (skip==0) {
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#else
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -158,15 +197,20 @@ void * emu_LineBuffer(int line)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ****************************************************
|
||||
// the setup() method runs once, when the sketch starts
|
||||
// ****************************************************
|
||||
void setup() {
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
|
||||
emu_init();
|
||||
|
||||
myTimer.begin(vblCount, 20000); //to run every 20ms
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -182,9 +226,13 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
vgaMode = false;
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
//digitalWrite(TFT_CS, 1);
|
||||
//digitalWrite(SD_CS, 1);
|
||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||
tft.startDMA();
|
||||
myTimer.begin(vblCount, 40000); //to run every 40ms
|
||||
}
|
||||
else if (action == ACTION_RUNVGA) {
|
||||
#ifdef HAS_VGA
|
||||
|
|
@ -192,6 +240,7 @@ void loop(void)
|
|||
vgaMode = true;
|
||||
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
|
||||
uvga.set_static_framebuffer(VGA_frame_buffer);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
int retvga = uvga.begin(&modeline);
|
||||
Serial.println(retvga);
|
||||
|
|
@ -202,6 +251,7 @@ void loop(void)
|
|||
// In VGA mode, we show the keyboard on TFT
|
||||
toggleVirtualkeyboard(true); // keepOn
|
||||
Serial.println("Starting");
|
||||
myTimer.begin(vblCount, 40000); //to run every 20ms
|
||||
#endif
|
||||
}
|
||||
delay(20);
|
||||
|
|
@ -217,12 +267,17 @@ void loop(void)
|
|||
#endif
|
||||
if ( (!virtualkeyboardIsActive()) || (vgaMode) ) {
|
||||
emu_Step();
|
||||
uint16_t bClick = 0; //emu_DebounceLocalKeys();
|
||||
//delay(20);
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
emu_Input(bClick);
|
||||
if (bClick & MASK_KEY_USER1) {
|
||||
mClick = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
|
|
@ -230,8 +285,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensygnuboy/vga_t_dma.h
Normal file
53
MCUME_teensy/teensygnuboy/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -5,8 +5,17 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#include "logo.h"
|
||||
#endif
|
||||
|
||||
#include "bmpjoy.h"
|
||||
#include "bmpvbar.h"
|
||||
#ifdef OLD_LAYOUT
|
||||
|
|
@ -19,6 +28,13 @@ extern "C" {
|
|||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
#include "USBHost_t36.h" // Read this header first for key info
|
||||
USBHost myusb;
|
||||
KeyboardController keyboard1(myusb);
|
||||
#endif
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef USE_SDFS
|
||||
#include "uSDFS.h"
|
||||
static FATFS fatfs;
|
||||
|
|
@ -84,7 +100,7 @@ static File file;
|
|||
#define MKEY_TFT 23
|
||||
#define MKEY_VGA 24
|
||||
|
||||
#define MAX_FILES 32
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
#define MAX_MENULINES (MKEY_L9)
|
||||
#define TEXT_HEIGHT 16
|
||||
|
|
@ -93,7 +109,7 @@ static File file;
|
|||
#define MENU_FILE_YOFFSET (2*TEXT_HEIGHT)
|
||||
#define MENU_FILE_W (MAX_FILENAME_SIZE*TEXT_WIDTH)
|
||||
#define MENU_FILE_H (MAX_MENULINES*TEXT_HEIGHT)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x20)
|
||||
#define MENU_FILE_BGCOLOR RGBVAL16(0x00,0x00,0x40)
|
||||
#define MENU_JOYS_YOFFSET (12*TEXT_HEIGHT)
|
||||
#define MENU_VBAR_XOFFSET (0*TEXT_WIDTH)
|
||||
#define MENU_VBAR_YOFFSET (MENU_FILE_YOFFSET)
|
||||
|
|
@ -113,13 +129,10 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static int16_t calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static int calMinX=-1,calMinY=-1,calMaxX=-1,calMaxY=-1;
|
||||
static bool i2cKeyboardPresent = false;
|
||||
//const uint16_t deflogo[] = {
|
||||
// 0x0000,0x0000
|
||||
//};
|
||||
//static const uint16_t * logo = deflogo;
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
const unsigned short menutouchareas[] = {
|
||||
TAREA_XY,MENU_FILE_XOFFSET,MENU_FILE_YOFFSET,
|
||||
|
|
@ -245,7 +258,7 @@ void emu_printf(int val)
|
|||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
Serial.println(val);
|
||||
Serial.println(val,HEX);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
|
|
@ -272,13 +285,29 @@ void * emu_Malloc(int size)
|
|||
}
|
||||
}
|
||||
else {
|
||||
emu_printf("could allocate ");
|
||||
emu_printf("could allocate dynamic ");
|
||||
emu_printf(size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * emu_MallocI(int size)
|
||||
{
|
||||
void * retval = NULL;
|
||||
|
||||
if ( (malbufpt+size) < sizeof(malbuf) ) {
|
||||
retval = (void *)&malbuf[malbufpt];
|
||||
malbufpt += size;
|
||||
emu_printf("could allocate static ");
|
||||
emu_printf(size);
|
||||
}
|
||||
else {
|
||||
emu_printf("failure to allocate");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
void emu_Free(void * pt)
|
||||
{
|
||||
free(pt);
|
||||
|
|
@ -400,6 +429,12 @@ int emu_ReadKeys(void)
|
|||
retval = ((j2 << 8) | j1);
|
||||
}
|
||||
|
||||
if (usbnavpad & MASK_JOY2_UP) retval |= MASK_JOY2_UP;
|
||||
if (usbnavpad & MASK_JOY2_DOWN) retval |= MASK_JOY2_DOWN;
|
||||
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
|
||||
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
|
||||
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
|
@ -575,7 +610,7 @@ bool virtualkeyboardIsActive(void) {
|
|||
void toggleVirtualkeyboard(bool keepOn) {
|
||||
|
||||
if (keepOn) {
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbKeepOn = true;
|
||||
vkbActive = true;
|
||||
|
|
@ -592,7 +627,7 @@ void toggleVirtualkeyboard(bool keepOn) {
|
|||
}
|
||||
else {
|
||||
tft.stopDMA();
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo);
|
||||
tft.drawSpriteNoDma(0,0,logo);
|
||||
//prev_zt = 0;
|
||||
vkbActive = true;
|
||||
exitVkbd = false;
|
||||
|
|
@ -637,7 +672,7 @@ void handleVirtualkeyboard() {
|
|||
|
||||
if (vkeyRefresh) {
|
||||
vkeyRefresh = false;
|
||||
tft.drawSpriteNoDma(0,0,(uint16_t*)logo, rx, ry, rw, rh);
|
||||
tft.drawSpriteNoDma(0,0,logo, rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
if ( (exitVkbd) && (vkbActive) ) {
|
||||
|
|
@ -651,10 +686,6 @@ void handleVirtualkeyboard() {
|
|||
}
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -726,10 +757,12 @@ void backgroundMenu(void) {
|
|||
menuRedraw=true;
|
||||
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
tft.drawTextNoDma(0,0, TITLE, RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), true);
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,(uint16_t*)bmpvbar);
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(MENU_VBAR_XOFFSET,MENU_VBAR_YOFFSET,bmpvbar);
|
||||
#endif
|
||||
#ifdef OLD_LAYOUT
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,(uint16_t*)bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,(uint16_t*)bmpvga);
|
||||
tft.drawSpriteNoDma(MENU_TFT_XOFFSET,MENU_TFT_YOFFSET,bmptft);
|
||||
tft.drawSpriteNoDma(MENU_VGA_XOFFSET,MENU_VGA_YOFFSET,bmpvga);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +872,7 @@ int handleMenu(uint16_t bClick)
|
|||
strcpy(selection,filename);
|
||||
}
|
||||
else {
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, 0xFFFF, 0x0000, true);
|
||||
tft.drawTextNoDma(MENU_FILE_XOFFSET,i*TEXT_HEIGHT+MENU_FILE_YOFFSET, filename, RGBVAL16(0xff,0xff,0xff), MENU_FILE_BGCOLOR, true);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
|
|
@ -847,8 +880,10 @@ int handleMenu(uint16_t bClick)
|
|||
fileIndex++;
|
||||
}
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0xff,0x00,0x00), false);
|
||||
#endif
|
||||
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
|
||||
menuRedraw=false;
|
||||
}
|
||||
|
||||
|
|
@ -1338,11 +1373,138 @@ void emu_FileTempWrite(int addr, unsigned char val)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
void OnPress(auto key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad |= MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad |= MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad |= MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad |= MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad |= MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnDown(keymodifier, key);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRelease(int key)
|
||||
{
|
||||
uint8_t keymodifier = keyboard1.getModifiers();
|
||||
|
||||
if(keymodifier == 0x40){
|
||||
// ALTGR Key modifier FR Keyboard
|
||||
switch (key) {
|
||||
#ifdef LAYOUT_FRENCH
|
||||
case 233 : key = '~' ; break;
|
||||
case 34 : key = '#' ; break;
|
||||
case 39 : key = '{' ; break;
|
||||
case 40 : key = '[' ; break;
|
||||
case 45 : key = '|' ; break;
|
||||
case 232 : key = '`' ; break;
|
||||
case 95 : key = 92 ; break;
|
||||
case 231 : key = '^' ; break;
|
||||
case 224 : key = '@' ; break;
|
||||
case 41 : key = ']' ; break;
|
||||
case 61 : key = '}' ; break;
|
||||
#endif
|
||||
#ifdef LAYOUT_FRENCH_BELGIAN
|
||||
case 38 : key = '|' ; break; //1
|
||||
case 233 : key = '@' ; break; //2
|
||||
case 34 : key = '#' ; break; //3
|
||||
case 167 : key = '^' ; break; //6
|
||||
case 231 : key = '{' ; break; //9
|
||||
case 224 : key = '}' ; break; //0
|
||||
case 36 : key = ']' ; break; //$
|
||||
case 61 : key = '~' ; break; //=
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (menuActive())
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 217:
|
||||
usbnavpad &= ~MASK_JOY2_DOWN;
|
||||
break;
|
||||
case 218:
|
||||
usbnavpad &= ~MASK_JOY2_UP;
|
||||
break;
|
||||
case 216:
|
||||
usbnavpad &= ~MASK_JOY2_LEFT;
|
||||
break;
|
||||
case 215:
|
||||
usbnavpad &= ~MASK_JOY2_RIGHT;
|
||||
break;
|
||||
case 10:
|
||||
usbnavpad &= ~MASK_JOY2_BTN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emu_KeyboardOnUp(keymodifier, key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef HAS_USBKEY
|
||||
myusb.begin();
|
||||
keyboard1.attachPress(OnPress);
|
||||
keyboard1.attachRelease(OnRelease);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDFS
|
||||
strcpy(romspath,SDFSDEV);
|
||||
strcat(romspath,ROMSDIR);
|
||||
|
|
@ -1355,9 +1517,9 @@ void emu_init(void)
|
|||
}
|
||||
#else
|
||||
#ifdef USE_SDFAT
|
||||
if (!SD.begin(SD_CONFIG))
|
||||
while (!SD.begin(SD_CONFIG))
|
||||
#else
|
||||
if (!SD.begin(SD_CS))
|
||||
while (!SD.begin(SD_CS))
|
||||
#endif
|
||||
{
|
||||
Serial.println("SD begin failed, retrying...");
|
||||
|
|
@ -1371,7 +1533,6 @@ void emu_init(void)
|
|||
Serial.print("SD initialized, files found: ");
|
||||
Serial.println(nbFiles);
|
||||
|
||||
|
||||
emu_InitJoysticks();
|
||||
#ifdef SWAP_JOYSTICK
|
||||
joySwapped = true;
|
||||
|
|
@ -1387,7 +1548,11 @@ void emu_init(void)
|
|||
{
|
||||
toggleMenu(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
#ifdef HAS_I2CKBD
|
||||
byte msg[7]={0,0,0,0,0,0,0};
|
||||
Wire.begin(); // join i2c bus SDA2/SCL2
|
||||
|
|
@ -1413,5 +1578,9 @@ void emu_init(void)
|
|||
Serial.println("i2C keyboard found");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_SND 1
|
||||
//#define HAS_I2CKBD 1
|
||||
//#define TIMER_REND 1
|
||||
#include "platform_config.h"
|
||||
|
||||
//#define TIMER_REND 1
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
// Title: < >
|
||||
|
|
@ -52,7 +49,7 @@ const unsigned short keysw[] = {
|
|||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keys[] = {
|
||||
const unsigned short key_map1[] = {
|
||||
30,31,32,33,34,35,36,37,38,39,
|
||||
20,26, 8,21,23,28,25,12,18,19,
|
||||
4, 9, 7,22, 4,11,13,14,15,40,
|
||||
|
|
@ -87,8 +84,10 @@ const unsigned short i2ckeys[] = {
|
|||
#define MASK_KEY_USER4 0x2000
|
||||
|
||||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
||||
extern void emu_printf(char * text);
|
||||
extern void emu_printi(int val);
|
||||
extern void * emu_Malloc(int size);
|
||||
|
|
@ -109,8 +108,11 @@ extern void emu_FileTempWrite(int addr, unsigned char val);
|
|||
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
|
||||
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
|
||||
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
|
||||
extern void emu_DrawVsync(void);
|
||||
extern int emu_FrameSkip(void);
|
||||
extern void * emu_LineBuffer(int line);
|
||||
|
||||
extern void emu_InitJoysticks(void);
|
||||
extern int emu_SwapJoysticks(int statusOnly);
|
||||
|
|
@ -120,6 +122,9 @@ extern int emu_GetPad(void);
|
|||
extern int emu_ReadAnalogJoyX(int min, int max);
|
||||
extern int emu_ReadAnalogJoyY(int min, int max);
|
||||
extern int emu_ReadI2CKeyboard(void);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
extern void emu_sndPlaySound(int chan, int volume, int freq);
|
||||
extern void emu_sndPlayBuzz(int size, int val);
|
||||
extern void emu_sndInit();
|
||||
|
|
@ -128,8 +133,9 @@ extern int emu_us(void);
|
|||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
extern void emu_FileTempInit(void);
|
||||
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
|
||||
extern void emu_FileTempWrite(int addr, unsigned char val);
|
||||
extern void emu_printh(int val);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,26 @@
|
|||
#define I2C_SDA_IO 18
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 5 extra buttons
|
||||
#ifdef HAS_T4_VGA
|
||||
#define PIN_JOY2_A1X A3
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 14
|
||||
#define PIN_KEY_USER1 22
|
||||
#define PIN_KEY_USER2 23
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 34
|
||||
#define PIN_JOY1_1 38 // UP
|
||||
#define PIN_JOY1_2 36 // DOWN
|
||||
#define PIN_JOY1_3 35 // RIGHT
|
||||
#define PIN_JOY1_4 37 // LEFT
|
||||
|
||||
#else
|
||||
#define PIN_JOY2_A1X A1
|
||||
#define PIN_JOY2_A2Y A2
|
||||
#define PIN_JOY2_BTN 17
|
||||
#define PIN_KEY_USER1 3 //34
|
||||
#define PIN_KEY_USER2 4 //35
|
||||
//#define PIN_KEY_USER3 33
|
||||
//#define PIN_KEY_USER4 39
|
||||
|
||||
// Second joystick
|
||||
#define PIN_JOY1_BTN 2
|
||||
|
|
@ -49,6 +62,7 @@
|
|||
#define PIN_JOY1_2 7 // DOWN
|
||||
#define PIN_JOY1_3 6 // RIGHT
|
||||
#define PIN_JOY1_4 5 // LEFT
|
||||
#endif
|
||||
|
||||
#else
|
||||
// OLD LAYOUT!!!!
|
||||
|
|
@ -87,7 +101,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,21 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
#define ILI9341 1
|
||||
//#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
#define EXTERNAL_SD 1
|
||||
//#define EXTERNAL_SD 1
|
||||
|
||||
#define HAS_PSRAM 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
|
|
|
|||
|
|
@ -2,31 +2,39 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
#include "tft_t_dma.h"
|
||||
|
||||
#include "keyboard_osd.h"
|
||||
#include <math.h>
|
||||
#include "mcume.h"
|
||||
|
||||
|
||||
#ifdef HAS_T4_VGA
|
||||
#include "vga_t_dma.h"
|
||||
TFT_T_DMA tft;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO, TFT_TOUCH_CS, TFT_TOUCH_INT);
|
||||
#endif
|
||||
|
||||
static int xOffLogo=0;
|
||||
static int swipeAngle=0;
|
||||
|
||||
void setup() {
|
||||
//emu_sndInit();
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
// NVIC_SET_PRIORITY(IRQ_QTIMER3, 0);
|
||||
#else
|
||||
tft.begin();
|
||||
//emu_sndPlaySound(0, 255, 4000);
|
||||
#endif
|
||||
emu_init();
|
||||
//delay(5000);
|
||||
//toggleMenu(false);
|
||||
//tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
|
||||
//tft.startDMA();
|
||||
}
|
||||
|
||||
static uint8_t col=0x00;
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
if (menuActive()) {
|
||||
int action = handleMenu(bClick);
|
||||
|
|
@ -62,7 +70,6 @@ void loop(void)
|
|||
#endif
|
||||
if ( (!virtualkeyboardIsActive()) ) {
|
||||
delay(20);
|
||||
//emu_printf("step");
|
||||
xOffLogo = 16*sin((2*3.14*swipeAngle)/256)+30;
|
||||
swipeAngle = (swipeAngle + 4)&0xff;
|
||||
tft.drawSprite(xOffLogo,10,(uint16_t*)logo);
|
||||
|
|
@ -75,6 +82,12 @@ void loop(void)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
|
|
@ -82,8 +95,15 @@ void loop(void)
|
|||
|
||||
AudioPlaySystem mymixer;
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
|
|
@ -91,6 +111,10 @@ AudioConnection patchCord1(mymixer, dac1);
|
|||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
|
||||
#include "TFT_T_DMA.h"
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include "font8x8.h"
|
||||
|
||||
|
||||
|
|
@ -1231,7 +1234,7 @@ void TFT_T_DMA::drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_
|
|||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
53
MCUME_teensy/teensylogo/vga_t_dma.h
Normal file
53
MCUME_teensy/teensylogo/vga_t_dma.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Wrapping class to extend VGA_T4 to TFT_T_DMA
|
||||
*/
|
||||
|
||||
#ifndef _VGA_T_DMAH_
|
||||
#define _VGA_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <VGA_t4.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define RGBVAL16(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
|
||||
|
||||
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA: public VGA_T4
|
||||
{
|
||||
public:
|
||||
// Fake touch screen functions
|
||||
bool isTouching(void) { return false; }
|
||||
void readRaw(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { }
|
||||
void readCal(uint16_t * oX, uint16_t * oY, uint16_t * oZ) { };
|
||||
void callibrateTouch(uint16_t xMin,uint16_t yMin,uint16_t xMax,uint16_t yMax) { }
|
||||
|
||||
// fake DMA functions
|
||||
void startDMA(void) { };
|
||||
void stopDMA(void) { };
|
||||
|
||||
// fake no DMA functions
|
||||
void writeScreenNoDma(const vga_pixel *pcolors) { writeScreen(pcolors); }
|
||||
void fillScreenNoDma(vga_pixel color) { clear(color); }
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); }
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap) { drawSprite(x, y, bitmap); }
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
BIN
MCUME_teensy/teensymsx/.DS_Store
vendored
BIN
MCUME_teensy/teensymsx/.DS_Store
vendored
Binary file not shown.
|
|
@ -6,7 +6,7 @@
|
|||
/** produced by General Instruments, Yamaha, etc. See **/
|
||||
/** AY8910.h for declarations. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
@ -148,7 +148,8 @@ void Write8910(register AY8910 *D,register byte R,register byte V)
|
|||
/* Compute channel number */
|
||||
R-=8;
|
||||
/* Compute and assign new volume */
|
||||
D->Volume[R+3]=D->Volume[R]=255*(V&0x0F)/15;
|
||||
D->Volume[R+3]=D->Volume[R]=
|
||||
V&0x10? (V&0x04? 0:255):255*(V&0x0F)/15;
|
||||
/* Start/stop envelope */
|
||||
D->Phase[R]=V&0x10? 1:0;
|
||||
/* Compute changed channels mask */
|
||||
|
|
@ -160,8 +161,8 @@ void Write8910(register AY8910 *D,register byte R,register byte V)
|
|||
/* Write value */
|
||||
D->R[R]=V;
|
||||
/* Compute frequency */
|
||||
J=((int)D->R[12]<<8)+D->R[11];
|
||||
D->EPeriod=1000*J/AY8910_BASE/16;
|
||||
J=((int)D->R[12]<<8)+D->R[11]+1;
|
||||
D->EPeriod=1000*(J<<4)/AY8910_BASE;
|
||||
D->ECount=0;
|
||||
/* No channels changed */
|
||||
return;
|
||||
|
|
@ -198,10 +199,12 @@ void Loop8910(register AY8910 *D,int mS)
|
|||
/* Count milliseconds */
|
||||
D->ECount+=mS;
|
||||
if(D->ECount<D->EPeriod) return;
|
||||
D->ECount-=D->EPeriod;
|
||||
|
||||
/* By how much do we change volume? */
|
||||
Step=mS>=D->EPeriod? mS/D->EPeriod:1;
|
||||
Step=(D->ECount<<8)/D->EPeriod;
|
||||
|
||||
/* Count the remaining milliseconds */
|
||||
D->ECount%=D->EPeriod;
|
||||
|
||||
for(J=0;J<3;J++)
|
||||
if(D->Phase[J]&&(D->R[J+8]&0x10))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/** produced by General Instruments, Yamaha, etc. See **/
|
||||
/** AY8910.c for the actual code. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains implementation for the main table of **/
|
||||
/** Z80 commands. It is included from Z80.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-1998 **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
@ -206,7 +206,7 @@ case POP_DE: M_POP(DE);break;
|
|||
case POP_HL: M_POP(HL);break;
|
||||
case POP_AF: M_POP(AF);break;
|
||||
|
||||
case DJNZ: if(--R->BC.B.h) { M_JR; } else R->PC.W++;break;
|
||||
case DJNZ: if(--R->BC.B.h) { R->ICount-=5;M_JR; } else R->PC.W++;break;
|
||||
case JP: M_JP;break;
|
||||
case JR: M_JR;break;
|
||||
case CALL: M_CALL;break;
|
||||
|
|
@ -214,18 +214,25 @@ case RET: M_RET;break;
|
|||
case SCF: S(C_FLAG);R(N_FLAG|H_FLAG);break;
|
||||
case CPL: R->AF.B.h=~R->AF.B.h;S(N_FLAG|H_FLAG);break;
|
||||
case NOP: break;
|
||||
case OUTA: OutZ80(RdZ80(R->PC.W++),R->AF.B.h);break;
|
||||
case INA: R->AF.B.h=InZ80(RdZ80(R->PC.W++));break;
|
||||
case HALT: R->PC.W--;R->IFF|=0x80;R->ICount=0;break;
|
||||
case OUTA: I=RdZ80(R->PC.W++);OutZ80(I,R->AF.B.h);break;
|
||||
case INA: I=RdZ80(R->PC.W++);R->AF.B.h=InZ80(I);break;
|
||||
|
||||
case HALT:
|
||||
R->PC.W--;
|
||||
R->IFF|=IFF_HALT;
|
||||
R->IBackup=0;
|
||||
R->ICount=0;
|
||||
break;
|
||||
|
||||
case DI:
|
||||
R->IFF&=0xFE;
|
||||
if(R->IFF&IFF_EI) R->ICount+=R->IBackup-1;
|
||||
R->IFF&=~(IFF_1|IFF_2|IFF_EI);
|
||||
break;
|
||||
|
||||
case EI:
|
||||
R->IFF|=0x01;
|
||||
if(R->IRequest!=INT_NONE)
|
||||
if(!(R->IFF&(IFF_1|IFF_EI)))
|
||||
{
|
||||
R->IFF|=0x20;
|
||||
R->IFF|=IFF_2|IFF_EI;
|
||||
R->IBackup=R->ICount;
|
||||
R->ICount=1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains implementation for the CB table of **/
|
||||
/** Z80 commands. It is included from Z80.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-1998 **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains implementation for the ED table of **/
|
||||
/** Z80 commands. It is included from Z80.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-1998 **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
@ -92,24 +92,24 @@ case RLD:
|
|||
|
||||
case LD_A_I:
|
||||
R->AF.B.h=R->I;
|
||||
R->AF.B.l=(R->AF.B.l&C_FLAG)|(R->IFF&1? P_FLAG:0)|ZSTable[R->AF.B.h];
|
||||
R->AF.B.l=(R->AF.B.l&C_FLAG)|(R->IFF&IFF_2? P_FLAG:0)|ZSTable[R->AF.B.h];
|
||||
break;
|
||||
|
||||
case LD_A_R:
|
||||
R->R++;
|
||||
R->AF.B.h=(byte)(R->R-R->ICount);
|
||||
R->AF.B.l=(R->AF.B.l&C_FLAG)|(R->IFF&1? P_FLAG:0)|ZSTable[R->AF.B.h];
|
||||
R->AF.B.l=(R->AF.B.l&C_FLAG)|(R->IFF&IFF_2? P_FLAG:0)|ZSTable[R->AF.B.h];
|
||||
break;
|
||||
|
||||
case LD_I_A: R->I=R->AF.B.h;break;
|
||||
case LD_R_A: break;
|
||||
|
||||
case IM_0: R->IFF&=0xF9;break;
|
||||
case IM_1: R->IFF=(R->IFF&0xF9)|2;break;
|
||||
case IM_2: R->IFF=(R->IFF&0xF9)|4;break;
|
||||
case IM_0: R->IFF&=~(IFF_IM1|IFF_IM2);break;
|
||||
case IM_1: R->IFF=(R->IFF&~IFF_IM2)|IFF_IM1;break;
|
||||
case IM_2: R->IFF=(R->IFF&~IFF_IM1)|IFF_IM2;break;
|
||||
|
||||
case RETI: M_RET;break;
|
||||
case RETN: if(R->IFF&0x40) R->IFF|=0x01; else R->IFF&=0xFE;
|
||||
case RETN: if(R->IFF&IFF_2) R->IFF|=IFF_1; else R->IFF&=~IFF_1;
|
||||
M_RET;break;
|
||||
|
||||
case NEG: I=R->AF.B.h;R->AF.B.h=0;M_SUB(I);break;
|
||||
|
|
@ -166,37 +166,59 @@ case INDR:
|
|||
break;
|
||||
|
||||
case OUTI:
|
||||
OutZ80(R->BC.B.l,RdZ80(R->HL.W++));
|
||||
I=RdZ80(R->HL.W++);
|
||||
OutZ80(R->BC.B.l,I);
|
||||
R->BC.B.h--;
|
||||
R->AF.B.l=N_FLAG|(R->BC.B.h? 0:Z_FLAG);
|
||||
R->AF.B.l=N_FLAG|(R->BC.B.h? 0:Z_FLAG)|(R->HL.B.l+I>255? (C_FLAG|H_FLAG):0);
|
||||
break;
|
||||
|
||||
case OTIR:
|
||||
do
|
||||
{
|
||||
OutZ80(R->BC.B.l,RdZ80(R->HL.W++));
|
||||
R->BC.B.h--;R->ICount-=21;
|
||||
I=RdZ80(R->HL.W++);
|
||||
OutZ80(R->BC.B.l,I);
|
||||
R->BC.B.h--;
|
||||
R->ICount-=21;
|
||||
}
|
||||
while(R->BC.B.h&&(R->ICount>0));
|
||||
if(R->BC.B.h) { R->AF.B.l=N_FLAG;R->PC.W-=2; }
|
||||
else { R->AF.B.l=Z_FLAG|N_FLAG;R->ICount+=5; }
|
||||
if(R->BC.B.h)
|
||||
{
|
||||
R->AF.B.l=N_FLAG|(R->HL.B.l+I>255? (C_FLAG|H_FLAG):0);
|
||||
R->PC.W-=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
R->AF.B.l=Z_FLAG|N_FLAG|(R->HL.B.l+I>255? (C_FLAG|H_FLAG):0);
|
||||
R->ICount+=5;
|
||||
}
|
||||
break;
|
||||
|
||||
case OUTD:
|
||||
OutZ80(R->BC.B.l,RdZ80(R->HL.W--));
|
||||
I=RdZ80(R->HL.W--);
|
||||
OutZ80(R->BC.B.l,I);
|
||||
R->BC.B.h--;
|
||||
R->AF.B.l=N_FLAG|(R->BC.B.h? 0:Z_FLAG);
|
||||
R->AF.B.l=N_FLAG|(R->BC.B.h? 0:Z_FLAG)|(R->HL.B.l+I>255? (C_FLAG|H_FLAG):0);
|
||||
break;
|
||||
|
||||
case OTDR:
|
||||
do
|
||||
{
|
||||
OutZ80(R->BC.B.l,RdZ80(R->HL.W--));
|
||||
R->BC.B.h--;R->ICount-=21;
|
||||
I=RdZ80(R->HL.W--);
|
||||
OutZ80(R->BC.B.l,I);
|
||||
R->BC.B.h--;
|
||||
R->ICount-=21;
|
||||
}
|
||||
while(R->BC.B.h&&(R->ICount>0));
|
||||
if(R->BC.B.h) { R->AF.B.l=N_FLAG;R->PC.W-=2; }
|
||||
else { R->AF.B.l=Z_FLAG|N_FLAG;R->ICount+=5; }
|
||||
if(R->BC.B.h)
|
||||
{
|
||||
R->AF.B.l=N_FLAG|(R->HL.B.l+I>255? (C_FLAG|H_FLAG):0);
|
||||
R->PC.W-=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
R->AF.B.l=Z_FLAG|N_FLAG|(R->HL.B.l+I>255? (C_FLAG|H_FLAG):0);
|
||||
R->ICount+=5;
|
||||
}
|
||||
break;
|
||||
|
||||
case LDI:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains implementation for FD/DD-CB tables **/
|
||||
/** of Z80 commands. It is included from Z80.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-1998 **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@
|
|||
/** This file contains implementation for FD/DD tables of **/
|
||||
/** Z80 commands. It is included from Z80.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-1998 **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
/*************************************************************/
|
||||
|
||||
case JR_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W++; else { M_JR; } break;
|
||||
case JR_NC: if(R->AF.B.l&C_FLAG) R->PC.W++; else { M_JR; } break;
|
||||
case JR_Z: if(R->AF.B.l&Z_FLAG) { M_JR; } else R->PC.W++; break;
|
||||
case JR_C: if(R->AF.B.l&C_FLAG) { M_JR; } else R->PC.W++; break;
|
||||
case JR_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W++; else { R->ICount-=5;M_JR; } break;
|
||||
case JR_NC: if(R->AF.B.l&C_FLAG) R->PC.W++; else { R->ICount-=5;M_JR; } break;
|
||||
case JR_Z: if(R->AF.B.l&Z_FLAG) { R->ICount-=5;M_JR; } else R->PC.W++; break;
|
||||
case JR_C: if(R->AF.B.l&C_FLAG) { R->ICount-=5;M_JR; } else R->PC.W++; break;
|
||||
|
||||
case JP_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W+=2; else { M_JP; } break;
|
||||
case JP_NC: if(R->AF.B.l&C_FLAG) R->PC.W+=2; else { M_JP; } break;
|
||||
|
|
@ -25,23 +25,23 @@ case JP_C: if(R->AF.B.l&C_FLAG) { M_JP; } else R->PC.W+=2; break;
|
|||
case JP_PE: if(R->AF.B.l&P_FLAG) { M_JP; } else R->PC.W+=2; break;
|
||||
case JP_M: if(R->AF.B.l&S_FLAG) { M_JP; } else R->PC.W+=2; break;
|
||||
|
||||
case RET_NZ: if(!(R->AF.B.l&Z_FLAG)) { M_RET; } break;
|
||||
case RET_NC: if(!(R->AF.B.l&C_FLAG)) { M_RET; } break;
|
||||
case RET_PO: if(!(R->AF.B.l&P_FLAG)) { M_RET; } break;
|
||||
case RET_P: if(!(R->AF.B.l&S_FLAG)) { M_RET; } break;
|
||||
case RET_Z: if(R->AF.B.l&Z_FLAG) { M_RET; } break;
|
||||
case RET_C: if(R->AF.B.l&C_FLAG) { M_RET; } break;
|
||||
case RET_PE: if(R->AF.B.l&P_FLAG) { M_RET; } break;
|
||||
case RET_M: if(R->AF.B.l&S_FLAG) { M_RET; } break;
|
||||
case RET_NZ: if(!(R->AF.B.l&Z_FLAG)) { R->ICount-=6;M_RET; } break;
|
||||
case RET_NC: if(!(R->AF.B.l&C_FLAG)) { R->ICount-=6;M_RET; } break;
|
||||
case RET_PO: if(!(R->AF.B.l&P_FLAG)) { R->ICount-=6;M_RET; } break;
|
||||
case RET_P: if(!(R->AF.B.l&S_FLAG)) { R->ICount-=6;M_RET; } break;
|
||||
case RET_Z: if(R->AF.B.l&Z_FLAG) { R->ICount-=6;M_RET; } break;
|
||||
case RET_C: if(R->AF.B.l&C_FLAG) { R->ICount-=6;M_RET; } break;
|
||||
case RET_PE: if(R->AF.B.l&P_FLAG) { R->ICount-=6;M_RET; } break;
|
||||
case RET_M: if(R->AF.B.l&S_FLAG) { R->ICount-=6;M_RET; } break;
|
||||
|
||||
case CALL_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W+=2; else { M_CALL; } break;
|
||||
case CALL_NC: if(R->AF.B.l&C_FLAG) R->PC.W+=2; else { M_CALL; } break;
|
||||
case CALL_PO: if(R->AF.B.l&P_FLAG) R->PC.W+=2; else { M_CALL; } break;
|
||||
case CALL_P: if(R->AF.B.l&S_FLAG) R->PC.W+=2; else { M_CALL; } break;
|
||||
case CALL_Z: if(R->AF.B.l&Z_FLAG) { M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_C: if(R->AF.B.l&C_FLAG) { M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_PE: if(R->AF.B.l&P_FLAG) { M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_M: if(R->AF.B.l&S_FLAG) { M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_NZ: if(R->AF.B.l&Z_FLAG) R->PC.W+=2; else { R->ICount-=7;M_CALL; } break;
|
||||
case CALL_NC: if(R->AF.B.l&C_FLAG) R->PC.W+=2; else { R->ICount-=7;M_CALL; } break;
|
||||
case CALL_PO: if(R->AF.B.l&P_FLAG) R->PC.W+=2; else { R->ICount-=7;M_CALL; } break;
|
||||
case CALL_P: if(R->AF.B.l&S_FLAG) R->PC.W+=2; else { R->ICount-=7;M_CALL; } break;
|
||||
case CALL_Z: if(R->AF.B.l&Z_FLAG) { R->ICount-=7;M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_C: if(R->AF.B.l&C_FLAG) { R->ICount-=7;M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_PE: if(R->AF.B.l&P_FLAG) { R->ICount-=7;M_CALL; } else R->PC.W+=2; break;
|
||||
case CALL_M: if(R->AF.B.l&S_FLAG) { R->ICount-=7;M_CALL; } else R->PC.W+=2; break;
|
||||
|
||||
case ADD_B: M_ADD(R->BC.B.h);break;
|
||||
case ADD_C: M_ADD(R->BC.B.l);break;
|
||||
|
|
@ -218,7 +218,7 @@ case POP_DE: M_POP(DE);break;
|
|||
case POP_HL: M_POP(XX);break;
|
||||
case POP_AF: M_POP(AF);break;
|
||||
|
||||
case DJNZ: if(--R->BC.B.h) { M_JR; } else R->PC.W++;break;
|
||||
case DJNZ: if(--R->BC.B.h) { R->ICount-=5;M_JR; } else R->PC.W++;break;
|
||||
case JP: M_JP;break;
|
||||
case JR: M_JR;break;
|
||||
case CALL: M_CALL;break;
|
||||
|
|
@ -229,14 +229,22 @@ case NOP: break;
|
|||
case OUTA: OutZ80(RdZ80(R->PC.W++),R->AF.B.h);break;
|
||||
case INA: R->AF.B.h=InZ80(RdZ80(R->PC.W++));break;
|
||||
|
||||
case DI:
|
||||
R->IFF&=0xFE;
|
||||
case HALT:
|
||||
R->PC.W--;
|
||||
R->IFF|=IFF_HALT;
|
||||
R->IBackup=0;
|
||||
R->ICount=0;
|
||||
break;
|
||||
|
||||
case DI:
|
||||
if(R->IFF&IFF_EI) R->ICount+=R->IBackup-1;
|
||||
R->IFF&=~(IFF_1|IFF_2|IFF_EI);
|
||||
break;
|
||||
|
||||
case EI:
|
||||
R->IFF|=0x01;
|
||||
if(R->IRequest!=INT_NONE)
|
||||
if(!(R->IFF&(IFF_1|IFF_EI)))
|
||||
{
|
||||
R->IFF|=0x20;
|
||||
R->IFF|=IFF_2|IFF_EI;
|
||||
R->IBackup=R->ICount;
|
||||
R->ICount=1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/** chip and the 8253 timer chip implementing a generic **/
|
||||
/** RS232 interface. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 2004-2005 **/
|
||||
/** Maarten ter Huurne 2000 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains definitions and declarations for **/
|
||||
/** routines in I8251.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 2004-2005 **/
|
||||
/** Maarten ter Huurne 2000 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/** port interface (PPI) chip from Intel. See I8255.h for **/
|
||||
/** declarations. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 2001-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 2001-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/** port interface (PPI) chip from Intel. See I8255.h for **/
|
||||
/** the actual code. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 2001-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 2001-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
|
|
@ -1,3 +1,17 @@
|
|||
/** EMULib Emulation Library *********************************/
|
||||
/** **/
|
||||
/** MIDIFreq.h **/
|
||||
/** **/
|
||||
/** This file contains a table to convert sound frequencies **/
|
||||
/** into MIDI octave/note numbers. It is included from the **/
|
||||
/** Sound.c and SndWin.c files. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
/*************************************************************/
|
||||
|
||||
{ -36, 8063 },{ -12, 8063 },{ -3, 8298 },{ 3, 8358 },
|
||||
{ 8, 8201 },{ 12, 8063 },{ 15, 8054 },{ 17, 8238 },
|
||||
{ 19, 8311 },{ 21, 8298 },{ 23, 8217 },{ 25, 8080 },
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
/** This file contains implementation for the PatchZ80() **/
|
||||
/** function necessary for emulating MSX disk and tape IO. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 1994-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
/*************************************************************/
|
||||
|
||||
#include "MSX.h"
|
||||
#include "Boot.h"
|
||||
#include <stdio.h>
|
||||
|
|
@ -351,6 +352,7 @@ case 0x00E1:
|
|||
|
||||
rewind(CasStream);
|
||||
}
|
||||
|
||||
if(Verbose&0x04) puts("FAILED");
|
||||
#endif
|
||||
return;
|
||||
|
|
@ -373,6 +375,7 @@ case 0x00E4:
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
case 0x00E7:
|
||||
/** TAPIOF: *****************************************************
|
||||
****************************************************************/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains emulation for the SCC sound chip **/
|
||||
/** produced by Konami. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/** This file contains definitions and declarations for **/
|
||||
/** routines in SCC.c. **/
|
||||
/** **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2003 **/
|
||||
/** Copyright (C) Marat Fayzullin 1996-2005 **/
|
||||
/** You are not allowed to distribute this software **/
|
||||
/** commercially. Please, notify me, if you make any **/
|
||||
/** changes to this file. **/
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue