Skip to content

Commit

Permalink
Update usage of 0/1 -> true/false
Browse files Browse the repository at this point in the history
- All bool types use true/false
- Updated `snapRecall` to include a clearer mode since 0/1 was confusing
  • Loading branch information
tstirrat committed Jul 31, 2024
1 parent 2305f6c commit 8fba11b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 32 deletions.
12 changes: 6 additions & 6 deletions Source/io/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ void updateMidiBuffer(void) {
return;
}
statusByte = byte;
capturedAddress = 0;
systemIdle = 0;
capturedAddress = false;
systemIdle = false;
return;
}

// 2ND BYTE (note/CC control)
if (!capturedAddress) {
capturedAddress = 1;
capturedAddress = true;
addressByte = byte;
systemIdle = 0;
systemIdle = false;
return;
}

// 3RD BYTE (velocity/value)
capturedAddress = 0;
capturedAddress = false;
valueByte = byte;
systemIdle = 0;
systemIdle = false;

switch ((statusByte >> 4) & 0x0F) {
case MIDI_STATUS_PB:
Expand Down
2 changes: 1 addition & 1 deletion Source/io/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void serial_isr(void) CRITICAL INTERRUPT {
// the interrupt can happen over a vblank, and if so, no rendering should
// happen otherwise we will get unsafe VRAM access.
// also this prioritises updateMidiBuffer()
systemIdle = 0;
systemIdle = false;
}

ISR_VECTOR(VECTOR_SERIAL, serial_isr)
2 changes: 1 addition & 1 deletion Source/mGB.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void main(void) {
inline void gameMain(void) {
rSC = SIOF_XFER_START | SIOF_CLOCK_EXT;
while (1) {
systemIdle = 1;
systemIdle = true;

updateMidiBuffer();

Expand Down
30 changes: 14 additions & 16 deletions Source/screen/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "../synth/wav.h"
#include "screen.h"

bool recallMode;
// v 1.3.3
const uint8_t versionnumber[10] = {32, 81, 2, 81, 4, 81, 4, 0, 0, 0};

Expand Down Expand Up @@ -261,9 +260,9 @@ void setCursor(void) {
cursorColumn = LAST_COL;
if (cursorColumn > LAST_COL)
cursorColumn = 0;
cursorEnable[cursorColumn] = 1U;
cursorEnable[cursorColumn] = true;
if (!shiftSelect) {
cursorEnable[cursorColumnLast] = 0U;
cursorEnable[cursorColumnLast] = false;
}

// cursorRow[cursorColumn] = cursorRowMain;
Expand All @@ -272,7 +271,7 @@ void setCursor(void) {

for (j = 0; j != NUM_COLS; j++) {
if (!shiftSelect && cursorColumn != j) {
cursorEnable[j] = 0;
cursorEnable[j] = false;
}
if (cursorEnable[j]) {
if (cursorRow[j] > 0xF0U)
Expand Down Expand Up @@ -307,26 +306,26 @@ void setPlayMarker(void) {

void clearParameterLocks(void) {
for (j = 0; j != 24; j++)
parameterLock[j] = 0;
parameterLock[j] = false;
}

void setDataValue(void) {
bool increasing = 0;
bool increasing = false;
uint8_t delta = 1;
systemIdle = 0;
systemIdle = false;

j = 0;
if (i & J_UP) {
j = 1;
increasing = 1;
increasing = true;
delta = 16;
} else if (i & J_DOWN) {
j = 1;
delta = 16;
} else if (i & J_LEFT) {
j = 1;
} else if (i & J_RIGHT) {
increasing = 1;
increasing = true;
j = 1;
}
if (j) {
Expand Down Expand Up @@ -369,7 +368,7 @@ void setDataValue(void) {
// EMU_printf("setDataValue dataSet[%d]: %d\n", p, dataSet[p]);
}
if (p < NUM_PARAMS) {
parameterLock[p] = 1;
parameterLock[p] = true;
}
updateValueSynth(p);
}
Expand All @@ -390,11 +389,10 @@ void getPadMainScreen(void) {

if (joyState & J_B) {
if (joyState & J_SELECT) {
recallMode = 0;
snapRecall(RECALL_SAVE);
} else {
recallMode = 1;
snapRecall(RECALL_LOAD);
}
snapRecall();
return;
}

Expand Down Expand Up @@ -441,11 +439,11 @@ void printbyte(uint8_t v1, uint8_t v2, uint8_t v3) {
set_bkg_tiles(1, 16, 10, 1, bkg);
}

void snapRecall(void) {
void snapRecall(RecallMode mode) {
if (cursorRowMain == LAST_ROW) {
for (l = 0; l < NUM_COLS; l++) {
if (cursorEnable[l]) {
if (!recallMode) {
if (mode == RECALL_SAVE) {
saveDataSet(l);
} else {
loadDataSet(l);
Expand All @@ -454,7 +452,7 @@ void snapRecall(void) {
}
}
} else {
if (!recallMode) {
if (mode == RECALL_SAVE) {
for (j = 0; j != 24; j++)
dataSetSnap[j] = dataSet[j];
} else {
Expand Down
7 changes: 5 additions & 2 deletions Source/screen/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#include <gbdk/platform.h>
#include <stdbool.h>

extern bool recallMode;
typedef enum RecallMode {
RECALL_SAVE = 0,
RECALL_LOAD = 1,
} RecallMode;

// v 1.3.3
extern const uint8_t versionnumber[10];
Expand Down Expand Up @@ -54,7 +57,7 @@ void updateDisplay(void);
void updateDisplaySynth(void);
void showCursor(void);
void setPlayMarker(void);
void snapRecall(void);
void snapRecall(RecallMode mode);
void updateSynth(uint8_t synth);
void showMainScreen(void);
void renderMainScreen(void);
Expand Down
2 changes: 1 addition & 1 deletion Source/synth/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ uint8_t outputSwitchValue[4] = {3, 3, 3, 3};
void setPitchBendFrequencyOffset(uint8_t synth) {
uint16_t freqRange;
uint16_t f = freq[noteStatus[synth].note];
systemIdle = 0;
systemIdle = false;
if (pbWheelIn[synth] & PBWHEEL_CENTER) {
freqRange = freq[pbNoteRange[synth].high];
currentFreq = (uint16_t)(pbWheelIn[synth] - 0x7F);
Expand Down
4 changes: 2 additions & 2 deletions Source/synth/noi.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void playNoteNoi(void) {
if (valueByte == 0) {
// Note off
if (noteStatus[NOI].note == noteIndex) {
noteStatus[NOI].active = 0;
noteStatus[NOI].active = false;

if (!noiSus) {
rAUD4ENV = 0x00;
Expand Down Expand Up @@ -85,7 +85,7 @@ void playNoteNoi(void) {
}

void setPitchBendFrequencyOffsetNoise(void) {
systemIdle = 0;
systemIdle = false;
if (pbWheelIn[NOI] & PBWHEEL_CENTER) {
// noteStatus[NOI].note = noteStatus[NOI].note;
currentFreq = noiFreq[noteStatus[NOI].note +
Expand Down
6 changes: 3 additions & 3 deletions Source/synth/wav.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void playNoteWav(void) {
pbNoteRange[WAV].high = noteIndex + pbRange[WAV];

noteStatus[WAV].active = true;
cueWavSweep = 1;
cueWavSweep = true;
wavNoteOffTrigger = false;
}

Expand All @@ -179,7 +179,7 @@ void updateWavSweep(void) {
wavCurrentFreq = currentFreqData[WAV] - (counterWav << wavSweepSpeed);
if (!(wavSweepSpeed >> 3U) && (wavCurrentFreq > 0x898U)) {
wavCurrentFreq = 0U;
cueWavSweep = 0U;
cueWavSweep = false;
}
rAUD3HIGH = wavCurrentFreq >> 8U;
rAUD3LOW = wavCurrentFreq;
Expand Down Expand Up @@ -211,5 +211,5 @@ void loadWav(uint8_t offset) {
rAUD3LOW = wavCurrentFreq;
rAUD3HIGH = (wavCurrentFreq >> 8U) | AUDHIGH_RESTART;

systemIdle = 0;
systemIdle = false;
}

0 comments on commit 8fba11b

Please sign in to comment.