add initial support for PICOMPUTER and MCUME_REV2
This commit is contained in:
parent
d13af01361
commit
2e8ec725aa
105 changed files with 4277 additions and 1456 deletions
|
|
@ -16,7 +16,9 @@ pico_sdk_init()
|
|||
|
||||
add_subdirectory(FatFs_SPI build)
|
||||
|
||||
include_directories(config)
|
||||
include_directories(vga_t4)
|
||||
include_directories(tft_t)
|
||||
|
||||
|
||||
set(PICO81_SOURCES
|
||||
|
|
@ -216,7 +218,10 @@ set(PICOSND_SOURCES
|
|||
set(VGA_T4_SOURCES
|
||||
vga_t4/VGA_t4.cpp
|
||||
vga_t4/scanvideo.c
|
||||
# vga_t4/vga_modes.c
|
||||
)
|
||||
|
||||
set(TFT_T_SOURCES
|
||||
tft_t/tft_t_dma.cpp
|
||||
)
|
||||
|
||||
set(GFXENGINE_SOURCES
|
||||
|
|
@ -232,13 +237,18 @@ set(TESTVGA_SOURCES
|
|||
testvga/testvga.cpp
|
||||
)
|
||||
|
||||
set(TESTTFT_SOURCES
|
||||
testtft/testtft.cpp
|
||||
testtft/emuapi.cpp
|
||||
)
|
||||
|
||||
add_executable(mcume
|
||||
${GFXENGINE_SOURCES}
|
||||
# ${GFXENGINE_SOURCES}
|
||||
# ${PICO81_SOURCES}
|
||||
# ${PICOSPECCY_SOURCES}
|
||||
# ${PICO800_SOURCES}
|
||||
# ${PICO5200_SOURCES}
|
||||
# ${PICOSPECCY_SOURCES}
|
||||
# ${PICO64_SOURCES}
|
||||
${PICO64_SOURCES}
|
||||
# ${PICOCOLEM_SOURCES}
|
||||
# ${PICOO2EM_SOURCES}
|
||||
# ${PICOVCS_SOURCES}
|
||||
|
|
@ -246,7 +256,9 @@ add_executable(mcume
|
|||
# ${PICOSND_SOURCES}
|
||||
# ${TESTIO_SOURCES}
|
||||
# ${TESTVGA_SOURCES}
|
||||
# ${TESTTFT_SOURCES}
|
||||
${VGA_T4_SOURCES}
|
||||
${TFT_T_SOURCES}
|
||||
)
|
||||
|
||||
pico_generate_pio_header(mcume ${CMAKE_CURRENT_LIST_DIR}/vga_t4/timing.pio)
|
||||
|
|
@ -272,6 +284,6 @@ target_compile_definitions(mcume PUBLIC DEBUG N_SD_CARDS=${N_SD_CARDS})
|
|||
|
||||
|
||||
#pico_enable_stdio_uart(mcume 0)
|
||||
#pico_enable_stdio_usb(mcume 1)
|
||||
pico_enable_stdio_usb(mcume 1)
|
||||
|
||||
pico_add_extra_outputs(mcume)
|
||||
|
|
|
|||
BIN
MCUME_pico/FatFs_SPI/.DS_Store
vendored
BIN
MCUME_pico/FatFs_SPI/.DS_Store
vendored
Binary file not shown.
|
|
@ -26,6 +26,8 @@ socket, which SPI it is driven by, and how it is wired.
|
|||
//
|
||||
#include "my_debug.h"
|
||||
//
|
||||
#include "iopins.h"
|
||||
|
||||
#include "hw_config.h"
|
||||
|
||||
void spi0_dma_isr();
|
||||
|
|
@ -35,10 +37,10 @@ void spi0_dma_isr();
|
|||
// selects.
|
||||
static spi_t spis[] = { // One for each SPI.
|
||||
{
|
||||
.hw_inst = spi0, // SPI component
|
||||
.miso_gpio = 16,
|
||||
.mosi_gpio = 19,
|
||||
.sck_gpio = 18,
|
||||
.hw_inst = SD_SPIREG, // SPI component
|
||||
.miso_gpio = SD_MISO,
|
||||
.mosi_gpio = SD_MOSI,
|
||||
.sck_gpio = SD_SCLK,
|
||||
/* The choice of SD card matters! SanDisk runs at the highest speed. PNY
|
||||
can only mangage 5 MHz. Those are all I've tried. */
|
||||
.baud_rate = 1000 * 1000,
|
||||
|
|
@ -56,8 +58,8 @@ static sd_card_t sd_cards[] = { // One for each SD card
|
|||
{
|
||||
.pcName = "0:", // Name used to mount device
|
||||
.spi = &spis[0], // Pointer to the SPI driving this card
|
||||
.ss_gpio = 17, // The SPI slave select GPIO for this SD card
|
||||
.card_detect_gpio = 22, // Card detect
|
||||
.ss_gpio = SD_CS, // The SPI slave select GPIO for this SD card
|
||||
.card_detect_gpio = SD_DETECT, // Card detect
|
||||
.card_detected_true = 1, // What the GPIO read returns when a card is
|
||||
// present. Use -1 if there is no card detect.
|
||||
// Following attributes are dynamically assigned
|
||||
|
|
|
|||
BIN
MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2
Normal file
Binary file not shown.
BIN
MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2
Normal file
Binary file not shown.
BIN
MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2
Normal file
Binary file not shown.
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2
Normal file
Binary file not shown.
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2
Normal file
Binary file not shown.
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2
Normal file
Binary file not shown.
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2
Normal file
BIN
MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2
Normal file
Binary file not shown.
109
MCUME_pico/config/iopins.h
Normal file
109
MCUME_pico/config/iopins.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
#ifdef MCUME_REV1
|
||||
|
||||
// Speaker
|
||||
#define AUDIO_PIN 28
|
||||
|
||||
// VGA
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
#define VGA_COLORBASE 2
|
||||
#define VGA_SYNCBASE 10
|
||||
|
||||
// TFT
|
||||
#define TFT_SPIREG spi1
|
||||
#define TFT_SPIDREQ DREQ_SPI1_TX
|
||||
#define TFT_SCLK 14
|
||||
#define TFT_MOSI 15
|
||||
#define TFT_MISO 12
|
||||
#define TFT_DC 28
|
||||
#define TFT_CS 13 // 255 for LORES ST7789 (NO CS)
|
||||
#define TFT_RST 255 // 255 for ILI/ST if connected to 3.3V
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
#define SD_SPIREG spi0
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
#define SD_DETECT 255 // 22
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// I2C keyboard (Not available on PICO)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
#else
|
||||
|
||||
// Speaker
|
||||
#define AUDIO_PIN 0 //28
|
||||
|
||||
// VGA
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
#define VGA_COLORBASE 2
|
||||
#define VGA_SYNCBASE 14
|
||||
|
||||
// TFT
|
||||
#define TFT_SPIREG spi0
|
||||
#define TFT_SPIDREQ DREQ_SPI0_TX
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_MOSI 19
|
||||
#define TFT_MISO 255 // Not required, used for DC...
|
||||
#define TFT_DC 16 //28
|
||||
#define TFT_CS 255 //17 // 255 for LORES ST7789 (NO CS)
|
||||
#define TFT_RST 21 //255 // 255 for ILI/ST if connected to 3.3V, required by 256x256 ST
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
#define SD_SPIREG spi1
|
||||
#define SD_SCLK 10 //14
|
||||
#define SD_MOSI 11 //15
|
||||
#define SD_MISO 12
|
||||
#define SD_CS 13
|
||||
#define SD_DETECT 255 // 22
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
// Keyboard matrix
|
||||
|
||||
//Cols (out)
|
||||
//1,2,3,4,5,14
|
||||
//Rows (in)
|
||||
//6,9,15,8,7,22
|
||||
|
||||
#else
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Second joystick (Not available on PICO)
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
#endif
|
||||
48
MCUME_pico/config/platform_config.h
Normal file
48
MCUME_pico/config/platform_config.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
// MCUME_REV2 is new layout with VGA+TFT+AnalogJoy+3buttons+Sound
|
||||
// MCUME_REV1 had only support for VGA+AnalogJoy+3buttons+Sound
|
||||
// PICOMPUTER has support for TFT+keymatrix+Sound
|
||||
|
||||
|
||||
//#define PICOMPUTER 1
|
||||
#define MCUME_REV1 1
|
||||
//#define MCUME_REV2 1
|
||||
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
#define ST7789 1
|
||||
#define LOHRES 1
|
||||
#define FLIP_SCREEN 1
|
||||
#define INVX 1
|
||||
#define HAS_SND 1
|
||||
#endif
|
||||
|
||||
#ifdef MCUME_REV1
|
||||
#define USE_VGA 1
|
||||
#define INVX 1
|
||||
#define HAS_SND 1
|
||||
#endif
|
||||
|
||||
#ifdef MCUME_REV2
|
||||
#define USE_VGA 1
|
||||
//#define ILI9341 1
|
||||
#define INVX 1
|
||||
#define HAS_SND 1
|
||||
#endif
|
||||
|
||||
//#define HAS_SND 1
|
||||
//#define INVY 1
|
||||
//#define HAS_USBKEY 1
|
||||
//#define USE_VGA 1
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
//#define ROTATE_SCREEN 1
|
||||
//#define FLIP_SCREEN 1
|
||||
//#define HAS_PSRAM 1
|
||||
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/pico5200/.DS_Store
vendored
BIN
MCUME_pico/pico5200/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,9 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
|
||||
static int keypadval=0;
|
||||
static bool joySwapped = false;
|
||||
|
|
@ -138,12 +142,8 @@ void emu_Free(void * pt)
|
|||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -156,12 +156,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
|||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A2Y
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -178,7 +174,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -186,10 +182,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +273,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -297,7 +347,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +427,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -370,6 +437,47 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -379,6 +487,8 @@ int emu_setKeymap(int index) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ff.h"
|
||||
static FATFS fatfs;
|
||||
static FIL file;
|
||||
|
|
@ -769,9 +879,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,33 +30,16 @@
|
|||
#define ACTION_RUNTFT 129
|
||||
#define ACTION_RUNVGA 130
|
||||
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
#ifdef PICOMPUTER
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 120
|
||||
#define KEYBOARD_Y 6
|
||||
#define KEYBOARD_KEY_H 23
|
||||
#define KEYBOARD_KEY_W 28
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,28,28,28,
|
||||
TAREA_NEW_COL,136,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,28,28,28,
|
||||
TAREA_NEW_ROW,28,28,28,
|
||||
TAREA_NEW_ROW,28,28,28,
|
||||
TAREA_NEW_ROW,28,28,28,
|
||||
TAREA_END};
|
||||
const unsigned short key_map1[] = {
|
||||
15+1,14+1,13+1,11+1,10+1,9+1,7+1,6+1,5+1,2+1,0,
|
||||
0,12+1,8+1,4+1,0+1,1+1,3+1,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
// These may be set to 1. The core handles clearing them.
|
||||
// [BREAK] 0 [ # ] 1 [ 0 ] 2 [ * ] 3
|
||||
|
|
@ -64,25 +47,20 @@ const unsigned short keysw[] = {
|
|||
// [PAUSE] 8 [ 6 ] 9 [ 5 ] 10 [ 4 ] 11
|
||||
// [START] 12 [ 3 ] 13 [ 2 ] 14 [ 1 ] 15
|
||||
|
||||
|
||||
const unsigned short key_map1[] = {
|
||||
12+1,8+1,4+1,
|
||||
0,
|
||||
15+1,14+1,13+1,
|
||||
11+1,10+1,9+1,
|
||||
7+1,6+1,9+1,
|
||||
3+1,2+1,1+1
|
||||
const unsigned short key_map2[] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008,0X0180,0X0108,0X0280,0X0208,0X0380,0X0308,0X0480,0X0408,
|
||||
0, 0X0040,0X0004,0X0140,0X0104,0X0240,0X0204,0X0340,0X0304,0X0440,0X0404,
|
||||
0, 0X0020,0X0002,0X0120,0X0102,0X0220,0X0202,0X0320,0X0302,0X0420,0X0402,
|
||||
0X0010,0X0001,0X0110,0X0101,0X0210,0X0201,0X0310,0X0301,0X0410,0X0401,
|
||||
};
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,29 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "atari5200.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
// tft.begin(VGA_MODE_400x240);
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +59,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +73,44 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/pico64/.DS_Store
vendored
BIN
MCUME_pico/pico64/.DS_Store
vendored
Binary file not shown.
|
|
@ -56,9 +56,14 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
extern TFT_T_DMA tft;
|
||||
|
||||
|
||||
inline unsigned long millis() {
|
||||
return (to_ms_since_boot(get_absolute_time ()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,9 +293,9 @@ static char * oskbtext2 = "12345678 TL ,.* 0123456789 ";
|
|||
static int oskbXPos = 10;
|
||||
static int oskbYPos = 0;
|
||||
|
||||
#define OSKB_TEXT VGA_RGB(0, 0, 170)
|
||||
#define OSKB_BG VGA_RGB(255, 255, 255)
|
||||
#define OSKB_HL VGA_RGB(255, 255, 0)
|
||||
#define OSKB_TEXT RGBVAL16(0, 0, 170)
|
||||
#define OSKB_BG RGBVAL16(255, 255, 255)
|
||||
#define OSKB_HL RGBVAL16(255, 255, 0)
|
||||
|
||||
int emu_oskbActive(void) {
|
||||
return (oskbActive?1:0);
|
||||
|
|
@ -314,7 +314,7 @@ void emu_DrawVsync(void)
|
|||
}
|
||||
//skip += 1;
|
||||
//skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ void c64_Input(int bClick) {
|
|||
}
|
||||
|
||||
if (nbkeys == 0) {
|
||||
if (bClick & MASK_KEY_USER1) {
|
||||
if (bClick & MASK_KEY_USER2) {
|
||||
if (!oskbActive) {
|
||||
oskbActive = true;
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ void c64_Input(int bClick) {
|
|||
oskbActive = false;
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_KEY_USER2) {
|
||||
else if (bClick & MASK_KEY_USER1) {
|
||||
if (firsttime) {
|
||||
firsttime = false;
|
||||
textseq = textload;
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,9 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
|
||||
static int keypadval=0;
|
||||
static bool joySwapped = false;
|
||||
|
|
@ -134,8 +138,6 @@ void emu_Free(void * pt)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
adc_select_input(0);
|
||||
|
|
@ -170,7 +172,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -178,10 +180,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -268,6 +271,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -289,7 +345,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -338,6 +413,7 @@ void emu_InitJoysticks(void) {
|
|||
gpio_set_dir(PIN_JOY2_BTN,GPIO_IN);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_init();
|
||||
adc_gpio_init(PIN_JOY2_A1X);
|
||||
adc_gpio_init(PIN_JOY2_A2Y);
|
||||
|
|
@ -349,7 +425,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -360,6 +435,47 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -765,9 +881,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,35 +28,29 @@
|
|||
#define ACTION_RUNVGA 130
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 104
|
||||
#define KEYBOARD_Y 78
|
||||
#define KEYBOARD_KEY_H 30
|
||||
#define KEYBOARD_KEY_W 21
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,40,40,
|
||||
TAREA_END};
|
||||
#ifdef PICOMPUTER
|
||||
|
||||
const unsigned short key_map1[] = {
|
||||
2,3};
|
||||
'Q','W','E','R','T','Y','U','I','O','P','0',
|
||||
0,'A','S','D','F','G','H','J','K','L',0xD,
|
||||
0,'Z','X','C','V','B','N','M',',',' ',
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short key_map2[] = {
|
||||
'1','2','3','4','5','6','7','8','9','0',0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,13 +6,17 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
#include "c64.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
bool repeating_timer_callback(struct repeating_timer *t) {
|
||||
|
|
@ -32,11 +36,13 @@ int main(void) {
|
|||
// set_sys_clock_khz(200000, true);
|
||||
// set_sys_clock_khz(225000, true);
|
||||
set_sys_clock_khz(250000, true);
|
||||
|
||||
stdio_init_all();
|
||||
|
||||
tft.begin(VGA_MODE_400x240);
|
||||
// tft.begin(VGA_MODE_320x240);
|
||||
#ifdef USE_VGA
|
||||
// tft.begin(VGA_MODE_400x240);
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -59,6 +65,7 @@ int main(void) {
|
|||
//emu_Input(bClick);
|
||||
emu_Step();
|
||||
}
|
||||
|
||||
//int c = getchar_timeout_us(0);
|
||||
//switch (c) {
|
||||
// case ' ':
|
||||
|
|
@ -69,45 +76,60 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
void * emu_LineBuffer(int line)
|
||||
{
|
||||
return (void*)tft.getLineBuffer(line);
|
||||
}
|
||||
//void emu_DrawVsync(void)
|
||||
//{
|
||||
// skip += 1;
|
||||
// skip &= VID_FRAME_SKIP;
|
||||
// //tft.waitSync();
|
||||
//}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,6 +138,11 @@ int emu_FrameSkip(void)
|
|||
return skip;
|
||||
}
|
||||
|
||||
void * emu_LineBuffer(int line)
|
||||
{
|
||||
return (void*)tft.getLineBuffer(line);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/pico64/reSID/.DS_Store
vendored
BIN
MCUME_pico/pico64/reSID/.DS_Store
vendored
Binary file not shown.
171
MCUME_pico/pico64/vic.cpp
Executable file → Normal file
171
MCUME_pico/pico64/vic.cpp
Executable file → Normal file
|
|
@ -45,6 +45,7 @@
|
|||
- optimize more
|
||||
*/
|
||||
|
||||
|
||||
#include "Teensy64.h"
|
||||
#include "vic.h"
|
||||
#include <string.h>
|
||||
|
|
@ -57,37 +58,28 @@
|
|||
#define PALETTE(r,g,b) (RGBVAL16(r,g,b)) //(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3))
|
||||
#include "vic_palette.h"
|
||||
|
||||
typedef uint8_t tpixel;
|
||||
|
||||
static tpixel * SCREENMEM=NULL;
|
||||
static int LINE_MEM_WIDTH=0;
|
||||
static int REAL_XRES=0;
|
||||
static int REAL_YRES=0;
|
||||
|
||||
#define SCREEN_WIDTH (320)
|
||||
|
||||
/*
|
||||
static int BORDER=0;
|
||||
static int SCREEN_HEIGHT=0;
|
||||
static int FIRSTDISPLAYLINE=0;
|
||||
static int LASTDISPLAYLINE=0;
|
||||
static int BORDER_LEFT=0;
|
||||
static int BORDER_RIGHT=0;
|
||||
*/
|
||||
|
||||
#define BORDER ((REAL_YRES-200)/2)
|
||||
#define BORDER (240-200)/2
|
||||
#define SCREEN_HEIGHT (200+2*BORDER)
|
||||
#define SCREEN_WIDTH 320
|
||||
//#define LINE_MEM_WIDTH 320
|
||||
#define FIRSTDISPLAYLINE ( 51 - BORDER )
|
||||
#define LASTDISPLAYLINE ( 250 + BORDER )
|
||||
#define BORDER_LEFT ((REAL_XRES-320)/2)
|
||||
#define BORDER_RIGHT ((REAL_XRES-320)/2)
|
||||
#define BORDER_LEFT (400-320)/2
|
||||
#define BORDER_RIGHT 0
|
||||
|
||||
#ifdef USE_VGA
|
||||
typedef uint8_t tpixel;
|
||||
#else
|
||||
typedef uint16_t tpixel;
|
||||
#endif
|
||||
|
||||
#define MAXCYCLESSPRITES0_2 3
|
||||
#define MAXCYCLESSPRITES3_7 5
|
||||
#define MAXCYCLESSPRITES (MAXCYCLESSPRITES0_2 + MAXCYCLESSPRITES3_7)
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
|
@ -1283,6 +1275,8 @@ typedef void (*modes_t)( tpixel *p, const tpixel *pe, uint16_t *spl, const uint1
|
|||
const modes_t modes[8] = {mode0, mode1, mode2, mode3, mode4, mode5, mode6, mode7};
|
||||
|
||||
|
||||
//static tpixel linebuffer[SCREEN_WIDTH];
|
||||
|
||||
void vic_do(void) {
|
||||
|
||||
uint16_t vc;
|
||||
|
|
@ -1301,7 +1295,6 @@ void vic_do(void) {
|
|||
*/
|
||||
|
||||
if ( cpu.vic.rasterLine >= LINECNT ) {
|
||||
|
||||
//reSID sound needs much time - too much to keep everything in sync and with stable refreshrate
|
||||
//but it is not called very often, so most of the time, we have more time than needed.
|
||||
//We can measure the time needed for a frame and calc a correction factor to speed things up.
|
||||
|
|
@ -1313,14 +1306,14 @@ void vic_do(void) {
|
|||
cpu.vic.rasterLine = 0;
|
||||
cpu.vic.vcbase = 0;
|
||||
cpu.vic.denLatch = 0;
|
||||
//if (cpu.vic.rasterLine == LINECNT) {
|
||||
emu_DrawVsync();
|
||||
//}
|
||||
|
||||
} else cpu.vic.rasterLine++;
|
||||
|
||||
int r = cpu.vic.rasterLine;
|
||||
|
||||
// if ( (r >= LASTDISPLAYLINE) && (emu_oskbActive()) ) return;
|
||||
|
||||
if (r == cpu.vic.intRasterLine )//Set Rasterline-Interrupt
|
||||
cpu.vic.R[0x19] |= 1 | ((cpu.vic.R[0x1a] & 1) << 7);
|
||||
|
||||
|
|
@ -1403,60 +1396,17 @@ void vic_do(void) {
|
|||
}
|
||||
|
||||
//max_x = (!cpu.vic.CSEL) ? 40:38;
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH;
|
||||
|
||||
|
||||
uint16_t col;
|
||||
//#if !VGA
|
||||
if(REAL_XRES == SCREEN_WIDTH) {
|
||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH;
|
||||
//p = &linebuffer[0]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE));
|
||||
pe = p + SCREEN_WIDTH;
|
||||
//Left Screenborder: Cycle 10
|
||||
spl = &cpu.vic.spriteLine[24];
|
||||
cpu_clock(6);
|
||||
}
|
||||
else {
|
||||
pe = p + SCREEN_WIDTH + BORDER_LEFT;
|
||||
col = cpu.vic.colors[0];
|
||||
|
||||
//Left Screenborder: Cycle 10
|
||||
for (int i = 0; i <2; i++) {
|
||||
cpu_clock(1);
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
}
|
||||
|
||||
//Left Screenborder: Cycle 13
|
||||
#if 0 //mit Sprites
|
||||
spl = &cpu.vic.spriteLine[0];
|
||||
uint16_t sprite;
|
||||
for (int i=0; i<3; i++) {
|
||||
cpu_clock(1);
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
}
|
||||
#else //ohne sprites
|
||||
spl = &cpu.vic.spriteLine[24];
|
||||
for (int i=0; i<3; i++) {
|
||||
cpu_clock(1);
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (cpu.vic.borderFlag) {
|
||||
//#if !VGA
|
||||
if(REAL_XRES == SCREEN_WIDTH) {
|
||||
cpu_clock(5);
|
||||
}
|
||||
if ( (!emu_oskbActive()) )
|
||||
fastFillLineNoSprites(p, pe + BORDER_RIGHT, cpu.vic.colors[0]);
|
||||
goto noDisplayIncRC ;
|
||||
}
|
||||
|
|
@ -1612,7 +1562,9 @@ g-Zugriff
|
|||
cpu_clock(1);
|
||||
uint16_t col = cpu.vic.colors[0];
|
||||
//p = &screen[r - FIRSTDISPLAYLINE][0];
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + BORDER_LEFT;
|
||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + BORDER_LEFT;
|
||||
//p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + BORDER_LEFT;
|
||||
#if 0
|
||||
// Sprites im Rand
|
||||
uint16_t sprite;
|
||||
|
|
@ -1635,7 +1587,9 @@ g-Zugriff
|
|||
|
||||
//Rand rechts:
|
||||
//p = &screen[r - FIRSTDISPLAYLINE][SCREEN_WIDTH - 9];
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
//p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
pe = p + 9;
|
||||
|
||||
#if 0
|
||||
|
|
@ -1646,32 +1600,20 @@ g-Zugriff
|
|||
}
|
||||
#else
|
||||
//keine Sprites im Rand
|
||||
while (p < pe) {
|
||||
*p++ = col;
|
||||
}
|
||||
//while (p < pe) {
|
||||
// *p++ = col;
|
||||
//}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
||||
|
||||
|
||||
//Rechter Rand nach CSEL, im Textbereich
|
||||
cpu_clock(5);
|
||||
//#if VGA
|
||||
if(REAL_XRES != SCREEN_WIDTH) {
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH + BORDER_LEFT;
|
||||
pe += BORDER_RIGHT;
|
||||
#if 0
|
||||
// Sprites im Rand
|
||||
while (p < pe) {
|
||||
SPRITEORFIXEDCOLOR();
|
||||
}
|
||||
#else
|
||||
//keine Sprites im Rand
|
||||
while (p < pe) {
|
||||
*p++ = col;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
noDisplayIncRC:
|
||||
|
|
@ -1953,7 +1895,7 @@ if ( cpu.vic.rasterLine >= LINECNT ) {
|
|||
cpu.vic.rasterLine = 0;
|
||||
cpu.vic.vcbase = 0;
|
||||
cpu.vic.denLatch = 0;
|
||||
emu_DrawVsync();
|
||||
|
||||
} else {
|
||||
cpu.vic.rasterLine++;
|
||||
cpu_clock(1);
|
||||
|
|
@ -1962,8 +1904,6 @@ if ( cpu.vic.rasterLine >= LINECNT ) {
|
|||
|
||||
int r = cpu.vic.rasterLine;
|
||||
|
||||
// if ( (r >= LASTDISPLAYLINE) && (emu_oskbActive()) ) return;
|
||||
|
||||
if (r == cpu.vic.intRasterLine )//Set Rasterline-Interrupt
|
||||
cpu.vic.R[0x19] |= 1 | ((cpu.vic.R[0x1a] & 1) << 7);
|
||||
|
||||
|
|
@ -2028,6 +1968,16 @@ if ( cpu.vic.rasterLine >= LINECNT ) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
||||
void installPalette(void) {
|
||||
memcpy(cpu.vic.palette, (void*)palette, sizeof(cpu.vic.palette));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
|
@ -2163,40 +2113,7 @@ uint8_t vic_read(uint32_t address) {
|
|||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
||||
void installPalette(void) {
|
||||
memcpy(cpu.vic.palette, (void*)palette, sizeof(cpu.vic.palette));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
#define XOFFSET 4
|
||||
#define YOFFSET 16
|
||||
|
||||
|
||||
void resetVic(void) {
|
||||
LINE_MEM_WIDTH = tft.get_frame_buffer_size(&REAL_XRES,&REAL_YRES);
|
||||
SCREENMEM=(tpixel*)emu_LineBuffer(0);
|
||||
/*
|
||||
if (REAL_XRES == SCREEN_WIDTH) {
|
||||
BORDER = (REAL_YRES-200)/2;
|
||||
SCREEN_HEIGHT = (200+2*BORDER);
|
||||
FIRSTDISPLAYLINE = ( 51 - BORDER );
|
||||
LASTDISPLAYLINE = ( 250 + BORDER );
|
||||
BORDER_LEFT = 0;
|
||||
BORDER_RIGHT = 0;
|
||||
}
|
||||
else {
|
||||
BORDER = (REAL_YRES-200)/2;
|
||||
SCREEN_HEIGHT = (200+2*BORDER);
|
||||
FIRSTDISPLAYLINE = ( 51 - BORDER );
|
||||
LASTDISPLAYLINE = ( 250 + BORDER );
|
||||
BORDER_LEFT = (REAL_XRES-320)/2;
|
||||
BORDER_RIGHT = (REAL_XRES-320)/2;
|
||||
}
|
||||
*/
|
||||
|
||||
enableCycleCounter();
|
||||
|
||||
cpu.vic.intRasterLine = 0;
|
||||
|
|
@ -2205,6 +2122,8 @@ void resetVic(void) {
|
|||
memset(&cpu.RAM[0x400], 0, 1000);
|
||||
memset(&cpu.vic, 0, sizeof(cpu.vic));
|
||||
|
||||
|
||||
|
||||
installPalette();
|
||||
|
||||
//http://dustlayer.com/vic-ii/2013/4/22/when-visibility-matters
|
||||
|
|
|
|||
172
MCUME_pico/pico64/vic.cpp_old → MCUME_pico/pico64/vic.cpp_new
Normal file → Executable file
172
MCUME_pico/pico64/vic.cpp_old → MCUME_pico/pico64/vic.cpp_new
Normal file → Executable file
|
|
@ -45,7 +45,6 @@
|
|||
- optimize more
|
||||
*/
|
||||
|
||||
|
||||
#include "Teensy64.h"
|
||||
#include "vic.h"
|
||||
#include <string.h>
|
||||
|
|
@ -58,24 +57,42 @@
|
|||
#define PALETTE(r,g,b) (RGBVAL16(r,g,b)) //(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3))
|
||||
#include "vic_palette.h"
|
||||
|
||||
#ifdef USE_VGA
|
||||
typedef uint8_t tpixel;
|
||||
#else
|
||||
typedef uint16_t tpixel;
|
||||
#endif
|
||||
|
||||
|
||||
#define BORDER (240-200)/2
|
||||
static tpixel * SCREENMEM=NULL;
|
||||
static int LINE_MEM_WIDTH=0;
|
||||
static int REAL_XRES=0;
|
||||
static int REAL_YRES=0;
|
||||
|
||||
#define SCREEN_WIDTH (320)
|
||||
|
||||
/*
|
||||
static int BORDER=0;
|
||||
static int SCREEN_HEIGHT=0;
|
||||
static int FIRSTDISPLAYLINE=0;
|
||||
static int LASTDISPLAYLINE=0;
|
||||
static int BORDER_LEFT=0;
|
||||
static int BORDER_RIGHT=0;
|
||||
*/
|
||||
|
||||
#define BORDER ((REAL_YRES-200)/2)
|
||||
#define SCREEN_HEIGHT (200+2*BORDER)
|
||||
#define SCREEN_WIDTH 320
|
||||
//#define LINE_MEM_WIDTH 320
|
||||
#define FIRSTDISPLAYLINE ( 51 - BORDER )
|
||||
#define LASTDISPLAYLINE ( 250 + BORDER )
|
||||
#define BORDER_LEFT (400-320)/2
|
||||
#define BORDER_RIGHT 0
|
||||
|
||||
typedef uint8_t tpixel;
|
||||
#define BORDER_LEFT ((REAL_XRES-320)/2)
|
||||
#define BORDER_RIGHT ((REAL_XRES-320)/2)
|
||||
|
||||
#define MAXCYCLESSPRITES0_2 3
|
||||
#define MAXCYCLESSPRITES3_7 5
|
||||
#define MAXCYCLESSPRITES (MAXCYCLESSPRITES0_2 + MAXCYCLESSPRITES3_7)
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
|
@ -1271,8 +1288,6 @@ typedef void (*modes_t)( tpixel *p, const tpixel *pe, uint16_t *spl, const uint1
|
|||
const modes_t modes[8] = {mode0, mode1, mode2, mode3, mode4, mode5, mode6, mode7};
|
||||
|
||||
|
||||
//static tpixel linebuffer[SCREEN_WIDTH];
|
||||
|
||||
void vic_do(void) {
|
||||
|
||||
uint16_t vc;
|
||||
|
|
@ -1291,6 +1306,7 @@ void vic_do(void) {
|
|||
*/
|
||||
|
||||
if ( cpu.vic.rasterLine >= LINECNT ) {
|
||||
|
||||
//reSID sound needs much time - too much to keep everything in sync and with stable refreshrate
|
||||
//but it is not called very often, so most of the time, we have more time than needed.
|
||||
//We can measure the time needed for a frame and calc a correction factor to speed things up.
|
||||
|
|
@ -1302,14 +1318,14 @@ void vic_do(void) {
|
|||
cpu.vic.rasterLine = 0;
|
||||
cpu.vic.vcbase = 0;
|
||||
cpu.vic.denLatch = 0;
|
||||
//if (cpu.vic.rasterLine == LINECNT) {
|
||||
emu_DrawVsync();
|
||||
//}
|
||||
|
||||
} else cpu.vic.rasterLine++;
|
||||
|
||||
int r = cpu.vic.rasterLine;
|
||||
|
||||
// if ( (r >= LASTDISPLAYLINE) && (emu_oskbActive()) ) return;
|
||||
|
||||
if (r == cpu.vic.intRasterLine )//Set Rasterline-Interrupt
|
||||
cpu.vic.R[0x19] |= 1 | ((cpu.vic.R[0x1a] & 1) << 7);
|
||||
|
||||
|
|
@ -1392,17 +1408,60 @@ void vic_do(void) {
|
|||
}
|
||||
|
||||
//max_x = (!cpu.vic.CSEL) ? 40:38;
|
||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH;
|
||||
//p = &linebuffer[0]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE));
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH;
|
||||
|
||||
|
||||
uint16_t col;
|
||||
//#if !VGA
|
||||
if(REAL_XRES == SCREEN_WIDTH) {
|
||||
pe = p + SCREEN_WIDTH;
|
||||
//Left Screenborder: Cycle 10
|
||||
spl = &cpu.vic.spriteLine[24];
|
||||
cpu_clock(6);
|
||||
}
|
||||
else {
|
||||
pe = p + SCREEN_WIDTH + BORDER_LEFT;
|
||||
col = cpu.vic.colors[0];
|
||||
|
||||
//Left Screenborder: Cycle 10
|
||||
for (int i = 0; i <2; i++) {
|
||||
cpu_clock(1);
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
}
|
||||
|
||||
//Left Screenborder: Cycle 13
|
||||
#if 0 //mit Sprites
|
||||
spl = &cpu.vic.spriteLine[0];
|
||||
uint16_t sprite;
|
||||
for (int i=0; i<3; i++) {
|
||||
cpu_clock(1);
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
SPRITEORFIXEDCOLOR();
|
||||
}
|
||||
#else //ohne sprites
|
||||
spl = &cpu.vic.spriteLine[24];
|
||||
for (int i=0; i<3; i++) {
|
||||
cpu_clock(1);
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
*p++ = col;*p++ = col;*p++ = col;*p++ = col;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (cpu.vic.borderFlag) {
|
||||
//#if !VGA
|
||||
if(REAL_XRES == SCREEN_WIDTH) {
|
||||
cpu_clock(5);
|
||||
}
|
||||
if ( (!emu_oskbActive()) )
|
||||
fastFillLineNoSprites(p, pe + BORDER_RIGHT, cpu.vic.colors[0]);
|
||||
goto noDisplayIncRC ;
|
||||
}
|
||||
|
|
@ -1558,9 +1617,7 @@ g-Zugriff
|
|||
cpu_clock(1);
|
||||
uint16_t col = cpu.vic.colors[0];
|
||||
//p = &screen[r - FIRSTDISPLAYLINE][0];
|
||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + BORDER_LEFT;
|
||||
//p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE));
|
||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + BORDER_LEFT;
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + BORDER_LEFT;
|
||||
#if 0
|
||||
// Sprites im Rand
|
||||
uint16_t sprite;
|
||||
|
|
@ -1583,9 +1640,7 @@ g-Zugriff
|
|||
|
||||
//Rand rechts:
|
||||
//p = &screen[r - FIRSTDISPLAYLINE][SCREEN_WIDTH - 9];
|
||||
//p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
//p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH - 9 + BORDER_LEFT;
|
||||
pe = p + 9;
|
||||
|
||||
#if 0
|
||||
|
|
@ -1596,20 +1651,32 @@ g-Zugriff
|
|||
}
|
||||
#else
|
||||
//keine Sprites im Rand
|
||||
//while (p < pe) {
|
||||
// *p++ = col;
|
||||
//}
|
||||
while (p < pe) {
|
||||
*p++ = col;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
|
||||
|
||||
|
||||
//Rechter Rand nach CSEL, im Textbereich
|
||||
cpu_clock(5);
|
||||
//#if VGA
|
||||
if(REAL_XRES != SCREEN_WIDTH) {
|
||||
p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH + BORDER_LEFT;
|
||||
pe += BORDER_RIGHT;
|
||||
#if 0
|
||||
// Sprites im Rand
|
||||
while (p < pe) {
|
||||
SPRITEORFIXEDCOLOR();
|
||||
}
|
||||
#else
|
||||
//keine Sprites im Rand
|
||||
while (p < pe) {
|
||||
*p++ = col;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
noDisplayIncRC:
|
||||
|
|
@ -1891,7 +1958,7 @@ if ( cpu.vic.rasterLine >= LINECNT ) {
|
|||
cpu.vic.rasterLine = 0;
|
||||
cpu.vic.vcbase = 0;
|
||||
cpu.vic.denLatch = 0;
|
||||
|
||||
emu_DrawVsync();
|
||||
} else {
|
||||
cpu.vic.rasterLine++;
|
||||
cpu_clock(1);
|
||||
|
|
@ -1900,6 +1967,8 @@ if ( cpu.vic.rasterLine >= LINECNT ) {
|
|||
|
||||
int r = cpu.vic.rasterLine;
|
||||
|
||||
// if ( (r >= LASTDISPLAYLINE) && (emu_oskbActive()) ) return;
|
||||
|
||||
if (r == cpu.vic.intRasterLine )//Set Rasterline-Interrupt
|
||||
cpu.vic.R[0x19] |= 1 | ((cpu.vic.R[0x1a] & 1) << 7);
|
||||
|
||||
|
|
@ -1964,16 +2033,6 @@ if ( cpu.vic.rasterLine >= LINECNT ) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
||||
void installPalette(void) {
|
||||
memcpy(cpu.vic.palette, (void*)palette, sizeof(cpu.vic.palette));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
|
@ -2109,7 +2168,40 @@ uint8_t vic_read(uint32_t address) {
|
|||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
|
||||
void installPalette(void) {
|
||||
memcpy(cpu.vic.palette, (void*)palette, sizeof(cpu.vic.palette));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
#define XOFFSET 4
|
||||
#define YOFFSET 16
|
||||
|
||||
|
||||
void resetVic(void) {
|
||||
LINE_MEM_WIDTH = tft.get_frame_buffer_size(&REAL_XRES,&REAL_YRES);
|
||||
SCREENMEM=(tpixel*)emu_LineBuffer(0);
|
||||
/*
|
||||
if (REAL_XRES == SCREEN_WIDTH) {
|
||||
BORDER = (REAL_YRES-200)/2;
|
||||
SCREEN_HEIGHT = (200+2*BORDER);
|
||||
FIRSTDISPLAYLINE = ( 51 - BORDER );
|
||||
LASTDISPLAYLINE = ( 250 + BORDER );
|
||||
BORDER_LEFT = 0;
|
||||
BORDER_RIGHT = 0;
|
||||
}
|
||||
else {
|
||||
BORDER = (REAL_YRES-200)/2;
|
||||
SCREEN_HEIGHT = (200+2*BORDER);
|
||||
FIRSTDISPLAYLINE = ( 51 - BORDER );
|
||||
LASTDISPLAYLINE = ( 250 + BORDER );
|
||||
BORDER_LEFT = (REAL_XRES-320)/2;
|
||||
BORDER_RIGHT = (REAL_XRES-320)/2;
|
||||
}
|
||||
*/
|
||||
|
||||
enableCycleCounter();
|
||||
|
||||
cpu.vic.intRasterLine = 0;
|
||||
|
|
@ -2118,8 +2210,6 @@ void resetVic(void) {
|
|||
memset(&cpu.RAM[0x400], 0, 1000);
|
||||
memset(&cpu.vic, 0, sizeof(cpu.vic));
|
||||
|
||||
|
||||
|
||||
installPalette();
|
||||
|
||||
//http://dustlayer.com/vic-ii/2013/4/22/when-visibility-matters
|
||||
BIN
MCUME_pico/pico800/.DS_Store
vendored
BIN
MCUME_pico/pico800/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,9 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
|
||||
static int keypadval=0;
|
||||
static bool joySwapped = false;
|
||||
|
|
@ -135,15 +139,10 @@ void emu_Free(void * pt)
|
|||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -156,12 +155,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
|||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A2Y
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -178,7 +173,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -186,10 +181,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +272,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -297,7 +346,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +426,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -370,6 +436,47 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -773,9 +880,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,50 +32,91 @@
|
|||
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 1
|
||||
#define KEYBOARD_Y 6
|
||||
#define KEYBOARD_KEY_H 23
|
||||
#define KEYBOARD_KEY_W 21
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,21,21,22,21,22,21,21,22,21,22,21,21,22,21,22,
|
||||
TAREA_NEW_ROW,34,21,21,21,21,21,21,21,21,21,21,21,21,34,
|
||||
TAREA_NEW_ROW,40,21,21,21,21,21,21,21,21,21,21,21,21,21,
|
||||
TAREA_NEW_ROW,50,21,21,21,21,21,21,21,21,21,21,21,45,
|
||||
TAREA_NEW_ROW,60,192,
|
||||
TAREA_END};
|
||||
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
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,
|
||||
0x3C+1,0x17+1,0x16+1,0x12+1,0x11+1,0x15+1,0x23+1,0x25+1,0x20+1,0x22+1,0x26+1, 0,0,
|
||||
0, 0x21+1
|
||||
//0x1F+1,0x1F ,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x34+1, // Digits
|
||||
0x2F+1,0x2F ,0x2A+1,0x28+1,0x2D+1,0x2B+1,0x0B+1,0x0D+1,0x08+1,0x0A+1,0x34+1,
|
||||
0x2C+1,0x3F+1,0x3F ,0x3A+1,0x38+1,0x3D+1,0x39+1,0x01+1,0x05+1,0x00+1,0x0C+1,
|
||||
0, 0x17+1,0x16+1,0x12+1,0x10+1,0x15+1,0x23+1,0x25+1,0x20+1, 0x21+1,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0, 0X0080,0X0008,0X0180,0X0108,0X0280,0X0208,0X0380,0X0308,0X0480,0X0408,0,0,0,0,
|
||||
0, 0X0040,0X0004,0X0140,0X0104,0X0240,0X0204,0X0340,0X0304,0X0440,0X0404,0,0,0X0402,
|
||||
0, 0X0020,0X0002,0X0120,0X0102,0X0220,0X0202,0X0320,0X0302,0X0420,0,0,0,0,
|
||||
0X0010,0X0001,0X0110,0X0101,0X0210,0X0201,0X0310,0X0301,0X0410,0,0,0,0,
|
||||
0, 0X0401};
|
||||
const unsigned short key_map2[] = {
|
||||
0x1F+1,0x1F ,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x34+1, // Digits
|
||||
0x2C+1,0x07+1,0x22+1,0x26+1,0x02+1,0x06+1,0x36+1,0x37+1,0x0F+1,0x0E + 1,0x06+1, // various
|
||||
//0x07+1=*, 0x22+1=.,0x26+1=/, 0x02+1=;, 0x06+1=+, 0x36+1=<, 0x37+1=>, 0x0F+1==, 0x0E+1=-, 0x06+1=+
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* Pokey code
|
||||
KEY_A = 63
|
||||
KEY_S = 62
|
||||
KEY_G = 61
|
||||
KEY_Cap = 60
|
||||
KEY_D = 58
|
||||
KEY_H = 57
|
||||
KEY_F = 56
|
||||
KEY_Great = 55
|
||||
KEY_Less = 54
|
||||
KEY_8 = 53
|
||||
KEY_BSp = 52
|
||||
KEY_7 = 51
|
||||
KEY_0 = 50
|
||||
KEY_9 = 48
|
||||
KEY_Q = 47
|
||||
KEY_W = 46
|
||||
KEY_T = 45
|
||||
KEY_Tab = 44
|
||||
KEY_Y = 43
|
||||
KEY_E = 42
|
||||
KEY_R = 40
|
||||
KEY_Inv = 39
|
||||
KEY_Slash = 38
|
||||
KEY_M = 37
|
||||
KEY_N = 35
|
||||
KEY_Dot = 34
|
||||
KEY_Spa = 33
|
||||
KEY_Comma = 32
|
||||
KEY_1 = 31
|
||||
KEY_2 = 30
|
||||
KEY_5 = 29
|
||||
KEY_Esc = 28
|
||||
KEY_6 = 27
|
||||
KEY_3 = 26
|
||||
KEY_4 = 24
|
||||
KEY_Z = 23
|
||||
KEY_X = 22
|
||||
KEY_B = 21
|
||||
KEY_F4 = 20
|
||||
KEY_F3 = 19
|
||||
KEY_C = 18
|
||||
KEY_Hlp = 17
|
||||
KEY_V = 16
|
||||
KEY_Equal = 15
|
||||
KEY_Minus = 14
|
||||
KEY_I = 13
|
||||
KEY_Ret = 12
|
||||
KEY_U = 11
|
||||
KEY_P = 10
|
||||
KEY_O = 8
|
||||
KEY_Aster = 7
|
||||
KEY_plus = 6
|
||||
KEY_K = 5
|
||||
KEY_F2 = 4
|
||||
KEY_F1 = 3
|
||||
KEY_Semi = 2
|
||||
KEY_J = 1
|
||||
KEY_L = 0
|
||||
*/
|
||||
|
||||
#define MASK_JOY2_RIGHT 0x0001
|
||||
#define MASK_JOY2_LEFT 0x0002
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,40 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "atari800.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
#include "hardware/clocks.h"
|
||||
#include "hardware/vreg.h"
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
// vreg_set_voltage(VREG_VOLTAGE_1_05);
|
||||
// set_sys_clock_khz(125000, true);
|
||||
// set_sys_clock_khz(150000, true);
|
||||
// set_sys_clock_khz(133000, true);
|
||||
// set_sys_clock_khz(200000, true);
|
||||
// set_sys_clock_khz(225000, true);
|
||||
// set_sys_clock_khz(250000, true);
|
||||
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
// tft.begin(VGA_MODE_400x240);
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +70,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +84,44 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/pico81/.DS_Store
vendored
BIN
MCUME_pico/pico81/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,13 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
static const unsigned short * keysw = keyswzx80;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -50,9 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
|
||||
static int keypadval=0;
|
||||
static bool joySwapped = false;
|
||||
|
|
@ -171,7 +174,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -179,10 +182,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -269,6 +273,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -290,7 +347,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -339,6 +415,7 @@ void emu_InitJoysticks(void) {
|
|||
gpio_set_dir(PIN_JOY2_BTN,GPIO_IN);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_init();
|
||||
adc_gpio_init(PIN_JOY2_A1X);
|
||||
adc_gpio_init(PIN_JOY2_A2Y);
|
||||
|
|
@ -350,7 +427,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -361,20 +437,53 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
if (index) {
|
||||
keysw = keyswzx81;
|
||||
}
|
||||
else {
|
||||
keysw = keyswzx80;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "ff.h"
|
||||
|
|
@ -771,9 +880,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,57 +25,41 @@
|
|||
#define ACTION_RUNTFT 129
|
||||
#define ACTION_RUNVGA 130
|
||||
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 10
|
||||
#define KEYBOARD_Y 8
|
||||
#define KEYBOARD_KEY_H 40
|
||||
#define KEYBOARD_KEY_W 30
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keyswzx80[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y+16,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H-6,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_END};
|
||||
|
||||
const unsigned short keyswzx81[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_NEW_ROW,30,30,30,30,30,30,30,30,30,30,
|
||||
TAREA_END};
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
/*
|
||||
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,
|
||||
25, 6,27,29,224,5,17,16,225,44
|
||||
};
|
||||
*/
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008,0X0180,0X0108,0X0280,0X0208,0X0380,0X0308,0X0480,0X0408,
|
||||
0X0040,0X0004,0X0140,0X0104,0X0240,0X0204,0X0340,0X0304,0X0440,0X0404,
|
||||
0X0020,0X0002,0X0120,0X0102,0X0220,0X0202,0X0320,0X0302,0X0420,0X0402,
|
||||
0X0010,0X0001,0X0110,0X0101,0X0210,0X0201,0X0310,0X0301,0X0410,0X0401,
|
||||
const unsigned short key_map1[] = {
|
||||
20,26,8,21,23,28,25,12,18,19,'0',
|
||||
0, 4, 9, 7,22, 4,11,13,14,15,40,
|
||||
0,6,27,29,224,5,17,16,225,44,
|
||||
0,0,0,0
|
||||
};
|
||||
#endif
|
||||
|
||||
const unsigned short key_map2[] = {
|
||||
30,31,32,33,34,35,36,37,38,39,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define MASK_JOY2_RIGHT 0x0001
|
||||
#define MASK_JOY2_LEFT 0x0002
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,28 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "zx81.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +58,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +78,11 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,21 +90,27 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
|
|
@ -494,7 +494,7 @@ void z81_Init(void)
|
|||
emu_SetPaletteEntry(Palette[J].R,Palette[J].G,Palette[J].B, J);
|
||||
|
||||
emu_printf("Allocating RAM");
|
||||
if (mem == 0) mem = emu_Malloc(MEMORYRAM_SIZE);
|
||||
if (mem == 0) mem = emu_Malloc(MEMORYRAM_SIZE); //&memo[0];
|
||||
|
||||
Reset8910(&ay,3500000,0);
|
||||
|
||||
|
|
|
|||
BIN
MCUME_pico/picocolem/.DS_Store
vendored
BIN
MCUME_pico/picocolem/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,8 +49,12 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
static int keyMap;
|
||||
|
||||
static int keypadval=0;
|
||||
|
|
@ -134,16 +138,10 @@ void emu_Free(void * pt)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -156,12 +154,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
|||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A2Y
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -178,7 +172,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -186,10 +180,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +271,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -297,7 +345,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +425,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -370,6 +435,47 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -796,9 +902,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,45 +25,39 @@
|
|||
#define ACTION_RUNTFT 129
|
||||
#define ACTION_RUNVGA 130
|
||||
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
#ifdef PICOMPUTER
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 128
|
||||
#define KEYBOARD_Y 84
|
||||
#define KEYBOARD_KEY_H 21
|
||||
#define KEYBOARD_KEY_W 21
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,20,20,20,
|
||||
TAREA_NEW_ROW,20,20,20,
|
||||
TAREA_NEW_ROW,20,20,20,
|
||||
TAREA_NEW_ROW,20,20,20,
|
||||
TAREA_END};
|
||||
const unsigned short key_map1[] = {
|
||||
2,3,4,5,6,7,8,9,10,1,0,
|
||||
0,11,12,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
/*
|
||||
const unsigned short key_map1[] = {
|
||||
2,3,4,
|
||||
5,6,7,
|
||||
8,9,10,
|
||||
11,1,12};
|
||||
*/
|
||||
|
||||
const unsigned short key_map2[] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008,0X0180,
|
||||
0X0108,0X0280,0X0208,
|
||||
0X0380,0X0308,0X0480,
|
||||
0X0040,0X0408,0X0004};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,28 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "Colem.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +58,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +72,44 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/piconofrendo/.DS_Store
vendored
BIN
MCUME_pico/piconofrendo/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,8 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,30 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "nes_emu.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
// tft.begin(VGA_MODE_400x240);
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +60,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +74,46 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/picoo2em/.DS_Store
vendored
BIN
MCUME_pico/picoo2em/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,11 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,8 +48,12 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
static int keyMap;
|
||||
|
||||
static int keypadval=0;
|
||||
|
|
@ -133,17 +136,10 @@ void emu_Free(void * pt)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -156,12 +152,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
|||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A2Y
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -178,7 +170,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -186,10 +178,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +269,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -297,7 +343,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +423,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -370,6 +433,47 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -796,9 +900,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,34 +26,16 @@
|
|||
#define ACTION_RUNVGA 130
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
#ifdef PICOMPUTER
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 20
|
||||
#define KEYBOARD_Y 15
|
||||
#define KEYBOARD_KEY_H 30
|
||||
#define KEYBOARD_KEY_W 28
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,28,28,28,28,29,29,28,28,28,28,
|
||||
TAREA_NEW_ROW,28,28,28,28,29,29,28,28,28,28,
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y+KEYBOARD_KEY_H+KEYBOARD_KEY_H+14,
|
||||
TAREA_NEW_ROW,28,28,28,28,29,29,28,28,28,28,
|
||||
|
||||
TAREA_NEW_ROW,12, 28,28,29,29,29,29,28,28,28,
|
||||
TAREA_NEW_ROW,28, 28,28,29,29,29,29,28,28,28,
|
||||
TAREA_NEW_ROW,100,90,
|
||||
TAREA_END};
|
||||
const unsigned short key_map1[] = {
|
||||
1,2,3,4,5,6,7,8,9,10,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
/*
|
||||
const unsigned short key_map1[] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
35,36,40,39,42,34,23,42,43,44,
|
||||
|
|
@ -62,7 +44,7 @@ const unsigned short key_map1[] = {
|
|||
ACTION_NONE, 11,29,14,16,17,18,20,21,22,
|
||||
ACTION_NONE, 36,34,13,32,12,24,23,ACTION_NONE,ACTION_NONE,
|
||||
ACTION_NONE, 41};
|
||||
|
||||
*/
|
||||
/*
|
||||
"A B C D E F G H I J"
|
||||
11,12,13,14,15,16,17,18,19,20,
|
||||
|
|
@ -74,18 +56,21 @@ const unsigned short key_map1[] = {
|
|||
31,32,33,34,35,36,37,36,39,40,
|
||||
*/
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008,0X0180,0X0108,0X0280,0X0208,0X0380,0X0308,0X0480,0X0408,
|
||||
0X0040,0X0004,0X0140,0X0104,0X0240,0X0204,0X0340,0X0304,0X0440,0X0404,
|
||||
0X0020,0X0002,0X0120,0X0102,0X0220,0X0202,0X0320,0X0302,0X0420,0X0402,
|
||||
0, 0X0010,0X0001,0X0110,0X0101,0X0210,0X0201,0X0310,0X0301,0X0410,0X0401,
|
||||
0, 0X0010,0X0001,0X0110,0X0101,0X0210,0X0201,0X0310, 0,
|
||||
0, 0X0010};
|
||||
#endif
|
||||
const unsigned short key_map2[] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define MASK_JOY2_RIGHT 0x0001
|
||||
#define MASK_JOY2_LEFT 0x0002
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,29 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "Oddemu.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
// tft.begin(VGA_MODE_400x240);
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +59,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +73,46 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +127,7 @@ void * emu_LineBuffer(int line)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
#include "AudioPlaySystem.h"
|
||||
AudioPlaySystem mymixer;
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
BIN
MCUME_pico/picosnd/.DS_Store
vendored
BIN
MCUME_pico/picosnd/.DS_Store
vendored
Binary file not shown.
BIN
MCUME_pico/picosnd/LibFC14/.DS_Store
vendored
BIN
MCUME_pico/picosnd/LibFC14/.DS_Store
vendored
Binary file not shown.
BIN
MCUME_pico/picosnd/StSnd/.DS_Store
vendored
BIN
MCUME_pico/picosnd/StSnd/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,8 +49,12 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
static int keyMap;
|
||||
|
||||
static int keypadval=0;
|
||||
|
|
@ -134,8 +138,6 @@ void emu_Free(void * pt)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
adc_select_input(0);
|
||||
|
|
@ -170,7 +172,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -178,10 +180,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -268,6 +271,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -289,7 +345,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -338,6 +413,7 @@ void emu_InitJoysticks(void) {
|
|||
gpio_set_dir(PIN_JOY2_BTN,GPIO_IN);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_init();
|
||||
adc_gpio_init(PIN_JOY2_A1X);
|
||||
adc_gpio_init(PIN_JOY2_A2Y);
|
||||
|
|
@ -349,7 +425,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -360,6 +435,47 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -765,9 +881,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,35 +28,29 @@
|
|||
#define ACTION_RUNVGA 130
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 104
|
||||
#define KEYBOARD_Y 78
|
||||
#define KEYBOARD_KEY_H 30
|
||||
#define KEYBOARD_KEY_W 21
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,40,40,
|
||||
TAREA_END};
|
||||
#ifdef PICOMPUTER
|
||||
|
||||
const unsigned short key_map1[] = {
|
||||
2,3};
|
||||
1,2,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short key_map2[] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,13 +6,19 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
#include "sndplay.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
TFT_T_DMA tft;
|
||||
static int skip=0;
|
||||
|
||||
bool repeating_timer_callback(struct repeating_timer *t) {
|
||||
|
|
@ -27,7 +33,11 @@ int main(void) {
|
|||
//set_sys_clock_khz(133000, true);
|
||||
//set_sys_clock_khz(48000, true);
|
||||
//set_sys_clock_khz(270000, true);
|
||||
#ifdef USE_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -78,7 +88,9 @@ void emu_DrawVsync(void)
|
|||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,21 +98,27 @@ void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
|||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
|
|
@ -48,7 +48,9 @@ static YMMUSIC *ymDecoder;
|
|||
|
||||
void snd_Init(void)
|
||||
{
|
||||
#ifdef HAS_SND
|
||||
emu_sndInit();
|
||||
#endif
|
||||
switch (mustype) {
|
||||
case C64Dmp:
|
||||
playSID.begin();
|
||||
|
|
|
|||
BIN
MCUME_pico/picospeccy/.DS_Store
vendored
BIN
MCUME_pico/picospeccy/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,9 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
|
||||
static int keypadval=0;
|
||||
static bool joySwapped = false;
|
||||
|
|
@ -134,16 +138,10 @@ void emu_Free(void * pt)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -156,12 +154,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
|||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A2Y
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -178,7 +172,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -186,10 +180,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +271,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -297,7 +345,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +425,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -370,8 +435,48 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -796,9 +901,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,30 +25,18 @@
|
|||
#define ACTION_RUNTFT 129
|
||||
#define ACTION_RUNVGA 130
|
||||
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
#ifdef PICOMPUTER
|
||||
/*
|
||||
const unsigned short key_map1[] = {
|
||||
30,31,32,33,34,35,36,37,38,39,
|
||||
0, 20,26, 8,21,23,28,25,12,18,19,
|
||||
0, 4, 9, 7,22, 4,11,13,14,15,40,
|
||||
25, 6,27,29,224,5,17,16,225,44
|
||||
};
|
||||
*/
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 16
|
||||
#define KEYBOARD_Y 32
|
||||
#define KEYBOARD_KEY_H 30
|
||||
#define KEYBOARD_KEY_W 28
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,27,27,28,28,28,28,28,28,28,28,
|
||||
TAREA_NEW_ROW,14,28,28,28,28,28,28,28,28,28,28,
|
||||
TAREA_NEW_ROW,20,28,28,28,28,28,28,28,28,28,28,
|
||||
TAREA_NEW_ROW,30,28,28,28,28,28,28,28,28,28,
|
||||
TAREA_END};
|
||||
/*
|
||||
{25, 6,27,29,224}, // vcxz<caps shift=Lshift>
|
||||
{10, 9, 7,22, 4}, // gfdsa
|
||||
|
|
@ -61,21 +49,26 @@ const unsigned short keysw[] = {
|
|||
*/
|
||||
|
||||
const unsigned short key_map1[] = {
|
||||
30,31,32,33,34,35,36,37,38,39,
|
||||
0, 20,26, 8,21,23,28,25,12,18,19,
|
||||
20,26,8,21,23,28,25,12,18,19,'0',
|
||||
0, 4, 9, 7,22, 4,11,13,14,15,40,
|
||||
25, 6,27,29,224,5,17,16,225,44
|
||||
0,6,27,29,224,5,17,16,225,44,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
#ifdef HAS_I2CKBD
|
||||
const unsigned short i2ckeys[] = {
|
||||
0X0080,0X0008,0X0180,0X0108,0X0280,0X0208,0X0380,0X0308,0X0480,0X0408,
|
||||
0, 0X0040,0X0004,0X0140,0X0104,0X0240,0X0204,0X0340,0X0304,0X0440,0X0404,
|
||||
0, 0X0020,0X0002,0X0120,0X0102,0X0220,0X0202,0X0320,0X0302,0X0420,0X0402,
|
||||
0X0010,0X0001,0X0110,0X0101,0X0210,0X0201,0X0310,0X0301,0X0410,0X0401,
|
||||
const unsigned short key_map2[] = {
|
||||
30,31,32,33,34,35,36,37,38,39,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,28 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "spec.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +58,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +72,44 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
// Web : www.mikrocontroller-4u.de
|
||||
//--------------------------------------------------------------
|
||||
#include "zx_filetyp_z80.h"
|
||||
#include "emuapi.h"
|
||||
//#include "emuapi.h"
|
||||
|
||||
//-------------------------------------------------------------
|
||||
extern uint8_t out_ram;
|
||||
|
|
|
|||
BIN
MCUME_pico/picovcs/.DS_Store
vendored
BIN
MCUME_pico/picovcs/.DS_Store
vendored
Binary file not shown.
|
|
@ -13,12 +13,12 @@ extern "C" {
|
|||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
const uint16_t deflogo[] = {
|
||||
0,0
|
||||
};
|
||||
static const uint16_t * logo = deflogo;
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_FILES 64
|
||||
#define MAX_FILENAME_SIZE 24
|
||||
|
|
@ -49,8 +49,12 @@ static char selection[MAX_FILENAME_SIZE+1]="";
|
|||
static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||
static bool menuRedraw=true;
|
||||
|
||||
static bool i2cKeyboardPresent = false;
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned short * keys;
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow=-1;
|
||||
static bool key_fn=false;
|
||||
#endif
|
||||
static int keyMap;
|
||||
|
||||
static int keypadval=0;
|
||||
|
|
@ -135,15 +139,10 @@ void emu_Free(void * pt)
|
|||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -156,12 +155,8 @@ int emu_ReadAnalogJoyX(int min, int max)
|
|||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
#ifdef PIN_JOY2_A2Y
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#else
|
||||
int val = 0;
|
||||
#endif
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
|
|
@ -178,7 +173,7 @@ int emu_ReadAnalogJoyY(int min, int max)
|
|||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
|
@ -186,10 +181,11 @@ static uint16_t readAnalogJoystick(void)
|
|||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +272,59 @@ int emu_ReadKeys(void)
|
|||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned char row;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
|
||||
gpio_put(cols[i], 0);
|
||||
row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
|
||||
//6,9,15,8,7,22
|
||||
#if INVX
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
|
||||
#else
|
||||
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
|
||||
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#if INVY
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_UP;
|
||||
#else
|
||||
if ( row & 0x4 ) retval |= MASK_JOY2_DOWN;
|
||||
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
|
||||
#endif
|
||||
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
|
||||
if ( row & 0x20 ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|
|
@ -297,7 +346,26 @@ unsigned short emu_DebounceLocalKeys(void)
|
|||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
if ( keymatrix[0] & 0x02 ) {
|
||||
key_fn = true;
|
||||
}
|
||||
if (key_fn) {
|
||||
keys = (unsigned short *)key_map2;
|
||||
}
|
||||
else {
|
||||
keys = (unsigned short *)key_map1;
|
||||
}
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
key_fn = false;
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +426,6 @@ void emu_InitJoysticks(void) {
|
|||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
|
|
@ -370,15 +436,55 @@ void emu_InitJoysticks(void) {
|
|||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "ff.h"
|
||||
static FATFS fatfs;
|
||||
static FIL file;
|
||||
|
|
@ -796,9 +902,7 @@ void emu_init(void)
|
|||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,31 +26,29 @@
|
|||
#define ACTION_RUNVGA 130
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
|
||||
#define TAREA_W_DEF 32
|
||||
#define TAREA_H_DEF 32
|
||||
#define TAREA_END 255
|
||||
#define TAREA_NEW_ROW 254
|
||||
#define TAREA_NEW_COL 253
|
||||
#define TAREA_XY 252
|
||||
#define TAREA_WH 251
|
||||
|
||||
#define KEYBOARD_X 8
|
||||
#define KEYBOARD_Y 50
|
||||
#define KEYBOARD_KEY_H 38
|
||||
#define KEYBOARD_KEY_W 28
|
||||
#define KEYBOARD_HIT_COLOR RGBVAL16(0xff,0x00,0x00)
|
||||
|
||||
const unsigned short keysw[] = {
|
||||
TAREA_XY,KEYBOARD_X,KEYBOARD_Y,
|
||||
TAREA_WH,KEYBOARD_KEY_W,KEYBOARD_KEY_H,
|
||||
TAREA_NEW_ROW,40,40,140,40,40,
|
||||
TAREA_END};
|
||||
#ifdef PICOMPUTER
|
||||
|
||||
const unsigned short key_map1[] = {
|
||||
1,2,ACTION_NONE,3,4
|
||||
1,2,3,4,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short key_map2[] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0, 0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x520, // row 1
|
||||
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
/*0x002*/ 0xfff,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MASK_JOY2_RIGHT 0x0001
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef IOPINS_H
|
||||
#define IOPINS_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
|
||||
// VGA (see in code!!!)
|
||||
/*
|
||||
2-9 RRRGGGBB
|
||||
10-11 VSYNC and HSYNC
|
||||
*/
|
||||
|
||||
// SD (see SPI0 in code!!!)
|
||||
/*
|
||||
#define SD_SCLK 18
|
||||
#define SD_MOSI 19
|
||||
#define SD_MISO 16
|
||||
#define SD_CS 17
|
||||
*/
|
||||
|
||||
// I2C keyboard (not used)
|
||||
/*
|
||||
#define I2C_SCL_IO 15?
|
||||
#define I2C_SDA_IO 14?
|
||||
*/
|
||||
|
||||
// Analog joystick (primary) for JOY2 and 3 extra buttons
|
||||
#define PIN_JOY2_A1X 26
|
||||
#define PIN_JOY2_A2Y 27
|
||||
#define PIN_JOY2_BTN 22
|
||||
#define PIN_KEY_USER1 20
|
||||
#define PIN_KEY_USER2 21
|
||||
|
||||
// Second joystick
|
||||
//#define PIN_JOY1_BTN 2
|
||||
//#define PIN_JOY1_1 14 // UP
|
||||
//#define PIN_JOY1_2 7 // DOWN
|
||||
//#define PIN_JOY1_3 6 // RIGHT
|
||||
//#define PIN_JOY1_4 5 // LEFT
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -6,19 +6,29 @@ extern "C" {
|
|||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
#include "vga_t_dma.h"
|
||||
|
||||
extern "C" {
|
||||
#include "Vcsemu.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
#ifdef USE_VGA
|
||||
// tft.begin(VGA_MODE_400x240);
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
if (menuActive()) {
|
||||
|
|
@ -49,11 +59,13 @@ int main(void) {
|
|||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,35 +73,46 @@ void emu_DrawVsync(void)
|
|||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
tft.waitSync();
|
||||
//tft.waitSync();
|
||||
}
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +127,7 @@ void * emu_LineBuffer(int line)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
#include "AudioPlaySystem.h"
|
||||
AudioPlaySystem mymixer;
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef _PLATFORM_CONFIG_H_
|
||||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#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 HAS_PSRAM 1
|
||||
|
||||
//#define USE_SDFAT 1
|
||||
//#define SD_FAT_TYPE 1
|
||||
//#define USE_SDFS 1
|
||||
//#define SDFSDEV "1:"
|
||||
|
||||
#endif
|
||||
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
BIN
MCUME_pico/testio/.DS_Store
vendored
BIN
MCUME_pico/testio/.DS_Store
vendored
Binary file not shown.
417
MCUME_pico/testtft/emuapi.cpp
Normal file
417
MCUME_pico/testtft/emuapi.cpp
Normal file
|
|
@ -0,0 +1,417 @@
|
|||
#define KEYMAP_PRESENT 1
|
||||
|
||||
#define PROGMEM
|
||||
|
||||
#include "pico.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include "hardware/adc.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" {
|
||||
#include "emuapi.h"
|
||||
#include "iopins.h"
|
||||
}
|
||||
|
||||
|
||||
static unsigned short * keys;
|
||||
static int keyMap;
|
||||
|
||||
static int keypadval=0;
|
||||
static bool joySwapped = false;
|
||||
static uint16_t bLastState;
|
||||
static int xRef;
|
||||
static int yRef;
|
||||
static uint8_t usbnavpad=0;
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
static unsigned char keymatrix[6];
|
||||
static int keymatrix_hitrow = -1;
|
||||
#endif
|
||||
|
||||
|
||||
void emu_printf(char * text)
|
||||
{
|
||||
printf("%s\n",text);
|
||||
}
|
||||
|
||||
void emu_printf(int val)
|
||||
{
|
||||
printf("%d\n",val);
|
||||
}
|
||||
|
||||
void emu_printi(int val)
|
||||
{
|
||||
printf("%d\n",val);
|
||||
}
|
||||
|
||||
void emu_printh(int val)
|
||||
{
|
||||
printf("0x%.8\n",val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_ReadAnalogJoyX(int min, int max)
|
||||
{
|
||||
adc_select_input(0);
|
||||
int val = adc_read();
|
||||
#if INVX
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
val = val-xRef;
|
||||
val = ((val*140)/100);
|
||||
if ( (val > -512) && (val < 512) ) val = 0;
|
||||
val = val+2048;
|
||||
return (val*(max-min))/4096;
|
||||
}
|
||||
|
||||
int emu_ReadAnalogJoyY(int min, int max)
|
||||
{
|
||||
adc_select_input(1);
|
||||
int val = adc_read();
|
||||
#if INVY
|
||||
val = 4095 - val;
|
||||
#endif
|
||||
val = val-yRef;
|
||||
val = ((val*120)/100);
|
||||
if ( (val > -512) && (val < 512) ) val = 0;
|
||||
//val = (val*(max-min))/4096;
|
||||
val = val+2048;
|
||||
//return val+(max-min)/2;
|
||||
return (val*(max-min))/4096;
|
||||
}
|
||||
|
||||
|
||||
static uint16_t readAnalogJoystick(void)
|
||||
{
|
||||
uint16_t joysval = 0;
|
||||
#ifdef PIN_JOY2_A1X
|
||||
int xReading = emu_ReadAnalogJoyX(0,256);
|
||||
if (xReading > 128) joysval |= MASK_JOY2_LEFT;
|
||||
else if (xReading < 128) joysval |= MASK_JOY2_RIGHT;
|
||||
|
||||
int yReading = emu_ReadAnalogJoyY(0,256);
|
||||
if (yReading < 128) joysval |= MASK_JOY2_UP;
|
||||
else if (yReading > 128) joysval |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
joysval |= (gpio_get(PIN_JOY2_BTN) ? 0 : MASK_JOY2_BTN);
|
||||
#endif
|
||||
|
||||
return (joysval);
|
||||
}
|
||||
|
||||
|
||||
int emu_SwapJoysticks(int statusOnly) {
|
||||
if (!statusOnly) {
|
||||
if (joySwapped) {
|
||||
joySwapped = false;
|
||||
}
|
||||
else {
|
||||
joySwapped = true;
|
||||
}
|
||||
}
|
||||
return(joySwapped?1:0);
|
||||
}
|
||||
|
||||
int emu_GetPad(void)
|
||||
{
|
||||
return(keypadval/*|((joySwapped?1:0)<<7)*/);
|
||||
}
|
||||
|
||||
int emu_ReadKeys(void)
|
||||
{
|
||||
uint16_t retval;
|
||||
uint16_t j1 = readAnalogJoystick();
|
||||
uint16_t j2 = 0;
|
||||
|
||||
// Second joystick
|
||||
#if INVY
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( !gpio_get(PIN_JOY1_1) ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( !gpio_get(PIN_JOY1_2) ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( !gpio_get(PIN_JOY1_1) ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( !gpio_get(PIN_JOY1_2) ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#endif
|
||||
#if INVX
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( !gpio_get(PIN_JOY1_3) ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( !gpio_get(PIN_JOY1_4) ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( !gpio_get(PIN_JOY1_3) ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( !gpio_get(PIN_JOY1_4) ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PIN_JOY1_BTN
|
||||
if ( !gpio_get(PIN_JOY1_BTN) ) j2 |= MASK_JOY2_BTN;
|
||||
#endif
|
||||
if (joySwapped) {
|
||||
retval = ((j1 << 8) | j2);
|
||||
}
|
||||
else {
|
||||
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 ( !gpio_get(PIN_KEY_USER1) ) retval |= MASK_KEY_USER1;
|
||||
#endif
|
||||
#ifdef PIN_KEY_USER2
|
||||
if ( !gpio_get(PIN_KEY_USER2) ) retval |= MASK_KEY_USER2;
|
||||
#endif
|
||||
#ifdef PIN_KEY_USER3
|
||||
if ( !gpio_get(PIN_KEY_USER3) ) retval |= MASK_KEY_USER3;
|
||||
#endif
|
||||
#ifdef PIN_KEY_USER4
|
||||
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_put(14, 0);
|
||||
|
||||
//6,9,15,8,7,22
|
||||
if ( !gpio_get(9) ) retval |= MASK_JOY2_LEFT;
|
||||
if ( !gpio_get(9) ) retval |= MASK_JOY2_LEFT;
|
||||
if ( !gpio_get(9) ) retval |= MASK_JOY2_LEFT;
|
||||
if ( !gpio_get(8) ) retval |= MASK_JOY2_RIGHT;
|
||||
if ( !gpio_get(6) ) retval |= MASK_JOY2_DOWN;
|
||||
if ( !gpio_get(15) ) retval |= MASK_JOY2_UP;
|
||||
if ( !gpio_get(7) ) retval |= MASK_JOY2_BTN;
|
||||
if ( !gpio_get(22) ) retval |= MASK_KEY_USER1;
|
||||
|
||||
gpio_put(14, 1);
|
||||
|
||||
keymatrix_hitrow = -1;
|
||||
unsigned short cols[6]={1,2,3,4,5,14};
|
||||
for (int i=0;i<6;i++){
|
||||
gpio_put(cols[i], 0);
|
||||
unsigned char row=0;
|
||||
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(9) ? 0 : 0x01);
|
||||
row |= (gpio_get(8) ? 0 : 0x02);
|
||||
row |= (gpio_get(6) ? 0 : 0x04);
|
||||
row |= (gpio_get(15) ? 0 : 0x08);
|
||||
row |= (gpio_get(7) ? 0 : 0x10);
|
||||
row |= (gpio_get(22) ? 0 : 0x20);
|
||||
/*
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(9) ) row |= 0x01;
|
||||
if ( !gpio_get(8) ) row |= 0x02;
|
||||
if ( !gpio_get(6) ) row |= 0x04;
|
||||
if ( !gpio_get(15) ) row |= 0x08;
|
||||
if ( !gpio_get(7) ) row |= 0x10;
|
||||
if ( !gpio_get(22) ) row |= 0x20;
|
||||
*/
|
||||
keymatrix[i]=row;
|
||||
if (row) keymatrix_hitrow=i;
|
||||
gpio_put(cols[i], 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Serial.println(retval,HEX);
|
||||
|
||||
if ( ((retval & (MASK_KEY_USER1+MASK_KEY_USER2)) == (MASK_KEY_USER1+MASK_KEY_USER2))
|
||||
|| (retval & MASK_KEY_USER4 ) )
|
||||
{
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
unsigned short emu_DebounceLocalKeys(void)
|
||||
{
|
||||
uint16_t bCurState = emu_ReadKeys();
|
||||
uint16_t bClick = bCurState & ~bLastState;
|
||||
bLastState = bCurState;
|
||||
|
||||
return (bClick);
|
||||
}
|
||||
|
||||
unsigned char emu_ReadI2CKeyboard2(int row) {
|
||||
int retval=0;
|
||||
#ifdef PICOMPUTER
|
||||
retval = keymatrix[row];
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
int emu_ReadI2CKeyboard(void) {
|
||||
int retval=0;
|
||||
#ifdef PICOMPUTER
|
||||
if (keymatrix_hitrow >=0 ) {
|
||||
unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow];
|
||||
for (int i=0; i<sizeof(matkeys); i++) {
|
||||
if (match == matkeys[i]) {
|
||||
return (keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return(retval);
|
||||
}
|
||||
|
||||
void emu_InitJoysticks(void) {
|
||||
|
||||
// Second Joystick
|
||||
#ifdef PIN_JOY1_1
|
||||
gpio_set_pulls(PIN_JOY1_1,true,false);
|
||||
gpio_set_dir(PIN_JOY1_1,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
gpio_set_pulls(PIN_JOY1_2,true,false);
|
||||
gpio_set_dir(PIN_JOY1_2,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_JOY1_3
|
||||
gpio_set_pulls(PIN_JOY1_3,true,false);
|
||||
gpio_set_dir(PIN_JOY1_3,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
gpio_set_pulls(PIN_JOY1_4,true,false);
|
||||
gpio_set_dir(PIN_JOY1_4,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_JOY1_BTN
|
||||
gpio_set_pulls(PIN_JOY1_BTN,true,false);
|
||||
gpio_set_dir(PIN_JOY1_BTN,GPIO_IN);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_KEY_USER1
|
||||
gpio_set_pulls(PIN_KEY_USER1,true,false);
|
||||
gpio_set_dir(PIN_KEY_USER1,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_KEY_USER2
|
||||
gpio_set_pulls(PIN_KEY_USER2,true,false);
|
||||
gpio_set_dir(PIN_KEY_USER2,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_KEY_USER3
|
||||
gpio_set_pulls(PIN_KEY_USER3,true,false);
|
||||
gpio_set_dir(PIN_KEY_USER3,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_KEY_USER4
|
||||
gpio_set_pulls(PIN_KEY_USER4,true,false);
|
||||
gpio_set_dir(PIN_KEY_USER4,GPIO_IN);
|
||||
#endif
|
||||
#ifdef PIN_JOY2_BTN
|
||||
gpio_set_pulls(PIN_JOY2_BTN,true,false);
|
||||
gpio_set_dir(PIN_JOY2_BTN,GPIO_IN);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_JOY2_A1X
|
||||
adc_init();
|
||||
adc_gpio_init(PIN_JOY2_A1X);
|
||||
adc_gpio_init(PIN_JOY2_A2Y);
|
||||
xRef=0; yRef=0;
|
||||
for (int i=0; i<10; i++) {
|
||||
adc_select_input(0);
|
||||
xRef += adc_read();
|
||||
adc_select_input(1);
|
||||
yRef += adc_read();
|
||||
sleep_ms(20);
|
||||
}
|
||||
#if INVX
|
||||
xRef = 4095 -xRef/10;
|
||||
#else
|
||||
xRef /= 10;
|
||||
#endif
|
||||
#if INVY
|
||||
yRef = 4095 -yRef/10;
|
||||
#else
|
||||
yRef /= 10;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
gpio_init(1);
|
||||
gpio_init(2);
|
||||
gpio_init(3);
|
||||
gpio_init(4);
|
||||
gpio_init(5);
|
||||
gpio_init(14);
|
||||
|
||||
gpio_init(6);
|
||||
gpio_init(9);
|
||||
gpio_init(15);
|
||||
gpio_init(8);
|
||||
gpio_init(7);
|
||||
gpio_init(22);
|
||||
gpio_set_dir(1, GPIO_OUT);
|
||||
gpio_set_dir(2, GPIO_OUT);
|
||||
gpio_set_dir(3, GPIO_OUT);
|
||||
gpio_set_dir(4, GPIO_OUT);
|
||||
gpio_set_dir(5, GPIO_OUT);
|
||||
gpio_set_dir(14, GPIO_OUT);
|
||||
gpio_put(1, 1);
|
||||
gpio_put(2, 1);
|
||||
gpio_put(3, 1);
|
||||
gpio_put(4, 1);
|
||||
gpio_put(5, 1);
|
||||
gpio_put(14, 1);
|
||||
gpio_set_pulls(6,true,false);
|
||||
gpio_set_dir(6,GPIO_IN);
|
||||
gpio_set_pulls(9,true,false);
|
||||
gpio_set_dir(9,GPIO_IN);
|
||||
gpio_set_pulls(15,true,false);
|
||||
gpio_set_dir(15,GPIO_IN);
|
||||
gpio_set_pulls(8,true,false);
|
||||
gpio_set_dir(8,GPIO_IN);
|
||||
gpio_set_pulls(7,true,false);
|
||||
gpio_set_dir(7,GPIO_IN);
|
||||
gpio_set_pulls(22,true,false);
|
||||
gpio_set_dir(22,GPIO_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int emu_setKeymap(int index) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
emu_InitJoysticks();
|
||||
#ifdef SWAP_JOYSTICK
|
||||
joySwapped = true;
|
||||
#else
|
||||
joySwapped = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void emu_start(void)
|
||||
{
|
||||
|
||||
usbnavpad = 0;
|
||||
|
||||
keys = (unsigned short *)key_map1;
|
||||
keyMap = 0;
|
||||
}
|
||||
67
MCUME_pico/testtft/emuapi.h
Normal file
67
MCUME_pico/testtft/emuapi.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef EMUAPI_H
|
||||
#define EMUAPI_H
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
//#define TIMER_REND 1
|
||||
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
|
||||
#ifdef KEYMAP_PRESENT
|
||||
|
||||
const unsigned short key_map1[] = {
|
||||
1,2,3,4,5,6,7,8,9,10,11,
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0 };
|
||||
|
||||
#ifdef PICOMPUTER
|
||||
const unsigned short matkeys[] = {
|
||||
0x020,0x120,0x220,0x320,0x420, 0x408,0x308,0x208,0x108,0x008 ,0x520, // row 1
|
||||
0x510, 0x010,0x110,0x210,0x310,0x410, 0x401,0x301,0x201,0x101,0x001, // row 2
|
||||
0x002,0x102,0x202,0x302,0x402, 0x404,0x304,0x204,0x104,0x004, // row 3
|
||||
0x508,0x501,0x502,0x504 }; // cursor keys
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MASK_JOY2_RIGHT 0x0001
|
||||
#define MASK_JOY2_LEFT 0x0002
|
||||
#define MASK_JOY2_UP 0x0004
|
||||
#define MASK_JOY2_DOWN 0x0008
|
||||
#define MASK_JOY2_BTN 0x0010
|
||||
#define MASK_KEY_USER1 0x0020
|
||||
#define MASK_KEY_USER2 0x0040
|
||||
#define MASK_KEY_USER3 0x0080
|
||||
#define MASK_JOY1_RIGHT 0x0100
|
||||
#define MASK_JOY1_LEFT 0x0200
|
||||
#define MASK_JOY1_UP 0x0400
|
||||
#define MASK_JOY1_DOWN 0x0800
|
||||
#define MASK_JOY1_BTN 0x1000
|
||||
#define MASK_KEY_USER4 0x2000
|
||||
|
||||
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
|
||||
extern void emu_InitJoysticks(void);
|
||||
extern int emu_SwapJoysticks(int statusOnly);
|
||||
extern unsigned short emu_DebounceLocalKeys(void);
|
||||
extern int emu_ReadKeys(void);
|
||||
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 unsigned char emu_ReadI2CKeyboard2(int row);
|
||||
extern void emu_KeyboardOnUp(int keymodifer, int key);
|
||||
extern void emu_KeyboardOnDown(int keymodifer, int key);
|
||||
|
||||
|
||||
extern int emu_setKeymap(int index);
|
||||
|
||||
|
||||
#endif
|
||||
129
MCUME_pico/testtft/testtft.cpp
Normal file
129
MCUME_pico/testtft/testtft.cpp
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
#include "pico.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
|
||||
TFT_T_DMA tft;
|
||||
|
||||
#define BLUE RGBVAL16(0, 0, 170)
|
||||
#define LIGHT_BLUE RGBVAL16(0, 136, 255)
|
||||
|
||||
static int fb_width, fb_height;
|
||||
|
||||
|
||||
#include "hardware/clocks.h"
|
||||
#include "hardware/vreg.h"
|
||||
|
||||
static const char * digits = "0123456789ABCDEF";
|
||||
|
||||
int main(void) {
|
||||
vreg_set_voltage(VREG_VOLTAGE_1_05);
|
||||
// set_sys_clock_khz(125000, true);
|
||||
// set_sys_clock_khz(150000, true);
|
||||
// set_sys_clock_khz(133000, true);
|
||||
// set_sys_clock_khz(200000, true);
|
||||
// set_sys_clock_khz(225000, true);
|
||||
set_sys_clock_khz(250000, true);
|
||||
|
||||
stdio_init_all();
|
||||
|
||||
printf("start\n");
|
||||
tft.begin();
|
||||
emu_init();
|
||||
emu_start();
|
||||
tft.startDMA();
|
||||
tft.fillScreen(LIGHT_BLUE);
|
||||
tft.get_frame_buffer_size(&fb_width, &fb_height);
|
||||
tft.drawRect((fb_width-320)/2,(fb_height-200)/2, 320,200, BLUE);
|
||||
tft.drawText((fb_width-320)/2,(fb_height-200)/2+1*8," **** COMMODORE 64 BASIC V2 **** ",LIGHT_BLUE,BLUE,false);
|
||||
tft.drawText((fb_width-320)/2,(fb_height-200)/2+3*8," 64K RAM SYSTEM 38911 BASIC BYTES FREE ",LIGHT_BLUE,BLUE,false);
|
||||
tft.drawText((fb_width-320)/2,(fb_height-200)/2+5*8,"READY.",LIGHT_BLUE,BLUE,false);
|
||||
|
||||
char buf[4] = {32,32,32,0};
|
||||
uint sys_clk = clock_get_hz(clk_sys)/1000000;
|
||||
uint r1 = sys_clk/100;
|
||||
uint r = sys_clk - r1*100;
|
||||
uint r2 = r/10;
|
||||
r = sys_clk - r1*100 - r2*10;
|
||||
uint r3 = r;
|
||||
buf[0] = digits[r1];
|
||||
buf[1] = digits[r2];
|
||||
buf[2] = digits[r3];
|
||||
tft.drawText(4*8,0,buf,BLUE,LIGHT_BLUE,false);
|
||||
|
||||
while (true) {
|
||||
uint16_t bClick = emu_ReadKeys();
|
||||
char buf[5] = {0,0,0,0,0};
|
||||
buf[0] = digits[(bClick>>12)&0xf];
|
||||
buf[1] = digits[(bClick>>8)&0xf];
|
||||
buf[2] = digits[(bClick>>4)&0xf];
|
||||
buf[3] = digits[bClick&0xf];
|
||||
tft.drawText(4*8,16,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
buf[3] = 0;
|
||||
int key = emu_ReadI2CKeyboard();
|
||||
buf[0] = digits[(key>>8)&0xf];
|
||||
buf[1] = digits[(key>>4)&0xf];
|
||||
buf[2] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*2,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
/*
|
||||
buf[2] = 0;
|
||||
uint8_t key = emu_ReadI2CKeyboard2(0);
|
||||
buf[0] = digits[(key>>4)&0xf];
|
||||
buf[1] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*2,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
key = emu_ReadI2CKeyboard2(1);
|
||||
buf[0] = digits[(key>>4)&0xf];
|
||||
buf[1] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*3,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
key = emu_ReadI2CKeyboard2(2);
|
||||
buf[0] = digits[(key>>4)&0xf];
|
||||
buf[1] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*4,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
key = emu_ReadI2CKeyboard2(3);
|
||||
buf[0] = digits[(key>>4)&0xf];
|
||||
buf[1] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*5,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
key = emu_ReadI2CKeyboard2(4);
|
||||
buf[0] = digits[(key>>4)&0xf];
|
||||
buf[1] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*6,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
key = emu_ReadI2CKeyboard2(5);
|
||||
buf[0] = digits[(key>>4)&0xf];
|
||||
buf[1] = digits[key&0xf];
|
||||
tft.drawText(4*8,16*7,buf,RGBVAL16(0x00,0x00,0x00),RGBVAL16(0xFF,0xFF,0xFF),true);
|
||||
*/
|
||||
sleep_ms(20);
|
||||
|
||||
/*
|
||||
sleep_ms(2000);
|
||||
tft.stopDMA();
|
||||
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||
sleep_ms(2000);
|
||||
tft.startDMA();
|
||||
tft.fillScreen(LIGHT_BLUE);
|
||||
*/
|
||||
|
||||
//tft.waitSync();
|
||||
//tft.drawText((fb_width-320)/2,(fb_height-200)/2+6*8," ",BLUE,LIGHT_BLUE,false);
|
||||
//sleep_ms(500);
|
||||
//tft.waitSync();
|
||||
//tft.drawText((fb_width-320)/2,(fb_height-200)/2+6*8," ",BLUE,BLUE,false);
|
||||
//sleep_ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,6 +31,7 @@ int main(void) {
|
|||
stdio_init_all();
|
||||
|
||||
printf("start\n");
|
||||
// vga.begin(VGA_MODE_400x240);
|
||||
vga.begin(VGA_MODE_320x240);
|
||||
//tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||
vga.clear(LIGHT_BLUE);
|
||||
|
|
@ -50,7 +51,7 @@ int main(void) {
|
|||
buf[0] = digits[r1];
|
||||
buf[1] = digits[r2];
|
||||
buf[2] = digits[r3];
|
||||
vga.drawText(0,0,buf,BLUE,LIGHT_BLUE,false);
|
||||
vga.drawText(4*8,0,buf,BLUE,LIGHT_BLUE,false);
|
||||
|
||||
|
||||
while (true) {
|
||||
|
|
|
|||
136
MCUME_pico/tft_t/tft_font8x8.h
Normal file
136
MCUME_pico/tft_t/tft_font8x8.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
|
||||
// Font: c64_lower.64c
|
||||
|
||||
const unsigned char font8x8[128][8] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
|
||||
{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
|
||||
{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
|
||||
{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
|
||||
{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
|
||||
{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
|
||||
{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
|
||||
{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
|
||||
{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
|
||||
{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
|
||||
{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
|
||||
{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
|
||||
{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
|
||||
{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
|
||||
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
|
||||
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
|
||||
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
|
||||
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
|
||||
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
|
||||
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
|
||||
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
|
||||
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
|
||||
{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
|
||||
{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
|
||||
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
|
||||
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (//)
|
||||
{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
|
||||
{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
|
||||
{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
|
||||
{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
|
||||
{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
|
||||
{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
|
||||
{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
|
||||
{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
|
||||
{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
|
||||
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
|
||||
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
|
||||
{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
|
||||
{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
|
||||
{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
|
||||
{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
|
||||
{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
|
||||
{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
|
||||
{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
|
||||
{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
|
||||
{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
|
||||
{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
|
||||
{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
|
||||
{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
|
||||
{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
|
||||
{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
|
||||
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
|
||||
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
|
||||
{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
|
||||
{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
|
||||
{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
|
||||
{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
|
||||
{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
|
||||
{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
|
||||
{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
|
||||
{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
|
||||
{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
|
||||
{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
|
||||
{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
|
||||
{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
|
||||
{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
|
||||
{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
|
||||
{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
|
||||
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
|
||||
{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
|
||||
{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
|
||||
{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
|
||||
{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
|
||||
{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
|
||||
{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
|
||||
{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
|
||||
{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
|
||||
{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
|
||||
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
|
||||
{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
|
||||
{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
|
||||
{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
|
||||
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
|
||||
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
|
||||
{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
|
||||
{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
|
||||
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
|
||||
{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
|
||||
{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
|
||||
{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
|
||||
{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
|
||||
{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
|
||||
};
|
||||
|
||||
|
||||
1151
MCUME_pico/tft_t/tft_t_dma.cpp
Normal file
1151
MCUME_pico/tft_t/tft_t_dma.cpp
Normal file
File diff suppressed because it is too large
Load diff
220
MCUME_pico/tft_t/tft_t_dma.h
Normal file
220
MCUME_pico/tft_t/tft_t_dma.h
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
#ifndef _TFT_T_DMAH_
|
||||
#define _TFT_T_DMAH_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "pico.h"
|
||||
#endif
|
||||
|
||||
#include "tft_t_dma_config.h"
|
||||
|
||||
#define RGBVAL32(r,g,b) ( (r<<16) | (g<<8) | b )
|
||||
#define RGBVAL16(r,g,b) ( (((r>>3)&0x1f)<<11) | (((g>>2)&0x3f)<<5) | (((b>>3)&0x1f)<<0) )
|
||||
#define RGBVAL8(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
|
||||
#define R16(rgb) ((rgb>>8)&0xf8)
|
||||
#define G16(rgb) ((rgb>>3)&0xfc)
|
||||
#define B16(rgb) ((rgb<<3)&0xf8)
|
||||
|
||||
|
||||
#ifdef LOHRES
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_REALWIDTH 240
|
||||
#else
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_REALWIDTH 320
|
||||
#endif
|
||||
#define TFT_HEIGHT 240
|
||||
#define TFT_REALHEIGHT 240
|
||||
|
||||
|
||||
#define LINES_PER_BLOCK 64
|
||||
#define NR_OF_BLOCK 4
|
||||
|
||||
|
||||
#ifdef ILI9341
|
||||
|
||||
#define ILI9341_NOP 0x00
|
||||
#define ILI9341_SWRESET 0x01
|
||||
#define ILI9341_RDDID 0x04
|
||||
#define ILI9341_RDDST 0x09
|
||||
|
||||
#define ILI9341_SLPIN 0x10
|
||||
#define ILI9341_SLPOUT 0x11
|
||||
#define ILI9341_PTLON 0x12
|
||||
#define ILI9341_NORON 0x13
|
||||
|
||||
#define ILI9341_RDMODE 0x0A
|
||||
#define ILI9341_RDMADCTL 0x0B
|
||||
#define ILI9341_RDPIXFMT 0x0C
|
||||
#define ILI9341_RDIMGFMT 0x0D
|
||||
#define ILI9341_RDSELFDIAG 0x0F
|
||||
|
||||
#define ILI9341_INVOFF 0x20
|
||||
#define ILI9341_INVON 0x21
|
||||
#define ILI9341_GAMMASET 0x26
|
||||
#define ILI9341_DISPOFF 0x28
|
||||
#define ILI9341_DISPON 0x29
|
||||
|
||||
#define ILI9341_CASET 0x2A
|
||||
#define ILI9341_PASET 0x2B
|
||||
#define ILI9341_RAMWR 0x2C
|
||||
#define ILI9341_RAMRD 0x2E
|
||||
|
||||
#define ILI9341_PTLAR 0x30
|
||||
#define ILI9341_MADCTL 0x36
|
||||
#define ILI9341_VSCRSADD 0x37
|
||||
#define ILI9341_PIXFMT 0x3A
|
||||
|
||||
#define ILI9341_FRMCTR1 0xB1
|
||||
#define ILI9341_FRMCTR2 0xB2
|
||||
#define ILI9341_FRMCTR3 0xB3
|
||||
#define ILI9341_INVCTR 0xB4
|
||||
#define ILI9341_DFUNCTR 0xB6
|
||||
|
||||
#define ILI9341_PWCTR1 0xC0
|
||||
#define ILI9341_PWCTR2 0xC1
|
||||
#define ILI9341_PWCTR3 0xC2
|
||||
#define ILI9341_PWCTR4 0xC3
|
||||
#define ILI9341_PWCTR5 0xC4
|
||||
#define ILI9341_VMCTR1 0xC5
|
||||
#define ILI9341_VMCTR2 0xC7
|
||||
|
||||
#define ILI9341_RDID1 0xDA
|
||||
#define ILI9341_RDID2 0xDB
|
||||
#define ILI9341_RDID3 0xDC
|
||||
#define ILI9341_RDID4 0xDD
|
||||
|
||||
#define ILI9341_GMCTRP1 0xE0
|
||||
#define ILI9341_GMCTRN1 0xE1
|
||||
|
||||
#define ILI9341_MADCTL_MY 0x80
|
||||
#define ILI9341_MADCTL_MX 0x40
|
||||
#define ILI9341_MADCTL_MV 0x20
|
||||
#define ILI9341_MADCTL_ML 0x10
|
||||
#define ILI9341_MADCTL_RGB 0x00
|
||||
#define ILI9341_MADCTL_BGR 0x08
|
||||
#define ILI9341_MADCTL_MH 0x04
|
||||
|
||||
#define TFT_CASET ILI9341_CASET
|
||||
#define TFT_PASET ILI9341_PASET
|
||||
#define TFT_RAMWR ILI9341_RAMWR
|
||||
#define TFT_MADCTL ILI9341_MADCTL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ST7789
|
||||
|
||||
#define ST7735_NOP 0x00
|
||||
#define ST7735_SWRESET 0x01
|
||||
#define ST7735_RDDID 0x04
|
||||
#define ST7735_RDDST 0x09
|
||||
|
||||
#define ST7735_SLPIN 0x10
|
||||
#define ST7735_SLPOUT 0x11
|
||||
#define ST7735_PTLON 0x12
|
||||
#define ST7735_NORON 0x13
|
||||
|
||||
#define ST7735_INVOFF 0x20
|
||||
#define ST7735_INVON 0x21
|
||||
#define ST7735_DISPOFF 0x28
|
||||
#define ST7735_DISPON 0x29
|
||||
#define ST7735_CASET 0x2A
|
||||
#define ST7735_RASET 0x2B
|
||||
#define ST7735_RAMWR 0x2C
|
||||
#define ST7735_RAMRD 0x2E
|
||||
|
||||
#define ST7735_PTLAR 0x30
|
||||
#define ST7735_COLMOD 0x3A
|
||||
#define ST7735_MADCTL 0x36
|
||||
|
||||
#define ST7735_FRMCTR1 0xB1
|
||||
#define ST7735_FRMCTR2 0xB2
|
||||
#define ST7735_FRMCTR3 0xB3
|
||||
#define ST7735_INVCTR 0xB4
|
||||
#define ST7735_DISSET5 0xB6
|
||||
|
||||
#define ST7735_PWCTR1 0xC0
|
||||
#define ST7735_PWCTR2 0xC1
|
||||
#define ST7735_PWCTR3 0xC2
|
||||
#define ST7735_PWCTR4 0xC3
|
||||
#define ST7735_PWCTR5 0xC4
|
||||
#define ST7735_VMCTR1 0xC5
|
||||
|
||||
#define ST7735_RDID1 0xDA
|
||||
#define ST7735_RDID2 0xDB
|
||||
#define ST7735_RDID3 0xDC
|
||||
#define ST7735_RDID4 0xDD
|
||||
|
||||
#define ST7735_PWCTR6 0xFC
|
||||
|
||||
#define ST7735_GMCTRP1 0xE0
|
||||
#define ST7735_GMCTRN1 0xE1
|
||||
|
||||
#define ST77XX_MADCTL_MY 0x80
|
||||
#define ST77XX_MADCTL_MX 0x40
|
||||
#define ST77XX_MADCTL_MV 0x20
|
||||
#define ST77XX_MADCTL_ML 0x10
|
||||
#define ST77XX_MADCTL_RGB 0x00
|
||||
#define ST77XX_MADCTL_BGR 0x08
|
||||
#define ST77XX_MADCTL_MH 0x04
|
||||
|
||||
#define TFT_CASET ST7735_CASET
|
||||
#define TFT_PASET ST7735_RASET
|
||||
#define TFT_RAMWR ST7735_RAMWR
|
||||
#define TFT_MADCTL ST7735_MADCTL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class TFT_T_DMA
|
||||
{
|
||||
public:
|
||||
TFT_T_DMA();
|
||||
|
||||
void setArea(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2);
|
||||
void begin(void);
|
||||
void flipscreen(bool flip);
|
||||
bool isflipped(void);
|
||||
void startDMA(void);
|
||||
void stopDMA();
|
||||
int get_frame_buffer_size(int *width, int *height);
|
||||
void waitSync();
|
||||
|
||||
void begin_audio(int samplesize, void (*callback)(short * stream, int len));
|
||||
void end_audio();
|
||||
|
||||
// NoDMA functions
|
||||
void fillScreenNoDma(uint16_t color);
|
||||
void writeScreenNoDma(const uint16_t *pcolors);
|
||||
void drawTextNoDma(int16_t x, int16_t y, const char * text, uint16_t fgcolor, uint16_t bgcolor, bool doublesize);
|
||||
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||
void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *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);
|
||||
|
||||
// DMA functions
|
||||
uint16_t * getLineBuffer(int j);
|
||||
void writeScreen(int width, int height, int stride, uint8_t *buffer, uint16_t *palette16);
|
||||
void writeLine(int width, int height, int stride, uint8_t *buffer, uint16_t *palette16);
|
||||
void writeLine(int width, int height, int y, uint16_t *buf);
|
||||
void fillScreen(uint16_t color);
|
||||
void drawText(int16_t x, int16_t y, const char * text, uint16_t fgcolor, uint16_t bgcolor, bool doublesize);
|
||||
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||
void drawSprite(int16_t x, int16_t y, const uint16_t *bitmap);
|
||||
void drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh);
|
||||
|
||||
protected:
|
||||
uint8_t _rst, _cs, _dc;
|
||||
uint8_t _miso, _mosi, _sclk;
|
||||
bool flipped=false;
|
||||
|
||||
void wait(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue