allow menu control with 2nd joystick
This commit is contained in:
parent
c64e63cb51
commit
471a09c568
9 changed files with 96 additions and 124 deletions
|
|
@ -68,9 +68,7 @@ static Channel chan[6] = {
|
|||
volatile bool playing = false;
|
||||
|
||||
|
||||
|
||||
|
||||
PROGMEM static void snd_Reset(void)
|
||||
static void snd_Reset(void)
|
||||
{
|
||||
#ifndef CUSTOM_SND
|
||||
chan[0].vol = 0;
|
||||
|
|
@ -90,10 +88,13 @@ PROGMEM static void snd_Reset(void)
|
|||
|
||||
|
||||
#ifdef CUSTOM_SND
|
||||
//extern "C" {
|
||||
void SND_Process(void *sndbuffer, int sndn);
|
||||
//}
|
||||
#endif
|
||||
|
||||
PROGMEM static void snd_Mixer(short * stream, int len )
|
||||
|
||||
FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len )
|
||||
{
|
||||
if (playing)
|
||||
{
|
||||
|
|
@ -103,7 +104,6 @@ PROGMEM static void snd_Mixer(short * stream, int len )
|
|||
int i;
|
||||
long s;
|
||||
len = len >> 1;
|
||||
|
||||
short v0=chan[0].vol;
|
||||
short v1=chan[1].vol;
|
||||
short v2=chan[2].vol;
|
||||
|
|
@ -131,40 +131,41 @@ PROGMEM static void snd_Mixer(short * stream, int len )
|
|||
}
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::begin(void)
|
||||
void AudioPlaySystem::begin(void)
|
||||
{
|
||||
//emu_printf("AudioPlaySystem constructor");
|
||||
this->reset();
|
||||
setSampleParameters(CLOCKFREQ, SAMPLERATE);
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::start(void)
|
||||
void AudioPlaySystem::start(void)
|
||||
{
|
||||
//emu_printf("allocating sound buf");
|
||||
#ifndef HAS_T4_VGA
|
||||
AudioMemory(16);
|
||||
#endif
|
||||
playing = true;
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
|
||||
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::reset(void)
|
||||
void AudioPlaySystem::reset(void)
|
||||
{
|
||||
snd_Reset();
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::stop(void)
|
||||
void AudioPlaySystem::stop(void)
|
||||
{
|
||||
//__disable_irq();
|
||||
playing = false;
|
||||
//__enable_irq();
|
||||
}
|
||||
|
||||
PROGMEM bool AudioPlaySystem::isPlaying(void)
|
||||
bool AudioPlaySystem::isPlaying(void)
|
||||
{
|
||||
return playing;
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::update(void) {
|
||||
#ifndef HAS_T4_VGA
|
||||
void AudioPlaySystem::update(void) {
|
||||
audio_block_t *block;
|
||||
|
||||
// only update if we're playing
|
||||
|
|
@ -180,8 +181,9 @@ PROGMEM void AudioPlaySystem::update(void) {
|
|||
transmit(block);
|
||||
release(block);
|
||||
}
|
||||
#endif
|
||||
|
||||
PROGMEM void AudioPlaySystem::sound(int C, int F, int V) {
|
||||
void AudioPlaySystem::sound(int C, int F, int V) {
|
||||
#ifndef CUSTOM_SND
|
||||
if (C < 6) {
|
||||
chan[C].vol = V;
|
||||
|
|
@ -190,7 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) {
|
|||
#endif
|
||||
}
|
||||
|
||||
PROGMEM void AudioPlaySystem::step(void) {
|
||||
void AudioPlaySystem::step(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include "platform_config.h"
|
||||
|
||||
//#undef HAS_T4_VGA // To force using Audio library!!
|
||||
|
||||
#ifndef HAS_T4_VGA
|
||||
|
||||
#include <Audio.h>
|
||||
|
||||
class AudioPlaySystem : public AudioStream
|
||||
|
|
@ -21,8 +27,28 @@ public:
|
|||
|
||||
private:
|
||||
virtual void update(void);
|
||||
static void snd_Mixer(short * stream, int len );
|
||||
};
|
||||
|
||||
#else
|
||||
class AudioPlaySystem
|
||||
{
|
||||
public:
|
||||
AudioPlaySystem(void) { };
|
||||
void begin(void);
|
||||
void setSampleParameters(float clockfreq, float samplerate);
|
||||
void reset(void);
|
||||
void start(void);
|
||||
void stop(void);
|
||||
bool isPlaying(void);
|
||||
void sound(int C, int F, int V);
|
||||
void buzz(int size, int val);
|
||||
void step(void);
|
||||
static void snd_Mixer(short * stream, int len );
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -389,36 +389,18 @@ int emu_ReadKeys(void)
|
|||
uint16_t j2 = 0;
|
||||
|
||||
// Second joystick
|
||||
#if INVY
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( digitalRead(PIN_JOY1_1) == LOW ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( digitalRead(PIN_JOY1_2) == LOW ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( digitalRead(PIN_JOY1_1) == LOW ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( digitalRead(PIN_JOY1_2) == LOW ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#endif
|
||||
#if INVX
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( digitalRead(PIN_JOY1_3) == LOW ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( digitalRead(PIN_JOY1_4) == LOW ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( digitalRead(PIN_JOY1_3) == LOW ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( digitalRead(PIN_JOY1_4) == LOW ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PIN_JOY1_BTN
|
||||
if ( digitalRead(PIN_JOY1_BTN) == LOW ) j2 |= MASK_JOY2_BTN;
|
||||
#endif
|
||||
|
|
@ -820,7 +802,7 @@ int handleMenu(uint16_t bClick)
|
|||
int rx=0,ry=0,rw=0,rh=0;
|
||||
char c = 0; //captureTouchZone(menutouchareas, menutouchactions, &rx,&ry,&rw,&rh);
|
||||
|
||||
if ( (bClick & MASK_JOY2_BTN) || (c == MKEY_TFT) ) {
|
||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) || (c == MKEY_TFT) ) {
|
||||
emu_printf(newpath);
|
||||
#ifdef USE_SDFS
|
||||
FILINFO entry;
|
||||
|
|
@ -851,7 +833,7 @@ int handleMenu(uint16_t bClick)
|
|||
//tft.drawRectNoDma( rx,ry,rw,rh, KEYBOARD_HIT_COLOR );
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_JOY2_UP) {
|
||||
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
|
||||
if (curFile!=0) {
|
||||
menuRedraw=true;
|
||||
curFile--;
|
||||
|
|
@ -866,7 +848,7 @@ int handleMenu(uint16_t bClick)
|
|||
curFile--;
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_JOY2_DOWN) {
|
||||
else if ( (bClick & MASK_JOY2_DOWN) || (bClick & MASK_JOY1_DOWN) ) {
|
||||
if ((curFile<(nbFiles-1)) && (nbFiles)) {
|
||||
curFile++;
|
||||
menuRedraw=true;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
#define HAS_T41 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
//#define HAS_SND 1
|
||||
#define HAS_SND 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
||||
|
|
|
|||
|
|
@ -267,34 +267,33 @@ void loop(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
#include <Audio.h>
|
||||
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
#ifdef HAS_T4_VGA
|
||||
//AudioOutputMQS mqs;
|
||||
//AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
AudioOutputI2S i2s1;
|
||||
AudioConnection patchCord8(mymixer, 0, i2s1, 0);
|
||||
AudioConnection patchCord9(mymixer, 0, i2s1, 1);
|
||||
AudioControlSGTL5000 sgtl5000_1;
|
||||
#else
|
||||
AudioOutputMQS mqs;
|
||||
AudioConnection patchCord9(mymixer, 0, mqs, 1);
|
||||
#endif
|
||||
#else
|
||||
AudioOutputAnalog dac1;
|
||||
AudioConnection patchCord1(mymixer, dac1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void emu_sndInit() {
|
||||
Serial.println("sound init");
|
||||
#ifdef HAS_T4_VGA
|
||||
sgtl5000_1.enable();
|
||||
sgtl5000_1.volume(0.6);
|
||||
tft.begin_audio(256, mymixer.snd_Mixer);
|
||||
// sgtl5000_1.enable();
|
||||
// sgtl5000_1.volume(0.6);
|
||||
#endif
|
||||
AudioMemory(16);
|
||||
mymixer.start();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -389,36 +389,18 @@ int emu_ReadKeys(void)
|
|||
uint16_t j2 = 0;
|
||||
|
||||
// Second joystick
|
||||
#if INVY
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( digitalRead(PIN_JOY1_1) == LOW ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( digitalRead(PIN_JOY1_2) == LOW ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( digitalRead(PIN_JOY1_1) == LOW ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( digitalRead(PIN_JOY1_2) == LOW ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#endif
|
||||
#if INVX
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( digitalRead(PIN_JOY1_3) == LOW ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( digitalRead(PIN_JOY1_4) == LOW ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( digitalRead(PIN_JOY1_3) == LOW ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( digitalRead(PIN_JOY1_4) == LOW ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PIN_JOY1_BTN
|
||||
if ( digitalRead(PIN_JOY1_BTN) == LOW ) j2 |= MASK_JOY2_BTN;
|
||||
#endif
|
||||
|
|
@ -778,7 +760,7 @@ int handleMenu(uint16_t bClick)
|
|||
int rx=0,ry=0,rw=0,rh=0;
|
||||
char c = 0; //captureTouchZone(menutouchareas, menutouchactions, &rx,&ry,&rw,&rh);
|
||||
|
||||
if ( (bClick & MASK_JOY2_BTN) || (c == MKEY_TFT) ) {
|
||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) || (c == MKEY_TFT) ) {
|
||||
emu_printf(newpath);
|
||||
#ifdef USE_SDFS
|
||||
FILINFO entry;
|
||||
|
|
@ -809,7 +791,7 @@ int handleMenu(uint16_t bClick)
|
|||
//tft.drawRectNoDma( rx,ry,rw,rh, KEYBOARD_HIT_COLOR );
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_JOY2_UP) {
|
||||
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
|
||||
if (curFile!=0) {
|
||||
menuRedraw=true;
|
||||
curFile--;
|
||||
|
|
@ -824,7 +806,7 @@ int handleMenu(uint16_t bClick)
|
|||
curFile--;
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_JOY2_DOWN) {
|
||||
else if ( (bClick & MASK_JOY2_DOWN) || (bClick & MASK_JOY1_DOWN) ) {
|
||||
if ((curFile<(nbFiles-1)) && (nbFiles)) {
|
||||
curFile++;
|
||||
menuRedraw=true;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#define HAS_T4_VGA 1
|
||||
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define INVY 1
|
||||
//#define HAS_SND 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
|
|
|||
|
|
@ -392,36 +392,18 @@ int emu_ReadKeys(void)
|
|||
uint16_t j2 = 0;
|
||||
|
||||
// Second joystick
|
||||
#if INVY
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( digitalRead(PIN_JOY1_1) == LOW ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( digitalRead(PIN_JOY1_2) == LOW ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_1
|
||||
if ( digitalRead(PIN_JOY1_1) == LOW ) j2 |= MASK_JOY2_UP;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_2
|
||||
if ( digitalRead(PIN_JOY1_2) == LOW ) j2 |= MASK_JOY2_DOWN;
|
||||
#endif
|
||||
#endif
|
||||
#if INVX
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( digitalRead(PIN_JOY1_3) == LOW ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( digitalRead(PIN_JOY1_4) == LOW ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#else
|
||||
#ifdef PIN_JOY1_3
|
||||
if ( digitalRead(PIN_JOY1_3) == LOW ) j2 |= MASK_JOY2_RIGHT;
|
||||
#endif
|
||||
#ifdef PIN_JOY1_4
|
||||
if ( digitalRead(PIN_JOY1_4) == LOW ) j2 |= MASK_JOY2_LEFT;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PIN_JOY1_BTN
|
||||
if ( digitalRead(PIN_JOY1_BTN) == LOW ) j2 |= MASK_JOY2_BTN;
|
||||
#endif
|
||||
|
|
@ -810,7 +792,7 @@ int handleMenu(uint16_t bClick)
|
|||
int rx=0,ry=0,rw=0,rh=0;
|
||||
char c = 0; //captureTouchZone(menutouchareas, menutouchactions, &rx,&ry,&rw,&rh);
|
||||
|
||||
if ( (bClick & MASK_JOY2_BTN) || (c == MKEY_TFT) ) {
|
||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) || (c == MKEY_TFT) ) {
|
||||
emu_printf(newpath);
|
||||
#ifdef USE_SDFS
|
||||
FILINFO entry;
|
||||
|
|
@ -841,7 +823,7 @@ int handleMenu(uint16_t bClick)
|
|||
//tft.drawRectNoDma( rx,ry,rw,rh, KEYBOARD_HIT_COLOR );
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_JOY2_UP) {
|
||||
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
|
||||
if (curFile!=0) {
|
||||
menuRedraw=true;
|
||||
curFile--;
|
||||
|
|
@ -856,7 +838,7 @@ int handleMenu(uint16_t bClick)
|
|||
curFile--;
|
||||
}
|
||||
}
|
||||
else if (bClick & MASK_JOY2_DOWN) {
|
||||
else if ( (bClick & MASK_JOY2_DOWN) || (bClick & MASK_JOY1_DOWN) ) {
|
||||
if ((curFile<(nbFiles-1)) && (nbFiles)) {
|
||||
curFile++;
|
||||
menuRedraw=true;
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ void uae_Input(int bClick) {
|
|||
|
||||
buttonstate[0] = 0;
|
||||
buttonstate[2] = 0;
|
||||
if (k & MASK_JOY2_BTN) buttonstate[0] = 1;
|
||||
if ( (k & MASK_JOY1_BTN)|| ( k & MASK_JOY2_BTN)) buttonstate[0] = 1;
|
||||
if (k & MASK_KEY_USER1) buttonstate[2] = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -420,11 +420,11 @@ void read_joystick(int nr, unsigned int *dir, int *button)
|
|||
|
||||
if (!isMouse)
|
||||
{
|
||||
if (k & MASK_JOY2_DOWN) bot=1;
|
||||
if (k & MASK_JOY2_UP) top=1;
|
||||
if (k & MASK_JOY2_LEFT) left=1;
|
||||
if (k & MASK_JOY2_RIGHT) right=1;
|
||||
if (k & MASK_JOY2_BTN) *button |=0xFF;
|
||||
if ((k & MASK_JOY2_DOWN) || ( k & MASK_JOY1_DOWN)) bot=1;
|
||||
if ((k & MASK_JOY2_UP) || ( k & MASK_JOY1_UP)) top=1;
|
||||
if ((k & MASK_JOY2_LEFT) || ( k & MASK_JOY1_LEFT)) left=1;
|
||||
if ((k & MASK_JOY2_RIGHT) || ( k & MASK_JOY1_RIGHT)) right=1;
|
||||
if ((k & MASK_JOY2_BTN) || ( k & MASK_JOY1_BTN)) *button |=0xFF;
|
||||
|
||||
if (left) top = !top;
|
||||
if (right) bot = !bot;
|
||||
|
|
|
|||
Loading…
Reference in a new issue