ref: 986a9df1593ab767caffd705013cada724219a22
parent: af91213d67a744cf532548803c4c150eef5cb7c1
author: Olav Sørensen <olav.sorensen@live.no>
date: Wed Apr 29 14:01:44 EDT 2020
Pushed v1.23 code - Bugfix: The "default dirctories" paths in the config only worked for modules and not the other types (fixes GitHub issue #6). - A much needed code refactoring of data structs. The code now also compiles with GCC 10.
--- a/src/ft2_about.c
+++ b/src/ft2_about.c
@@ -6,6 +6,7 @@
#include "ft2_bmp.h"
#include "ft2_video.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
// ported from original FT2 code
@@ -235,12 +236,10 @@
void showAboutScreen(void) // called once when About screen is opened
{
#define TEXT_BORDER_COL 0x202020
-
- const char *infoString = "Clone by Olav \"8bitbubsy\" S\025rensen - https://16-bits.org";
char verText[32];
uint16_t x, y;
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
@@ -254,24 +253,25 @@
setCustomPalColor(TEXT_BORDER_COL); // sets PAL_CUSTOM
- x = 5 + (SCREEN_W - textWidth(infoString)) / 2;
+ const char *infoString = "Clone by Olav \"8bitbubsy\" S\025rensen";
+ x = (SCREEN_W - textWidth(infoString)) >> 1;
y = 147;
textOutBorder(x, y, PAL_FORGRND, PAL_CUSTOM, infoString);
sprintf(verText, "v%s (compiled on %s)", PROG_VER_STR, __DATE__);
- x = ((3 + ABOUT_SCREEN_W) - textWidth(verText)) / 2;
- y = (3 + ABOUT_SCREEN_H) - ((FONT1_CHAR_H - 2) + 3);
+ x = (SCREEN_W - textWidth(verText)) >> 1;
+ y = 159;
textOutBorder(x, y, PAL_FORGRND, PAL_CUSTOM, verText);
aboutInit();
- editor.ui.aboutScreenShown = true;
+ ui.aboutScreenShown = true;
}
void hideAboutScreen(void)
{
hidePushButton(PB_EXIT_ABOUT);
- editor.ui.aboutScreenShown = false;
+ ui.aboutScreenShown = false;
}
void exitAboutScreen(void)
--- a/src/ft2_audio.c
+++ b/src/ft2_audio.c
@@ -14,9 +14,19 @@
#include "ft2_wav_renderer.h"
#include "ft2_mix.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
#define INITIAL_DITHER_SEED 0x12345000
+// globalized
+audio_t audio;
+pattSyncData_t *pattSyncEntry;
+chSyncData_t *chSyncEntry;
+chSync_t chSync;
+pattSync_t pattSync;
+volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
+
+
static int8_t pmpCountDiv, pmpChannels = 2;
static uint16_t smpBuffSize;
static int32_t masterVol, oldAudioFreq, pmpLeft, randSeed = INITIAL_DITHER_SEED;
@@ -31,11 +41,6 @@
static uint32_t oldSFrq, oldSFrqRev;
#endif
-pattSyncData_t *pattSyncEntry;
-chSyncData_t *chSyncEntry;
-
-volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
-
#if !defined __amd64__ && !defined _WIN64
void resetCachedMixerVars(void)
{
@@ -93,7 +98,7 @@
}
// also update config audio radio buttons if we're on that screen at the moment
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
setConfigIORadioButtonStates();
// if it didn't work to use the old settings again, then something is seriously wrong...
@@ -1214,7 +1219,7 @@
setLastWorkingAudioDevName();
// update config audio radio buttons if we're on that screen at the moment
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
showConfigScreen();
updateWavRendererSettings();
--- a/src/ft2_audio.h
+++ b/src/ft2_audio.h
@@ -42,7 +42,7 @@
// for audio/video sync queue. (2^n-1 - don't change this! Queue buffer is already ~2.7MB in size)
#define SYNC_QUEUE_LEN 4095
-struct audio_t
+typedef struct audio_t
{
char *currInputDevice, *currOutputDevice, *lastWorkingAudioDeviceName;
char *inputDeviceNames[MAX_AUDIO_DEVICES], *outputDeviceNames[MAX_AUDIO_DEVICES];
@@ -57,7 +57,7 @@
double dAudioLatencyMs, dSpeedValMul, dPianoDeltaMul;
SDL_AudioDeviceID dev;
uint32_t wantFreq, haveFreq, wantSamples, haveSamples, wantChannels, haveChannels;
-} audio;
+} audio_t;
typedef struct
{
@@ -86,11 +86,11 @@
uint64_t timestamp;
} pattSyncData_t;
-struct pattSync
+typedef struct pattSync_t
{
volatile int32_t readPos, writePos;
pattSyncData_t data[SYNC_QUEUE_LEN + 1];
-} pattSync;
+} pattSync_t;
typedef struct chSyncData_t
{
@@ -98,14 +98,18 @@
uint64_t timestamp;
} chSyncData_t;
-struct chSync
+typedef struct chSync_t
{
volatile int32_t readPos, writePos;
chSyncData_t data[SYNC_QUEUE_LEN + 1];
-} chSync;
+} chSync_t;
+// in ft2_audio.c
+extern audio_t audio;
extern pattSyncData_t *pattSyncEntry;
extern chSyncData_t *chSyncEntry;
+extern chSync_t chSync;
+extern pattSync_t pattSync;
extern volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
--- a/src/ft2_audioselector.c
+++ b/src/ft2_audioselector.c
@@ -11,6 +11,7 @@
#include "ft2_gui.h"
#include "ft2_mouse.h"
#include "ft2_audioselector.h"
+#include "ft2_structs.h"
char *getAudioOutputDeviceFromConfig(void)
{
@@ -220,7 +221,7 @@
int32_t mx, my, deviceNum;
uint32_t devStringLen;
- if (!editor.ui.configScreenShown || editor.currConfigScreen != CONFIG_SCREEN_IO_DEVICES)
+ if (!ui.configScreenShown || editor.currConfigScreen != CONFIG_SCREEN_IO_DEVICES)
return false;
mx = mouse.x;
@@ -420,7 +421,7 @@
const char *deviceName;
uint32_t stringLen;
- listShown = (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES);
+ listShown = (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES);
freeAudioDeviceLists();
@@ -518,7 +519,7 @@
{
(void)pos;
- if (editor.ui.configScreenShown && (editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES))
+ if (ui.configScreenShown && (editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES))
drawAudioOutputList();
}
@@ -526,6 +527,6 @@
{
(void)pos;
- if (editor.ui.configScreenShown && (editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES))
+ if (ui.configScreenShown && (editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES))
drawAudioInputList();
}
--- a/src/ft2_bmp.c
+++ b/src/ft2_bmp.c
@@ -41,6 +41,8 @@
static uint8_t *loadBMPTo1Bit(const uint8_t *src);
static uint8_t *loadBMPTo4BitPal(const uint8_t *src);
+bmp_t bmp; // globalized
+
// if you match a color in this table, you have the real palette index (LUT pos)
#define NUM_CUSTOM_PALS 17
static const uint32_t bmpCustomPalette[NUM_CUSTOM_PALS] =
--- a/src/ft2_bmp.h
+++ b/src/ft2_bmp.h
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
-struct
+typedef struct bmp_t
{
uint8_t *font1, *font2, *font3, *font4, *font6, *font7, *font8;
uint8_t *ft2LogoBadges, *ft2ByBadges, *radiobuttonGfx, *checkboxGfx;
@@ -11,7 +11,9 @@
uint8_t *mouseCursors, *mouseCursorBusyClock, *mouseCursorBusyGlass;
uint8_t *whitePianoKeys, *blackPianoKeys, *vibratoWaveforms, *scopeRec, *scopeMute;
uint32_t *ft2AboutLogo;
-} bmp;
+} bmp_t;
+
+extern bmp_t bmp; // ft2_bmp.c
bool loadBMPs(void);
void freeBMPs(void);
--- a/src/ft2_checkboxes.c
+++ b/src/ft2_checkboxes.c
@@ -14,6 +14,7 @@
#include "ft2_mouse.h"
#include "ft2_edit.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
checkBox_t checkBoxes[NUM_CHECKBOXES] =
{
@@ -182,7 +183,7 @@
uint16_t start, end;
checkBox_t *checkBox;
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
{
// if a system request is open, only test the first three checkboxes (reserved)
start = 0;
--- a/src/ft2_config.c
+++ b/src/ft2_config.c
@@ -31,6 +31,7 @@
#include "ft2_pattern_draw.h"
#include "ft2_tables.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
// globals
config_t config;
@@ -189,7 +190,7 @@
setMouseShape(config.mouseType);
changeLogoType(config.id_FastLogo);
changeBadgeType(config.id_TritonProd);
- editor.ui.maxVisibleChannels = (uint8_t)(2 + ((config.ptnMaxChannels + 1) * 2));
+ ui.maxVisibleChannels = (uint8_t)(2 + ((config.ptnMaxChannels + 1) * 2));
setPal16(palTable[config.cfg_StdPalNr], true);
updatePattFontPtrs();
@@ -275,7 +276,7 @@
if (midi.initThreadDone)
{
setMidiInputDeviceFromConfig();
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MIDI_INPUT)
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MIDI_INPUT)
drawMidiInputList();
}
#endif
@@ -1083,11 +1084,11 @@
void showConfigScreen(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
- editor.ui.configScreenShown = true;
+ ui.configScreenShown = true;
drawFramework(0, 0, 110, 173, FRAMEWORK_TYPE1);
@@ -1503,7 +1504,7 @@
hideScrollBar(SB_MIDI_INPUT_SCROLL);
#endif
- editor.ui.configScreenShown = false;
+ ui.configScreenShown = false;
}
void exitConfigScreen(void)
@@ -1703,11 +1704,11 @@
static void redrawPatternEditor(void) // called after changing some pattern editor settings in config
{
// if the cursor was on the volume column while we turned volume column off, move it to effect type slot
- if (!config.ptnS3M && (editor.cursor.object == CURSOR_VOL1 || editor.cursor.object == CURSOR_VOL2))
- editor.cursor.object = CURSOR_EFX0;
+ if (!config.ptnS3M && (cursor.object == CURSOR_VOL1 || cursor.object == CURSOR_VOL2))
+ cursor.object = CURSOR_EFX0;
updateChanNums();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
void cbConfigPattStretch(void)
@@ -1841,7 +1842,7 @@
{
config.ptnMaxChannels = MAX_CHANS_SHOWN_4;
checkRadioButton(RB_CONFIG_MAXCHAN_4);
- editor.ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
+ ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
redrawPatternEditor();
}
@@ -1849,7 +1850,7 @@
{
config.ptnMaxChannels = MAX_CHANS_SHOWN_6;
checkRadioButton(RB_CONFIG_MAXCHAN_6);
- editor.ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
+ ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
redrawPatternEditor();
}
@@ -1857,7 +1858,7 @@
{
config.ptnMaxChannels = MAX_CHANS_SHOWN_8;
checkRadioButton(RB_CONFIG_MAXCHAN_8);
- editor.ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
+ ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
redrawPatternEditor();
}
@@ -1865,7 +1866,7 @@
{
config.ptnMaxChannels = MAX_CHANS_SHOWN_12;
checkRadioButton(RB_CONFIG_MAXCHAN_12);
- editor.ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
+ ui.maxVisibleChannels = 2 + (((uint8_t)config.ptnMaxChannels + 1) * 2);
redrawPatternEditor();
}
--- a/src/ft2_diskop.c
+++ b/src/ft2_diskop.c
@@ -38,8 +38,9 @@
#include "ft2_events.h"
#include "ft2_video.h"
#include "ft2_inst_ed.h"
+#include "ft2_structs.h"
-// hide POSIX warnings
+// hide POSIX warnings for chdir()
#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif
@@ -669,7 +670,7 @@
free(ansiPath);
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
drawTextBox(TB_DISKOP_FILENAME);
}
@@ -770,7 +771,7 @@
strcat(name, ext);
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
diskOp_DrawDirectory();
}
@@ -777,7 +778,7 @@
void diskOpChangeFilenameExt(char *ext)
{
changeFilenameExt(FReq_FileName, ext, PATH_MAX);
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
diskOp_DrawDirectory();
}
@@ -1136,7 +1137,7 @@
{
int32_t tmpEntry, max;
- if (!editor.ui.diskOpShown || FReq_FileCount == 0)
+ if (!ui.diskOpShown || FReq_FileCount == 0)
return false;
max = FReq_FileCount - FReq_DirPos;
@@ -1200,7 +1201,7 @@
void testDiskOpMouseRelease(void)
{
- if (editor.ui.diskOpShown && FReq_EntrySelected != -1)
+ if (ui.diskOpShown && FReq_EntrySelected != -1)
{
if (mouse.x >= 169 && mouse.x <= 329 && mouse.y >= 4 && mouse.y <= 168)
fileListPressed((mouse.y - 4) / (FONT1_CHAR_H + 1));
@@ -2071,7 +2072,7 @@
if (FReq_Item == DISKOP_ITEM_PATTERN) radioButtons[RB_DISKOP_PAT_SAVEAS_XP].state = RADIOBUTTON_CHECKED;
if (FReq_Item == DISKOP_ITEM_TRACK) radioButtons[RB_DISKOP_TRK_SAVEAS_XT].state = RADIOBUTTON_CHECKED;
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
{
switch (FReq_Item)
{
@@ -2104,7 +2105,12 @@
case DISKOP_ITEM_MODULE:
{
FReq_FileName = modTmpFName;
+
+ // FReq_ModCurPathU is always set at this point
+
FReq_CurPathU = FReq_ModCurPathU;
+ if (FReq_CurPathU != NULL)
+ UNICHAR_CHDIR(FReq_CurPathU);
}
break;
@@ -2119,6 +2125,8 @@
}
FReq_CurPathU = FReq_InsCurPathU;
+ if (FReq_CurPathU != NULL)
+ UNICHAR_CHDIR(FReq_CurPathU);
}
break;
@@ -2133,6 +2141,8 @@
}
FReq_CurPathU = FReq_SmpCurPathU;
+ if (FReq_CurPathU != NULL)
+ UNICHAR_CHDIR(FReq_CurPathU);
}
break;
@@ -2142,11 +2152,13 @@
if (!patPathSet)
{
- UNICHAR_STRCPY(FReq_SmpCurPathU, FReq_CurPathU);
+ UNICHAR_STRCPY(FReq_PatCurPathU, FReq_CurPathU);
patPathSet = true;
}
FReq_CurPathU = FReq_PatCurPathU;
+ if (FReq_CurPathU != NULL)
+ UNICHAR_CHDIR(FReq_CurPathU);
}
break;
@@ -2161,6 +2173,8 @@
}
FReq_CurPathU = FReq_TrkCurPathU;
+ if (FReq_CurPathU != NULL)
+ UNICHAR_CHDIR(FReq_CurPathU);
}
break;
}
@@ -2176,7 +2190,7 @@
FReq_ShowAllFiles = false;
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
{
editor.diskOpReadDir = true;
@@ -2275,12 +2289,12 @@
firstTimeOpeningDiskOp = false;
}
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
- editor.ui.diskOpShown = true;
- editor.ui.scopesShown = false;
+ ui.diskOpShown = true;
+ ui.scopesShown = false;
showTopRightMainScreen();
drawDiskOpScreen();
@@ -2322,19 +2336,19 @@
hideRadioButtonGroup(RB_GROUP_DISKOP_PAT_SAVEAS);
hideRadioButtonGroup(RB_GROUP_DISKOP_TRK_SAVEAS);
- editor.ui.diskOpShown = false;
+ ui.diskOpShown = false;
}
void exitDiskOpScreen(void)
{
hideDiskOpScreen();
- editor.ui.oldTopLeftScreen = 0; // disk op. ignores previously opened top screens
+ ui.oldTopLeftScreen = 0; // disk op. ignores previously opened top screens
showTopScreen(true);
}
void toggleDiskOpScreen(void)
{
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
exitDiskOpScreen();
else
showDiskOpScreen();
--- a/src/ft2_edit.c
+++ b/src/ft2_edit.c
@@ -14,6 +14,7 @@
#include "ft2_sysreqs.h"
#include "ft2_textboxes.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
enum
{
@@ -70,7 +71,7 @@
uint16_t pattLen;
tonTyp *ton;
- if (editor.cursor.object == CURSOR_NOTE)
+ if (cursor.object == CURSOR_NOTE)
{
// the edit cursor is at the note slot
@@ -88,7 +89,7 @@
// convert key to slot data
- if (editor.cursor.object == CURSOR_VOL1)
+ if (cursor.object == CURSOR_VOL1)
{
// volume column effect type (mixed keys)
@@ -101,7 +102,7 @@
if (i == KEY2VOL_ENTRIES)
i = -1; // invalid key for slot
}
- else if (editor.cursor.object == CURSOR_EFX0)
+ else if (cursor.object == CURSOR_EFX0)
{
// effect type (mixed keys)
@@ -133,8 +134,8 @@
// insert slot data
- ton = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + editor.cursor.ch];
- switch (editor.cursor.object)
+ ton = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + cursor.ch];
+ switch (cursor.object)
{
case CURSOR_INST1:
{
@@ -234,7 +235,7 @@
if (i == 0) // if we inserted a zero, check if pattern is empty, for killing
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
return true;
}
@@ -352,7 +353,7 @@
}
else
{
- c = editor.cursor.ch;
+ c = cursor.ch;
}
for (i = 0; i < song.antChn; i++)
@@ -395,7 +396,7 @@
}
else
{
- c = editor.cursor.ch;
+ c = cursor.ch;
}
for (i = 0; i < song.antChn; i++)
@@ -454,7 +455,7 @@
}
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
}
@@ -525,7 +526,7 @@
}
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
}
@@ -547,7 +548,7 @@
if (patt[editor.editPattern] == NULL)
return true;
- note = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + editor.cursor.ch];
+ note = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + cursor.ch];
if (keyb.leftShiftPressed)
{
@@ -569,7 +570,7 @@
}
else
{
- if (editor.cursor.object == CURSOR_VOL1 || editor.cursor.object == CURSOR_VOL2)
+ if (cursor.object == CURSOR_VOL1 || cursor.object == CURSOR_VOL2)
{
// delete volume column
note->vol = 0;
@@ -589,7 +590,7 @@
if (playMode == PLAYMODE_EDIT && pattLen >= 1)
setPos(-1, (editor.pattPos + editor.ID_Add) % pattLen, true);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
return true;
@@ -615,12 +616,12 @@
if (patt[editor.editPattern] != NULL)
{
- note = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + editor.cursor.ch];
+ note = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + cursor.ch];
writeVol = note->vol;
writeEff = (note->effTyp << 8) | note->eff;
}
- if (editor.cursor.object == CURSOR_VOL1 || editor.cursor.object == CURSOR_VOL2)
+ if (cursor.object == CURSOR_VOL1 || cursor.object == CURSOR_VOL2)
config.volMacro[slot] = writeVol;
else
config.comMacro[slot] = writeEff;
@@ -639,9 +640,9 @@
return;
pattLen = pattLens[editor.editPattern];
- note = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + editor.cursor.ch];
+ note = &patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + cursor.ch];
- if (editor.cursor.object == CURSOR_VOL1 || editor.cursor.object == CURSOR_VOL2)
+ if (cursor.object == CURSOR_VOL1 || cursor.object == CURSOR_VOL2)
{
note->vol = (uint8_t)config.volMacro[slot];
}
@@ -666,7 +667,7 @@
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -691,14 +692,14 @@
if (pattLen > 1)
{
for (int32_t i = pattLen-2; i >= pattPos; i--)
- pattPtr[((i + 1) * MAX_VOICES) + editor.cursor.ch] = pattPtr[(i * MAX_VOICES) + editor.cursor.ch];
+ pattPtr[((i + 1) * MAX_VOICES) + cursor.ch] = pattPtr[(i * MAX_VOICES) + cursor.ch];
}
- memset(&pattPtr[(pattPos * MAX_VOICES) + editor.cursor.ch], 0, sizeof (tonTyp));
+ memset(&pattPtr[(pattPos * MAX_VOICES) + cursor.ch], 0, sizeof (tonTyp));
killPatternIfUnused(nr);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -734,7 +735,7 @@
killPatternIfUnused(nr);
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -760,9 +761,9 @@
editor.pattPos = song.pattPos = pattPos;
for (int32_t i = pattPos; i < pattLen-1; i++)
- pattPtr[(i * MAX_VOICES) + editor.cursor.ch] = pattPtr[((i + 1) * MAX_VOICES) + editor.cursor.ch];
+ pattPtr[(i * MAX_VOICES) + cursor.ch] = pattPtr[((i + 1) * MAX_VOICES) + cursor.ch];
- memset(&pattPtr[((pattLen - 1) * MAX_VOICES) + editor.cursor.ch], 0, sizeof (tonTyp));
+ memset(&pattPtr[((pattLen - 1) * MAX_VOICES) + cursor.ch], 0, sizeof (tonTyp));
}
}
else
@@ -776,7 +777,7 @@
killPatternIfUnused(nr);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -824,7 +825,7 @@
killPatternIfUnused(nr);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -845,7 +846,7 @@
if (pattPtr == NULL)
return; // empty pattern
- pattPtr += editor.cursor.ch;
+ pattPtr += cursor.ch;
pattLen = pattLens[editor.editPattern];
for (row = 0; row < pattLen; row++)
@@ -976,7 +977,7 @@
if (pattPtr == NULL)
return; // empty pattern
- pattPtr += editor.cursor.ch;
+ pattPtr += cursor.ch;
pattLen = pattLens[editor.editPattern];
for (row = 0; row < pattLen; row++)
@@ -1094,7 +1095,7 @@
default: break;
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1401,7 +1402,7 @@
{
memset(trackCopyBuff, 0, MAX_PATT_LEN * sizeof (tonTyp));
for (i = 0; i < pattLen; i++)
- copyNote(&pattPtr[(i * MAX_VOICES) + editor.cursor.ch], &trackCopyBuff[i]);
+ copyNote(&pattPtr[(i * MAX_VOICES) + cursor.ch], &trackCopyBuff[i]);
trkBufLen = pattLen;
}
@@ -1408,12 +1409,12 @@
pauseMusic();
for (i = 0; i < pattLen; i++)
- pasteNote(&clearNote, &pattPtr[(i * MAX_VOICES) + editor.cursor.ch]);
+ pasteNote(&clearNote, &pattPtr[(i * MAX_VOICES) + cursor.ch]);
resumeMusic();
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1430,7 +1431,7 @@
memset(trackCopyBuff, 0, MAX_PATT_LEN * sizeof (tonTyp));
for (i = 0; i < pattLen; i++)
- copyNote(&pattPtr[(i * MAX_VOICES) + editor.cursor.ch], &trackCopyBuff[i]);
+ copyNote(&pattPtr[(i * MAX_VOICES) + cursor.ch], &trackCopyBuff[i]);
trkBufLen = pattLen;
}
@@ -1448,12 +1449,12 @@
pauseMusic();
for (i = 0; i < pattLen; i++)
- pasteNote(&trackCopyBuff[i], &pattPtr[(i * MAX_VOICES) + editor.cursor.ch]);
+ pasteNote(&trackCopyBuff[i], &pattPtr[(i * MAX_VOICES) + cursor.ch]);
resumeMusic();
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1490,7 +1491,7 @@
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1514,7 +1515,7 @@
ptnBufLen = pattLen;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
void pastePattern(void)
@@ -1547,7 +1548,7 @@
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1590,7 +1591,7 @@
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1631,7 +1632,7 @@
pattLen = pattLens[editor.editPattern];
- xpos = editor.cursor.ch;
+ xpos = cursor.ch;
ypos = editor.pattPos;
j = markXSize;
@@ -1657,7 +1658,7 @@
killPatternIfUnused(editor.editPattern);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1702,7 +1703,7 @@
editor.srcInstr, editor.curInstr);
resumeMusic();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1713,12 +1714,12 @@
pauseMusic();
remapInstrXY(editor.editPattern,
- editor.cursor.ch, 0,
- editor.cursor.ch, pattLens[editor.editPattern] - 1,
+ cursor.ch, 0,
+ cursor.ch, pattLens[editor.editPattern] - 1,
editor.srcInstr, editor.curInstr);
resumeMusic();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1734,7 +1735,7 @@
editor.srcInstr, editor.curInstr);
resumeMusic();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1757,7 +1758,7 @@
}
resumeMusic();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
@@ -1882,7 +1883,7 @@
pauseMusic();
for (uint16_t row = 0; row < pattLen; row++)
{
- scaleNote(editor.editPattern, editor.cursor.ch, row, dVol);
+ scaleNote(editor.editPattern, cursor.ch, row, dVol);
dVol += dIPy;
}
resumeMusic();
--- a/src/ft2_events.c
+++ b/src/ft2_events.c
@@ -31,10 +31,11 @@
#include "ft2_keyboard.h"
#include "ft2_sample_ed.h"
#include "ft2_sample_ed_features.h"
+#include "ft2_structs.h"
#define CRASH_TEXT "Oh no!\nThe Fasttracker II clone has crashed...\n\nA backup .xm was hopefully " \
- "saved to the current module directory.\n\nPlease report this to 8bitbubsy " \
- "(IRC or olav.sorensen@live.no).\nTry to mention what you did before the crash happened."
+ "saved to the current module directory.\n\nPlease report this bug if you can.\n" \
+ "Try to mention what you did before the crash happened."
static bool backupMadeAfterCrash;
@@ -112,7 +113,7 @@
midi.rescanDevicesFlag = false;
rescanMidiInputDevices();
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MIDI_INPUT)
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MIDI_INPUT)
drawMidiInputList();
}
#endif
@@ -158,7 +159,7 @@
if (editor.diskOpReadDone)
{
editor.diskOpReadDone = false;
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
diskOp_DrawDirectory();
}
@@ -165,8 +166,8 @@
handleLoadMusicEvents();
if (editor.samplingAudioFlag) handleSamplingUpdates();
- if (editor.ui.setMouseBusy) mouseAnimOn();
- if (editor.ui.setMouseIdle) mouseAnimOff();
+ if (ui.setMouseBusy) mouseAnimOn();
+ if (ui.setMouseIdle) mouseAnimOff();
if (editor.updateWindowTitle)
{
@@ -495,7 +496,7 @@
}
else if (event.type == SDL_QUIT)
{
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
continue;
if (editor.editTextFlag)
--- a/src/ft2_gui.c
+++ b/src/ft2_gui.c
@@ -22,6 +22,7 @@
#include "ft2_video.h"
#include "ft2_tables.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
static void releaseMouseStates(void)
{
@@ -35,9 +36,9 @@
mouse.buttonCounter = 0;
mouse.lastX = 0;
mouse.lastY = 0;
- editor.ui.sampleDataOrLoopDrag = -1;
- editor.ui.leftLoopPinMoving = false;
- editor.ui.rightLoopPinMoving = false;
+ ui.sampleDataOrLoopDrag = -1;
+ ui.leftLoopPinMoving = false;
+ ui.rightLoopPinMoving = false;
}
void unstuckLastUsedGUIElement(void)
@@ -53,16 +54,16 @@
** sample data loop pins, and unstuck them if so
*/
- if (editor.ui.leftLoopPinMoving)
+ if (ui.leftLoopPinMoving)
{
setLeftLoopPinState(false);
- editor.ui.leftLoopPinMoving = false;
+ ui.leftLoopPinMoving = false;
}
- if (editor.ui.rightLoopPinMoving)
+ if (ui.rightLoopPinMoving)
{
setRightLoopPinState(false);
- editor.ui.rightLoopPinMoving = false;
+ ui.rightLoopPinMoving = false;
}
releaseMouseStates();
@@ -1052,36 +1053,36 @@
void showTopLeftMainScreen(bool restoreScreens)
{
- editor.ui.diskOpShown = false;
- editor.ui.sampleEditorExtShown = false;
- editor.ui.instEditorExtShown = false;
- editor.ui.transposeShown = false;
- editor.ui.advEditShown = false;
- editor.ui.wavRendererShown = false;
- editor.ui.trimScreenShown = false;
+ ui.diskOpShown = false;
+ ui.sampleEditorExtShown = false;
+ ui.instEditorExtShown = false;
+ ui.transposeShown = false;
+ ui.advEditShown = false;
+ ui.wavRendererShown = false;
+ ui.trimScreenShown = false;
- editor.ui.scopesShown = true;
+ ui.scopesShown = true;
if (restoreScreens)
{
- switch (editor.ui.oldTopLeftScreen)
+ switch (ui.oldTopLeftScreen)
{
default: break;
- case 1: editor.ui.diskOpShown = true; break;
- case 2: editor.ui.sampleEditorExtShown = true; break;
- case 3: editor.ui.instEditorExtShown = true; break;
- case 4: editor.ui.transposeShown = true; break;
- case 5: editor.ui.advEditShown = true; break;
- case 6: editor.ui.wavRendererShown = true; break;
- case 7: editor.ui.trimScreenShown = true; break;
+ case 1: ui.diskOpShown = true; break;
+ case 2: ui.sampleEditorExtShown = true; break;
+ case 3: ui.instEditorExtShown = true; break;
+ case 4: ui.transposeShown = true; break;
+ case 5: ui.advEditShown = true; break;
+ case 6: ui.wavRendererShown = true; break;
+ case 7: ui.trimScreenShown = true; break;
}
- if (editor.ui.oldTopLeftScreen > 0)
- editor.ui.scopesShown = false;
+ if (ui.oldTopLeftScreen > 0)
+ ui.scopesShown = false;
}
- editor.ui.oldTopLeftScreen = 0;
+ ui.oldTopLeftScreen = 0;
- if (editor.ui.diskOpShown)
+ if (ui.diskOpShown)
{
showDiskOpScreen();
}
@@ -1157,7 +1158,7 @@
textOutShadow(4, 80, PAL_FORGRND, PAL_DSKTOP2, "Global volume");
drawGlobalVol(song.globVol);
- editor.ui.updatePosSections = true;
+ ui.updatePosSections = true;
textOutShadow(204, 80, PAL_FORGRND, PAL_DSKTOP2, "Time");
charOutShadow(250, 80, PAL_FORGRND, PAL_DSKTOP2, ':');
@@ -1165,14 +1166,14 @@
drawPlaybackTime();
- if (editor.ui.sampleEditorExtShown) drawSampleEditorExt();
- else if (editor.ui.instEditorExtShown) drawInstEditorExt();
- else if (editor.ui.transposeShown) drawTranspose();
- else if (editor.ui.advEditShown) drawAdvEdit();
- else if (editor.ui.wavRendererShown) drawWavRenderer();
- else if (editor.ui.trimScreenShown) drawTrimScreen();
+ if (ui.sampleEditorExtShown) drawSampleEditorExt();
+ else if (ui.instEditorExtShown) drawInstEditorExt();
+ else if (ui.transposeShown) drawTranspose();
+ else if (ui.advEditShown) drawAdvEdit();
+ else if (ui.wavRendererShown) drawWavRenderer();
+ else if (ui.trimScreenShown) drawTrimScreen();
- if (editor.ui.scopesShown)
+ if (ui.scopesShown)
drawScopeFramework();
}
}
@@ -1187,7 +1188,7 @@
hideWavRenderer();
hideTrimScreen();
- editor.ui.scopesShown = false;
+ ui.scopesShown = false;
// position editor
hideScrollBar(SB_POS_ED);
@@ -1251,7 +1252,7 @@
showPushButton(PB_HELP);
// instrument switcher
- editor.ui.instrSwitcherShown = true;
+ ui.instrSwitcherShown = true;
showInstrumentSwitcher();
// song name
@@ -1275,7 +1276,7 @@
// instrument switcher
hideInstrumentSwitcher();
- editor.ui.instrSwitcherShown = false;
+ ui.instrSwitcherShown = false;
hideTextBox(TB_SONG_NAME);
}
@@ -1284,13 +1285,13 @@
void setOldTopLeftScreenFlag(void)
{
- if (editor.ui.diskOpShown) editor.ui.oldTopLeftScreen = 1;
- else if (editor.ui.sampleEditorExtShown) editor.ui.oldTopLeftScreen = 2;
- else if (editor.ui.instEditorExtShown) editor.ui.oldTopLeftScreen = 3;
- else if (editor.ui.transposeShown) editor.ui.oldTopLeftScreen = 4;
- else if (editor.ui.advEditShown) editor.ui.oldTopLeftScreen = 5;
- else if (editor.ui.wavRendererShown) editor.ui.oldTopLeftScreen = 6;
- else if (editor.ui.trimScreenShown) editor.ui.oldTopLeftScreen = 7;
+ if (ui.diskOpShown) ui.oldTopLeftScreen = 1;
+ else if (ui.sampleEditorExtShown) ui.oldTopLeftScreen = 2;
+ else if (ui.instEditorExtShown) ui.oldTopLeftScreen = 3;
+ else if (ui.transposeShown) ui.oldTopLeftScreen = 4;
+ else if (ui.advEditShown) ui.oldTopLeftScreen = 5;
+ else if (ui.wavRendererShown) ui.oldTopLeftScreen = 6;
+ else if (ui.trimScreenShown) ui.oldTopLeftScreen = 7;
}
void hideTopLeftScreen(void)
@@ -1315,33 +1316,33 @@
hideAboutScreen();
hideHelpScreen();
- editor.ui.instrSwitcherShown = false;
- editor.ui.scopesShown = false;
+ ui.instrSwitcherShown = false;
+ ui.scopesShown = false;
}
void showTopScreen(bool restoreScreens)
{
- editor.ui.scopesShown = false;
+ ui.scopesShown = false;
- if (editor.ui.aboutScreenShown)
+ if (ui.aboutScreenShown)
{
showAboutScreen();
}
- else if (editor.ui.configScreenShown)
+ else if (ui.configScreenShown)
{
showConfigScreen();
}
- else if (editor.ui.helpScreenShown)
+ else if (ui.helpScreenShown)
{
showHelpScreen();
}
- else if (editor.ui.nibblesShown)
+ else if (ui.nibblesShown)
{
showNibblesScreen();
}
else
{
- showTopLeftMainScreen(restoreScreens); // updates editor.ui.scopesShown
+ showTopLeftMainScreen(restoreScreens); // updates ui.scopesShown
showTopRightMainScreen();
}
}
@@ -1348,11 +1349,11 @@
void showBottomScreen(void)
{
- if (editor.ui.extended || editor.ui.patternEditorShown)
+ if (ui.extended || ui.patternEditorShown)
showPatternEditor();
- else if (editor.ui.instEditorShown)
+ else if (ui.instEditorShown)
showInstEditor();
- else if (editor.ui.sampleEditorShown)
+ else if (ui.sampleEditorShown)
showSampleEditor();
}
@@ -1363,5 +1364,5 @@
showTopScreen(false); // false = don't restore screens
showPatternEditor();
- editor.ui.updatePosSections = true;
+ ui.updatePosSections = true;
}
--- a/src/ft2_header.h
+++ b/src/ft2_header.h
@@ -12,7 +12,7 @@
#endif
#include "ft2_replayer.h"
-#define PROG_VER_STR "1.22"
+#define PROG_VER_STR "1.23"
// do NOT change these! It will only mess things up...
@@ -75,75 +75,3 @@
(((uint32_t)((value) & 0x00FF0000)) >> 8) | \
(((uint32_t)((value) & 0xFF000000)) >> 24) \
)
-
-struct cpu_t
-{
- bool hasSSE, hasSSE2;
-} cpu;
-
-struct editor_t
-{
- struct ui_t
- {
- volatile bool setMouseBusy, setMouseIdle;
- bool sysReqEnterPressed;
- char fullscreenButtonText[24];
-
- // all screens
- bool extended, sysReqShown;
-
- // top screens
- bool instrSwitcherShown, aboutScreenShown, helpScreenShown, configScreenShown;
- bool scopesShown, diskOpShown, nibblesShown, transposeShown, instEditorExtShown;
- bool sampleEditorExtShown, advEditShown, wavRendererShown, trimScreenShown;
- bool drawBPMFlag, drawSpeedFlag, drawGlobVolFlag, drawPosEdFlag, drawPattNumLenFlag;
- bool updatePosSections, updatePosEdScrollBar;
- uint8_t oldTopLeftScreen;
-
- // bottom screens
- bool patternEditorShown, instEditorShown, sampleEditorShown, pattChanScrollShown;
- bool leftLoopPinMoving, rightLoopPinMoving;
- bool drawReplayerPianoFlag, drawPianoFlag, updatePatternEditor;
- uint8_t channelOffset, numChannelsShown, maxVisibleChannels;
- uint16_t patternChannelWidth;
- int32_t sampleDataOrLoopDrag;
-
- // backup flag for when entering/exiting extended pattern editor (TODO: this is lame and shouldn't be hardcoded)
- bool _aboutScreenShown, _helpScreenShown, _configScreenShown, _diskOpShown;
- bool _nibblesShown, _transposeShown, _instEditorShown;
- bool _instEditorExtShown, _sampleEditorExtShown, _patternEditorShown;
- bool _sampleEditorShown, _advEditShown, _wavRendererShown, _trimScreenShown;
- // -------------------------------------------------------------------------
- } ui;
-
- struct cursor_t
- {
- uint8_t ch;
- int8_t object;
- } cursor;
-
- UNICHAR binaryPathU[PATH_MAX + 2];
- UNICHAR *tmpFilenameU, *tmpInstrFilenameU; // used by saving/loading threads
- UNICHAR *configFileLocation, *audioDevConfigFileLocation, *midiConfigFileLocation;
-
- volatile bool mainLoopOngoing;
- volatile bool busy, scopeThreadMutex, programRunning, wavIsRendering, wavReachedEndFlag;
- volatile bool updateCurSmp, updateCurInstr, diskOpReadDir, diskOpReadDone, updateWindowTitle;
- volatile uint8_t loadMusicEvent;
- volatile FILE *wavRendererFileHandle;
-
- bool autoPlayOnDrop, trimThreadWasDone, throwExit, editTextFlag;
- bool copyMaskEnable, diskOpReadOnOpen, samplingAudioFlag, editSampleFlag;
- bool instrBankSwapped, chnMode[MAX_VOICES], NI_Play;
-
- uint8_t curPlayInstr, curPlaySmp, curSmpChannel, currPanEnvPoint, currVolEnvPoint;
- uint8_t copyMask[5], pasteMask[5], transpMask[5], smpEd_NoteNr, instrBankOffset, sampleBankOffset;
- uint8_t srcInstr, curInstr, srcSmp, curSmp, currHelpScreen, currConfigScreen, textCursorBlinkCounter;
- uint8_t keyOnTab[MAX_VOICES], ID_Add, curOctave;
- uint8_t sampleSaveMode, moduleSaveMode, ptnJumpPos[4];
- int16_t globalVol, songPos, pattPos;
- uint16_t tmpPattern, editPattern, speed, tempo, timer, ptnCursorY;
- int32_t keyOffNr, keyOffTime[MAX_VOICES];
- uint32_t framesPassed, wavRendererTime;
- double dPerfFreq, dPerfFreqMulMicro, dPerfFreqMulMs;
-} editor;
--- a/src/ft2_help.c
+++ b/src/ft2_help.c
@@ -11,6 +11,7 @@
#include "ft2_video.h"
#include "ft2_pattern_ed.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
#include "helpdata/ft2_help_data.h"
typedef struct
@@ -386,11 +387,11 @@
{
uint16_t tmpID;
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
- editor.ui.helpScreenShown = true;
+ ui.helpScreenShown = true;
drawFramework(0, 0, 128, 173, FRAMEWORK_TYPE1);
drawFramework(128, 0, 504, 173, FRAMEWORK_TYPE1);
@@ -437,7 +438,7 @@
hideRadioButtonGroup(RB_GROUP_HELP);
hideScrollBar(SB_HELP_SCROLL);
- editor.ui.helpScreenShown = false;
+ ui.helpScreenShown = false;
}
void exitHelpScreen(void)
--- a/src/ft2_inst_ed.c
+++ b/src/ft2_inst_ed.c
@@ -21,6 +21,7 @@
#include "ft2_module_loader.h"
#include "ft2_tables.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
#ifdef _MSC_VER
#pragma pack(push)
@@ -339,15 +340,15 @@
void updateNewSample(void)
{
- if (editor.ui.instrSwitcherShown)
+ if (ui.instrSwitcherShown)
updateInstrumentSwitcher();
updateSampleEditorSample();
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
updateSampleEditor();
- if (editor.ui.instEditorShown || editor.ui.instEditorExtShown)
+ if (ui.instEditorShown || ui.instEditorExtShown)
updateInstEditor();
}
@@ -355,7 +356,7 @@
{
updateTextBoxPointers();
- if (editor.ui.instrSwitcherShown)
+ if (ui.instrSwitcherShown)
updateInstrumentSwitcher();
editor.currVolEnvPoint = 0;
@@ -363,13 +364,13 @@
updateSampleEditorSample();
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
updateSampleEditor();
- if (editor.ui.instEditorShown || editor.ui.instEditorExtShown)
+ if (ui.instEditorShown || ui.instEditorExtShown)
updateInstEditor();
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
updateAdvEdit();
}
@@ -1604,7 +1605,7 @@
uint8_t key, note, octave;
int32_t mx, my, quotient, remainder;
- if (!editor.ui.instEditorShown)
+ if (!ui.instEditorShown)
return false; // area not clicked
if (editor.curInstr == 0 || instr[editor.curInstr] == NULL)
@@ -2024,7 +2025,7 @@
void hideInstEditor(void)
{
- editor.ui.instEditorShown = false;
+ ui.instEditorShown = false;
hideScrollBar(SB_INST_VOL);
hideScrollBar(SB_INST_PAN);
@@ -2110,7 +2111,7 @@
s = &ins->samp[editor.curSmp];
// update instrument editor extension
- if (editor.ui.instEditorExtShown)
+ if (ui.instEditorExtShown)
{
checkBoxes[CB_INST_EXT_MIDI].checked = ins->midiOn ? true : false;
checkBoxes[CB_INST_EXT_MUTE].checked = ins->mute ? true : false;
@@ -2127,7 +2128,7 @@
drawMIDIBend();
}
- if (!editor.ui.instEditorShown)
+ if (!ui.instEditorShown)
return;
drawVolEnvSus();
@@ -2197,12 +2198,12 @@
void showInstEditor(void)
{
- if (editor.ui.extended) exitPatternEditorExtended();
- if (editor.ui.sampleEditorShown) hideSampleEditor();
- if (editor.ui.sampleEditorExtShown) hideSampleEditorExt();
+ if (ui.extended) exitPatternEditorExtended();
+ if (ui.sampleEditorShown) hideSampleEditor();
+ if (ui.sampleEditorExtShown) hideSampleEditorExt();
hidePatternEditor();
- editor.ui.instEditorShown = true;
+ ui.instEditorShown = true;
drawFramework(0, 173, 438, 87, FRAMEWORK_TYPE1);
drawFramework(0, 260, 438, 87, FRAMEWORK_TYPE1);
@@ -2315,10 +2316,10 @@
void toggleInstEditor(void)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
hideSampleEditor();
- if (editor.ui.instEditorShown)
+ if (ui.instEditorShown)
{
exitInstEditor();
}
@@ -2335,7 +2336,7 @@
int32_t x, y, mx, my, minX, maxX;
instrTyp *ins;
- if (!editor.ui.instEditorShown || editor.curInstr == 0 || instr[editor.curInstr] == NULL)
+ if (!ui.instEditorShown || editor.curInstr == 0 || instr[editor.curInstr] == NULL)
return false;
ins = instr[editor.curInstr];
@@ -2434,7 +2435,7 @@
int32_t x, y, mx, my, minX, maxX;
instrTyp *ins;
- if (!editor.ui.instEditorShown || editor.curInstr == 0 || instr[editor.curInstr] == NULL)
+ if (!ui.instEditorShown || editor.curInstr == 0 || instr[editor.curInstr] == NULL)
return false;
ins = instr[editor.curInstr];
@@ -2606,14 +2607,14 @@
void showInstEditorExt(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
showTopScreen(false);
- editor.ui.instEditorExtShown = true;
- editor.ui.scopesShown = false;
+ ui.instEditorExtShown = true;
+ ui.scopesShown = false;
drawInstEditorExt();
}
@@ -2631,14 +2632,14 @@
hidePushButton(PB_INST_EXT_MIDI_BEND_DOWN);
hidePushButton(PB_INST_EXT_MIDI_BEND_UP);
- editor.ui.instEditorExtShown = false;
- editor.ui.scopesShown = true;
+ ui.instEditorExtShown = false;
+ ui.scopesShown = true;
drawScopeFramework();
}
void toggleInstEditorExt(void)
{
- if (editor.ui.instEditorExtShown)
+ if (ui.instEditorExtShown)
hideInstEditorExt();
else
showInstEditorExt();
@@ -2686,7 +2687,7 @@
editor.srcInstr = newEntry;
updateInstrumentSwitcher();
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
updateAdvEdit();
}
@@ -2711,8 +2712,8 @@
updateInstrumentSwitcher();
updateSampleEditorSample();
- if (editor.ui.sampleEditorShown) updateSampleEditor();
- else if (editor.ui.instEditorShown) updateInstEditor();
+ if (ui.sampleEditorShown) updateSampleEditor();
+ else if (ui.instEditorShown) updateInstEditor();
}
return true;
@@ -2763,7 +2764,7 @@
editor.srcInstr = newEntry;
updateInstrumentSwitcher();
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
updateAdvEdit();
}
@@ -2805,7 +2806,7 @@
editor.srcInstr = newEntry;
updateInstrumentSwitcher();
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
updateAdvEdit();
}
@@ -2836,10 +2837,10 @@
bool testInstrSwitcherMouseDown(void)
{
- if (!editor.ui.instrSwitcherShown)
+ if (!ui.instrSwitcherShown)
return false;
- if (editor.ui.extended)
+ if (ui.extended)
return testInstrSwitcherExtended();
else
return testInstrSwitcherNormal();
--- a/src/ft2_keyboard.c
+++ b/src/ft2_keyboard.c
@@ -22,9 +22,9 @@
#include "ft2_audio.h"
#include "ft2_trim.h"
#include "ft2_sample_ed_features.h"
+#include "ft2_structs.h"
-static void handleKeys(SDL_Keycode keycode, SDL_Scancode scanKey);
-static bool checkModifiedKeys(SDL_Keycode keycode);
+keyb_t keyb; // globalized
static const uint8_t scancodeKey2Note[52] = // keys (USB usage page standard) to FT2 notes look-up table
{
@@ -37,6 +37,9 @@
0x00, 0x0D, 0x0F, 0x11
};
+static void handleKeys(SDL_Keycode keycode, SDL_Scancode scanKey);
+static bool checkModifiedKeys(SDL_Keycode keycode);
+
int8_t scancodeKeyToNote(SDL_Scancode scancode)
{
int8_t note;
@@ -76,11 +79,12 @@
{
(void)keycode;
- if (editor.editTextFlag || editor.ui.sysReqShown)
+ if (editor.editTextFlag || ui.sysReqShown)
return; // kludge: don't handle key up! (XXX: Is this hack really needed anymore?)
/* Yet another kludge for not leaving a ghost key-up event after an inputBox/okBox
- ** was exited with a key press. They could be picked up as note release events. */
+ ** was exited with a key press. They could be picked up as note release events.
+ */
if (keyb.ignoreCurrKeyUp)
{
keyb.ignoreCurrKeyUp = false;
@@ -87,7 +91,7 @@
return;
}
- if (editor.cursor.object == CURSOR_NOTE && !keyb.keyModifierDown)
+ if (cursor.object == CURSOR_NOTE && !keyb.keyModifierDown)
testNoteKeysRelease(scancode);
if (scancode == SDL_SCANCODE_KP_PLUS)
@@ -105,12 +109,12 @@
if (mouse.mode != MOUSE_MODE_NORMAL)
setMouseMode(MOUSE_MODE_NORMAL);
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
{
if (keycode == SDLK_RETURN)
- editor.ui.sysReqEnterPressed = true;
+ ui.sysReqEnterPressed = true;
else if (keycode == SDLK_ESCAPE)
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return;
}
@@ -161,7 +165,6 @@
static void handleKeys(SDL_Keycode keycode, SDL_Scancode scanKey)
{
- bool audioWasntLocked;
uint16_t pattLen;
// if we're holding numpad plus but not pressing bank keys, don't check any other key
@@ -308,9 +311,9 @@
editor.ID_Add++;
}
- if (!editor.ui.nibblesShown && !editor.ui.configScreenShown &&
- !editor.ui.aboutScreenShown && !editor.ui.diskOpShown &&
- !editor.ui.helpScreenShown && !editor.ui.extended)
+ if (!ui.nibblesShown && !ui.configScreenShown &&
+ !ui.aboutScreenShown && !ui.diskOpShown &&
+ !ui.helpScreenShown && !ui.extended)
{
drawIDAdd();
}
@@ -320,7 +323,7 @@
default: break;
}
- // no normal key (keycode) pressed (XXX: shouldn't happen? Whatever...)
+ // no normal key (keycode) pressed (XXX: shouldn't happen..?)
if (keycode == SDLK_UNKNOWN)
return;
@@ -331,7 +334,7 @@
case SDLK_DELETE: // non-FT2 addition
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
sampCut();
}
break;
@@ -345,18 +348,19 @@
if (!allocatePattern(editor.editPattern))
break;
- patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + editor.cursor.ch].ton = 97;
+ patt[editor.editPattern][(editor.pattPos * MAX_VOICES) + cursor.ch].ton = 97;
pattLen = pattLens[editor.editPattern];
if (playMode == PLAYMODE_EDIT && pattLen >= 1)
setPos(-1, (editor.pattPos + editor.ID_Add) % pattLen, true);
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
setSongModifiedFlag();
}
}
break;
+ // This is maybe not ideal to implement...
//case SDLK_PRINTSCREEN: togglePatternEditorExtended(); break;
// EDIT/PLAY KEYS
@@ -382,7 +386,7 @@
lockMixerCallback();
memset(editor.keyOnTab, 0, sizeof (editor.keyOnTab));
playMode = PLAYMODE_EDIT;
- editor.ui.updatePosSections = true; // for updating mode text
+ ui.updatePosSections = true; // for updating mode text
unlockMixerCallback();
}
else
@@ -482,7 +486,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
unlockAudio();
@@ -500,7 +504,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
unlockAudio();
@@ -518,7 +522,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
unlockAudio();
@@ -536,7 +540,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
unlockAudio();
@@ -556,7 +560,7 @@
case SDLK_BACKSPACE:
{
- if (editor.ui.diskOpShown) diskOpGoParent();
+ if (ui.diskOpShown) diskOpGoParent();
else if (keyb.leftShiftPressed) deletePatternLine();
else deletePatternNote();
}
@@ -597,7 +601,7 @@
case SDLK_PAGEUP:
{
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -609,7 +613,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -619,7 +623,7 @@
case SDLK_PAGEDOWN:
{
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -631,7 +635,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -641,7 +645,7 @@
case SDLK_HOME:
{
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -649,7 +653,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -659,7 +663,7 @@
case SDLK_END:
{
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -667,7 +671,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -753,7 +757,7 @@
case SDLK_a:
if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
rangeAll();
else
showAdvEdit();
@@ -762,7 +766,7 @@
}
else if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
rangeAll();
else
jumpToChannel(8);
@@ -774,7 +778,7 @@
case SDLK_b:
if (keyb.leftCtrlPressed)
{
- if (!editor.ui.aboutScreenShown)
+ if (!ui.aboutScreenShown)
showAboutScreen();
return true;
@@ -784,7 +788,7 @@
case SDLK_c:
if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
{
sampCopy();
}
@@ -791,12 +795,12 @@
else
{
// mark current track (non-FT2 feature)
- pattMark.markX1 = editor.cursor.ch;
+ pattMark.markX1 = cursor.ch;
pattMark.markX2 = pattMark.markX1;
pattMark.markY1 = 0;
pattMark.markY2 = pattLens[editor.editPattern];
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
return true;
@@ -803,7 +807,7 @@
}
else if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
sampCopy();
else
showConfigScreen();
@@ -820,7 +824,7 @@
}
else if (keyb.leftCtrlPressed)
{
- if (!editor.ui.diskOpShown)
+ if (!ui.diskOpShown)
showDiskOpScreen();
return true;
@@ -835,10 +839,10 @@
}
else if (keyb.leftCtrlPressed)
{
- if (editor.ui.aboutScreenShown) hideAboutScreen();
- if (editor.ui.configScreenShown) hideConfigScreen();
- if (editor.ui.helpScreenShown) hideHelpScreen();
- if (editor.ui.nibblesShown) hideNibblesScreen();
+ if (ui.aboutScreenShown) hideAboutScreen();
+ if (ui.configScreenShown) hideConfigScreen();
+ if (ui.helpScreenShown) hideHelpScreen();
+ if (ui.nibblesShown) hideNibblesScreen();
showSampleEditorExt();
return true;
@@ -860,7 +864,7 @@
video.showFPSCounter ^= 1;
if (!video.showFPSCounter)
{
- if (editor.ui.extended) // yet another kludge...
+ if (ui.extended) // yet another kludge...
exitPatternEditorExtended();
showTopScreen(false);
@@ -926,10 +930,10 @@
case SDLK_m:
if (keyb.leftCtrlPressed)
{
- if (editor.ui.aboutScreenShown) hideAboutScreen();
- if (editor.ui.configScreenShown) hideConfigScreen();
- if (editor.ui.helpScreenShown) hideHelpScreen();
- if (editor.ui.nibblesShown) hideNibblesScreen();
+ if (ui.aboutScreenShown) hideAboutScreen();
+ if (ui.configScreenShown) hideConfigScreen();
+ if (ui.helpScreenShown) hideHelpScreen();
+ if (ui.nibblesShown) hideNibblesScreen();
showInstEditorExt();
@@ -948,11 +952,11 @@
case SDLK_p:
if (keyb.leftCtrlPressed)
{
- if (!editor.ui.patternEditorShown)
+ if (!ui.patternEditorShown)
{
- if (editor.ui.sampleEditorShown) hideSampleEditor();
- if (editor.ui.sampleEditorExtShown) hideSampleEditorExt();
- if (editor.ui.instEditorShown) hideInstEditor();
+ if (ui.sampleEditorShown) hideSampleEditor();
+ if (ui.sampleEditorExtShown) hideSampleEditorExt();
+ if (ui.instEditorShown) hideInstEditor();
showPatternEditor();
}
@@ -972,7 +976,7 @@
case SDLK_r:
if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
sampCrop();
else
jumpToChannel(3);
@@ -989,7 +993,7 @@
case SDLK_s:
if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
showRange();
else
jumpToChannel(9);
@@ -1027,9 +1031,9 @@
case SDLK_v:
if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
sampPaste();
- else if (!editor.ui.instEditorShown)
+ else if (!ui.instEditorShown)
scaleFadeVolumeBlock();
return true;
@@ -1036,9 +1040,9 @@
}
else if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
sampPaste();
- else if (!editor.ui.instEditorShown)
+ else if (!ui.instEditorShown)
scaleFadeVolumePattern();
return true;
@@ -1045,7 +1049,7 @@
}
else if (keyb.leftShiftPressed)
{
- if (!editor.ui.sampleEditorShown && !editor.ui.instEditorShown)
+ if (!ui.sampleEditorShown && !ui.instEditorShown)
{
keyb.ignoreTextEditKey = true; // ignore key from first frame
scaleFadeVolumeTrack();
@@ -1066,7 +1070,7 @@
case SDLK_x:
if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
sampCut();
return true;
@@ -1073,22 +1077,22 @@
}
else if (keyb.leftCtrlPressed || keyb.leftCommandPressed)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
- if (editor.ui.sampleEditorShown) hideSampleEditor();
- if (editor.ui.sampleEditorExtShown) hideSampleEditorExt();
- if (editor.ui.instEditorShown) hideInstEditor();
- if (editor.ui.instEditorExtShown) hideInstEditorExt();
- if (editor.ui.transposeShown) hideTranspose();
- if (editor.ui.aboutScreenShown) hideAboutScreen();
- if (editor.ui.configScreenShown) hideConfigScreen();
- if (editor.ui.helpScreenShown) hideHelpScreen();
- if (editor.ui.nibblesShown) hideNibblesScreen();
- if (editor.ui.diskOpShown) hideDiskOpScreen();
- if (editor.ui.advEditShown) hideAdvEdit();
- if (editor.ui.wavRendererShown) hideWavRenderer();
- if (editor.ui.trimScreenShown) hideTrimScreen();
+ if (ui.sampleEditorShown) hideSampleEditor();
+ if (ui.sampleEditorExtShown) hideSampleEditorExt();
+ if (ui.instEditorShown) hideInstEditor();
+ if (ui.instEditorExtShown) hideInstEditorExt();
+ if (ui.transposeShown) hideTranspose();
+ if (ui.aboutScreenShown) hideAboutScreen();
+ if (ui.configScreenShown) hideConfigScreen();
+ if (ui.helpScreenShown) hideHelpScreen();
+ if (ui.nibblesShown) hideNibblesScreen();
+ if (ui.diskOpShown) hideDiskOpScreen();
+ if (ui.advEditShown) hideAdvEdit();
+ if (ui.wavRendererShown) hideWavRenderer();
+ if (ui.trimScreenShown) hideTrimScreen();
showTopScreen(false);
showBottomScreen();
@@ -1110,7 +1114,7 @@
case SDLK_z:
if (keyb.leftAltPressed)
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
zoomOut();
return true;
--- a/src/ft2_keyboard.h
+++ b/src/ft2_keyboard.h
@@ -4,13 +4,15 @@
#include <stdbool.h>
#include <SDL2/SDL.h>
-struct keyb_t
+typedef struct keyb_t
{
uint8_t keyRepeat, keyPressed;
bool ignoreCurrKeyUp, ignoreTextEditKey, numPadPlusPressed;
bool keyModifierDown, commandPressed, leftCommandPressed;
bool leftShiftPressed, leftCtrlPressed, ctrlPressed, leftAltPressed;
-} keyb;
+} keyb_t;
+
+extern keyb_t keyb; // ft2_keyboard.c
int8_t scancodeKeyToNote(SDL_Scancode scancode);
void keyUpHandler(SDL_Scancode scancode, SDL_Keycode keycode);
--- a/src/ft2_main.c
+++ b/src/ft2_main.c
@@ -32,6 +32,7 @@
#include "ft2_midi.h"
#include "ft2_events.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
#ifdef HAS_MIDI
static SDL_Thread *initMidiThread;
@@ -77,8 +78,7 @@
#ifdef _WIN32
showErrorMsgBox("SDL2.dll is not the expected version, the program will terminate.\n\n" \
"Loaded dll version: %d.%d.%d\n" \
- "Required (compiled with) version: %d.%d.%d\n\n" \
- "The needed SDL2.dll is located in the .zip from 16-bits.org/ft2.php\n",
+ "Required (compiled with) version: %d.%d.%d\n\n",
sdlVer.major, sdlVer.minor, sdlVer.patch,
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
#else
@@ -277,7 +277,7 @@
audio.locked = true;
audio.rescanAudioDevicesSupported = true;
- strcpy(editor.ui.fullscreenButtonText, "Go fullscreen");
+ strcpy(ui.fullscreenButtonText, "Go fullscreen");
// set non-zero values
@@ -284,7 +284,7 @@
editor.moduleSaveMode = MOD_SAVE_MODE_XM;
editor.sampleSaveMode = SMP_SAVE_MODE_WAV;
- editor.ui.sampleDataOrLoopDrag = -1;
+ ui.sampleDataOrLoopDrag = -1;
mouse.lastUsedObjectID = OBJECT_ID_NONE;
--- a/src/ft2_midi.c
+++ b/src/ft2_midi.c
@@ -15,6 +15,7 @@
#include "ft2_audio.h"
#include "ft2_mouse.h"
#include "ft2_pattern_ed.h"
+#include "ft2_structs.h"
#include "rtmidi/rtmidi_c.h"
// hide POSIX warnings
@@ -22,8 +23,10 @@
#pragma warning(disable: 4996)
#endif
-// MIDI INPUT ONLY!
+// This implements MIDI input only!
+midi_t midi; // globalized
+
static volatile bool midiDeviceOpened;
static bool recMIDIValidChn = true;
static RtMidiPtr midiDev;
@@ -251,7 +254,7 @@
if (!allocatePattern(nr))
return;
- note = &patt[nr][(editor.pattPos * MAX_VOICES) + editor.cursor.ch];
+ note = &patt[nr][(editor.pattPos * MAX_VOICES) + cursor.ch];
if (note->effTyp != effTyp || note->eff != effData)
setSongModifiedFlag();
@@ -460,7 +463,7 @@
{
(void)pos;
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MIDI_INPUT)
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MIDI_INPUT)
drawMidiInputList();
}
@@ -468,7 +471,7 @@
{
int32_t mx, my, deviceNum;
- if (!editor.ui.configScreenShown || editor.currConfigScreen != CONFIG_SCREEN_MIDI_INPUT)
+ if (!ui.configScreenShown || editor.currConfigScreen != CONFIG_SCREEN_MIDI_INPUT)
return false; // we didn't click the area
if (!midi.initThreadDone)
--- a/src/ft2_midi.h
+++ b/src/ft2_midi.h
@@ -9,7 +9,7 @@
#define MIDI_INPUT_SELECTOR_BOX_WIDTH 247
#define MAX_MIDI_DEVICES 99
-struct midi_t
+typedef struct midi_t
{
char *inputDeviceName, *inputDeviceNames[MAX_MIDI_DEVICES];
volatile bool closeMidiOnExit, initThreadDone;
@@ -17,7 +17,9 @@
bool enable, rescanDevicesFlag;
int16_t currMIDIVibDepth, currMIDIPitch;
int32_t numInputDevices;
-} midi;
+} midi_t;
+
+extern midi_t midi; // ft2_midi.c
void closeMidiInDevice(void);
void freeMidiIn(void);
--- a/src/ft2_module_loader.c
+++ b/src/ft2_module_loader.c
@@ -25,6 +25,7 @@
#include "ft2_events.h"
#include "ft2_video.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
/* This is a *HUGE* mess!
** I hope you never have to modify it, and you probably shouldn't either.
@@ -2461,7 +2462,7 @@
diskOpSetFilename(DISKOP_ITEM_MODULE, editor.tmpFilenameU);
// redraw top part of screen
- if (editor.ui.extended)
+ if (ui.extended)
{
togglePatternEditorExtended(); // exit
togglePatternEditorExtended(); // re-enter (force redrawing)
@@ -2476,7 +2477,7 @@
updateSampleEditorSample();
showBottomScreen(); // redraw bottom screen (also redraws pattern editor)
- if (editor.ui.instEditorShown)
+ if (ui.instEditorShown)
drawPiano(NULL); // redraw piano now (since if playing = wait for next tick update)
removeSongModifiedFlag();
@@ -2549,7 +2550,7 @@
int32_t fullPathLen, filesize;
UNICHAR *fullPathU;
- if (editor.ui.sysReqShown || fullPathUTF8 == NULL)
+ if (ui.sysReqShown || fullPathUTF8 == NULL)
return;
fullPathLen = (int32_t)strlen(fullPathUTF8);
--- a/src/ft2_module_saver.c
+++ b/src/ft2_module_saver.c
@@ -12,6 +12,7 @@
#include "ft2_sample_ed.h"
#include "ft2_module_loader.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
/* These savers are directly ported, so they should act identical to FT2
** except for some very minor changes.
--- a/src/ft2_mouse.c
+++ b/src/ft2_mouse.c
@@ -19,23 +19,26 @@
#include "ft2_audioselector.h"
#include "ft2_midi.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
#define NUM_CURSORS 6
+mouse_t mouse; // globalized
+
static bool mouseBusyGfxBackwards;
static int16_t mouseShape;
static int32_t mouseModeGfxOffs, mouseBusyGfxFrame;
static SDL_Cursor *cursors[NUM_CURSORS];
-static bool setSystemCursor(SDL_Cursor *cursor)
+static bool setSystemCursor(SDL_Cursor *cur)
{
- if (cursor == NULL)
+ if (cur == NULL)
{
SDL_SetCursor(SDL_GetDefaultCursor());
return false;
}
- SDL_SetCursor(cursor);
+ SDL_SetCursor(cur);
return true;
}
@@ -298,7 +301,7 @@
for (i = 0; i < NUM_TEXTBOXES; i++)
{
- if (editor.ui.sysReqShown && i > 0)
+ if (ui.sysReqShown && i > 0)
continue;
t = &textBoxes[i];
@@ -345,20 +348,20 @@
{
if (busy)
{
- editor.ui.setMouseIdle = false;
- editor.ui.setMouseBusy = true;
+ ui.setMouseIdle = false;
+ ui.setMouseBusy = true;
}
else
{
- editor.ui.setMouseBusy = false;
- editor.ui.setMouseIdle = true;
+ ui.setMouseBusy = false;
+ ui.setMouseIdle = true;
}
}
void mouseAnimOn(void)
{
- editor.ui.setMouseBusy = false;
- editor.ui.setMouseIdle = false;
+ ui.setMouseBusy = false;
+ ui.setMouseIdle = false;
editor.busy = true;
setMouseShape(config.mouseAnimType);
@@ -366,8 +369,8 @@
void mouseAnimOff(void)
{
- editor.ui.setMouseBusy = false;
- editor.ui.setMouseIdle = false;
+ ui.setMouseBusy = false;
+ ui.setMouseIdle = false;
editor.busy = false;
setMouseShape(config.mouseType);
@@ -403,10 +406,10 @@
void mouseWheelHandler(bool directionUp)
{
- if (editor.ui.sysReqShown || editor.editTextFlag)
+ if (ui.sysReqShown || editor.editTextFlag)
return;
- if (editor.ui.extended)
+ if (ui.extended)
{
if (mouse.y <= 52)
{
@@ -425,7 +428,7 @@
{
// top screens
- if (editor.ui.helpScreenShown)
+ if (ui.helpScreenShown)
{
// help screen
@@ -440,7 +443,7 @@
helpScrollDown();
}
}
- else if (editor.ui.diskOpShown)
+ else if (ui.diskOpShown)
{
// disk op - 3x speed
if (mouse.x <= 355)
@@ -459,7 +462,7 @@
}
}
}
- else if (editor.ui.configScreenShown)
+ else if (ui.configScreenShown)
{
if (editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
{
@@ -482,8 +485,8 @@
#endif
}
- if (!editor.ui.aboutScreenShown && !editor.ui.helpScreenShown &&
- !editor.ui.configScreenShown && !editor.ui.nibblesShown)
+ if (!ui.aboutScreenShown && !ui.helpScreenShown &&
+ !ui.configScreenShown && !ui.nibblesShown)
{
if (mouse.x >= 421 && mouse.y <= 173)
{
@@ -490,7 +493,7 @@
if (mouse.y <= 93) directionUp ? decCurIns() : incCurIns();
else if (mouse.y >= 94) directionUp ? decCurSmp() : incCurSmp();
}
- else if (!editor.ui.diskOpShown && mouse.x <= 111 && mouse.y <= 76)
+ else if (!ui.diskOpShown && mouse.x <= 111 && mouse.y <= 76)
{
directionUp ? decSongPos() : incSongPos();
}
@@ -500,12 +503,12 @@
{
// bottom screens
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
{
if (mouse.y >= 174 && mouse.y <= 328)
directionUp ? mouseZoomSampleDataIn() : mouseZoomSampleDataOut();
}
- else if (editor.ui.patternEditorShown)
+ else if (ui.patternEditorShown)
{
directionUp ? mouseWheelDecRow() : mouseWheelIncRow();
}
@@ -514,7 +517,7 @@
static bool testSamplerDataMouseDown(void)
{
- if (editor.ui.sampleEditorShown && mouse.y >= 174 && mouse.y <= 327 && editor.ui.sampleDataOrLoopDrag == -1)
+ if (ui.sampleEditorShown && mouse.y >= 174 && mouse.y <= 327 && ui.sampleDataOrLoopDrag == -1)
{
handleSampleDataMouseDown(false);
return true;
@@ -527,10 +530,10 @@
{
uint16_t y1, y2;
- if (editor.ui.patternEditorShown)
+ if (ui.patternEditorShown)
{
- y1 = editor.ui.extended ? 56 : 176;
- y2 = editor.ui.pattChanScrollShown ? 382 : 396;
+ y1 = ui.extended ? 56 : 176;
+ y2 = ui.pattChanScrollShown ? 382 : 396;
if (mouse.y >= y1 && mouse.y <= y2 && mouse.x >= 29 && mouse.x <= 602)
{
@@ -549,16 +552,16 @@
mouse.leftButtonPressed = false;
mouse.leftButtonReleased = true;
- if (editor.ui.leftLoopPinMoving)
+ if (ui.leftLoopPinMoving)
{
setLeftLoopPinState(false);
- editor.ui.leftLoopPinMoving = false;
+ ui.leftLoopPinMoving = false;
}
- if (editor.ui.rightLoopPinMoving)
+ if (ui.rightLoopPinMoving)
{
setRightLoopPinState(false);
- editor.ui.rightLoopPinMoving = false;
+ ui.rightLoopPinMoving = false;
}
}
else if (mouseButton == SDL_BUTTON_RIGHT)
@@ -574,7 +577,7 @@
resumeAudio();
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
writeSample(true);
setSongModifiedFlag();
@@ -591,13 +594,13 @@
if ( mouse.leftButtonPressed && !mouse.rightButtonPressed) return;
if (!mouse.leftButtonPressed && mouse.rightButtonPressed) return;
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
testSmpEdMouseUp();
mouse.lastX = 0;
mouse.lastY = 0;
- editor.ui.sampleDataOrLoopDrag = -1;
+ ui.sampleDataOrLoopDrag = -1;
// check if we released a GUI object
testDiskOpMouseRelease();
@@ -622,7 +625,7 @@
// if already holding left button and clicking right, don't do mouse down handling
if (mouseButton == SDL_BUTTON_RIGHT && mouse.leftButtonPressed)
{
- if (editor.ui.sampleDataOrLoopDrag == -1)
+ if (ui.sampleDataOrLoopDrag == -1)
{
mouse.rightButtonPressed = true;
mouse.rightButtonReleased = false;
@@ -629,7 +632,7 @@
}
// kludge - we must do scope solo/unmute all here
- if (!editor.ui.sysReqShown)
+ if (!ui.sysReqShown)
testScopesMouseDown();
return;
@@ -638,7 +641,7 @@
// if already holding right button and clicking left, don't do mouse down handling
if (mouseButton == SDL_BUTTON_LEFT && mouse.rightButtonPressed)
{
- if (editor.ui.sampleDataOrLoopDrag == -1)
+ if (ui.sampleDataOrLoopDrag == -1)
{
mouse.leftButtonPressed = true;
mouse.leftButtonReleased = false;
@@ -645,7 +648,7 @@
}
// kludge - we must do scope solo/unmute all here
- if (!editor.ui.sysReqShown)
+ if (!ui.sysReqShown)
testScopesMouseDown();
return;
@@ -701,7 +704,7 @@
if (testRadioButtonMouseDown()) return;
// at this point, we don't need to test more widgets if a system request is shown
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
return;
if (testInstrVolEnvMouseDown(false)) return;
--- a/src/ft2_mouse.h
+++ b/src/ft2_mouse.h
@@ -13,7 +13,7 @@
MOUSE_WHEEL_UP = 1
};
-struct mouse_t
+typedef struct mouse_t
{
volatile bool setPosFlag;
bool leftButtonPressed, rightButtonPressed, leftButtonReleased, rightButtonReleased;
@@ -23,7 +23,9 @@
int32_t x, y, lastX, lastY, xBias, yBias, setPosX, setPosY;
int32_t lastScrollX, lastScrollXTmp, lastScrollY, saveMouseX, saveMouseY;
uint32_t buttonState;
-} mouse;
+} mouse_t;
+
+extern mouse_t mouse; // ft2_mouse.c
// do not change these!
#define MOUSE_CURSOR_W 26
--- a/src/ft2_nibbles.c
+++ b/src/ft2_nibbles.c
@@ -10,6 +10,7 @@
#include "ft2_pattern_ed.h"
#include "ft2_bmp.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
#define NI_MAXLEVEL 30
@@ -561,7 +562,7 @@
{
int16_t i, j;
- if (editor.ui.sysReqShown || --NI_CurTick60Hz != 0)
+ if (ui.sysReqShown || --NI_CurTick60Hz != 0)
return;
if (nibblesBufferFull(0))
@@ -731,11 +732,11 @@
void showNibblesScreen(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
- editor.ui.nibblesShown = true;
+ ui.nibblesShown = true;
drawFramework(0, 0, 632, 3, FRAMEWORK_TYPE1);
drawFramework(0, 3, 148, 49, FRAMEWORK_TYPE1);
@@ -812,7 +813,7 @@
hideCheckBox(CB_NIBBLES_GRID);
hideCheckBox(CB_NIBBLES_WRAP);
- editor.ui.nibblesShown = false;
+ ui.nibblesShown = false;
}
void exitNibblesScreen(void)
--- a/src/ft2_pattern_draw.c
+++ b/src/ft2_pattern_draw.c
@@ -12,6 +12,7 @@
#include "ft2_video.h"
#include "ft2_tables.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
static tonTyp emptyPattern[MAX_VOICES * MAX_PATT_LEN];
@@ -58,14 +59,14 @@
const pattCoord2_t *pattCoord;
// get heights/pos/rows depending on configuration
- pattCoord = &pattCoord2Table[config.ptnUnpressed][editor.ui.pattChanScrollShown][editor.ui.extended];
+ pattCoord = &pattCoord2Table[config.ptnUnpressed][ui.pattChanScrollShown][ui.extended];
// set pattern cursor Y position
editor.ptnCursorY = pattCoord->lowerRowsY - 9;
- chans = editor.ui.numChannelsShown;
- if (chans > editor.ui.maxVisibleChannels)
- chans = editor.ui.maxVisibleChannels;
+ chans = ui.numChannelsShown;
+ if (chans > ui.maxVisibleChannels)
+ chans = ui.maxVisibleChannels;
// in some configurations, there will be two empty channels to the right, fix that
if (chans == 2)
@@ -78,7 +79,7 @@
chanWidth = chanWidths[(chans / 2) - 1] + 2;
// fill scrollbar framework (if needed)
- if (editor.ui.pattChanScrollShown)
+ if (ui.pattChanScrollShown)
drawFramework(0, 383, 632, 17, FRAMEWORK_TYPE1);
if (config.ptnFrmWrk)
@@ -85,7 +86,7 @@
{
// pattern editor w/ framework
- if (editor.ui.extended)
+ if (ui.extended)
{
vLine(0, 54, 345, PAL_DSKTOP1);
vLine(631, 53, 346, PAL_DSKTOP2);
@@ -96,7 +97,7 @@
hLine(0, 53, 631, PAL_DSKTOP1);
hLine(1, 54, 630, PAL_DESKTOP);
- if (!editor.ui.pattChanScrollShown)
+ if (!ui.pattChanScrollShown)
{
hLine(1, 398, 630, PAL_DESKTOP);
hLine(0, 399, 632, PAL_DSKTOP2);
@@ -113,7 +114,7 @@
hLine(0, 173, 631, PAL_DSKTOP1);
hLine(1, 174, 630, PAL_DESKTOP);
- if (!editor.ui.pattChanScrollShown)
+ if (!ui.pattChanScrollShown)
{
hLine(1, 398, 630, PAL_DESKTOP);
hLine(0, 399, 632, PAL_DSKTOP2);
@@ -149,14 +150,14 @@
{
// pattern editor without framework
- if (editor.ui.extended)
+ if (ui.extended)
{
- clearSize = editor.ui.pattChanScrollShown ? (SCREEN_W * sizeof (int32_t) * 330) : (SCREEN_W * sizeof (int32_t) * 347);
+ clearSize = ui.pattChanScrollShown ? (SCREEN_W * sizeof (int32_t) * 330) : (SCREEN_W * sizeof (int32_t) * 347);
memset(&video.frameBuffer[53 * SCREEN_W], 0, clearSize);
}
else
{
- clearSize = editor.ui.pattChanScrollShown ? (SCREEN_W * sizeof(int32_t) * 210) : (SCREEN_W * sizeof(int32_t) * 227);
+ clearSize = ui.pattChanScrollShown ? (SCREEN_W * sizeof(int32_t) * 210) : (SCREEN_W * sizeof(int32_t) * 227);
memset(&video.frameBuffer[173 * SCREEN_W], 0, clearSize);
}
@@ -163,7 +164,7 @@
drawFramework(0, pattCoord->lowerRowsY - 10, SCREEN_W, 11, FRAMEWORK_TYPE1);
}
- if (editor.ui.pattChanScrollShown)
+ if (ui.pattChanScrollShown)
{
showScrollBar(SB_CHAN_SCROLL);
showPushButton(PB_CHAN_SCROLL_LEFT);
@@ -183,13 +184,13 @@
{
uint32_t *dstPtr, xPos, width, tabOffset;
- tabOffset = (config.ptnS3M * 32) + (columnModeTab[editor.ui.numChannelsShown - 1] * 8) + editor.cursor.object;
+ tabOffset = (config.ptnS3M * 32) + (columnModeTab[ui.numChannelsShown - 1] * 8) + cursor.object;
xPos = pattCursorXTab[tabOffset];
width = pattCursorWTab[tabOffset];
assert(editor.ptnCursorY > 0 && xPos > 0 && width > 0);
- xPos += ((editor.cursor.ch - editor.ui.channelOffset) * editor.ui.patternChannelWidth);
+ xPos += ((cursor.ch - ui.channelOffset) * ui.patternChannelWidth);
dstPtr = &video.frameBuffer[(editor.ptnCursorY * SCREEN_W) + xPos];
for (uint32_t y = 0; y < 9; y++)
@@ -211,8 +212,8 @@
if (pattMark.markY1 > pattMark.markY2)
return;
- startCh = editor.ui.channelOffset;
- endCh = editor.ui.channelOffset + (editor.ui.numChannelsShown - 1);
+ startCh = ui.channelOffset;
+ endCh = ui.channelOffset + (ui.numChannelsShown - 1);
startRow = currRow - pattCoord->numUpperRows;
endRow = currRow + pattCoord->numLowerRows;
@@ -220,18 +221,18 @@
if (pattMark.markX1 > endCh || pattMark.markX2 < startCh || pattMark.markY1 > endRow || pattMark.markY2 < startRow)
return;
- markCoord = &markCoordTable[config.ptnUnpressed][editor.ui.pattChanScrollShown][editor.ui.extended];
+ markCoord = &markCoordTable[config.ptnUnpressed][ui.pattChanScrollShown][ui.extended];
pattYStart = markCoord->upperRowsY;
// X1
- x1 = 32 + ((pattMark.markX1 - editor.ui.channelOffset) * editor.ui.patternChannelWidth);
+ x1 = 32 + ((pattMark.markX1 - ui.channelOffset) * ui.patternChannelWidth);
if (x1 < 32)
x1 = 32;
// X2
- x2 = (32 - 8) + (((pattMark.markX2 + 1) - editor.ui.channelOffset) * editor.ui.patternChannelWidth);
+ x2 = (32 - 8) + (((pattMark.markX2 + 1) - ui.channelOffset) * ui.patternChannelWidth);
if (x2 > 608)
x2 = 608;
@@ -272,7 +273,7 @@
}
// kludge! (some mark situations could overwrite illegal areas)
- if (config.ptnUnpressed && editor.ui.pattChanScrollShown)
+ if (config.ptnUnpressed && ui.pattChanScrollShown)
{
if (y1 == pattCoord->upperRowsY-1 || y1 == pattCoord->lowerRowsY-1)
y1++;
@@ -310,9 +311,9 @@
#define CH_NUM_XPOS 30
uint16_t xPos = CH_NUM_XPOS;
- int32_t ch = editor.ui.channelOffset + 1;
+ int32_t ch = ui.channelOffset + 1;
- for (uint8_t i = 0; i < editor.ui.numChannelsShown; i++)
+ for (uint8_t i = 0; i < ui.numChannelsShown; i++)
{
if (ch < 10)
{
@@ -325,7 +326,7 @@
}
ch++;
- xPos += editor.ui.patternChannelWidth;
+ xPos += ui.patternChannelWidth;
}
}
@@ -385,7 +386,7 @@
assert(ton >= 0 && ton <= 97);
- if (editor.ui.numChannelsShown <= 4)
+ if (ui.numChannelsShown <= 4)
{
if (ton <= 0 || ton > 97)
drawEmptyNoteBig(xPos, yPos, color);
@@ -409,13 +410,13 @@
{
uint8_t chr1, chr2, charW, fontType;
- if (editor.ui.numChannelsShown <= 4)
+ if (ui.numChannelsShown <= 4)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
xPos += 67;
}
- else if (editor.ui.numChannelsShown <= 6)
+ else if (ui.numChannelsShown <= 6)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
@@ -450,7 +451,7 @@
{
uint8_t char1, char2, fontType, charW;
- if (editor.ui.numChannelsShown <= 4)
+ if (ui.numChannelsShown <= 4)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
@@ -462,7 +463,7 @@
else
char2 = vol & 0x0F;
}
- else if (editor.ui.numChannelsShown <= 6)
+ else if (ui.numChannelsShown <= 6)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
@@ -495,13 +496,13 @@
{
uint8_t fontType, charW;
- if (editor.ui.numChannelsShown <= 4)
+ if (ui.numChannelsShown <= 4)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
xPos += 115;
}
- else if (editor.ui.numChannelsShown <= 6)
+ else if (ui.numChannelsShown <= 6)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
@@ -527,7 +528,7 @@
assert(ton >= 0 && ton <= 97);
- if (editor.ui.numChannelsShown <= 6)
+ if (ui.numChannelsShown <= 6)
{
if (ton <= 0 || ton > 97)
drawEmptyNoteBig(xPos, yPos, color);
@@ -536,7 +537,7 @@
else
drawNoteBig(xPos, yPos, ton, color);
}
- else if (editor.ui.numChannelsShown <= 8)
+ else if (ui.numChannelsShown <= 8)
{
if (ton <= 0 || ton > 97)
drawEmptyNoteMedium(xPos, yPos, color);
@@ -560,19 +561,19 @@
{
uint8_t chr1, chr2, charW, fontType;
- if (editor.ui.numChannelsShown <= 4)
+ if (ui.numChannelsShown <= 4)
{
fontType = FONT_TYPE5;
charW = FONT5_CHAR_W;
xPos += 59;
}
- else if (editor.ui.numChannelsShown <= 6)
+ else if (ui.numChannelsShown <= 6)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
xPos += 51;
}
- else if (editor.ui.numChannelsShown <= 8)
+ else if (ui.numChannelsShown <= 8)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
@@ -616,19 +617,19 @@
{
uint8_t charW, fontType;
- if (editor.ui.numChannelsShown <= 4)
+ if (ui.numChannelsShown <= 4)
{
fontType = FONT_TYPE5;
charW = FONT5_CHAR_W;
xPos += 91;
}
- else if (editor.ui.numChannelsShown <= 6)
+ else if (ui.numChannelsShown <= 6)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
xPos += 67;
}
- else if (editor.ui.numChannelsShown <= 8)
+ else if (ui.numChannelsShown <= 8)
{
fontType = FONT_TYPE4;
charW = FONT4_CHAR_W;
@@ -667,19 +668,19 @@
// setup variables
- chans = editor.ui.numChannelsShown;
- if (chans > editor.ui.maxVisibleChannels)
- chans = editor.ui.maxVisibleChannels;
+ chans = ui.numChannelsShown;
+ if (chans > ui.maxVisibleChannels)
+ chans = ui.maxVisibleChannels;
assert(chans >= 2 && chans <= 12);
// get channel width
chanWidth = chanWidths[(chans / 2) - 1];
- editor.ui.patternChannelWidth = (uint16_t)(chanWidth + 3);
+ ui.patternChannelWidth = (uint16_t)(chanWidth + 3);
// get heights/pos/rows depending on configuration
rowHeight = config.ptnUnpressed ? 11 : 8;
- pattCoord = &pattCoordTable[config.ptnUnpressed][editor.ui.pattChanScrollShown][editor.ui.extended];
+ pattCoord = &pattCoordTable[config.ptnUnpressed][ui.pattChanScrollShown][ui.extended];
midRowTextY = pattCoord->midRowTextY;
lowerRowsTextY = pattCoord->lowerRowsTextY;
row = currRow - pattCoord->numUpperRows;
@@ -687,7 +688,7 @@
textY = pattCoord->upperRowsTextY;
afterCurrRow = currRow + 1;
- numChannels = editor.ui.numChannelsShown;
+ numChannels = ui.numChannelsShown;
pattPtr = patt[pattern];
numRows = pattLens[pattern];
noteTextColors[0] = video.palette[PAL_PATTEXT]; // not selected
@@ -695,7 +696,7 @@
// increment pattern data pointer by horizontal scrollbar offset/channel
if (pattPtr != NULL)
- pattPtr += editor.ui.channelOffset;
+ pattPtr += ui.channelOffset;
// set up function pointers for drawing
if (config.ptnS3M)
@@ -728,7 +729,7 @@
note = &pattPtr[(uint32_t)row * MAX_VOICES];
xPos = 29;
- xWidth = editor.ui.patternChannelWidth;
+ xWidth = ui.patternChannelWidth;
color = noteTextColors[selectedRowFlag];
for (int32_t j = 0; j < numChannels; j++)
--- a/src/ft2_pattern_ed.c
+++ b/src/ft2_pattern_ed.c
@@ -21,7 +21,10 @@
#include "ft2_video.h"
#include "ft2_tables.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
+pattMark_t pattMark; // globalized
+
// for pattern marking w/ keyboard
static int8_t lastChMark;
static int16_t lastRowMark;
@@ -41,14 +44,12 @@
bool allocatePattern(uint16_t nr) // for tracker use only, not in loader!
{
- bool audioWasntLocked;
+ const bool audioWasntLocked = !audio.locked;
+ if (audioWasntLocked)
+ lockAudio();
if (patt[nr] == NULL)
{
- audioWasntLocked = !audio.locked;
- if (audioWasntLocked)
- lockAudio();
-
/* Original FT2 allocates only the amount of rows needed, but we don't
** do that to avoid out of bondary row look-up between out-of-sync replayer
** state and tracker state (yes it used to happen, rarely). We're not wasting
@@ -67,33 +68,31 @@
// XXX: Do we really need this? Sounds redundant.
song.pattLen = pattLens[nr];
-
- if (audioWasntLocked)
- unlockAudio();
}
+ if (audioWasntLocked)
+ unlockAudio();
+
return true;
}
void killPatternIfUnused(uint16_t nr) // for tracker use only, not in loader!
{
- bool audioWasntLocked;
+ const bool audioWasntLocked = !audio.locked;
+ if (audioWasntLocked)
+ lockAudio();
if (patternEmpty(nr))
{
- audioWasntLocked = !audio.locked;
- if (audioWasntLocked)
- lockAudio();
-
if (patt[nr] != NULL)
{
free(patt[nr]);
patt[nr] = NULL;
}
-
- if (audioWasntLocked)
- unlockAudio();
}
+
+ if (audioWasntLocked)
+ unlockAudio();
}
uint8_t getMaxVisibleChannels(void)
@@ -119,12 +118,12 @@
void updatePatternWidth(void)
{
- if (editor.ui.numChannelsShown > editor.ui.maxVisibleChannels)
- editor.ui.numChannelsShown = editor.ui.maxVisibleChannels;
+ if (ui.numChannelsShown > ui.maxVisibleChannels)
+ ui.numChannelsShown = ui.maxVisibleChannels;
- assert(editor.ui.numChannelsShown >= 2 && editor.ui.numChannelsShown <= 12);
+ assert(ui.numChannelsShown >= 2 && ui.numChannelsShown <= 12);
- editor.ui.patternChannelWidth = chanWidths[(editor.ui.numChannelsShown / 2) - 1] + 3;
+ ui.patternChannelWidth = chanWidths[(ui.numChannelsShown / 2) - 1] + 3;
}
void updateAdvEdit(void)
@@ -205,7 +204,7 @@
void hideAdvEdit(void)
{
- editor.ui.advEditShown = false;
+ ui.advEditShown = false;
hidePushButton(PB_REMAP_TRACK);
hidePushButton(PB_REMAP_PATTERN);
@@ -229,26 +228,26 @@
hideCheckBox(CB_TRANSP_MASK_3);
hideCheckBox(CB_TRANSP_MASK_4);
- editor.ui.scopesShown = true;
+ ui.scopesShown = true;
drawScopeFramework();
}
void showAdvEdit(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
showTopScreen(false);
- editor.ui.advEditShown = true;
- editor.ui.scopesShown = false;
+ ui.advEditShown = true;
+ ui.scopesShown = false;
drawAdvEdit();
}
void toggleAdvEdit(void)
{
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
hideAdvEdit();
else
showAdvEdit();
@@ -307,14 +306,14 @@
void showTranspose(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
showTopScreen(false);
- editor.ui.transposeShown = true;
- editor.ui.scopesShown = false;
+ ui.transposeShown = true;
+ ui.scopesShown = false;
drawTranspose();
}
@@ -353,14 +352,14 @@
hidePushButton(PB_TRANSP_ALL_INS_BLK_12UP);
hidePushButton(PB_TRANSP_ALL_INS_BLK_12DN);
- editor.ui.transposeShown = false;
- editor.ui.scopesShown = true;
+ ui.transposeShown = false;
+ ui.scopesShown = true;
drawScopeFramework();
}
void toggleTranspose(void)
{
- if (editor.ui.transposeShown)
+ if (ui.transposeShown)
hideTranspose();
else
showTranspose();
@@ -370,20 +369,20 @@
void cursorChannelLeft(void)
{
- editor.cursor.object = CURSOR_EFX2;
+ cursor.object = CURSOR_EFX2;
- if (editor.cursor.ch == 0)
+ if (cursor.ch == 0)
{
- editor.cursor.ch = (uint8_t)(song.antChn - 1);
- if (editor.ui.pattChanScrollShown)
+ cursor.ch = (uint8_t)(song.antChn - 1);
+ if (ui.pattChanScrollShown)
setScrollBarPos(SB_CHAN_SCROLL, song.antChn, true);
}
else
{
- editor.cursor.ch--;
- if (editor.ui.pattChanScrollShown)
+ cursor.ch--;
+ if (ui.pattChanScrollShown)
{
- if (editor.cursor.ch < editor.ui.channelOffset)
+ if (cursor.ch < ui.channelOffset)
scrollBarScrollUp(SB_CHAN_SCROLL, 1);
}
}
@@ -391,18 +390,18 @@
void cursorChannelRight(void)
{
- editor.cursor.object = CURSOR_NOTE;
+ cursor.object = CURSOR_NOTE;
- if (editor.cursor.ch >= song.antChn-1)
+ if (cursor.ch >= song.antChn-1)
{
- editor.cursor.ch = 0;
- if (editor.ui.pattChanScrollShown)
+ cursor.ch = 0;
+ if (ui.pattChanScrollShown)
setScrollBarPos(SB_CHAN_SCROLL, 0, true);
}
else
{
- editor.cursor.ch++;
- if (editor.ui.pattChanScrollShown && editor.cursor.ch >= editor.ui.channelOffset+editor.ui.numChannelsShown)
+ cursor.ch++;
+ if (ui.pattChanScrollShown && cursor.ch >= ui.channelOffset+ui.numChannelsShown)
scrollBarScrollDown(SB_CHAN_SCROLL, 1);
}
}
@@ -409,78 +408,78 @@
void cursorTabLeft(void)
{
- if (editor.cursor.object == CURSOR_NOTE)
+ if (cursor.object == CURSOR_NOTE)
cursorChannelLeft();
- editor.cursor.object = CURSOR_NOTE;
- editor.ui.updatePatternEditor = true;
+ cursor.object = CURSOR_NOTE;
+ ui.updatePatternEditor = true;
}
void cursorTabRight(void)
{
cursorChannelRight();
- editor.cursor.object = CURSOR_NOTE;
- editor.ui.updatePatternEditor = true;
+ cursor.object = CURSOR_NOTE;
+ ui.updatePatternEditor = true;
}
void chanLeft(void)
{
cursorChannelLeft();
- editor.cursor.object = CURSOR_NOTE;
- editor.ui.updatePatternEditor = true;
+ cursor.object = CURSOR_NOTE;
+ ui.updatePatternEditor = true;
}
void chanRight(void)
{
cursorChannelRight();
- editor.cursor.object = CURSOR_NOTE;
- editor.ui.updatePatternEditor = true;
+ cursor.object = CURSOR_NOTE;
+ ui.updatePatternEditor = true;
}
void cursorLeft(void)
{
- editor.cursor.object--;
+ cursor.object--;
if (!config.ptnS3M)
{
- while (editor.cursor.object == CURSOR_VOL1 || editor.cursor.object == CURSOR_VOL2)
- editor.cursor.object--;
+ while (cursor.object == CURSOR_VOL1 || cursor.object == CURSOR_VOL2)
+ cursor.object--;
}
- if (editor.cursor.object == -1)
+ if (cursor.object == -1)
{
- editor.cursor.object = CURSOR_EFX2;
+ cursor.object = CURSOR_EFX2;
cursorChannelLeft();
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
void cursorRight(void)
{
- editor.cursor.object++;
+ cursor.object++;
if (!config.ptnS3M)
{
- while (editor.cursor.object == CURSOR_VOL1 || editor.cursor.object == CURSOR_VOL2)
- editor.cursor.object++;
+ while (cursor.object == CURSOR_VOL1 || cursor.object == CURSOR_VOL2)
+ cursor.object++;
}
- if (editor.cursor.object == 8)
+ if (cursor.object == 8)
{
- editor.cursor.object = CURSOR_NOTE;
+ cursor.object = CURSOR_NOTE;
cursorChannelRight();
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
void showPatternEditor(void)
{
- editor.ui.patternEditorShown = true;
+ ui.patternEditorShown = true;
updateChanNums();
drawPatternBorders();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
void hidePatternEditor(void)
@@ -489,7 +488,7 @@
hidePushButton(PB_CHAN_SCROLL_LEFT);
hidePushButton(PB_CHAN_SCROLL_RIGHT);
- editor.ui.patternEditorShown = false;
+ ui.patternEditorShown = false;
}
static void updatePatternEditorGUI(void)
@@ -498,7 +497,7 @@
pushButton_t *p;
textBox_t *t;
- if (editor.ui.extended)
+ if (ui.extended)
{
// extended pattern editor
@@ -625,29 +624,29 @@
void patternEditorExtended(void)
{
// backup old screen flags
- editor.ui._aboutScreenShown = editor.ui.aboutScreenShown;
- editor.ui._helpScreenShown = editor.ui.helpScreenShown;
- editor.ui._configScreenShown = editor.ui.configScreenShown;
- editor.ui._diskOpShown = editor.ui.diskOpShown;
- editor.ui._nibblesShown = editor.ui.nibblesShown;
- editor.ui._transposeShown = editor.ui.transposeShown;
- editor.ui._instEditorShown = editor.ui.instEditorShown;
- editor.ui._instEditorExtShown = editor.ui.instEditorExtShown;
- editor.ui._sampleEditorExtShown = editor.ui.sampleEditorExtShown;
- editor.ui._patternEditorShown = editor.ui.patternEditorShown;
- editor.ui._sampleEditorShown = editor.ui.sampleEditorShown;
- editor.ui._advEditShown= editor.ui.advEditShown;
- editor.ui._wavRendererShown = editor.ui.wavRendererShown;
- editor.ui._trimScreenShown = editor.ui.trimScreenShown;
+ ui._aboutScreenShown = ui.aboutScreenShown;
+ ui._helpScreenShown = ui.helpScreenShown;
+ ui._configScreenShown = ui.configScreenShown;
+ ui._diskOpShown = ui.diskOpShown;
+ ui._nibblesShown = ui.nibblesShown;
+ ui._transposeShown = ui.transposeShown;
+ ui._instEditorShown = ui.instEditorShown;
+ ui._instEditorExtShown = ui.instEditorExtShown;
+ ui._sampleEditorExtShown = ui.sampleEditorExtShown;
+ ui._patternEditorShown = ui.patternEditorShown;
+ ui._sampleEditorShown = ui.sampleEditorShown;
+ ui._advEditShown= ui.advEditShown;
+ ui._wavRendererShown = ui.wavRendererShown;
+ ui._trimScreenShown = ui.trimScreenShown;
hideTopScreen();
hideSampleEditor();
hideInstEditor();
- editor.ui.extended = true;
- editor.ui.patternEditorShown = true;
+ ui.extended = true;
+ ui.patternEditorShown = true;
updatePatternEditorGUI(); // change pattern editor layout (based on ui.extended flag)
- editor.ui.updatePatternEditor = true; // redraw pattern editor
+ ui.updatePatternEditor = true; // redraw pattern editor
drawFramework(0, 0, 112, 53, FRAMEWORK_TYPE1);
drawFramework(112, 0, 106, 33, FRAMEWORK_TYPE1);
@@ -684,7 +683,7 @@
textOutShadow(222, 39, PAL_FORGRND, PAL_DSKTOP2, "Ptn.");
textOutShadow(305, 39, PAL_FORGRND, PAL_DSKTOP2, "Ln.");
- editor.ui.instrSwitcherShown = true;
+ ui.instrSwitcherShown = true;
showInstrumentSwitcher();
drawSongLength();
@@ -692,7 +691,7 @@
drawEditPattern(editor.editPattern);
drawPatternLength(editor.editPattern);
drawPosEdNums(editor.songPos);
- editor.ui.updatePosSections = true;
+ ui.updatePosSections = true;
// kludge to fix scrollbar thumb when the scrollbar height changes during playback
if (songPlaying)
@@ -701,7 +700,7 @@
void exitPatternEditorExtended(void)
{
- editor.ui.extended = false;
+ ui.extended = false;
updatePatternEditorGUI();
hidePushButton(PB_EXIT_EXT_PATT);
@@ -708,20 +707,20 @@
// set back top screen button maps
// set back old screen flags
- editor.ui.aboutScreenShown = editor.ui._aboutScreenShown;
- editor.ui.helpScreenShown = editor.ui._helpScreenShown;
- editor.ui.configScreenShown = editor.ui._configScreenShown;
- editor.ui.diskOpShown = editor.ui._diskOpShown;
- editor.ui.nibblesShown = editor.ui._nibblesShown;
- editor.ui.transposeShown = editor.ui._transposeShown;
- editor.ui.instEditorShown = editor.ui._instEditorShown;
- editor.ui.instEditorExtShown = editor.ui._instEditorExtShown;
- editor.ui.sampleEditorExtShown = editor.ui._sampleEditorExtShown;
- editor.ui.patternEditorShown = editor.ui._patternEditorShown;
- editor.ui.sampleEditorShown = editor.ui._sampleEditorShown;
- editor.ui.advEditShown = editor.ui._advEditShown;
- editor.ui.wavRendererShown = editor.ui._wavRendererShown;
- editor.ui.trimScreenShown = editor.ui.trimScreenShown;
+ ui.aboutScreenShown = ui._aboutScreenShown;
+ ui.helpScreenShown = ui._helpScreenShown;
+ ui.configScreenShown = ui._configScreenShown;
+ ui.diskOpShown = ui._diskOpShown;
+ ui.nibblesShown = ui._nibblesShown;
+ ui.transposeShown = ui._transposeShown;
+ ui.instEditorShown = ui._instEditorShown;
+ ui.instEditorExtShown = ui._instEditorExtShown;
+ ui.sampleEditorExtShown = ui._sampleEditorExtShown;
+ ui.patternEditorShown = ui._patternEditorShown;
+ ui.sampleEditorShown = ui._sampleEditorShown;
+ ui.advEditShown = ui._advEditShown;
+ ui.wavRendererShown = ui._wavRendererShown;
+ ui.trimScreenShown = ui.trimScreenShown;
showTopScreen(true);
showBottomScreen();
@@ -733,7 +732,7 @@
void togglePatternEditorExtended(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
else
patternEditorExtended();
@@ -771,16 +770,16 @@
int8_t ch, chEnd;
int32_t mouseX;
- assert(editor.ui.patternChannelWidth > 0);
- if (editor.ui.patternChannelWidth == 0)
+ assert(ui.patternChannelWidth > 0);
+ if (ui.patternChannelWidth == 0)
return 0;
mouseX = mouse.x - 29;
mouseX = CLAMP(mouseX, 0, 573);
- chEnd = (editor.ui.channelOffset + editor.ui.numChannelsShown) - 1;
+ chEnd = (ui.channelOffset + ui.numChannelsShown) - 1;
- ch = editor.ui.channelOffset + (int8_t)(mouseX / editor.ui.patternChannelWidth);
+ ch = ui.channelOffset + (int8_t)(mouseX / ui.patternChannelWidth);
ch = CLAMP(ch, 0, chEnd);
// in some setups there can be non-used channels to the right, do clamping
@@ -796,10 +795,10 @@
int16_t row, patternLen, my, maxY, maxRow;
const pattCoordsMouse_t *pattCoordsMouse;
- pattCoordsMouse = &pattCoordMouseTable[config.ptnUnpressed][editor.ui.pattChanScrollShown][editor.ui.extended];
+ pattCoordsMouse = &pattCoordMouseTable[config.ptnUnpressed][ui.pattChanScrollShown][ui.extended];
// clamp mouse y to boundaries
- maxY = editor.ui.pattChanScrollShown ? 382 : 396;
+ maxY = ui.pattChanScrollShown ? 382 : 396;
my = (int16_t)(CLAMP(mouse.y, pattCoordsMouse->upperRowsY, maxY));
charHeight = config.ptnUnpressed ? 11 : 8;
@@ -825,7 +824,7 @@
row = (editor.pattPos + 1) + ((my - pattCoordsMouse->lowerRowsY) / charHeight);
// prevent being able to mark the next unseen row on the bottom (in some configurations)
- mode = (editor.ui.extended * 4) + (config.ptnUnpressed * 2) + editor.ui.pattChanScrollShown;
+ mode = (ui.extended * 4) + (config.ptnUnpressed * 2) + ui.pattChanScrollShown;
maxRow = (ptnAntLine[mode] + (editor.pattPos - ptnLineSub[mode])) - 1;
if (row > maxRow)
@@ -850,7 +849,7 @@
if (mouse.rightButtonPressed)
{
clearPattMark();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
return;
}
@@ -873,7 +872,7 @@
checkMarkLimits();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
return;
}
@@ -882,7 +881,7 @@
forceMarking = songPlaying;
// scroll left/right with mouse
- if (editor.ui.pattChanScrollShown)
+ if (ui.pattChanScrollShown)
{
if (mouse.x < 29)
{
@@ -916,7 +915,7 @@
if (lastMarkX1 != pattMark.markX1 || lastMarkX2 != pattMark.markX2)
{
checkMarkLimits();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
lastMarkX1 = pattMark.markX1;
lastMarkX2 = pattMark.markX2;
@@ -926,8 +925,8 @@
// scroll down/up with mouse (if song is not playing)
if (!songPlaying)
{
- y1 = editor.ui.extended ? 56 : 176;
- y2 = editor.ui.pattChanScrollShown ? 382 : 396;
+ y1 = ui.extended ? 56 : 176;
+ y2 = ui.pattChanScrollShown ? 382 : 396;
if (mouse.y < y1)
{
@@ -936,7 +935,7 @@
setPos(-1, editor.pattPos - 1, true);
forceMarking = true;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
else if (mouse.y > y2)
{
@@ -945,7 +944,7 @@
setPos(-1, editor.pattPos + 1, true);
forceMarking = true;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
}
@@ -969,7 +968,7 @@
if (lastMarkY1 != pattMark.markY1 || lastMarkY2 != pattMark.markY2)
{
checkMarkLimits();
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
lastMarkY1 = pattMark.markY1;
lastMarkY2 = pattMark.markY2;
@@ -979,7 +978,7 @@
void rowOneUpWrap(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -987,7 +986,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -996,7 +995,7 @@
void rowOneDownWrap(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1008,7 +1007,7 @@
{
song.pattPos = (song.pattPos + 1 + song.pattLen) % song.pattLen;
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -1017,7 +1016,7 @@
void rowUp(uint16_t amount)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1028,7 +1027,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -1037,7 +1036,7 @@
void rowDown(uint16_t amount)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1048,7 +1047,7 @@
if (!songPlaying)
{
editor.pattPos = (uint8_t)song.pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (audioWasntLocked)
@@ -1060,7 +1059,7 @@
int8_t xPos;
int16_t pattPos;
- xPos = editor.cursor.ch;
+ xPos = cursor.ch;
pattPos = editor.pattPos;
if (xPos != pattMark.markX1 && xPos != pattMark.markX2)
@@ -1097,7 +1096,7 @@
int8_t xPos;
int16_t pattPos;
- xPos = editor.cursor.ch;
+ xPos = cursor.ch;
pattPos = editor.pattPos;
if (xPos != pattMark.markX1 && xPos != pattMark.markX2)
@@ -1133,7 +1132,7 @@
int8_t xPos;
int16_t pattPos;
- xPos = editor.cursor.ch;
+ xPos = cursor.ch;
pattPos = editor.pattPos;
if (pattPos != pattMark.markY1-1 && pattPos != pattMark.markY2)
@@ -1167,7 +1166,7 @@
int8_t xPos;
int16_t pattPos;
- xPos = editor.cursor.ch;
+ xPos = cursor.ch;
pattPos = editor.pattPos;
if (pattPos != pattMark.markY1-1 && pattPos != pattMark.markY2)
@@ -1248,7 +1247,7 @@
lockMixerCallback();
for (uint16_t i = 0; i < pattLen; i++)
{
- pattPtr = &patt[nr][(i * MAX_VOICES) + editor.cursor.ch];
+ pattPtr = &patt[nr][(i * MAX_VOICES) + cursor.ch];
*pattPtr = loadBuff[i];
// non-FT2 security fix: remove overflown (illegal) stuff
@@ -1266,8 +1265,8 @@
fclose(f);
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
diskOpSetFilename(DISKOP_ITEM_TRACK, filenameU);
setSongModifiedFlag();
@@ -1304,7 +1303,7 @@
pattLen = pattLens[nr];
for (i = 0; i < pattLen; i++)
- saveBuff[i] = pattPtr[(i * MAX_VOICES) + editor.cursor.ch];
+ saveBuff[i] = pattPtr[(i * MAX_VOICES) + cursor.ch];
th.len = pattLen;
th.ver = 1;
@@ -1400,8 +1399,8 @@
fclose(f);
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
diskOpSetFilename(DISKOP_ITEM_PATTERN, filenameU);
setSongModifiedFlag();
@@ -1471,61 +1470,61 @@
void setChannelScrollPos(uint32_t pos)
{
- if (!editor.ui.pattChanScrollShown)
+ if (!ui.pattChanScrollShown)
{
- editor.ui.channelOffset = 0;
+ ui.channelOffset = 0;
return;
}
- if (editor.ui.channelOffset == (uint8_t)pos)
+ if (ui.channelOffset == (uint8_t)pos)
return;
- editor.ui.channelOffset = (uint8_t)pos;
+ ui.channelOffset = (uint8_t)pos;
- assert(song.antChn > editor.ui.numChannelsShown);
- if (editor.ui.channelOffset >= song.antChn-editor.ui.numChannelsShown)
- editor.ui.channelOffset = (uint8_t)(song.antChn-editor.ui.numChannelsShown);
+ assert(song.antChn > ui.numChannelsShown);
+ if (ui.channelOffset >= song.antChn-ui.numChannelsShown)
+ ui.channelOffset = (uint8_t)(song.antChn-ui.numChannelsShown);
- if (editor.cursor.ch >= editor.ui.channelOffset+editor.ui.numChannelsShown)
+ if (cursor.ch >= ui.channelOffset+ui.numChannelsShown)
{
- editor.cursor.object = CURSOR_NOTE;
- editor.cursor.ch = (editor.ui.channelOffset + editor.ui.numChannelsShown) - 1;
+ cursor.object = CURSOR_NOTE;
+ cursor.ch = (ui.channelOffset + ui.numChannelsShown) - 1;
}
- else if (editor.cursor.ch < editor.ui.channelOffset)
+ else if (cursor.ch < ui.channelOffset)
{
- editor.cursor.object = CURSOR_NOTE;
- editor.cursor.ch = editor.ui.channelOffset;
+ cursor.object = CURSOR_NOTE;
+ cursor.ch = ui.channelOffset;
}
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
void jumpToChannel(uint8_t channel) // for ALT+q..i ALT+a..k
{
- if (editor.ui.sampleEditorShown || editor.ui.instEditorShown)
+ if (ui.sampleEditorShown || ui.instEditorShown)
return;
channel %= song.antChn;
- if (editor.cursor.ch == channel)
+ if (cursor.ch == channel)
return;
- if (editor.ui.pattChanScrollShown)
+ if (ui.pattChanScrollShown)
{
- assert(song.antChn > editor.ui.numChannelsShown);
+ assert(song.antChn > ui.numChannelsShown);
- if (channel >= editor.ui.channelOffset+editor.ui.numChannelsShown)
- scrollBarScrollDown(SB_CHAN_SCROLL, (channel - (editor.ui.channelOffset + editor.ui.numChannelsShown)) + 1);
- else if (channel < editor.ui.channelOffset)
- scrollBarScrollUp(SB_CHAN_SCROLL, editor.ui.channelOffset - channel);
+ if (channel >= ui.channelOffset+ui.numChannelsShown)
+ scrollBarScrollDown(SB_CHAN_SCROLL, (channel - (ui.channelOffset + ui.numChannelsShown)) + 1);
+ else if (channel < ui.channelOffset)
+ scrollBarScrollUp(SB_CHAN_SCROLL, ui.channelOffset - channel);
}
- editor.cursor.ch = channel; // set it here since scrollBarScrollX() changes it...
- editor.ui.updatePatternEditor = true;
+ cursor.ch = channel; // set it here since scrollBarScrollX() changes it...
+ ui.updatePatternEditor = true;
}
void sbPosEdPos(uint32_t pos)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1538,7 +1537,7 @@
void pbPosEdPosUp(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1551,7 +1550,7 @@
void pbPosEdPosDown(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1578,8 +1577,8 @@
song.len++;
- editor.ui.updatePosSections = true;
- editor.ui.updatePosEdScrollBar = true;
+ ui.updatePosSections = true;
+ ui.updatePosEdScrollBar = true;
setSongModifiedFlag();
unlockMixerCallback();
@@ -1608,8 +1607,8 @@
setPos(song.songPos, -1, false);
}
- editor.ui.updatePosSections = true;
- editor.ui.updatePosEdScrollBar = true;
+ ui.updatePosSections = true;
+ ui.updatePosEdScrollBar = true;
setSongModifiedFlag();
unlockMixerCallback();
@@ -1628,8 +1627,8 @@
editor.editPattern = (uint8_t)song.pattNr;
song.pattLen = pattLens[editor.editPattern];
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
setSongModifiedFlag();
}
unlockMixerCallback();
@@ -1648,8 +1647,8 @@
editor.editPattern = (uint8_t)song.pattNr;
song.pattLen = pattLens[editor.editPattern];
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
setSongModifiedFlag();
}
unlockMixerCallback();
@@ -1657,19 +1656,17 @@
void pbPosEdLenUp(void)
{
- bool audioWasntLocked;
-
if (song.len >= 255)
return;
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
song.len++;
- editor.ui.updatePosSections = true;
- editor.ui.updatePosEdScrollBar = true;
+ ui.updatePosSections = true;
+ ui.updatePosEdScrollBar = true;
setSongModifiedFlag();
if (audioWasntLocked)
@@ -1678,12 +1675,10 @@
void pbPosEdLenDown(void)
{
- bool audioWasntLocked;
-
if (song.len <= 1)
return;
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1698,8 +1693,8 @@
setPos(song.songPos, -1, false);
}
- editor.ui.updatePosSections = true;
- editor.ui.updatePosEdScrollBar = true;
+ ui.updatePosSections = true;
+ ui.updatePosEdScrollBar = true;
setSongModifiedFlag();
if (audioWasntLocked)
@@ -1708,7 +1703,7 @@
void pbPosEdRepSUp(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1715,7 +1710,7 @@
if (song.repS < song.len-1)
{
song.repS++;
- editor.ui.updatePosSections = true;
+ ui.updatePosSections = true;
setSongModifiedFlag();
}
@@ -1725,7 +1720,7 @@
void pbPosEdRepSDown(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1732,7 +1727,7 @@
if (song.repS > 0)
{
song.repS--;
- editor.ui.updatePosSections = true;
+ ui.updatePosSections = true;
setSongModifiedFlag();
}
@@ -1745,7 +1740,7 @@
if (song.speed == 255)
return;
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1771,7 +1766,7 @@
if (song.speed == 32)
return;
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1797,7 +1792,7 @@
if (song.tempo == 31)
return;
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1822,7 +1817,7 @@
if (song.tempo == 0)
return;
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1874,7 +1869,7 @@
showTopLeftMainScreen(true);
showTopRightMainScreen();
- if (editor.ui.patternEditorShown)
+ if (ui.patternEditorShown)
showPatternEditor();
setSongModifiedFlag();
@@ -1896,7 +1891,7 @@
showTopLeftMainScreen(true);
showTopRightMainScreen();
- if (editor.ui.patternEditorShown)
+ if (ui.patternEditorShown)
showPatternEditor();
setSongModifiedFlag();
@@ -1919,18 +1914,7 @@
void pbEditPattUp(void)
{
- if (songPlaying)
- {
- if (song.pattNr == 255)
- return;
- }
- else
- {
- if (editor.editPattern == 255)
- return;
- }
-
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1941,8 +1925,8 @@
song.pattNr++;
updatePtnLen();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
}
}
else
@@ -1954,8 +1938,8 @@
song.pattNr = editor.editPattern;
updatePtnLen();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
}
}
@@ -1965,18 +1949,7 @@
void pbEditPattDown(void)
{
- if (songPlaying)
- {
- if (song.pattNr == 0)
- return;
- }
- else
- {
- if (editor.editPattern == 0)
- return;
- }
-
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -1987,8 +1960,8 @@
song.pattNr--;
updatePtnLen();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
}
}
else
@@ -2000,8 +1973,8 @@
song.pattNr = editor.editPattern;
updatePtnLen();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
}
}
@@ -2011,27 +1984,21 @@
void pbPattLenUp(void)
{
- bool audioWasntLocked;
- uint16_t pattLen;
-
- if (pattLens[editor.editPattern] >= 256)
+ const uint16_t pattLen = pattLens[editor.editPattern];
+ if (pattLen >= 256)
return;
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
+
+ setPatternLen(editor.editPattern, pattLen + 1);
+ checkMarkLimits();
- pattLen = pattLens[editor.editPattern];
- if (pattLen < 256)
- {
- setPatternLen(editor.editPattern, pattLen + 1);
- checkMarkLimits();
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
+ setSongModifiedFlag();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
- setSongModifiedFlag();
- }
-
if (audioWasntLocked)
unlockAudio();
}
@@ -2038,27 +2005,21 @@
void pbPattLenDown(void)
{
- bool audioWasntLocked;
- uint16_t pattLen;
-
- if (pattLens[editor.editPattern] <= 1)
+ const uint16_t pattLen = pattLens[editor.editPattern];
+ if (pattLen <= 1)
return;
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
+
+ setPatternLen(editor.editPattern, pattLen - 1);
+ checkMarkLimits();
- pattLen = pattLens[editor.editPattern];
- if (pattLen > 1)
- {
- setPatternLen(editor.editPattern, pattLen - 1);
- checkMarkLimits();
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
+ setSongModifiedFlag();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
- setSongModifiedFlag();
- }
-
if (audioWasntLocked)
unlockAudio();
}
@@ -2076,7 +2037,7 @@
songPos = song.len - 1;
// clear
- if (editor.ui.extended)
+ if (ui.extended)
{
clearRect(8, 4, 39, 16);
fillRect(8, 23, 39, 7, PAL_DESKTOP);
@@ -2098,7 +2059,7 @@
assert(entry < 256);
- if (editor.ui.extended)
+ if (ui.extended)
{
pattTwoHexOut(8, 4 + (y * 9), (uint8_t)entry, color1);
pattTwoHexOut(32, 4 + (y * 9), song.songTab[entry], color1);
@@ -2113,7 +2074,7 @@
assert(songPos < 256);
// middle
- if (editor.ui.extended)
+ if (ui.extended)
{
pattTwoHexOut(8, 23, (uint8_t)songPos, color2);
pattTwoHexOut(32, 23, song.songTab[songPos], color2);
@@ -2131,7 +2092,7 @@
if (entry >= song.len)
break;
- if (editor.ui.extended)
+ if (ui.extended)
{
pattTwoHexOut(8, 33 + (y * 9), (uint8_t)entry, color1);
pattTwoHexOut(32, 33 + (y * 9), song.songTab[entry], color1);
@@ -2148,7 +2109,7 @@
{
int16_t x, y;
- if (editor.ui.extended)
+ if (ui.extended)
{
x = 165;
y = 5;
@@ -2166,7 +2127,7 @@
{
int16_t x, y;
- if (editor.ui.extended)
+ if (ui.extended)
{
x = 165;
y = 19;
@@ -2185,7 +2146,7 @@
char str[4];
const char *strOut;
- if (editor.ui.extended)
+ if (ui.extended)
return;
if (val <= 255)
@@ -2210,7 +2171,7 @@
void drawSongSpeed(uint16_t val)
{
- if (editor.ui.extended)
+ if (ui.extended)
return;
if (val > 99)
@@ -2223,7 +2184,7 @@
{
int16_t x, y;
- if (editor.ui.extended)
+ if (ui.extended)
{
x = 252;
y = 39;
@@ -2241,7 +2202,7 @@
{
int16_t x, y;
- if (editor.ui.extended)
+ if (ui.extended)
{
x = 326;
y = 39;
@@ -2257,7 +2218,7 @@
void drawGlobalVol(uint16_t val)
{
- if (editor.ui.extended)
+ if (ui.extended)
return;
assert(val <= 64);
@@ -2342,7 +2303,7 @@
int8_t i;
int16_t y;
- if (editor.ui.extended) // extended pattern editor
+ if (ui.extended) // extended pattern editor
{
//INSTRUMENTS
@@ -2449,13 +2410,13 @@
{
uint16_t i;
- if (!editor.ui.instrSwitcherShown)
+ if (!ui.instrSwitcherShown)
return;
for (i = 0; i < 8; i++)
showTextBox(TB_INST1 + i);
- if (editor.ui.extended)
+ if (ui.extended)
{
hidePushButton(PB_SAMPLE_LIST_UP);
hidePushButton(PB_SAMPLE_LIST_DOWN);
@@ -2531,7 +2492,7 @@
updateTextBoxPointers();
- if (editor.ui.instrSwitcherShown)
+ if (ui.instrSwitcherShown)
{
updateInstrumentSwitcher();
for (uint16_t i = 0; i < 8; i++)
@@ -2755,9 +2716,9 @@
updateSampleEditorSample();
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
updateSampleEditor();
- else if (editor.ui.instEditorShown || editor.ui.instEditorExtShown)
+ else if (ui.instEditorShown || ui.instEditorExtShown)
updateInstEditor();
unlockMixerCallback();
@@ -2816,11 +2777,11 @@
void resetChannelOffset(void)
{
- editor.ui.pattChanScrollShown = song.antChn > getMaxVisibleChannels();
- editor.cursor.object = CURSOR_NOTE;
- editor.cursor.ch = 0;
+ ui.pattChanScrollShown = song.antChn > getMaxVisibleChannels();
+ cursor.object = CURSOR_NOTE;
+ cursor.ch = 0;
setScrollBarPos(SB_CHAN_SCROLL, 0, true);
- editor.ui.channelOffset = 0;
+ ui.channelOffset = 0;
}
void shrinkPattern(void)
@@ -2859,8 +2820,8 @@
editor.pattPos = song.pattPos;
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
unlockMixerCallback();
setSongModifiedFlag();
@@ -2916,8 +2877,8 @@
editor.pattPos = song.pattPos;
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
unlockMixerCallback();
setSongModifiedFlag();
--- a/src/ft2_pattern_ed.h
+++ b/src/ft2_pattern_ed.h
@@ -52,10 +52,12 @@
uint16_t upperRowsY, midRowY, lowerRowsY;
} markCoord_t;
-struct pattMark_t
+typedef struct pattMark_t
{
int16_t markX1, markX2, markY1, markY2;
-} pattMark;
+} pattMark_t;
+
+extern pattMark_t pattMark; // ft2_pattern_ed.c
void resetPlaybackTime(void);
--- a/src/ft2_pushbuttons.c
+++ b/src/ft2_pushbuttons.c
@@ -29,6 +29,7 @@
#include "ft2_edit.h"
#include "ft2_sample_ed_features.h"
#include "ft2_palette.h"
+#include "ft2_structs.h"
pushButton_t pushButtons[NUM_PUSHBUTTONS] =
{
@@ -335,7 +336,7 @@
// ------ CONFIG MISCELLANEOUS PUSHBUTTONS ------
//x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
- { 113, 155, 93, 16, 0, 0, editor.ui.fullscreenButtonText, NULL, NULL, toggleFullScreen },
+ { 113, 155, 93, 16, 0, 0, ui.fullscreenButtonText, NULL, NULL, toggleFullScreen },
{ 370, 121, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configQuantizeUp, NULL },
{ 387, 121, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configQuantizeDown, NULL },
{ 594, 106, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDIChnUp, NULL },
@@ -560,7 +561,7 @@
uint16_t start, end;
pushButton_t *pushButton;
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
{
// if a system request is open, only test the first eight pushbuttons (reserved)
start = 0;
--- a/src/ft2_radiobuttons.c
+++ b/src/ft2_radiobuttons.c
@@ -16,6 +16,7 @@
#include "ft2_mouse.h"
#include "ft2_wav_renderer.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
radioButton_t radioButtons[NUM_RADIOBUTTONS] =
{
@@ -321,7 +322,7 @@
{
radioButton_t *radioButton;
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
return false;
for (uint16_t i = 0; i < NUM_RADIOBUTTONS; i++)
--- a/src/ft2_replayer.c
+++ b/src/ft2_replayer.c
@@ -19,6 +19,7 @@
#include "ft2_mouse.h"
#include "ft2_sample_loader.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
/* This is a *huge* mess, directly ported from the original FT2 code (and modified).
** You will experience a lot of headaches if you dig into it...
@@ -97,17 +98,14 @@
void resetChannels(void)
{
- bool audioWasntLocked;
- stmTyp *ch;
-
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
memset(stm, 0, sizeof (stm));
- for (uint8_t i = 0; i < MAX_VOICES; i++)
+ for (int32_t i = 0; i < MAX_VOICES; i++)
{
- ch = &stm[i];
+ stmTyp *ch = &stm[i];
ch->instrSeg = instr[0];
ch->status = IS_Vol;
@@ -153,14 +151,11 @@
void setPatternLen(uint16_t nr, int16_t len)
{
- bool audioWasntLocked;
-
assert(nr < MAX_PATTERNS);
-
if ((len < 1 || len > MAX_PATT_LEN) || len == pattLens[nr])
return;
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -181,8 +176,8 @@
if (audioWasntLocked)
unlockAudio();
- editor.ui.updatePatternEditor = true;
- editor.ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
}
int16_t getUsedSamples(int16_t nr)
@@ -298,7 +293,7 @@
resumeAudio();
// update "frequency table" radiobutton, if it's shown
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
setConfigIORadioButtonStates();
}
@@ -2185,7 +2180,7 @@
void resetMusic(void)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -2206,7 +2201,7 @@
void setPos(int16_t songPos, int16_t pattPos, bool resetTimer)
{
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -2236,7 +2231,7 @@
if (pattPos > -1)
{
editor.pattPos = (uint8_t)pattPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
if (songPos > -1)
@@ -2243,7 +2238,7 @@
{
editor.editPattern = (uint8_t)song.pattNr;
editor.songPos = song.songPos;
- editor.ui.updatePosSections = true;
+ ui.updatePosSections = true;
}
}
@@ -2373,19 +2368,16 @@
bool allocateInstr(int16_t nr)
{
- bool audioWasntLocked;
- instrTyp *p;
-
if (instr[nr] != NULL)
return false; // already allocated
- p = (instrTyp *)malloc(sizeof (instrTyp));
+ instrTyp *p = (instrTyp *)malloc(sizeof (instrTyp));
if (p == NULL)
return false;
memset(p, 0, sizeof (instrTyp));
- for (int8_t i = 0; i < 16; i++) // set standard sample pan/vol
+ for (int32_t i = 0; i < MAX_SMP_PER_INST; i++) // set standard sample pan/vol
{
p->samp[i].pan = 128;
p->samp[i].vol = 64;
@@ -2393,7 +2385,7 @@
setStdEnvelope(p, 0, 3);
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -2592,50 +2584,50 @@
else if (song.antChn >= 12) pageLen = 12;
}
- editor.ui.numChannelsShown = pageLen;
+ ui.numChannelsShown = pageLen;
if (song.antChn == 2)
- editor.ui.numChannelsShown = 2;
+ ui.numChannelsShown = 2;
if (config.ptnMaxChannels == 0)
{
- if (editor.ui.numChannelsShown > 4)
- editor.ui.numChannelsShown = 4;
+ if (ui.numChannelsShown > 4)
+ ui.numChannelsShown = 4;
}
else if (config.ptnMaxChannels == 1)
{
- if (editor.ui.numChannelsShown > 6)
- editor.ui.numChannelsShown = 6;
+ if (ui.numChannelsShown > 6)
+ ui.numChannelsShown = 6;
}
else if (config.ptnMaxChannels == 2)
{
- if (editor.ui.numChannelsShown > 8)
- editor.ui.numChannelsShown = 8;
+ if (ui.numChannelsShown > 8)
+ ui.numChannelsShown = 8;
}
else if (config.ptnMaxChannels == 3)
{
if (config.ptnS3M)
{
- if (editor.ui.numChannelsShown > 8)
- editor.ui.numChannelsShown = 8;
+ if (ui.numChannelsShown > 8)
+ ui.numChannelsShown = 8;
}
else
{
- if (editor.ui.numChannelsShown > 12)
- editor.ui.numChannelsShown = 12;
+ if (ui.numChannelsShown > 12)
+ ui.numChannelsShown = 12;
}
}
- editor.ui.pattChanScrollShown = song.antChn > getMaxVisibleChannels();
+ ui.pattChanScrollShown = song.antChn > getMaxVisibleChannels();
- if (editor.ui.patternEditorShown)
+ if (ui.patternEditorShown)
{
- if (editor.ui.channelOffset > song.antChn-editor.ui.numChannelsShown)
- setScrollBarPos(SB_CHAN_SCROLL, song.antChn - editor.ui.numChannelsShown, true);
+ if (ui.channelOffset > song.antChn-ui.numChannelsShown)
+ setScrollBarPos(SB_CHAN_SCROLL, song.antChn - ui.numChannelsShown, true);
}
- if (editor.ui.pattChanScrollShown)
+ if (ui.pattChanScrollShown)
{
- if (editor.ui.patternEditorShown)
+ if (ui.patternEditorShown)
{
showScrollBar(SB_CHAN_SCROLL);
showPushButton(PB_CHAN_SCROLL_LEFT);
@@ -2643,7 +2635,7 @@
}
setScrollBarEnd(SB_CHAN_SCROLL, song.antChn);
- setScrollBarPageLength(SB_CHAN_SCROLL, editor.ui.numChannelsShown);
+ setScrollBarPageLength(SB_CHAN_SCROLL, ui.numChannelsShown);
}
else
{
@@ -2653,11 +2645,11 @@
setScrollBarPos(SB_CHAN_SCROLL, 0, false);
- editor.ui.channelOffset = 0;
+ ui.channelOffset = 0;
}
- if (editor.cursor.ch >= editor.ui.channelOffset+editor.ui.numChannelsShown)
- editor.cursor.ch = editor.ui.channelOffset+editor.ui.numChannelsShown - 1;
+ if (cursor.ch >= ui.channelOffset+ui.numChannelsShown)
+ cursor.ch = ui.channelOffset+ui.numChannelsShown - 1;
}
void conv8BitSample(int8_t *p, int32_t len, bool stereo)
@@ -2822,8 +2814,8 @@
unlockMixerCallback();
- editor.ui.updatePosSections = true;
- editor.ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
}
void stopPlaying(void)
@@ -2862,13 +2854,13 @@
memset(editor.keyOnTab, 0, sizeof (editor.keyOnTab));
- editor.ui.updatePosSections = true;
- editor.ui.updatePatternEditor = true;
+ ui.updatePosSections = true;
+ ui.updatePatternEditor = true;
// certain non-FT2 fixes
song.timer = editor.timer = 1;
song.globVol = editor.globalVol = 64;
- editor.ui.drawGlobVolFlag = true;
+ ui.drawGlobVolFlag = true;
}
// from keyboard/smp. ed.
@@ -3064,16 +3056,13 @@
void stopVoices(void)
{
- bool audioWasntLocked;
- stmTyp *ch;
-
- audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
- for (uint8_t i = 0; i < MAX_VOICES; i++)
+ for (int32_t i = 0; i < MAX_VOICES; i++)
{
- ch = &stm[i];
+ stmTyp *ch = &stm[i];
lastChInstr[i].sampleNr = 255;
lastChInstr[i].instrNr = 255;
@@ -3121,7 +3110,7 @@
if (song.songPos == 0)
return;
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -3137,7 +3126,7 @@
if (song.songPos == song.len-1)
return;
- bool audioWasntLocked = !audio.locked;
+ const bool audioWasntLocked = !audio.locked;
if (audioWasntLocked)
lockAudio();
@@ -3162,7 +3151,7 @@
updateTextBoxPointers();
updateNewInstrument();
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
updateAdvEdit();
}
@@ -3182,7 +3171,7 @@
updateTextBoxPointers();
updateNewInstrument();
- if (editor.ui.advEditShown)
+ if (ui.advEditShown)
updateAdvEdit();
}
@@ -3304,7 +3293,7 @@
if (chSyncEntry != NULL)
{
handleScopesFromChQueue(chSyncEntry, scopeUpdateStatus);
- editor.ui.drawReplayerPianoFlag = true;
+ ui.drawReplayerPianoFlag = true;
}
if (!songPlaying || pattSyncEntry == NULL)
@@ -3317,25 +3306,25 @@
if (editor.speed != pattSyncEntry->speed)
{
editor.speed = pattSyncEntry->speed;
- editor.ui.drawBPMFlag = true;
+ ui.drawBPMFlag = true;
}
if (editor.tempo != pattSyncEntry->tempo)
{
editor.tempo = pattSyncEntry->tempo;
- editor.ui.drawSpeedFlag = true;
+ ui.drawSpeedFlag = true;
}
if (editor.globalVol != pattSyncEntry->globalVol)
{
editor.globalVol = pattSyncEntry->globalVol;
- editor.ui.drawGlobVolFlag = true;
+ ui.drawGlobVolFlag = true;
}
if (editor.songPos != pattSyncEntry->songPos)
{
editor.songPos = pattSyncEntry->songPos;
- editor.ui.drawPosEdFlag = true;
+ ui.drawPosEdFlag = true;
}
// somewhat of a kludge...
@@ -3344,10 +3333,10 @@
// set pattern number
editor.editPattern = editor.tmpPattern = pattSyncEntry->pattern;
checkMarkLimits();
- editor.ui.drawPattNumLenFlag = true;
+ ui.drawPattNumLenFlag = true;
// set row
editor.pattPos = (uint8_t)pattSyncEntry->patternPos;
- editor.ui.updatePatternEditor = true;
+ ui.updatePatternEditor = true;
}
}
--- a/src/ft2_sample_ed.c
+++ b/src/ft2_sample_ed.c
@@ -23,6 +23,7 @@
#include "ft2_mouse.h"
#include "ft2_diskop.h"
#include "ft2_keyboard.h"
+#include "ft2_structs.h"
static const char sharpNote1Char[12] = { 'C', 'C', 'D', 'D', 'E', 'F', 'F', 'G', 'G', 'A', 'A', 'B' };
static const char sharpNote2Char[12] = { '-', '#', '-', '#', '-', '-', '#', '-', '#', '-', '#', '-' };
@@ -400,10 +401,10 @@
bool showLoopPins = true;
s = getCurSample();
- if (s == NULL || s->len <= 0 || s->pek == NULL || (s->typ & 3) == 0 || !editor.ui.sampleEditorShown)
+ if (s == NULL || s->len <= 0 || s->pek == NULL || (s->typ & 3) == 0 || !ui.sampleEditorShown)
showLoopPins = false;
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
{
// draw Repeat/Replen. numbers
hexOutBg(536, 375, PAL_FORGRND, PAL_DESKTOP, curSmpRepS, 8);
@@ -577,7 +578,7 @@
uint32_t *ptr32;
// very first sample (rx1=0,rx2=0) is the "no range" special case
- if (!editor.ui.sampleEditorShown || smpEd_ViewSize == 0 || (smpEd_Rx1 == 0 && smpEd_Rx2 == 0))
+ if (!ui.sampleEditorShown || smpEd_ViewSize == 0 || (smpEd_Rx1 == 0 && smpEd_Rx2 == 0))
return;
// test if range is outside of view (passed it by scrolling)
@@ -1084,18 +1085,18 @@
}
// handle updating
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
{
// check if we need to redraw sample data
if (forceSmpRedraw || (old_SmpScrPos != smpEd_ScrPos || old_ViewSize != smpEd_ViewSize))
{
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
writeWaveform();
old_SmpScrPos = smpEd_ScrPos;
old_ViewSize = smpEd_ViewSize;
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
writeRange(); // range was overwritten, draw it again
smpEd_OldSmpPosLine = -1;
@@ -1114,7 +1115,7 @@
smpEd_Rx1 = old_Rx1;
smpEd_Rx2 = old_Rx2;
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
writeRange();
// write new range
@@ -1121,7 +1122,7 @@
smpEd_Rx1 = tmpRx1;
smpEd_Rx2 = tmpRx2;
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
writeRange();
old_Rx1 = smpEd_Rx1;
@@ -1131,7 +1132,7 @@
fixRepeatGadgets();
}
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
fixSampleDrag();
updateSampleEditor();
@@ -1191,7 +1192,7 @@
uint8_t note, typ;
int32_t sampleLen;
- if (!editor.ui.sampleEditorShown)
+ if (!ui.sampleEditorShown)
return;
if (instr[editor.curInstr] == NULL)
@@ -1344,17 +1345,17 @@
void sampPlayWave(void)
{
- playSample(editor.cursor.ch, editor.curInstr, editor.curSmp, editor.smpEd_NoteNr, 0, 0);
+ playSample(cursor.ch, editor.curInstr, editor.curSmp, editor.smpEd_NoteNr, 0, 0);
}
void sampPlayDisplay(void)
{
- playRange(editor.cursor.ch, editor.curInstr, editor.curSmp, editor.smpEd_NoteNr, 0, 0, smpEd_ScrPos, smpEd_ViewSize);
+ playRange(cursor.ch, editor.curInstr, editor.curSmp, editor.smpEd_NoteNr, 0, 0, smpEd_ScrPos, smpEd_ViewSize);
}
void sampPlayRange(void)
{
- playRange(editor.cursor.ch, editor.curInstr, editor.curSmp, editor.smpEd_NoteNr, 0, 0, smpEd_Rx1, smpEd_Rx2 - smpEd_Rx1);
+ playRange(cursor.ch, editor.curInstr, editor.curSmp, editor.smpEd_NoteNr, 0, 0, smpEd_Rx1, smpEd_Rx2 - smpEd_Rx1);
}
void showRange(void)
@@ -2813,7 +2814,7 @@
hideScrollBar(SB_SAMP_SCROLL);
- editor.ui.sampleEditorShown = false;
+ ui.sampleEditorShown = false;
hideSprite(SPRITE_LEFT_LOOP_PIN);
hideSprite(SPRITE_RIGHT_LOOP_PIN);
@@ -2823,7 +2824,7 @@
{
hideSampleEditor();
- if (editor.ui.sampleEditorExtShown)
+ if (ui.sampleEditorExtShown)
hideSampleEditorExt();
showPatternEditor();
@@ -2831,12 +2832,12 @@
void showSampleEditor(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideInstEditor();
hidePatternEditor();
- editor.ui.sampleEditorShown = true;
+ ui.sampleEditorShown = true;
drawFramework(0, 329, 632, 17, FRAMEWORK_TYPE1);
drawFramework(0, 346, 115, 54, FRAMEWORK_TYPE1);
@@ -2903,7 +2904,7 @@
{
hideInstEditor();
- if (editor.ui.sampleEditorShown)
+ if (ui.sampleEditorShown)
{
exitSampleEditor();
}
@@ -2980,7 +2981,7 @@
{
// update sample editor
- if (!editor.ui.sampleEditorShown || editor.samplingAudioFlag)
+ if (!ui.sampleEditorShown || editor.samplingAudioFlag)
return;
if (writeSampleFlag)
@@ -3262,9 +3263,9 @@
if (!mouseButtonHeld)
{
- editor.ui.rightLoopPinMoving = false;
- editor.ui.leftLoopPinMoving = false;
- editor.ui.sampleDataOrLoopDrag = -1;
+ ui.rightLoopPinMoving = false;
+ ui.leftLoopPinMoving = false;
+ ui.sampleDataOrLoopDrag = -1;
mouseXOffs = 0;
lastMouseX = mx;
@@ -3282,12 +3283,12 @@
{
mouseXOffs = (leftLoopPinPos + 8) - mx;
- editor.ui.sampleDataOrLoopDrag = true;
+ ui.sampleDataOrLoopDrag = true;
setLeftLoopPinState(true);
lastMouseX = mx;
- editor.ui.leftLoopPinMoving = true;
+ ui.leftLoopPinMoving = true;
return;
}
}
@@ -3298,12 +3299,12 @@
{
mouseXOffs = (rightLoopPinPos + 8) - mx;
- editor.ui.sampleDataOrLoopDrag = true;
+ ui.sampleDataOrLoopDrag = true;
setRightLoopPinState(true);
lastMouseX = mx;
- editor.ui.rightLoopPinMoving = true;
+ ui.rightLoopPinMoving = true;
return;
}
}
@@ -3310,7 +3311,7 @@
// mark data
lastMouseX = mx;
- editor.ui.sampleDataOrLoopDrag = mx;
+ ui.sampleDataOrLoopDrag = mx;
setSampleRange(mx, mx);
}
@@ -3317,7 +3318,7 @@
else if (mouse.rightButtonPressed)
{
// edit data
- editor.ui.sampleDataOrLoopDrag = true;
+ ui.sampleDataOrLoopDrag = true;
editSampleData(false);
}
@@ -3334,27 +3335,27 @@
{
if (mouse.leftButtonPressed)
{
- if (editor.ui.leftLoopPinMoving)
+ if (ui.leftLoopPinMoving)
{
lastMouseX = mx;
setLeftLoopPinPos(mouseXOffs + mx);
}
- else if (editor.ui.rightLoopPinMoving)
+ else if (ui.rightLoopPinMoving)
{
lastMouseX = mx;
setRightLoopPinPos(mouseXOffs + mx);
}
- else if (editor.ui.sampleDataOrLoopDrag >= 0)
+ else if (ui.sampleDataOrLoopDrag >= 0)
{
// mark data
lastMouseX = mx;
- if (lastMouseX > editor.ui.sampleDataOrLoopDrag)
- setSampleRange(editor.ui.sampleDataOrLoopDrag, mx);
- else if (lastMouseX == editor.ui.sampleDataOrLoopDrag)
- setSampleRange(editor.ui.sampleDataOrLoopDrag, editor.ui.sampleDataOrLoopDrag);
- else if (lastMouseX < editor.ui.sampleDataOrLoopDrag)
- setSampleRange(mx, editor.ui.sampleDataOrLoopDrag);
+ if (lastMouseX > ui.sampleDataOrLoopDrag)
+ setSampleRange(ui.sampleDataOrLoopDrag, mx);
+ else if (lastMouseX == ui.sampleDataOrLoopDrag)
+ setSampleRange(ui.sampleDataOrLoopDrag, ui.sampleDataOrLoopDrag);
+ else if (lastMouseX < ui.sampleDataOrLoopDrag)
+ setSampleRange(mx, ui.sampleDataOrLoopDrag);
}
}
}
@@ -3409,20 +3410,20 @@
hideTopScreen();
showTopScreen(false);
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
- if (!editor.ui.sampleEditorShown)
+ if (!ui.sampleEditorShown)
showSampleEditor();
- editor.ui.sampleEditorExtShown = true;
- editor.ui.scopesShown = false;
+ ui.sampleEditorExtShown = true;
+ ui.scopesShown = false;
drawSampleEditorExt();
}
void hideSampleEditorExt(void)
{
- editor.ui.sampleEditorExtShown = false;
+ ui.sampleEditorExtShown = false;
hidePushButton(PB_SAMP_EXT_CLEAR_COPYBUF);
hidePushButton(PB_SAMP_EXT_CONV);
@@ -3437,13 +3438,13 @@
hidePushButton(PB_SAMP_EXT_RESAMPLE);
hidePushButton(PB_SAMP_EXT_MIX_SAMPLE);
- editor.ui.scopesShown = true;
+ ui.scopesShown = true;
drawScopeFramework();
}
void toggleSampleEditorExt(void)
{
- if (editor.ui.sampleEditorExtShown)
+ if (ui.sampleEditorExtShown)
hideSampleEditorExt();
else
showSampleEditorExt();
--- a/src/ft2_sample_ed_features.c
+++ b/src/ft2_sample_ed_features.c
@@ -24,6 +24,7 @@
#include "ft2_sample_ed.h"
#include "ft2_keyboard.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
static volatile bool stopThread;
@@ -35,14 +36,14 @@
static void pbExit(void)
{
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
exitFlag = true;
}
static void windowOpen(void)
{
- editor.ui.sysReqShown = true;
- editor.ui.sysReqEnterPressed = false;
+ ui.sysReqShown = true;
+ ui.sysReqEnterPressed = false;
unstuckLastUsedGUIElement();
SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
@@ -108,7 +109,7 @@
{
outOfMemory = true;
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -188,7 +189,7 @@
setSongModifiedFlag();
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -346,10 +347,10 @@
outOfMemory = false;
exitFlag = false;
- while (editor.ui.sysReqShown)
+ while (ui.sysReqShown)
{
readInput();
- if (editor.ui.sysReqEnterPressed)
+ if (ui.sysReqEnterPressed)
pbDoResampling();
setSyncedReplayerVars();
@@ -456,7 +457,7 @@
if (echo_nEcho < 1)
{
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -472,7 +473,7 @@
if (nEchoes < 1)
{
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -499,7 +500,7 @@
{
outOfMemory = true;
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return false;
}
@@ -614,7 +615,7 @@
setSongModifiedFlag();
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -848,10 +849,10 @@
outOfMemory = false;
exitFlag = false;
- while (editor.ui.sysReqShown)
+ while (ui.sysReqShown)
{
readInput();
- if (editor.ui.sysReqEnterPressed)
+ if (ui.sysReqEnterPressed)
pbCreateEcho();
setSyncedReplayerVars();
@@ -895,7 +896,7 @@
if (destIns == mixIns && destSmp == mixSmp)
{
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -948,7 +949,7 @@
if (maxLen <= 0)
{
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -957,7 +958,7 @@
{
outOfMemory = true;
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -965,7 +966,7 @@
{
outOfMemory = true;
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -1023,7 +1024,7 @@
setSongModifiedFlag();
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return true;
}
@@ -1165,10 +1166,10 @@
outOfMemory = false;
exitFlag = false;
- while (editor.ui.sysReqShown)
+ while (ui.sysReqShown)
{
readInput();
- if (editor.ui.sysReqEnterPressed)
+ if (ui.sysReqEnterPressed)
pbMix();
setSyncedReplayerVars();
@@ -1346,7 +1347,7 @@
applyVolumeExit:
setMouseBusy(false);
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
(void)ptr;
return true;
@@ -1356,7 +1357,7 @@
{
if (vol_StartVol == 100 && vol_EndVol == 100)
{
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
return; // no volume change to be done
}
@@ -1692,10 +1693,10 @@
windowOpen();
exitFlag = false;
- while (editor.ui.sysReqShown)
+ while (ui.sysReqShown)
{
readInput();
- if (editor.ui.sysReqEnterPressed)
+ if (ui.sysReqEnterPressed)
{
pbApplyVolume();
keyb.ignoreCurrKeyUp = true; // don't handle key up event for this key release
@@ -1705,7 +1706,7 @@
handleRedrawing();
// this is needed for the "Get maximum scale" button
- if (editor.ui.setMouseIdle) mouseAnimOff();
+ if (ui.setMouseIdle) mouseAnimOff();
drawSampleVolumeBox();
setScrollBarPos(0, 500 + vol_StartVol, false);
--- a/src/ft2_sample_loader.c
+++ b/src/ft2_sample_loader.c
@@ -14,6 +14,7 @@
#include "ft2_sample_ed.h"
#include "ft2_mouse.h"
#include "ft2_diskop.h"
+#include "ft2_structs.h"
/* All of these routines were written from scratch and were not present
** in original FT2.
--- a/src/ft2_sample_saver.c
+++ b/src/ft2_sample_saver.c
@@ -14,6 +14,7 @@
#include "ft2_sample_ed.h"
#include "ft2_diskop.h"
#include "ft2_mouse.h"
+#include "ft2_structs.h"
typedef struct wavHeader_t
{
--- a/src/ft2_sampling.c
+++ b/src/ft2_sampling.c
@@ -11,6 +11,7 @@
#include "ft2_sample_ed.h"
#include "ft2_video.h"
#include "ft2_sampling.h"
+#include "ft2_structs.h"
// these may very well change after opening the audio input device
#define SAMPLING_BUFFER_SIZE 2048
--- a/src/ft2_scopes.c
+++ b/src/ft2_scopes.c
@@ -21,6 +21,7 @@
#include "ft2_video.h"
#include "ft2_scopedraw.h"
#include "ft2_tables.h"
+#include "ft2_structs.h"
enum
{
@@ -273,7 +274,7 @@
const uint16_t *scopeLens;
int32_t i, chansPerRow, chanToToggle;
- if (!editor.ui.scopesShown)
+ if (!ui.scopesShown)
return false;
if (mouse.y >= 95 && mouse.y <= 169 && mouse.x >= 3 && mouse.x <= 288)
--- a/src/ft2_scrollbars.c
+++ b/src/ft2_scrollbars.c
@@ -19,6 +19,7 @@
#include "ft2_mouse.h"
#include "ft2_video.h"
#include "ft2_palette.h"
+#include "ft2_structs.h"
/* Prevent the scrollbar thumbs from being so small that
** it's difficult to use them. In units of pixels.
@@ -501,7 +502,7 @@
double dTmp;
scrollBar_t *scrollBar;
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
{
// if a system request is open, only test the first three scrollbars (reserved)
start = 0;
--- /dev/null
+++ b/src/ft2_structs.c
@@ -1,0 +1,6 @@
+#include "ft2_structs.h"
+
+cpu_t cpu;
+editor_t editor;
+ui_t ui;
+cursor_t cursor;
--- /dev/null
+++ b/src/ft2_structs.h
@@ -1,0 +1,82 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ft2_header.h"
+
+typedef struct cpu_t
+{
+ bool hasSSE, hasSSE2;
+} cpu_t;
+
+typedef struct editor_t
+{
+ UNICHAR binaryPathU[PATH_MAX + 2];
+ UNICHAR *tmpFilenameU, *tmpInstrFilenameU; // used by saving/loading threads
+ UNICHAR *configFileLocation, *audioDevConfigFileLocation, *midiConfigFileLocation;
+
+ volatile bool mainLoopOngoing;
+ volatile bool busy, scopeThreadMutex, programRunning, wavIsRendering, wavReachedEndFlag;
+ volatile bool updateCurSmp, updateCurInstr, diskOpReadDir, diskOpReadDone, updateWindowTitle;
+ volatile uint8_t loadMusicEvent;
+ volatile FILE *wavRendererFileHandle;
+
+ bool autoPlayOnDrop, trimThreadWasDone, throwExit, editTextFlag;
+ bool copyMaskEnable, diskOpReadOnOpen, samplingAudioFlag, editSampleFlag;
+ bool instrBankSwapped, chnMode[MAX_VOICES], NI_Play;
+
+ uint8_t curPlayInstr, curPlaySmp, curSmpChannel, currPanEnvPoint, currVolEnvPoint;
+ uint8_t copyMask[5], pasteMask[5], transpMask[5], smpEd_NoteNr, instrBankOffset, sampleBankOffset;
+ uint8_t srcInstr, curInstr, srcSmp, curSmp, currHelpScreen, currConfigScreen, textCursorBlinkCounter;
+ uint8_t keyOnTab[MAX_VOICES], ID_Add, curOctave;
+ uint8_t sampleSaveMode, moduleSaveMode, ptnJumpPos[4];
+ int16_t globalVol, songPos, pattPos;
+ uint16_t tmpPattern, editPattern, speed, tempo, timer, ptnCursorY;
+ int32_t keyOffNr, keyOffTime[MAX_VOICES];
+ uint32_t framesPassed, wavRendererTime;
+ double dPerfFreq, dPerfFreqMulMicro, dPerfFreqMulMs;
+} editor_t;
+
+typedef struct ui_t
+{
+ volatile bool setMouseBusy, setMouseIdle;
+ bool sysReqEnterPressed;
+ char fullscreenButtonText[24];
+
+ // all screens
+ bool extended, sysReqShown;
+
+ // top screens
+ bool instrSwitcherShown, aboutScreenShown, helpScreenShown, configScreenShown;
+ bool scopesShown, diskOpShown, nibblesShown, transposeShown, instEditorExtShown;
+ bool sampleEditorExtShown, advEditShown, wavRendererShown, trimScreenShown;
+ bool drawBPMFlag, drawSpeedFlag, drawGlobVolFlag, drawPosEdFlag, drawPattNumLenFlag;
+ bool updatePosSections, updatePosEdScrollBar;
+ uint8_t oldTopLeftScreen;
+
+ // bottom screens
+ bool patternEditorShown, instEditorShown, sampleEditorShown, pattChanScrollShown;
+ bool leftLoopPinMoving, rightLoopPinMoving;
+ bool drawReplayerPianoFlag, drawPianoFlag, updatePatternEditor;
+ uint8_t channelOffset, numChannelsShown, maxVisibleChannels;
+ uint16_t patternChannelWidth;
+ int32_t sampleDataOrLoopDrag;
+
+ // backup flag for when entering/exiting extended pattern editor (TODO: this is lame and shouldn't be hardcoded)
+ bool _aboutScreenShown, _helpScreenShown, _configScreenShown, _diskOpShown;
+ bool _nibblesShown, _transposeShown, _instEditorShown;
+ bool _instEditorExtShown, _sampleEditorExtShown, _patternEditorShown;
+ bool _sampleEditorShown, _advEditShown, _wavRendererShown, _trimScreenShown;
+ // -------------------------------------------------------------------------
+} ui_t;
+
+typedef struct cursor_t
+{
+ uint8_t ch;
+ int8_t object;
+} cursor_t;
+
+extern cpu_t cpu;
+extern editor_t editor;
+extern ui_t ui;
+extern cursor_t cursor;
--- a/src/ft2_sysreqs.c
+++ b/src/ft2_sysreqs.c
@@ -6,6 +6,8 @@
#include "ft2_keyboard.h"
#include "ft2_textboxes.h"
#include "ft2_video.h"
+#include "ft2_sysreqs.h"
+#include "ft2_structs.h"
#define SYSTEM_REQUEST_H 67
#define SYSTEM_REQUEST_Y 249
@@ -13,6 +15,8 @@
#define NUM_SYSREQ_TYPES 10
+okBoxData_t okBoxData; // globalized
+
static char *buttonText[NUM_SYSREQ_TYPES][5] =
{
{ "OK", "","","","" },
@@ -75,8 +79,8 @@
const uint16_t h = SYSTEM_REQUEST_H;
uint16_t x, y;
- x = (SCREEN_W - w) / 2;
- y = editor.ui.extended ? 91 : SYSTEM_REQUEST_Y;
+ x = (SCREEN_W - w) >> 1;
+ y = ui.extended ? 91 : SYSTEM_REQUEST_Y;
// main fill
fillRect(x + 1, y + 1, w - 2, h - 2, PAL_BUTTONS);
@@ -168,12 +172,12 @@
if (mouse.mode != MOUSE_MODE_NORMAL)
setMouseMode(MOUSE_MODE_NORMAL);
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
return 0;
SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
- editor.ui.sysReqShown = true;
+ ui.sysReqShown = true;
mouseAnimOff();
oldLastUsedObjectID = mouse.lastUsedObjectID;
@@ -204,7 +208,7 @@
x = (SCREEN_W - wlen) >> 1;
// the box y position differs in extended pattern editor mode
- y = editor.ui.extended ? SYSTEM_REQUEST_Y_EXT : SYSTEM_REQUEST_Y;
+ y = ui.extended ? SYSTEM_REQUEST_Y_EXT : SYSTEM_REQUEST_Y;
// set up buttons
for (i = 0; i < knp; i++)
@@ -250,7 +254,7 @@
// input/rendering loop
returnVal = 0;
- while (editor.ui.sysReqShown)
+ while (ui.sysReqShown)
{
beginFPSCounter();
readMouseXY();
@@ -271,12 +275,12 @@
if (inputEvent.key.keysym.sym == SDLK_ESCAPE)
{
returnVal = 0;
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
}
else if (inputEvent.key.keysym.sym == SDLK_RETURN)
{
returnVal = 1;
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
keyb.ignoreCurrKeyUp = true; // don't handle key up event for any keys that were pressed
}
@@ -285,7 +289,7 @@
if (shortCut[typ][i] == inputEvent.key.keysym.sym)
{
returnVal = i + 1;
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
keyb.ignoreCurrKeyUp = true; // don't handle key up event for any keys that were pressed
break;
}
@@ -300,7 +304,7 @@
returnVal = testPushButtonMouseRelease(false) + 1;
if (returnVal > 0)
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
mouse.lastUsedObjectID = OBJECT_ID_NONE;
mouse.lastUsedObjectType = OBJECT_NONE;
@@ -315,11 +319,11 @@
}
}
- if (!editor.ui.sysReqShown)
+ if (!ui.sysReqShown)
break;
}
- if (!editor.ui.sysReqShown)
+ if (!ui.sysReqShown)
break;
handleRedrawing();
@@ -378,7 +382,7 @@
if (mouse.mode != MOUSE_MODE_NORMAL)
setMouseMode(MOUSE_MODE_NORMAL);
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
return 0;
oldLastUsedObjectID = mouse.lastUsedObjectID;
@@ -408,7 +412,7 @@
SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
- editor.ui.sysReqShown = true;
+ ui.sysReqShown = true;
mouseAnimOff();
wlen = textWidth(headline);
@@ -432,7 +436,7 @@
wlen = 600;
// the box y position differs in extended pattern editor mode
- y = editor.ui.extended ? SYSTEM_REQUEST_Y_EXT : SYSTEM_REQUEST_Y;
+ y = ui.extended ? SYSTEM_REQUEST_Y_EXT : SYSTEM_REQUEST_Y;
// set further text box settings
t->x = (SCREEN_W - TEXTBOX_W) >> 1;
@@ -466,7 +470,7 @@
// input/rendering loop
returnVal = 0;
- while (editor.ui.sysReqShown)
+ while (ui.sysReqShown)
{
beginFPSCounter();
readMouseXY();
@@ -508,12 +512,12 @@
if (inputEvent.key.keysym.sym == SDLK_ESCAPE)
{
returnVal = 0;
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
}
else if (inputEvent.key.keysym.sym == SDLK_RETURN)
{
returnVal = 1;
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
keyb.ignoreCurrKeyUp = true; // don't handle key up event for any keys that were pressed
}
@@ -528,7 +532,7 @@
if (shortCut[1][i] == inputEvent.key.keysym.sym)
{
returnVal = i + 1;
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
keyb.ignoreCurrKeyUp = true; // don't handle key up event for any keys that were pressed
break;
}
@@ -541,7 +545,7 @@
{
returnVal = testPushButtonMouseRelease(false) + 1;
if (returnVal > 0)
- editor.ui.sysReqShown = false;
+ ui.sysReqShown = false;
mouse.lastUsedObjectID = OBJECT_ID_NONE;
mouse.lastUsedObjectType = OBJECT_NONE;
@@ -556,11 +560,11 @@
}
}
- if (!editor.ui.sysReqShown)
+ if (!ui.sysReqShown)
break;
}
- if (!editor.ui.sysReqShown)
+ if (!ui.sysReqShown)
break;
handleRedrawing();
@@ -648,7 +652,7 @@
int16_t quitBox(bool skipQuitMsg)
{
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
return 0;
if (!song.isModified && skipQuitMsg)
--- a/src/ft2_sysreqs.h
+++ b/src/ft2_sysreqs.h
@@ -10,12 +10,14 @@
bool askUnsavedChanges(uint8_t type);
// for thread-safe version of okBox()
-struct
+typedef struct okBoxData_t
{
volatile bool active;
int16_t typ, returnData;
const char *headline, *text;
-} okBoxData;
+} okBoxData_t;
+
+extern okBoxData_t okBoxData; // ft2_sysreqs.c
enum
{
--- a/src/ft2_textboxes.c
+++ b/src/ft2_textboxes.c
@@ -13,6 +13,7 @@
#include "ft2_keyboard.h"
#include "ft2_mouse.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
textBox_t textBoxes[NUM_TEXTBOXES] =
{
@@ -699,7 +700,7 @@
oldMouseX = mouse.x;
oldCursorPos = 0;
- if (editor.ui.sysReqShown)
+ if (ui.sysReqShown)
{
// if a system request is open, only test the first textbox (reserved)
start = 0;
--- a/src/ft2_trim.c
+++ b/src/ft2_trim.c
@@ -15,6 +15,7 @@
#include "ft2_replayer.h"
#include "ft2_audio.h"
#include "ft2_mouse.h"
+#include "ft2_structs.h"
// this is truly a mess, but it works...
@@ -999,14 +1000,14 @@
if (removeChans)
{
- if (editor.ui.patternEditorShown)
+ if (ui.patternEditorShown)
{
- if (editor.ui.channelOffset > song.antChn-editor.ui.numChannelsShown)
- setScrollBarPos(SB_CHAN_SCROLL, song.antChn - editor.ui.numChannelsShown, true);
+ if (ui.channelOffset > song.antChn-ui.numChannelsShown)
+ setScrollBarPos(SB_CHAN_SCROLL, song.antChn - ui.numChannelsShown, true);
}
- if (editor.cursor.ch >= editor.ui.channelOffset+editor.ui.numChannelsShown)
- editor.cursor.ch = editor.ui.channelOffset+editor.ui.numChannelsShown - 1;
+ if (cursor.ch >= ui.channelOffset+ui.numChannelsShown)
+ cursor.ch = ui.channelOffset+ui.numChannelsShown - 1;
}
checkMarkLimits();
@@ -1137,21 +1138,21 @@
hidePushButton(PB_TRIM_CALC);
hidePushButton(PB_TRIM_TRIM);
- editor.ui.trimScreenShown = false;
- editor.ui.scopesShown = true;
+ ui.trimScreenShown = false;
+ ui.scopesShown = true;
drawScopeFramework();
}
void showTrimScreen(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
showTopScreen(false);
- editor.ui.trimScreenShown = true;
- editor.ui.scopesShown = false;
+ ui.trimScreenShown = true;
+ ui.scopesShown = false;
drawTrimScreen();
}
@@ -1158,7 +1159,7 @@
void toggleTrimScreen(void)
{
- if (editor.ui.trimScreenShown)
+ if (ui.trimScreenShown)
hideTrimScreen();
else
showTrimScreen();
@@ -1220,7 +1221,7 @@
if (xmAfterTrimSize64 < 0)
xmAfterTrimSize64 = 0;
- if (editor.ui.trimScreenShown)
+ if (ui.trimScreenShown)
drawTrimScreen();
}
@@ -1252,6 +1253,6 @@
xmAfterTrimSize64 = -1;
spaceSaved64 = -1;
- if (editor.ui.trimScreenShown)
+ if (ui.trimScreenShown)
drawTrimScreen();
}
--- a/src/ft2_unicode.h
+++ b/src/ft2_unicode.h
@@ -17,7 +17,7 @@
#define UNICHAR_STRCMP(a, b) wcscmp(a, b)
#define UNICHAR_STRNCMP(a, b, c) wcsncmp(a, b, c)
#define UNICHAR_STRCAT(a, b) wcscat(a, b)
-#define UNICHAR_STRDUP(a) wcsdup(a)
+#define UNICHAR_STRDUP(a) _wcsdup(a)
#define UNICHAR_FOPEN(a, b) _wfopen(a, L ## b)
#define UNICHAR_CHDIR(a) _wchdir(a)
#define UNICHAR_GETCWD(a, b) _wgetcwd(a, b)
--- a/src/ft2_video.c
+++ b/src/ft2_video.c
@@ -33,6 +33,7 @@
#include "ft2_module_loader.h"
#include "ft2_midi.h"
#include "ft2_bmp.h"
+#include "ft2_structs.h"
static const uint8_t textCursorData[12] =
{
@@ -42,6 +43,8 @@
PAL_FORGRND, PAL_FORGRND, PAL_FORGRND
};
+video_t video; // globalized
+
static bool songIsModified;
static char wndTitle[128 + PATH_MAX];
static uint64_t timeNext64, timeNext64Frac;
@@ -282,8 +285,8 @@
{
SDL_DisplayMode dm;
- strcpy(editor.ui.fullscreenButtonText, "Go windowed");
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MISCELLANEOUS)
+ strcpy(ui.fullscreenButtonText, "Go windowed");
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MISCELLANEOUS)
showConfigScreen(); // redraw so that we can see the new button text
if (config.windowFlags & FILTERING)
@@ -307,8 +310,8 @@
void leaveFullScreen(void)
{
- strcpy(editor.ui.fullscreenButtonText, "Go fullscreen");
- if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MISCELLANEOUS)
+ strcpy(ui.fullscreenButtonText, "Go fullscreen");
+ if (ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_MISCELLANEOUS)
showConfigScreen(); // redraw so that we can see the new button text
SDL_SetWindowFullscreen(video.window, 0);
@@ -1034,13 +1037,13 @@
{
textBox_t *txt;
- if (!editor.ui.configScreenShown && !editor.ui.helpScreenShown)
+ if (!ui.configScreenShown && !ui.helpScreenShown)
{
- if (editor.ui.aboutScreenShown)
+ if (ui.aboutScreenShown)
{
aboutFrame();
}
- else if (editor.ui.nibblesShown)
+ else if (ui.nibblesShown)
{
if (editor.NI_Play)
moveNibblePlayers();
@@ -1047,11 +1050,11 @@
}
else
{
- if (editor.ui.updatePosSections)
+ if (ui.updatePosSections)
{
- editor.ui.updatePosSections = false;
+ ui.updatePosSections = false;
- if (!editor.ui.diskOpShown)
+ if (!ui.diskOpShown)
{
drawSongRepS();
drawSongLength();
@@ -1066,7 +1069,7 @@
setScrollBarPos(SB_POS_ED, editor.songPos, false);
// draw current mode text (not while in extended pattern editor mode)
- if (!editor.ui.extended)
+ if (!ui.extended)
{
fillRect(115, 80, 74, 10, PAL_DESKTOP);
@@ -1078,21 +1081,21 @@
}
}
- if (editor.ui.updatePosEdScrollBar)
+ if (ui.updatePosEdScrollBar)
{
- editor.ui.updatePosEdScrollBar = false;
+ ui.updatePosEdScrollBar = false;
setScrollBarPos(SB_POS_ED, song.songPos, false);
setScrollBarEnd(SB_POS_ED, (song.len - 1) + 5);
}
- if (!editor.ui.extended)
+ if (!ui.extended)
{
- if (!editor.ui.diskOpShown)
+ if (!ui.diskOpShown)
drawPlaybackTime();
- if (editor.ui.sampleEditorExtShown)
+ if (ui.sampleEditorExtShown)
handleSampleEditorExtRedrawing();
- else if (editor.ui.scopesShown)
+ else if (ui.scopesShown)
drawScopes();
}
}
@@ -1100,9 +1103,9 @@
drawReplayerData();
- if (editor.ui.instEditorShown)
+ if (ui.instEditorShown)
handleInstEditorRedrawing();
- else if (editor.ui.sampleEditorShown)
+ else if (ui.sampleEditorShown)
handleSamplerRedrawing();
// blink text edit cursor
@@ -1131,17 +1134,17 @@
if (songPlaying)
{
- if (editor.ui.drawReplayerPianoFlag)
+ if (ui.drawReplayerPianoFlag)
{
- editor.ui.drawReplayerPianoFlag = false;
- if (editor.ui.instEditorShown && chSyncEntry != NULL)
+ ui.drawReplayerPianoFlag = false;
+ if (ui.instEditorShown && chSyncEntry != NULL)
drawPiano(chSyncEntry);
}
drawPosText = true;
- if (editor.ui.configScreenShown || editor.ui.nibblesShown ||
- editor.ui.helpScreenShown || editor.ui.aboutScreenShown ||
- editor.ui.diskOpShown)
+ if (ui.configScreenShown || ui.nibblesShown ||
+ ui.helpScreenShown || ui.aboutScreenShown ||
+ ui.diskOpShown)
{
drawPosText = false;
}
@@ -1148,49 +1151,49 @@
if (drawPosText)
{
- if (editor.ui.drawBPMFlag)
+ if (ui.drawBPMFlag)
{
- editor.ui.drawBPMFlag = false;
+ ui.drawBPMFlag = false;
drawSongBPM(editor.speed);
}
- if (editor.ui.drawSpeedFlag)
+ if (ui.drawSpeedFlag)
{
- editor.ui.drawSpeedFlag = false;
+ ui.drawSpeedFlag = false;
drawSongSpeed(editor.tempo);
}
- if (editor.ui.drawGlobVolFlag)
+ if (ui.drawGlobVolFlag)
{
- editor.ui.drawGlobVolFlag = false;
+ ui.drawGlobVolFlag = false;
drawGlobalVol(editor.globalVol);
}
- if (editor.ui.drawPosEdFlag)
+ if (ui.drawPosEdFlag)
{
- editor.ui.drawPosEdFlag = false;
+ ui.drawPosEdFlag = false;
drawPosEdNums(editor.songPos);
setScrollBarPos(SB_POS_ED, editor.songPos, false);
}
- if (editor.ui.drawPattNumLenFlag)
+ if (ui.drawPattNumLenFlag)
{
- editor.ui.drawPattNumLenFlag = false;
+ ui.drawPattNumLenFlag = false;
drawEditPattern(editor.editPattern);
drawPatternLength(editor.editPattern);
}
}
}
- else if (editor.ui.instEditorShown)
+ else if (ui.instEditorShown)
{
drawPiano(NULL);
}
// handle pattern data updates
- if (editor.ui.updatePatternEditor)
+ if (ui.updatePatternEditor)
{
- editor.ui.updatePatternEditor = false;
- if (editor.ui.patternEditorShown)
+ ui.updatePatternEditor = false;
+ if (ui.patternEditorShown)
writePattern(editor.pattPos, editor.editPattern);
}
}
--- a/src/ft2_video.h
+++ b/src/ft2_video.h
@@ -16,7 +16,7 @@
SPRITE_NUM
};
-struct video_t
+typedef struct video_t
{
bool fullscreen, showFPSCounter;
uint32_t xScale, yScale;
@@ -33,7 +33,7 @@
SDL_Renderer *renderer;
SDL_Texture *texture;
SDL_Surface *iconSurface;
-} video;
+} video_t;
typedef struct
{
@@ -43,6 +43,8 @@
int16_t newX, newY, x, y;
uint16_t w, h;
} sprite_t;
+
+extern video_t video; // ft2_video.c
void resetFPSCounter(void);
void beginFPSCounter(void);
--- a/src/ft2_wav_renderer.c
+++ b/src/ft2_wav_renderer.c
@@ -17,6 +17,7 @@
#include "ft2_inst_ed.h"
#include "ft2_audio.h"
#include "ft2_wav_renderer.h"
+#include "ft2_structs.h"
#define TICKS_PER_RENDER_CHUNK 64
@@ -117,20 +118,20 @@
WDStartPos = 0;
WDStopPos = (uint8_t)song.len - 1;
- if (editor.ui.wavRendererShown)
+ if (ui.wavRendererShown)
updateWavRenderer();
}
void showWavRenderer(void)
{
- if (editor.ui.extended)
+ if (ui.extended)
exitPatternEditorExtended();
hideTopScreen();
showTopScreen(false);
- editor.ui.wavRendererShown = true;
- editor.ui.scopesShown = false;
+ ui.wavRendererShown = true;
+ ui.scopesShown = false;
WDStartPos = 0;
WDStopPos = (uint8_t)song.len - 1;
@@ -140,7 +141,7 @@
void hideWavRenderer(void)
{
- editor.ui.wavRendererShown = false;
+ ui.wavRendererShown = false;
hidePushButton(PB_WAV_RENDER);
hidePushButton(PB_WAV_EXIT);
@@ -154,7 +155,7 @@
hidePushButton(PB_WAV_END_DOWN);
hideRadioButtonGroup(RB_GROUP_WAV_RENDER_BITDEPTH);
- editor.ui.scopesShown = true;
+ ui.scopesShown = true;
drawScopeFramework();
}
@@ -288,13 +289,13 @@
editor.tempo = song.tempo;
editor.globalVol = song.globVol;
- editor.ui.drawPosEdFlag = true;
- editor.ui.drawPattNumLenFlag = true;
- editor.ui.drawReplayerPianoFlag = true;
- editor.ui.drawBPMFlag = true;
- editor.ui.drawSpeedFlag = true;
- editor.ui.drawGlobVolFlag = true;
- editor.ui.updatePatternEditor = true;
+ ui.drawPosEdFlag = true;
+ ui.drawPattNumLenFlag = true;
+ ui.drawReplayerPianoFlag = true;
+ ui.drawBPMFlag = true;
+ ui.drawSpeedFlag = true;
+ ui.drawGlobVolFlag = true;
+ ui.updatePatternEditor = true;
drawPlaybackTime();
}
--- a/vs2019_project/ft2-clone/ft2-clone.vcxproj
+++ b/vs2019_project/ft2-clone/ft2-clone.vcxproj
@@ -27,13 +27,13 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<PlatformToolset>v142</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
+ <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
@@ -94,7 +94,6 @@
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__WINDOWS_MM__;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;HAVE_M_PI;HAS_MIDI</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
- <CompileAsManaged>false</CompileAsManaged>
<IntrinsicFunctions>true</IntrinsicFunctions>
<StringPooling>true</StringPooling>
<MinimalRebuild>false</MinimalRebuild>
@@ -101,31 +100,24 @@
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <ExceptionHandling>false</ExceptionHandling>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<FloatingPointModel>Fast</FloatingPointModel>
- <EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
- <FloatingPointExceptions>false</FloatingPointExceptions>
<OmitFramePointers>true</OmitFramePointers>
<CompileAsWinRT>false</CompileAsWinRT>
- <ControlFlowGuard>false</ControlFlowGuard>
- <CreateHotpatchableImage>false</CreateHotpatchableImage>
- <RuntimeTypeInfo>false</RuntimeTypeInfo>
- <OpenMPSupport>false</OpenMPSupport>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<DebugInformationFormat>None</DebugInformationFormat>
- <LanguageStandard>stdcpplatest</LanguageStandard>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
- <AdditionalDependencies>SDL2main.lib;SDL2.lib;winmm.lib;shlwapi.lib;libcmt.lib;libvcruntime.lib;libucrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <IgnoreSpecificDefaultLibraries>
- </IgnoreSpecificDefaultLibraries>
- <AdditionalOptions>/NODEFAULTLIB:MSVCRT "notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>SDL2main.lib;SDL2.lib;winmm.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <AdditionalOptions>"notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
<MinimumRequiredVersion>5.1</MinimumRequiredVersion>
<FullProgramDatabaseFile>
@@ -133,10 +125,11 @@
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
- <DataExecutionPrevention>false</DataExecutionPrevention>
- <ImageHasSafeExceptionHandlers>true</ImageHasSafeExceptionHandlers>
<LargeAddressAware>true</LargeAddressAware>
<GenerateDebugInformation>false</GenerateDebugInformation>
+ <SetChecksum>true</SetChecksum>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ <FixedBaseAddress>false</FixedBaseAddress>
</Link>
<PostBuildEvent />
<Manifest />
@@ -143,6 +136,9 @@
<Manifest>
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
</Manifest>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -152,38 +148,29 @@
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__WINDOWS_MM__;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;HAVE_M_PI;HAS_MIDI</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
- <CompileAsManaged>false</CompileAsManaged>
<IntrinsicFunctions>true</IntrinsicFunctions>
<StringPooling>true</StringPooling>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <ExceptionHandling>false</ExceptionHandling>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<FloatingPointModel>Fast</FloatingPointModel>
- <EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
- <FloatingPointExceptions>false</FloatingPointExceptions>
<OmitFramePointers>true</OmitFramePointers>
- <CompileAsWinRT>false</CompileAsWinRT>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
- <ControlFlowGuard>false</ControlFlowGuard>
- <CreateHotpatchableImage>false</CreateHotpatchableImage>
- <RuntimeTypeInfo>false</RuntimeTypeInfo>
- <OpenMPSupport>false</OpenMPSupport>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<BufferSecurityCheck>false</BufferSecurityCheck>
<DebugInformationFormat>None</DebugInformationFormat>
- <LanguageStandard>stdcpplatest</LanguageStandard>
+ <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
- <AdditionalDependencies>SDL2main.lib;SDL2.lib;winmm.lib;shlwapi.lib;libcmt.lib;libvcruntime.lib;libucrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>SDL2main.lib;SDL2.lib;winmm.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
- <IgnoreSpecificDefaultLibraries>
- </IgnoreSpecificDefaultLibraries>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AdditionalOptions>/NODEFAULTLIB:MSVCRT "notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
<MinimumRequiredVersion>
@@ -193,11 +180,12 @@
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
- <DataExecutionPrevention>false</DataExecutionPrevention>
<ImageHasSafeExceptionHandlers>
</ImageHasSafeExceptionHandlers>
<LargeAddressAware>true</LargeAddressAware>
<GenerateDebugInformation>false</GenerateDebugInformation>
+ <SetChecksum>true</SetChecksum>
+ <FixedBaseAddress>false</FixedBaseAddress>
</Link>
<PostBuildEvent>
<Message>
@@ -208,7 +196,7 @@
<Manifest />
<ResourceCompile />
<ResourceCompile>
- <PreprocessorDefinitions>_WIN64</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN64;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Manifest />
<Manifest>
@@ -359,6 +347,7 @@
<ClCompile Include="..\..\src\ft2_scopedraw.c" />
<ClCompile Include="..\..\src\ft2_scopes.c" />
<ClCompile Include="..\..\src\ft2_scrollbars.c" />
+ <ClCompile Include="..\..\src\ft2_structs.c" />
<ClCompile Include="..\..\src\ft2_sysreqs.c" />
<ClCompile Include="..\..\src\ft2_tables.c" />
<ClCompile Include="..\..\src\ft2_textboxes.c" />
@@ -430,6 +419,7 @@
<ClInclude Include="..\..\src\ft2_scopedraw.h" />
<ClInclude Include="..\..\src\ft2_scopes.h" />
<ClInclude Include="..\..\src\ft2_scrollbars.h" />
+ <ClInclude Include="..\..\src\ft2_structs.h" />
<ClInclude Include="..\..\src\ft2_sysreqs.h" />
<ClInclude Include="..\..\src\ft2_tables.h" />
<ClInclude Include="..\..\src\ft2_textboxes.h" />
--- a/vs2019_project/ft2-clone/ft2-clone.vcxproj.filters
+++ b/vs2019_project/ft2-clone/ft2-clone.vcxproj.filters
@@ -76,6 +76,7 @@
<ClCompile Include="..\..\src\gfxdata\ft2_bmp_gui.c">
<Filter>graphics</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\ft2_structs.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\ft2_audio.h">
@@ -214,6 +215,9 @@
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ft2_bmp.h">
+ <Filter>headers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\ft2_structs.h">
<Filter>headers</Filter>
</ClInclude>
</ItemGroup>