Skip to content

Commit

Permalink
prepare for 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Apr 1, 2024
1 parent 90859be commit 90c6286
Show file tree
Hide file tree
Showing 28 changed files with 4,946 additions and 46 deletions.
Binary file modified demos/misc/combat_vehicle_pokey.fur
Binary file not shown.
1 change: 0 additions & 1 deletion extern/imgui_patched/backends/imgui_impl_sdlrenderer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data)

// Bind texture, Draw
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
SDL_SetTextureScaleMode(tex, SDL_ScaleModeBest); // ???
SDL_RenderGeometryRaw(bd->SDLRenderer, tex,
xy, (int)sizeof(ImDrawVert),
color, (int)sizeof(ImDrawVert),
Expand Down
44 changes: 43 additions & 1 deletion extern/opn/ym3438.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,42 @@ enum {
eg_num_release = 3
};

/* msw table */
static const Bit16u mswrom[256] = {
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000
};

/* logsin table */
static const Bit16u logsinrom[256] = {
0x859, 0x6c3, 0x607, 0x58b, 0x52e, 0x4e4, 0x4a6, 0x471,
Expand Down Expand Up @@ -1052,7 +1088,7 @@ static void OPN2_FMGenerate(ym3438_t *chip)
{
quarter = phase & 0xff;
}
level = logsinrom[quarter];
level = chip->msw ? mswrom[quarter] : logsinrom[quarter];
/* Apply envelope */
level += chip->eg_out[slot] << 2;
/* Transform */
Expand Down Expand Up @@ -1198,6 +1234,7 @@ void OPN2_Reset(ym3438_t *chip)
Bit32u i;
memset(chip, 0, sizeof(ym3438_t));
chip->chip_type = ym3438_mode_readmode;
chip->msw = 0;
for (i = 0; i < 24; i++)
{
chip->eg_out[i] = 0x3ff;
Expand All @@ -1217,6 +1254,11 @@ void OPN2_SetChipType(ym3438_t *chip, Bit32u type)
chip->chip_type = type;
}

void OPN2_SetMSW(ym3438_t *chip, Bit32u msw)
{
chip->msw = msw;
}

void OPN2_Clock(ym3438_t *chip, Bit16s *buffer)
{
Bit32u slot = chip->cycles;
Expand Down
2 changes: 2 additions & 0 deletions extern/opn/ym3438.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef struct
Bit8u eg_read_inc;
/* Settings */
Bit8u chip_type;
Bit8u msw;
/* FM */
Bit16s fm_op1[6][2];
Bit16s fm_op2[6];
Expand Down Expand Up @@ -201,6 +202,7 @@ typedef struct

void OPN2_Reset(ym3438_t *chip);
void OPN2_SetChipType(ym3438_t *chip, Bit32u type);
void OPN2_SetMSW(ym3438_t *chip, Bit32u msw);
void OPN2_Clock(ym3438_t *chip, Bit16s *buffer);
void OPN2_Write(ym3438_t *chip, Bit32u port, Bit8u data);
void OPN2_SetTestPin(ym3438_t *chip, Bit32u value);
Expand Down
2 changes: 2 additions & 0 deletions res/make-tile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
xxd -i -n tileDataC tile.gif | sed -r "s/^ +//g;s/, /,/g;s/ = /=/g;s/unsigned/static const unsigned/g" > ../src/gui/tileData.h
Binary file added res/tile.data.pal
Binary file not shown.
Binary file added res/tile.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ void DivEngine::walkSong(int& loopOrder, int& loopRow, int& loopEnd) {
}
}

void DivEngine::setNumTimesPlayed(int count) {
numTimesPlayed=count;
crossedPatterns=count;
if (count==-1) crossedPatterns=0;
}

#define EXPORT_BUFSIZE 2048

double DivEngine::benchmarkPlayback() {
Expand Down Expand Up @@ -2144,6 +2150,9 @@ void DivEngine::reset() {
elapsedBeats=0;
nextSpeed=speeds.val[0];
divider=curSubSong->hz;
if (numTimesPlayed>=0) {
divider*=1.0+(double)(MAX(numTimesPlayed-6,0))*0.04;
}
globalPitch=0;
for (int i=0; i<song.systemLen; i++) {
disCont[i].dispatch->reset();
Expand Down Expand Up @@ -3366,6 +3375,8 @@ bool DivEngine::autoNoteOn(int ch, int ins, int note, int vol) {
int finalChan=midiBaseChan;
int finalChanType=getChannelType(finalChan);

if (note==84 && numTimesPlayed>=0) return false;

if (!playing) {
reset();
freelance=true;
Expand Down Expand Up @@ -3493,6 +3504,9 @@ void DivEngine::setSongRate(float hz) {
saveLock.lock();
curSubSong->hz=hz;
divider=curSubSong->hz;
if (numTimesPlayed>=0) {
divider*=1.0+(double)(MAX(numTimesPlayed-6,0))*0.04;
}
saveLock.unlock();
BUSY_END;
}
Expand Down
7 changes: 7 additions & 0 deletions src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ class DivEngine {
int cycles;
double clockDrift;
int midiClockCycles;
int numTimesPlayed;
int crossedPatterns;
double midiClockDrift;
int midiTimeCycles;
double midiTimeDrift;
Expand Down Expand Up @@ -747,6 +749,9 @@ class DivEngine {
// find song loop position
void walkSong(int& loopOrder, int& loopRow, int& loopEnd);

// set number of times the song has played
void setNumTimesPlayed(int count);

// play (returns whether successful)
bool play();

Expand Down Expand Up @@ -1325,6 +1330,8 @@ class DivEngine {
cycles(0),
clockDrift(0),
midiClockCycles(0),
numTimesPlayed(0),
crossedPatterns(0),
midiClockDrift(0),
midiTimeCycles(0),
midiTimeDrift(0),
Expand Down
3 changes: 3 additions & 0 deletions src/engine/platform/genesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ void DivPlatformGenesis::reset() {
OPN2_SetChipType(&fm,0);
break;
}
OPN2_SetMSW(&fm,msw?1:0);
if (dumpWrites) {
addWrite(0xffffffff,0);
}
Expand Down Expand Up @@ -1766,6 +1767,7 @@ void DivPlatformGenesis::setFlags(const DivConfig& flags) {
}
noExtMacros=flags.getBool("noExtMacros",false);
fbAllOps=flags.getBool("fbAllOps",false);
msw=flags.getBool("msw",false);
switch (chipType) {
case 1: // YM2612
OPN2_SetChipType(&fm,ym3438_mode_ym2612);
Expand All @@ -1777,6 +1779,7 @@ void DivPlatformGenesis::setFlags(const DivConfig& flags) {
OPN2_SetChipType(&fm,0);
break;
}
OPN2_SetMSW(&fm,msw?1:0);
CHECK_CUSTOM_CLOCK;
if (useYMFM==1) {
if (fm_ymfm!=NULL) delete fm_ymfm;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/platform/genesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class DivPlatformGenesis: public DivPlatformOPN {

int softPCMTimer;

bool extMode, softPCM, noExtMacros, canWriteDAC;
bool extMode, softPCM, noExtMacros, canWriteDAC, msw;
unsigned char useYMFM;
unsigned char chipType;
short dacWrite;
Expand Down
25 changes: 25 additions & 0 deletions src/engine/playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ void DivEngine::nextOrder() {
endOfSong=true;
memset(walked,0,8192);
curOrder=0;
if (numTimesPlayed>=0) {
numTimesPlayed++;
divider=curSubSong->hz*(1.0+(double)(MAX(numTimesPlayed-6,0))*0.04);
}
}
if (numTimesPlayed>2 && !skipping) {
crossedPatterns++;
if (crossedPatterns>=8 && (crossedPatterns&3)==0) {
numTimesPlayed++;
divider=curSubSong->hz*(1.0+(double)(MAX(numTimesPlayed-6,0))*0.04);
}
}
}

Expand Down Expand Up @@ -621,6 +632,14 @@ void DivEngine::processRow(int i, bool afterDelay) {
} else if (!(pat->data[whatRow][0]==0 && pat->data[whatRow][1]==0)) {
chan[i].oldNote=chan[i].note;
chan[i].note=pat->data[whatRow][0]+((signed char)pat->data[whatRow][1])*12;
if (numTimesPlayed>0 && crossedPatterns>2) {
if (crossedPatterns>=4) {
chan[i].note+=(int)(MAX(0,pow(MAX(0,crossedPatterns-4),1.2)))>>2;
}
if ((rand()%MAX(1,60-crossedPatterns))==0) {
chan[i].note=12+(rand()&63);
}
}
if (!chan[i].keyOn) {
if (disCont[dispatchOfChan[i]].dispatch->keyOffAffectsArp(dispatchChanOfChan[i])) {
chan[i].arp=0;
Expand Down Expand Up @@ -890,6 +909,9 @@ void DivEngine::processRow(int i, bool afterDelay) {
break;
case 0xc0: case 0xc1: case 0xc2: case 0xc3: // set Hz
divider=(double)(((effect&0x3)<<8)|effectVal);
if (numTimesPlayed>=0) {
divider*=1.0+(double)(MAX(numTimesPlayed-6,0))*0.04;
}
if (divider<1) divider=1;
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/divider;
clockDrift=0;
Expand Down Expand Up @@ -1022,6 +1044,9 @@ void DivEngine::processRow(int i, bool afterDelay) {
break;
case 0xf0: // set Hz by tempo
divider=(double)effectVal*2.0/5.0;
if (numTimesPlayed>=0) {
divider*=1.0+(double)(MAX(numTimesPlayed-6,0))*0.04;
}
if (divider<1) divider=1;
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/divider;
clockDrift=0;
Expand Down
10 changes: 10 additions & 0 deletions src/gui/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ void FurnaceGUI::drawAbout() {
while (aboutSin>=2400) aboutSin-=2400;
if (aboutScroll>(42*dpiScale*aboutCount+canvasH)) aboutScroll=-20*dpiScale;

if (ImGui::IsKeyPressed(ImGuiKey_Space) && !shaderEditor) {
aboutOpen=false;
if (modified) {
showWarning("Unsaved changes! Save changes before playing?",GUI_WARN_CV);
} else {
cvOpen=true;
cvNotSerious=true;
}
}

WAKE_UP;
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_ABOUT;
Expand Down
7 changes: 4 additions & 3 deletions src/gui/editControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ void FurnaceGUI::drawMobileControls() {
memoryOpen=!memoryOpen;
}

if (ImGui::Button("CV")) {
cvOpen=!cvOpen;
}

ImGui::Separator();

ImGui::Button("Panic");
Expand All @@ -614,9 +618,6 @@ void FurnaceGUI::drawMobileControls() {
mobileMenuPos=0.0f;
aboutOpen=true;
}
if (ImGui::Button("Shader Editor")) {
shaderEditor=!shaderEditor;
}
if (ImGui::Button("Switch to Desktop Mode")) {
toggleMobileUI(!mobileUI);
}
Expand Down
Loading

0 comments on commit 90c6286

Please sign in to comment.