Skip to content

Commit

Permalink
* sound_set_vol behaves more like original Dink ( yeoldetoast, https:…
Browse files Browse the repository at this point in the history
  • Loading branch information
SethRobinson committed Apr 30, 2024
1 parent 93d1590 commit 6513326
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
10 changes: 8 additions & 2 deletions bin/version_history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ use timing (Myster island camera sequence for example) easier though, not sure.
* say() text is now drawn under choice menus rather than above, previously dmods that used sp_kill to make text permanent could cause visual problems in choice menus (Robj)
* A saved game is no longer included, oops
* The screen scroll effect now respects sprites that were drawn over the GUI parts (Robj)
* Overlapping text is easier to read now, for two reasons, the main problem was Proton SDK does batching under the hood (this didn't exist when the original Dink HD was made) and it was trying to batch all the the text backgrounds together on the same later which isn't what we wanted, and two, I made the bg slightly darker
* Overlapping text is easier to read now, for two reasons, the main problem was Proton SDK does batching under the hood (this didn't exist when the original Dink HD was made) and it was trying to batch all the the text backgrounds together on the same layer which isn't what we wanted, and two, I made the bg slightly darker
* attack_wait for sprite 1 is now preserved across saves to match functionality of other dink versions (RobJ)
* DinkC change: LogMsg (a script command that let's a script print text to the log.txt file directly) now properly handles &variables
* DMOD installer fixed to work with older v7 tar format (big thanks to drone1400 for help with this)
Expand All @@ -387,4 +387,10 @@ some Windows/proton keyboard problems. At least the method I used should work on
* (Win) Added ` (backtick) to toggle an overlay window showing the log. I wanted to do Shift-Tilde or something so it wasn't accidently hit but ran into
* Removed "View log" from debug menu because the above option replaces it
* Added "set_music_vol" DinkC command. Accepts between 0 and 100. 50 means set the music/midi to 50% of whatever the current setting is in options.
* get_version now returns 113 instead of 112 due to the DinkC addition
* get_version now returns 113 instead of 112 due to the DinkC addition

------- Chang

* BUGFIX with map_tile, now goes 0 to 5247 (Robj, yeoldetoast, https://www.dinknetwork.com/forum.cgi?MID=209752&Posts=16 )
* BUGFIX with disable_all_sprites/enable_all_sprites (Robj, yeoldetoast, https://www.dinknetwork.com/forum.cgi?MID=209752&Posts=16 )
* sound_set_vol behaves more like original Dink ( https://www.dinknetwork.com/forum.cgi?MID=209752#209908 )
19 changes: 15 additions & 4 deletions source/dink/dink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ void UnloadAllGraphics();

#endif


//adjusted from https://stackoverflow.com/questions/36072054/get-the-inverse-of-a-function-millibels-to-percentage-percentage-to-millibels

double ConvertMillibelsToPercentage(int value)
{
double exponent = ((value / 1000.0) + 10);
double numerator = 100.0 * (pow(2, exponent) - 1);
double final = (numerator / 1023.0) / 100.0f;


return final;
}


void BackgroundSpriteManager::Clear()
{
m_sprites.clear();
Expand Down Expand Up @@ -8422,12 +8436,10 @@ int process_line (int script, char *pLineIn, bool doelse)
{
if (sound_on)
{
//let's set one sound to survive
if (g_nlist[0] > 0)
{
soundinfo[g_nlist[0]].vol = g_nlist[1];

soundbank[g_nlist[0]].SetVolume(g_nlist[1]);
soundbank[g_nlist[0]].SetVolumeLogarithmic(g_nlist[1]);
}
}
}
Expand All @@ -8445,7 +8457,6 @@ int process_line (int script, char *pLineIn, bool doelse)
{
if (sound_on)
{
//let's set one sound to survive
if (g_nlist[0] > 0)
{
soundbank[g_nlist[0]].Stop();
Expand Down
31 changes: 27 additions & 4 deletions source/dink/dink.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ struct soundstruct
int32 freq; //what speed it was played at
};

double ConvertMillibelsToPercentage(int value);

class SoundBankDummy
{
public:
Expand All @@ -634,8 +636,31 @@ class SoundBankDummy
}

void Stop() {GetAudioManager()->Stop(m_audioID); m_audioID = 0; m_soundIDThatPlayedUs = 0;};
void SetPan(float f) {GetAudioManager()->SetPan(m_audioID,f/1700);};
void SetVolume(float f){GetAudioManager()->SetVol(m_audioID, (1800+f) / 1800);};
void SetPan(float f)
{

float finalPan = f/1700;
#ifdef _DEBUG
//LogMsg("Setting pan of %.02f to %f", f, finalPan);
#endif
GetAudioManager()->SetPan(m_audioID, finalPan);
};

void SetVolume(float f)
{
GetAudioManager()->SetVol(m_audioID, (1800+f) / 1800);
};

void SetVolumeLogarithmic(float f)
{
#ifdef _DEBUG
//LogMsg("Old SetVolume: Changing %.02f to final vol of %.2f", f, (1800 + f) / 1800);
//LogMsg("New SetVolume: Changing vol %.02f to %f", f, ConvertMillibelsToPercentage(f));
#endif
GetAudioManager()->SetVol(m_audioID, ConvertMillibelsToPercentage(f));
};


bool IsInUse() {if (m_audioID == 0) return false; return GetAudioManager()->IsPlaying(m_audioID);}
void Reset()
{
Expand Down Expand Up @@ -716,7 +741,6 @@ struct DinkGlobalsStatic

bool m_bRenderBackgroundOnLoad;


char g_lastBitmapShown[C_SHOWN_BITMAP_SIZE];
int32 last_fill_screen_palette_color;

Expand All @@ -731,7 +755,6 @@ struct DinkGlobalsStatic
};



enum eDinkGameState
{
//helps us to know when to automatically save the game
Expand Down

0 comments on commit 6513326

Please sign in to comment.