Skip to content

Commit

Permalink
Namespace/centralize more stuff, add to-do list.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbaumann committed Nov 29, 2024
1 parent 8b23905 commit c51391a
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 363 deletions.
39 changes: 20 additions & 19 deletions src/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "logging.h"
#include "main.pio.h"
#include "pico/stdlib.h"
#include "picostation.h"
#include "utils.h"
#include "values.h"

Expand All @@ -16,25 +17,6 @@
#define DEBUG_PRINT(...) while (0)
#endif

extern uint g_countTrack;
extern int g_track;
extern int g_originalTrack;

extern int g_sledMoveDirection;
extern uint64_t g_sledTimer;

extern volatile int g_sector;
extern int g_sectorForTrackUpdate;

extern int g_targetPlaybackSpeed;

extern volatile bool g_sensData[16];
extern volatile bool g_subqDelay;

extern volatile bool g_soctEnabled;
extern uint g_soctOffset;
extern volatile uint g_imageIndex;

void setSens(uint what, bool new_value);

namespace picostation {
Expand Down Expand Up @@ -74,6 +56,25 @@ static volatile uint s_currentSens;
static volatile uint s_latched = 0; // Command latch
// Indirectly accessed from both cores by updateMechSens, leave volatile

volatile bool g_sensData[16] = {
0, // $0X - FZC
0, // $1X - AS
0, // $2X - TZC
0, // $3X - Misc.
0, // $4X - XBUSY
1, // $5X - FOK
0, // $6X - 0
0, // $7X - 0
0, // $8X - 0
0, // $9X - 0
1, // $AX - GFS
0, // $BX - COMP
0, // $CX - COUT
0, // $DX - 0
0, // $EX - OV64
0 // $FX - 0
};

static void autoSequence();
static void funcSpec();
static void modeSpec();
Expand Down
3 changes: 3 additions & 0 deletions src/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace picostation {
namespace mechcommand {

extern volatile bool g_sensData[16];

void interrupt_xlat(uint gpio, uint32_t events);
void setSens(uint what, bool new_value);
void updateMechSens();
Expand Down
22 changes: 5 additions & 17 deletions src/i2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "logging.h"
#include "main.pio.h"
#include "pico/stdlib.h"
#include "picostation.h"
#include "rtc.h"
#include "subq.h"
#include "utils.h"
Expand All @@ -26,25 +27,13 @@
#define DEBUG_PRINT(...) while (0)
#endif

// To-do:
// This was a placeholder for multi-cue support
// but need a console side menu to select the cue file still
const TCHAR target_Cues[NUM_IMAGES][11] = {
"UNIROM.cue",
};
volatile int g_imageIndex = 0;

extern volatile int g_sector;
extern volatile int g_sectorSending;
extern volatile bool g_sensData[16];
extern volatile bool g_soctEnabled;
extern mutex_t g_mechaconMutex;
extern volatile bool g_coreReady[2];

static uint64_t s_psneeTimer;

void psnee(const int sector);

inline void picostation::I2S::generateScramblingKey(uint16_t *cdScramblingKey) {
int key = 1;

Expand Down Expand Up @@ -125,7 +114,7 @@ inline int picostation::I2S::initDMA(const volatile void *read_addr, uint transf
while (true) {
// Update latching, output SENS
if (mutex_try_enter(&g_mechaconMutex, 0)) {
picostation::mechcommand::updateMechSens();
mechcommand::updateMechSens();
mutex_exit(&g_mechaconMutex);
}

Expand Down Expand Up @@ -216,10 +205,9 @@ inline int picostation::I2S::initDMA(const volatile void *read_addr, uint transf
__builtin_unreachable();
}

void psnee(const int sector) {
void picostation::I2S::psnee(const int sector) {
static constexpr int PSNEE_SECTOR_LIMIT = c_leadIn;
static constexpr char SCEX_DATA[][44] = {
// To-do: Change psnee to UART(250 baud)
{1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0,
1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0},
{1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0,
Expand All @@ -230,8 +218,8 @@ void psnee(const int sector) {

static int psnee_hysteresis = 0;

if (sector > 0 && sector < PSNEE_SECTOR_LIMIT && g_sensData[SENS::GFS] && !g_soctEnabled &&
picostation::g_discImage.hasData() && ((time_us_64() - s_psneeTimer) > 13333)) {
if (sector > 0 && sector < PSNEE_SECTOR_LIMIT && mechcommand::g_sensData[SENS::GFS] && !g_soctEnabled &&
g_discImage.hasData() && ((time_us_64() - s_psneeTimer) > 13333)) {
psnee_hysteresis++;
s_psneeTimer = time_us_64();
}
Expand Down
1 change: 1 addition & 0 deletions src/i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class I2S {
void generateScramblingKey(uint16_t *cdScramblingKey);
int initDMA(const volatile void *read_addr, uint transfer_count); // Returns DMA channel number
void mountSDCard();
void psnee(const int sector);
void reset();
};
} // namespace picostation
4 changes: 2 additions & 2 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define DEBUG_CMD 0
#define DEBUG_CUE 0
#define DEBUG_I2S 0
#define DEBUG_MISC 0
#define DEBUG_MAIN 0
#define DEBUG_SUBQ 0

#define DEBUG_LOGGING_ENABLED (DEBUG_CMD | DEBUG_CUE | DEBUG_I2S | DEBUG_MISC | DEBUG_SUBQ)
#define DEBUG_LOGGING_ENABLED (DEBUG_CMD | DEBUG_CUE | DEBUG_I2S | DEBUG_MAIN | DEBUG_SUBQ)
Loading

0 comments on commit c51391a

Please sign in to comment.