More-accurate Organya.cpp variable arrangement
Also found some authentic variable names
This commit is contained in:
parent
718cb714ee
commit
5abf8a8878
1 changed files with 57 additions and 61 deletions
118
src/Organya.cpp
118
src/Organya.cpp
|
@ -117,16 +117,8 @@ typedef struct OrgData
|
||||||
BOOL InitMusicData(const char *path);
|
BOOL InitMusicData(const char *path);
|
||||||
} ORGDATA;
|
} ORGDATA;
|
||||||
|
|
||||||
ORGDATA org_data;
|
|
||||||
|
|
||||||
LPDIRECTSOUNDBUFFER lpORGANBUFFER[8][8][2] = {NULL};
|
LPDIRECTSOUNDBUFFER lpORGANBUFFER[8][8][2] = {NULL};
|
||||||
|
|
||||||
int gTrackVol[MAXTRACK];
|
|
||||||
int gOrgVolume = 100;
|
|
||||||
BOOL bFadeout = FALSE;
|
|
||||||
BOOL g_mute[MAXTRACK]; // Used by the debug Mute menu
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
//■オルガーニャ■■■■■■■■■■■■/////// (Organya)
|
//■オルガーニャ■■■■■■■■■■■■/////// (Organya)
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
@ -139,7 +131,7 @@ typedef struct
|
||||||
short oct_size;
|
short oct_size;
|
||||||
} OCTWAVE;
|
} OCTWAVE;
|
||||||
|
|
||||||
static const OCTWAVE oct_wave[8] =
|
OCTWAVE oct_wave[8] =
|
||||||
{
|
{
|
||||||
{ 256, 1, 4 }, // 0 Oct
|
{ 256, 1, 4 }, // 0 Oct
|
||||||
{ 256, 2, 8 }, // 1 Oct
|
{ 256, 2, 8 }, // 1 Oct
|
||||||
|
@ -151,7 +143,7 @@ static const OCTWAVE oct_wave[8] =
|
||||||
{ 8,128, 32 }, // 7 Oct
|
{ 8,128, 32 }, // 7 Oct
|
||||||
};
|
};
|
||||||
|
|
||||||
static WAVEFORMATEX format_tbl2 = {WAVE_FORMAT_PCM, 1, 22050, 22050, 1, 8, 0}; // 22050HzのFormat
|
WAVEFORMATEX format_tbl2 = {WAVE_FORMAT_PCM, 1, 22050, 22050, 1, 8, 0}; // 22050HzのFormat
|
||||||
|
|
||||||
// In the original source code, format_tbl2 was a raw array of bytes, as seen below
|
// In the original source code, format_tbl2 was a raw array of bytes, as seen below
|
||||||
// BYTE format_tbl2[] = {0x01,0x00,0x01,0x00,0x22,0x56,0x00,0x00,0x22,0x56,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00}; // 22050HzのFormat
|
// BYTE format_tbl2[] = {0x01,0x00,0x01,0x00,0x22,0x56,0x00,0x00,0x22,0x56,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00}; // 22050HzのFormat
|
||||||
|
@ -240,7 +232,7 @@ BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const short freq_tbl[12] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};
|
short freq_tbl[12] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};
|
||||||
|
|
||||||
void ChangeOrganFrequency(unsigned char key, signed char track, long a)
|
void ChangeOrganFrequency(unsigned char key, signed char track, long a)
|
||||||
{
|
{
|
||||||
|
@ -252,7 +244,8 @@ void ChangeOrganFrequency(unsigned char key, signed char track, long a)
|
||||||
lpORGANBUFFER[track][j][i]->SetFrequency(((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000)); // 1000を+αのデフォルト値とする (1000 is the default value for + α)
|
lpORGANBUFFER[track][j][i]->SetFrequency(((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000)); // 1000を+αのデフォルト値とする (1000 is the default value for + α)
|
||||||
}
|
}
|
||||||
|
|
||||||
const short pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
|
BOOL g_mute[MAXTRACK]; // Used by the debug Mute menu
|
||||||
|
short pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
|
||||||
unsigned char old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // 再生中の音 (Sound being played)
|
unsigned char old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // 再生中の音 (Sound being played)
|
||||||
unsigned char key_on[MAXTRACK]; // キースイッチ (Key switch)
|
unsigned char key_on[MAXTRACK]; // キースイッチ (Key switch)
|
||||||
unsigned char key_twin[MAXTRACK]; // 今使っているキー(連続時のノイズ防止の為に二つ用意) (Currently used keys (prepared for continuous noise prevention))
|
unsigned char key_twin[MAXTRACK]; // 今使っているキー(連続時のノイズ防止の為に二つ用意) (Currently used keys (prepared for continuous noise prevention))
|
||||||
|
@ -456,11 +449,11 @@ void PlayDramObject(unsigned char key, int mode, signed char track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ORGDATA org_data;
|
||||||
|
|
||||||
OrgData::OrgData(void)
|
OrgData::OrgData(void)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < MAXTRACK; i++)
|
||||||
|
|
||||||
for (i = 0; i < MAXTRACK; i++)
|
|
||||||
{
|
{
|
||||||
info.tdata[i].note_list = NULL;
|
info.tdata[i].note_list = NULL;
|
||||||
info.tdata[i].note_p = NULL;
|
info.tdata[i].note_p = NULL;
|
||||||
|
@ -477,8 +470,7 @@ void OrgData::InitOrgData(void)
|
||||||
info.repeat_x = info.dot * info.line * 0;
|
info.repeat_x = info.dot * info.line * 0;
|
||||||
info.end_x = info.dot * info.line * 255;
|
info.end_x = info.dot * info.line * 255;
|
||||||
|
|
||||||
int i;
|
for (int i = 0; i < MAXTRACK; i++)
|
||||||
for (i = 0; i < MAXTRACK; i++)
|
|
||||||
{
|
{
|
||||||
info.tdata[i].freq = 1000;
|
info.tdata[i].freq = 1000;
|
||||||
info.tdata[i].wave_no = 0;
|
info.tdata[i].wave_no = 0;
|
||||||
|
@ -597,8 +589,8 @@ void OrgData::ReleaseNote(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char pass[7] = "Org-01";
|
char pass[7] = "Org-01";
|
||||||
static const char pass2[7] = "Org-02"; // Pipi
|
char pass2[7] = "Org-02"; // Pipi
|
||||||
|
|
||||||
BOOL OrgData::InitMusicData(const char *path)
|
BOOL OrgData::InitMusicData(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -765,9 +757,9 @@ BOOL QuitMMTimer();
|
||||||
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
|
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
|
||||||
//グローバル変数 (Global variable)
|
//グローバル変数 (Global variable)
|
||||||
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
|
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
|
||||||
static UINT ExactTime = 13; // 最小精度 (Minimum accuracy)
|
UINT ExactTime = 13; // 最小精度 (Minimum accuracy)
|
||||||
static UINT TimerID;
|
UINT TimerID;
|
||||||
static BOOL nameless_flag;
|
BOOL nameless_flag;
|
||||||
|
|
||||||
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
|
/*■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
|
||||||
// タイマー精度を設定する。 (Set timer accuracy.)
|
// タイマー精度を設定する。 (Set timer accuracy.)
|
||||||
|
@ -872,37 +864,41 @@ BOOL QuitMMTimer(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play data
|
// Play data
|
||||||
long play_p;
|
long PlayPos; // Called 'play_p' in the source code release
|
||||||
NOTELIST *play_np[MAXTRACK];
|
NOTELIST *np[MAXTRACK];
|
||||||
long now_leng[MAXMELODY];
|
long now_leng[MAXMELODY];
|
||||||
|
|
||||||
|
int Volume = 100;
|
||||||
|
int TrackVol[MAXTRACK];
|
||||||
|
BOOL bFadeout = FALSE;
|
||||||
|
|
||||||
void OrgData::PlayData(void)
|
void OrgData::PlayData(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Handle fading out
|
// Handle fading out
|
||||||
if (bFadeout && gOrgVolume)
|
if (bFadeout && Volume)
|
||||||
gOrgVolume -= 2;
|
Volume -= 2;
|
||||||
if (gOrgVolume < 0)
|
if (Volume < 0)
|
||||||
gOrgVolume = 0;
|
Volume = 0;
|
||||||
|
|
||||||
// メロディの再生 (Play melody)
|
// メロディの再生 (Play melody)
|
||||||
for (i = 0; i < MAXMELODY; i++)
|
for (i = 0; i < MAXMELODY; i++)
|
||||||
{
|
{
|
||||||
if (play_np[i] != NULL && play_p == play_np[i]->x)
|
if (np[i] != NULL && PlayPos == np[i]->x)
|
||||||
{
|
{
|
||||||
if (!g_mute[i] && play_np[i]->y != KEYDUMMY) // 音が来た。 (The sound has come.)
|
if (!g_mute[i] && np[i]->y != KEYDUMMY) // 音が来た。 (The sound has come.)
|
||||||
{
|
{
|
||||||
PlayOrganObject(play_np[i]->y, -1, i, info.tdata[i].freq);
|
PlayOrganObject(np[i]->y, -1, i, info.tdata[i].freq);
|
||||||
now_leng[i] = play_np[i]->length;
|
now_leng[i] = np[i]->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (play_np[i]->pan != PANDUMMY)
|
if (np[i]->pan != PANDUMMY)
|
||||||
ChangeOrganPan(play_np[i]->y, play_np[i]->pan, i);
|
ChangeOrganPan(np[i]->y, np[i]->pan, i);
|
||||||
if (play_np[i]->volume != VOLDUMMY)
|
if (np[i]->volume != VOLDUMMY)
|
||||||
gTrackVol[i] = play_np[i]->volume;
|
TrackVol[i] = np[i]->volume;
|
||||||
|
|
||||||
play_np[i] = play_np[i]->to; // 次の音符を指す (Points to the next note)
|
np[i] = np[i]->to; // 次の音符を指す (Points to the next note)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now_leng[i] == 0)
|
if (now_leng[i] == 0)
|
||||||
|
@ -911,36 +907,36 @@ void OrgData::PlayData(void)
|
||||||
if (now_leng[i] > 0)
|
if (now_leng[i] > 0)
|
||||||
now_leng[i]--;
|
now_leng[i]--;
|
||||||
|
|
||||||
if (play_np[i])
|
if (np[i])
|
||||||
ChangeOrganVolume(play_np[i]->y, gTrackVol[i] * gOrgVolume / 0x7F, i);
|
ChangeOrganVolume(np[i]->y, TrackVol[i] * Volume / 0x7F, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ドラムの再生 (Drum playback)
|
// ドラムの再生 (Drum playback)
|
||||||
for (i = MAXMELODY; i < MAXTRACK; i++)
|
for (i = MAXMELODY; i < MAXTRACK; i++)
|
||||||
{
|
{
|
||||||
if (play_np[i] != NULL && play_p == play_np[i]->x) // 音が来た。 (The sound has come.)
|
if (np[i] != NULL && PlayPos == np[i]->x) // 音が来た。 (The sound has come.)
|
||||||
{
|
{
|
||||||
if (play_np[i]->y != KEYDUMMY && !g_mute[i]) // ならす (Tame)
|
if (np[i]->y != KEYDUMMY && !g_mute[i]) // ならす (Tame)
|
||||||
PlayDramObject(play_np[i]->y, 1, i - MAXMELODY);
|
PlayDramObject(np[i]->y, 1, i - MAXMELODY);
|
||||||
|
|
||||||
if (play_np[i]->pan != PANDUMMY)
|
if (np[i]->pan != PANDUMMY)
|
||||||
ChangeDramPan(play_np[i]->pan, i - MAXMELODY);
|
ChangeDramPan(np[i]->pan, i - MAXMELODY);
|
||||||
if (play_np[i]->volume != VOLDUMMY)
|
if (np[i]->volume != VOLDUMMY)
|
||||||
gTrackVol[i] = play_np[i]->volume;
|
TrackVol[i] = np[i]->volume;
|
||||||
|
|
||||||
play_np[i] = play_np[i]->to; // 次の音符を指す (Points to the next note)
|
np[i] = np[i]->to; // 次の音符を指す (Points to the next note)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (play_np[i])
|
if (np[i])
|
||||||
ChangeDramVolume(gTrackVol[i] * gOrgVolume / 0x7F, i - MAXMELODY);
|
ChangeDramVolume(TrackVol[i] * Volume / 0x7F, i - MAXMELODY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looping
|
// Looping
|
||||||
play_p++;
|
PlayPos++;
|
||||||
if (play_p >= info.end_x)
|
if (PlayPos >= info.end_x)
|
||||||
{
|
{
|
||||||
play_p = info.repeat_x;
|
PlayPos = info.repeat_x;
|
||||||
SetPlayPointer(play_p);
|
SetPlayPointer(PlayPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,12 +944,12 @@ void OrgData::SetPlayPointer(long x)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAXTRACK; i++)
|
for (int i = 0; i < MAXTRACK; i++)
|
||||||
{
|
{
|
||||||
play_np[i] = info.tdata[i].note_list;
|
np[i] = info.tdata[i].note_list;
|
||||||
while (play_np[i] != NULL && play_np[i]->x < x)
|
while (np[i] != NULL && np[i]->x < x)
|
||||||
play_np[i] = play_np[i]->to; // 見るべき音符を設定 (Set note to watch)
|
np[i] = np[i]->to; // 見るべき音符を設定 (Set note to watch)
|
||||||
}
|
}
|
||||||
|
|
||||||
play_p = x;
|
PlayPos = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start and end organya
|
// Start and end organya
|
||||||
|
@ -979,7 +975,7 @@ BOOL LoadOrganya(const char *name)
|
||||||
if (!org_data.InitMusicData(name))
|
if (!org_data.InitMusicData(name))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gOrgVolume = 100;
|
Volume = 100;
|
||||||
bFadeout = 0;
|
bFadeout = 0;
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
|
@ -995,7 +991,7 @@ void SetOrganyaPosition(unsigned int x)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
org_data.SetPlayPointer(x);
|
org_data.SetPlayPointer(x);
|
||||||
gOrgVolume = 100;
|
Volume = 100;
|
||||||
bFadeout = FALSE;
|
bFadeout = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,7 +1000,7 @@ unsigned int GetOrganyaPosition(void)
|
||||||
if (lpDS == NULL)
|
if (lpDS == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return play_p;
|
return PlayPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayOrganyaMusic(void)
|
void PlayOrganyaMusic(void)
|
||||||
|
@ -1025,7 +1021,7 @@ BOOL ChangeOrganyaVolume(signed int volume)
|
||||||
if (volume < 0 || volume > 100)
|
if (volume < 0 || volume > 100)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gOrgVolume = volume;
|
Volume = volume;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue