Did initial sweep with regexes
Changed regex to "((//|\;)[^ \t\n]|(for|while|if|while|do|void|int|bool)\((for|while|if|while|do)\ \(.*\)\;|\(\ |\ \)|//\ [a-z]|\ \ )|break;\n[\t]*[^\n\t\}(\/\/ Fallthrough]|[^\t\n]\{[^\n]|[^\n\t]\}[^\n]|\,[^\ ]" Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
parent
620401b671
commit
3a80d8f4fb
3 changed files with 113 additions and 95 deletions
161
src/Organya.cpp
161
src/Organya.cpp
|
@ -19,7 +19,7 @@
|
||||||
#define MAXMELODY 8
|
#define MAXMELODY 8
|
||||||
#define MAXDRAM 8
|
#define MAXDRAM 8
|
||||||
|
|
||||||
SOUNDBUFFER* lpORGANBUFFER[8][8][2] = {NULL};
|
SOUNDBUFFER* lpORGANBUFFER[8][8][2] = { NULL };
|
||||||
SOUNDBUFFER** lpDRAMBUFFER = &lpSECONDARYBUFFER[0x96];
|
SOUNDBUFFER** lpDRAMBUFFER = &lpSECONDARYBUFFER[0x96];
|
||||||
|
|
||||||
MUSICINFO info;
|
MUSICINFO info;
|
||||||
|
@ -63,10 +63,10 @@ BOOL OrganyaNoteAlloc(unsigned short alloc)
|
||||||
|
|
||||||
for(int j = 0; j < MAXMELODY; j++)
|
for(int j = 0; j < MAXMELODY; j++)
|
||||||
MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi);
|
MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi);
|
||||||
//for(int j = 0; j < MAXDRAM; j++)
|
// for(int j = 0; j < MAXDRAM; j++)
|
||||||
// InitDramObject(j);
|
// InitDramObject(j);
|
||||||
|
|
||||||
//this->track = 0;
|
// this->track = 0;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,14 @@ void OrganyaReleaseNote()
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
delete[] info.tdata[i].note_p;
|
delete[] info.tdata[i].note_p;
|
||||||
#else
|
#else
|
||||||
delete info.tdata[i].note_p; // should be delete[]
|
delete info.tdata[i].note_p; // Should be delete[]
|
||||||
#endif
|
#endif
|
||||||
info.tdata[i].note_p = NULL;
|
info.tdata[i].note_p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Wave playing and loading
|
// Wave playing and loading
|
||||||
typedef struct {
|
typedef struct {
|
||||||
short wave_size;
|
short wave_size;
|
||||||
short oct_par;
|
short oct_par;
|
||||||
|
@ -95,14 +95,14 @@ typedef struct {
|
||||||
} OCTWAVE;
|
} OCTWAVE;
|
||||||
|
|
||||||
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
|
||||||
{ 128, 4, 12 }, //2 Oct
|
{ 128, 4, 12 }, // 2 Oct
|
||||||
{ 128, 8, 16 }, //3 Oct
|
{ 128, 8, 16 }, // 3 Oct
|
||||||
{ 64, 16, 20 }, //4 Oct
|
{ 64, 16, 20 }, // 4 Oct
|
||||||
{ 32, 32, 24 }, //5 Oct
|
{ 32, 32, 24 }, // 5 Oct
|
||||||
{ 16, 64, 28 }, //6 Oct
|
{ 16, 64, 28 }, // 6 Oct
|
||||||
{ 8,128, 32 }, //7 Oct
|
{ 8,128, 32 }, // 7 Oct
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
|
BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
|
||||||
|
@ -114,10 +114,10 @@ BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
|
||||||
size_t wave_size = oct_wave[j].wave_size;
|
size_t wave_size = oct_wave[j].wave_size;
|
||||||
size_t data_size = pipi ? wave_size * oct_wave[j].oct_size : wave_size;
|
size_t data_size = pipi ? wave_size * oct_wave[j].oct_size : wave_size;
|
||||||
|
|
||||||
//Create sound buffer
|
// Create sound buffer
|
||||||
lpORGANBUFFER[track][j][k] = new SOUNDBUFFER(data_size);
|
lpORGANBUFFER[track][j][k] = new SOUNDBUFFER(data_size);
|
||||||
|
|
||||||
//Get wave data
|
// Get wave data
|
||||||
unsigned char *wp = new unsigned char[data_size];
|
unsigned char *wp = new unsigned char[data_size];
|
||||||
unsigned char *wp_sub = wp;
|
unsigned char *wp_sub = wp;
|
||||||
size_t wav_tp = 0;
|
size_t wav_tp = 0;
|
||||||
|
@ -136,7 +136,7 @@ BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
|
||||||
wp_sub++;
|
wp_sub++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copy wave data to sound buffer
|
// Copy wave data to sound buffer
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
lpORGANBUFFER[track][j][k]->Lock(&buf, NULL);
|
lpORGANBUFFER[track][j][k]->Lock(&buf, NULL);
|
||||||
memcpy(buf, wp, data_size);
|
memcpy(buf, wp, data_size);
|
||||||
|
@ -149,7 +149,7 @@ BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Playing melody tracks
|
// Playing melody tracks
|
||||||
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)
|
||||||
|
@ -161,10 +161,10 @@ void ChangeOrganFrequency(unsigned char key, signed char track, long a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
|
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};
|
unsigned char old_key[MAXTRACK] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
unsigned char key_on[MAXTRACK] = {0};
|
unsigned char key_on[MAXTRACK] = { 0 };
|
||||||
unsigned char key_twin[MAXTRACK] = {0};
|
unsigned char key_twin[MAXTRACK] = { 0 };
|
||||||
|
|
||||||
void ChangeOrganPan(unsigned char key, unsigned char pan, signed char track)
|
void ChangeOrganPan(unsigned char key, unsigned char pan, signed char track)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +234,7 @@ void PlayOrganObject(unsigned char key, int mode, signed char track, long freq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Release tracks
|
// Release tracks
|
||||||
void ReleaseOrganyaObject(signed char track)
|
void ReleaseOrganyaObject(signed char track)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 8; i++)
|
for(int i = 0; i < 8; i++)
|
||||||
|
@ -252,7 +252,7 @@ void ReleaseOrganyaObject(signed char track)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handling WAVE100
|
// Handling WAVE100
|
||||||
signed char wave_data[100][0x100];
|
signed char wave_data[100][0x100];
|
||||||
|
|
||||||
BOOL InitWaveData100()
|
BOOL InitWaveData100()
|
||||||
|
@ -267,7 +267,7 @@ BOOL InitWaveData100()
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create org wave
|
// Create org wave
|
||||||
BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi)
|
BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi)
|
||||||
{
|
{
|
||||||
if(wave_no > 99)
|
if(wave_no > 99)
|
||||||
|
@ -281,7 +281,7 @@ BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dram
|
// Dram
|
||||||
void ChangeDramFrequency(unsigned char key, signed char track)
|
void ChangeDramFrequency(unsigned char key, signed char track)
|
||||||
{
|
{
|
||||||
lpDRAMBUFFER[track]->SetFrequency(key * 800 + 100);
|
lpDRAMBUFFER[track]->SetFrequency(key * 800 + 100);
|
||||||
|
@ -305,52 +305,55 @@ void PlayDramObject(unsigned char key, int mode, signed char track)
|
||||||
lpDRAMBUFFER[track]->Stop();
|
lpDRAMBUFFER[track]->Stop();
|
||||||
lpDRAMBUFFER[track]->SetCurrentPosition(0);
|
lpDRAMBUFFER[track]->SetCurrentPosition(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
lpDRAMBUFFER[track]->Stop();
|
lpDRAMBUFFER[track]->Stop();
|
||||||
lpDRAMBUFFER[track]->SetCurrentPosition(0);
|
lpDRAMBUFFER[track]->SetCurrentPosition(0);
|
||||||
ChangeDramFrequency(key, track);
|
ChangeDramFrequency(key, track);
|
||||||
lpDRAMBUFFER[track]->Play(false);
|
lpDRAMBUFFER[track]->Play(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Play data
|
// Play data
|
||||||
long play_p;
|
long play_p;
|
||||||
NOTELIST *play_np[MAXTRACK];
|
NOTELIST *play_np[MAXTRACK];
|
||||||
long now_leng[MAXMELODY] = {0};
|
long now_leng[MAXMELODY] = { 0 };
|
||||||
|
|
||||||
void OrganyaPlayData()
|
void OrganyaPlayData()
|
||||||
{
|
{
|
||||||
//Handle fading out
|
// Handle fading out
|
||||||
if (bFadeout && gOrgVolume)
|
if (bFadeout && gOrgVolume)
|
||||||
gOrgVolume -= 2;
|
gOrgVolume -= 2;
|
||||||
if (gOrgVolume < 0)
|
if (gOrgVolume < 0)
|
||||||
gOrgVolume = 0;
|
gOrgVolume = 0;
|
||||||
|
|
||||||
//Play melody
|
// Play melody
|
||||||
for(int i = 0; i < MAXMELODY; i++)
|
for(int i = 0; i < MAXMELODY; i++)
|
||||||
{
|
{
|
||||||
if (play_np[i] != NULL && play_p == play_np[i]->x)
|
if (play_np[i] != NULL && play_p == play_np[i]->x)
|
||||||
{
|
{
|
||||||
if(play_np[i]->y != KEYDUMMY)
|
if(play_np[i]->y != KEYDUMMY)
|
||||||
{
|
{
|
||||||
PlayOrganObject(play_np[i]->y,-1,i,info.tdata[i].freq);
|
PlayOrganObject(play_np[i]->y, -1, i, info.tdata[i].freq);
|
||||||
now_leng[i] = play_np[i]->length;
|
now_leng[i] = play_np[i]->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(play_np[i]->pan != PANDUMMY)
|
if(play_np[i]->pan != PANDUMMY)
|
||||||
ChangeOrganPan(play_np[i]->y,play_np[i]->pan, i);
|
ChangeOrganPan(play_np[i]->y, play_np[i]->pan, i);
|
||||||
if(play_np[i]->volume != VOLDUMMY)
|
if(play_np[i]->volume != VOLDUMMY)
|
||||||
gTrackVol[i] = play_np[i]->volume;
|
gTrackVol[i] = play_np[i]->volume;
|
||||||
|
|
||||||
play_np[i] = play_np[i]->to;
|
play_np[i] = play_np[i]->to;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now_leng[i] == 0 )
|
if (now_leng[i] == 0)
|
||||||
PlayOrganObject(0, 2, i, info.tdata[i].freq);
|
PlayOrganObject(0, 2, i, info.tdata[i].freq);
|
||||||
|
|
||||||
if (now_leng[i] > 0)
|
if (now_leng[i] > 0)
|
||||||
|
@ -365,10 +368,10 @@ void OrganyaPlayData()
|
||||||
if (play_np[i] != NULL && play_p == play_np[i]->x)
|
if (play_np[i] != NULL && play_p == play_np[i]->x)
|
||||||
{
|
{
|
||||||
if (play_np[i]->y != KEYDUMMY)
|
if (play_np[i]->y != KEYDUMMY)
|
||||||
PlayDramObject(play_np[i]->y,1,i-MAXMELODY);
|
PlayDramObject(play_np[i]->y, 1, i - MAXMELODY);
|
||||||
|
|
||||||
if(play_np[i]->pan != PANDUMMY)
|
if(play_np[i]->pan != PANDUMMY)
|
||||||
ChangeDramPan(play_np[i]->pan,i-MAXMELODY);
|
ChangeDramPan(play_np[i]->pan, i - MAXMELODY);
|
||||||
if(play_np[i]->volume != VOLDUMMY)
|
if(play_np[i]->volume != VOLDUMMY)
|
||||||
gTrackVol[i] = play_np[i]->volume;
|
gTrackVol[i] = play_np[i]->volume;
|
||||||
|
|
||||||
|
@ -379,7 +382,7 @@ void OrganyaPlayData()
|
||||||
ChangeDramVolume(gOrgVolume * gTrackVol[i] / 0x7F, i - MAXMELODY);
|
ChangeDramVolume(gOrgVolume * gTrackVol[i] / 0x7F, i - MAXMELODY);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Looping
|
// Looping
|
||||||
play_p++;
|
play_p++;
|
||||||
if(play_p >= info.end_x)
|
if(play_p >= info.end_x)
|
||||||
{
|
{
|
||||||
|
@ -403,35 +406,40 @@ void SetPlayPointer(long x)
|
||||||
#define READ_LE16(pointer) pointer[0] | (pointer[1] << 8); pointer += 2;
|
#define READ_LE16(pointer) pointer[0] | (pointer[1] << 8); pointer += 2;
|
||||||
#define READ_LE32(pointer) pointer[0] | (pointer[1] << 8) | (pointer[2] << 16) | (pointer[3] << 24); pointer += 4;
|
#define READ_LE32(pointer) pointer[0] | (pointer[1] << 8) | (pointer[2] << 16) | (pointer[3] << 24); pointer += 4;
|
||||||
|
|
||||||
//Load organya file
|
// Load organya file
|
||||||
void LoadOrganya(const char *name)
|
void LoadOrganya(const char *name)
|
||||||
{
|
{
|
||||||
//Unload previous things
|
// Unload previous things
|
||||||
OrganyaReleaseNote();
|
OrganyaReleaseNote();
|
||||||
memset(&info, 0, sizeof(info));
|
memset(&info, 0, sizeof(info));
|
||||||
OrganyaNoteAlloc(0xFFFF);
|
OrganyaNoteAlloc(0xFFFF);
|
||||||
|
|
||||||
//Stop currently playing notes
|
// Stop currently playing notes
|
||||||
memset(play_np, 0, sizeof(play_np));
|
memset(play_np, 0, sizeof(play_np));
|
||||||
memset(old_key, 0xFF, sizeof(old_key));
|
memset(old_key, 0xFF, sizeof(old_key));
|
||||||
memset(key_on, 0, sizeof(key_on));
|
memset(key_on, 0, sizeof(key_on));
|
||||||
memset(key_twin, 0, sizeof(key_twin));
|
memset(key_twin, 0, sizeof(key_twin));
|
||||||
memset(now_leng, 0, sizeof(now_leng));
|
memset(now_leng, 0, sizeof(now_leng));
|
||||||
|
|
||||||
//Open file
|
// Open file
|
||||||
printf("Loading org %s\n", name);
|
printf("Loading org %s\n", name);
|
||||||
const unsigned char *p = FindResource(name, "ORG", NULL);
|
const unsigned char *p = FindResource(name, "ORG", NULL);
|
||||||
|
|
||||||
//Version Check
|
// Version Check
|
||||||
unsigned char ver = 0;
|
unsigned char ver = 0;
|
||||||
char pass_check[6];
|
char pass_check[6];
|
||||||
|
|
||||||
memcpy(pass_check, p, 6);
|
memcpy(pass_check, p, 6);
|
||||||
p += 6;
|
p += 6;
|
||||||
|
|
||||||
if (!memcmp(pass_check, "Org-01", 6))ver = 1;
|
if (!memcmp(pass_check, "Org-01", 6))
|
||||||
if (!memcmp(pass_check, "Org-02", 6))ver = 2;
|
ver = 1;
|
||||||
//if (!memcmp(pass_check, "Org-03", 6))ver = 2;
|
|
||||||
|
if (!memcmp(pass_check, "Org-02", 6))
|
||||||
|
ver = 2;
|
||||||
|
|
||||||
|
// if (!memcmp(pass_check, "Org-03", 6))
|
||||||
|
// ver = 2;
|
||||||
|
|
||||||
if (!ver)
|
if (!ver)
|
||||||
{
|
{
|
||||||
|
@ -439,7 +447,7 @@ void LoadOrganya(const char *name)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set song information
|
// Set song information
|
||||||
info.wait = READ_LE16(p);
|
info.wait = READ_LE16(p);
|
||||||
info.line = *p++;
|
info.line = *p++;
|
||||||
info.dot = *p++;
|
info.dot = *p++;
|
||||||
|
@ -454,73 +462,76 @@ void LoadOrganya(const char *name)
|
||||||
info.tdata[i].note_num = READ_LE16(p);
|
info.tdata[i].note_num = READ_LE16(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load notes
|
// Load notes
|
||||||
NOTELIST *np;
|
NOTELIST *np;
|
||||||
|
|
||||||
for (int j = 0; j < 16; j++) {
|
for (int j = 0; j < 16; j++)
|
||||||
//The first note from is NULL
|
{
|
||||||
if (info.tdata[j].note_num == 0) {
|
// The first note from is NULL
|
||||||
|
if (info.tdata[j].note_num == 0)
|
||||||
|
{
|
||||||
info.tdata[j].note_list = NULL;
|
info.tdata[j].note_list = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make note list
|
// Make note list
|
||||||
np = info.tdata[j].note_p;
|
np = info.tdata[j].note_p;
|
||||||
info.tdata[j].note_list = info.tdata[j].note_p;
|
info.tdata[j].note_list = info.tdata[j].note_p;
|
||||||
np->from = NULL;
|
np->from = NULL;
|
||||||
np->to = (np + 1);
|
np->to = (np + 1);
|
||||||
np++;
|
np++;
|
||||||
|
|
||||||
for (int i = 1; i < info.tdata[j].note_num; i++) {
|
for (int i = 1; i < info.tdata[j].note_num; i++)
|
||||||
|
{
|
||||||
np->from = (np - 1);
|
np->from = (np - 1);
|
||||||
np->to = (np + 1);
|
np->to = (np + 1);
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//The last note to is NULL
|
// The last note to is NULL
|
||||||
np--;
|
np--;
|
||||||
np->to = NULL;
|
np->to = NULL;
|
||||||
|
|
||||||
//Set note properties
|
// Set note properties
|
||||||
np = info.tdata[j].note_p; //X position
|
np = info.tdata[j].note_p; // X position
|
||||||
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
||||||
np->x = READ_LE32(p);
|
np->x = READ_LE32(p);
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
|
|
||||||
np = info.tdata[j].note_p; //Y position
|
np = info.tdata[j].note_p; // Y position
|
||||||
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
||||||
np->y = *p++;
|
np->y = *p++;
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
|
|
||||||
np = info.tdata[j].note_p; //Length
|
np = info.tdata[j].note_p; // Length
|
||||||
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
||||||
np->length = *p++;
|
np->length = *p++;
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
|
|
||||||
np = info.tdata[j].note_p; //Volume
|
np = info.tdata[j].note_p; // Volume
|
||||||
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
||||||
np->volume = *p++;
|
np->volume = *p++;
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
|
|
||||||
np = info.tdata[j].note_p; //Pan
|
np = info.tdata[j].note_p; // Pan
|
||||||
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
for (int i = 0; i < info.tdata[j].note_num; i++) {
|
||||||
np->pan = *p++;
|
np->pan = *p++;
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create waves
|
// Create waves
|
||||||
for (int j = 0; j < 8; j++)
|
for (int j = 0; j < 8; j++)
|
||||||
MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi);
|
MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi);
|
||||||
|
|
||||||
//Reset position
|
// Reset position
|
||||||
SetPlayPointer(0);
|
SetPlayPointer(0);
|
||||||
|
|
||||||
//Set as loaded
|
// Set as loaded
|
||||||
info.loaded = TRUE;
|
info.loaded = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +549,7 @@ unsigned int GetOrganyaPosition()
|
||||||
|
|
||||||
void PlayOrganyaMusic()
|
void PlayOrganyaMusic()
|
||||||
{
|
{
|
||||||
//Start timer
|
// Start timer
|
||||||
OrganyaStartTimer(info.wait);
|
OrganyaStartTimer(info.wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,10 +566,10 @@ BOOL ChangeOrganyaVolume(signed int volume)
|
||||||
|
|
||||||
void StopOrganyaMusic()
|
void StopOrganyaMusic()
|
||||||
{
|
{
|
||||||
//Stop timer
|
// Stop timer
|
||||||
OrganyaEndTimer();
|
OrganyaEndTimer();
|
||||||
|
|
||||||
//Stop notes
|
// Stop notes
|
||||||
for (int i = 0; i < MAXMELODY; i++)
|
for (int i = 0; i < MAXMELODY; i++)
|
||||||
PlayOrganObject(0, 2, i, 0);
|
PlayOrganObject(0, 2, i, 0);
|
||||||
|
|
||||||
|
@ -572,7 +583,7 @@ void SetOrganyaFadeout()
|
||||||
bFadeout = TRUE;
|
bFadeout = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Org timer
|
// Org timer
|
||||||
SDL_Thread *OrganyaTimer = NULL;
|
SDL_Thread *OrganyaTimer = NULL;
|
||||||
BOOL bEndTimer = FALSE;
|
BOOL bEndTimer = FALSE;
|
||||||
|
|
||||||
|
@ -580,27 +591,27 @@ int OrganyaPlayTimer(void *ptr)
|
||||||
{
|
{
|
||||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||||
|
|
||||||
//Set time for next step to play
|
// Set time for next step to play
|
||||||
Uint32 NextTick = SDL_GetTicks() + info.wait;
|
Uint32 NextTick = SDL_GetTicks() + info.wait;
|
||||||
|
|
||||||
while (bEndTimer == FALSE)
|
while (bEndTimer == FALSE)
|
||||||
{
|
{
|
||||||
if (info.loaded)
|
if (info.loaded)
|
||||||
{
|
{
|
||||||
//Play music
|
// Play music
|
||||||
OrganyaPlayData();
|
OrganyaPlayData();
|
||||||
|
|
||||||
//Wait until this step is over
|
// Wait until this step is over
|
||||||
while (NextTick > SDL_GetTicks())
|
while (NextTick > SDL_GetTicks())
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
|
|
||||||
//Get time for next step to play
|
// Get time for next step to play
|
||||||
while (NextTick <= SDL_GetTicks())
|
while (NextTick <= SDL_GetTicks())
|
||||||
NextTick += info.wait;
|
NextTick += info.wait;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Wait until the org is loaded
|
// Wait until the org is loaded
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,24 +628,24 @@ void OrganyaStartTimer(unsigned int wait)
|
||||||
|
|
||||||
void OrganyaEndTimer()
|
void OrganyaEndTimer()
|
||||||
{
|
{
|
||||||
bEndTimer = TRUE; //Tell thread to end
|
bEndTimer = TRUE; // Tell thread to end
|
||||||
SDL_WaitThread(OrganyaTimer, NULL); //Wait for thread to end
|
SDL_WaitThread(OrganyaTimer, NULL); // Wait for thread to end
|
||||||
OrganyaTimer = NULL;
|
OrganyaTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start and end organya
|
// Start and end organya
|
||||||
void StartOrganya()
|
void StartOrganya()
|
||||||
{
|
{
|
||||||
//Initialize org stuff
|
// Initialize org stuff
|
||||||
InitWaveData100();
|
InitWaveData100();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndOrganya()
|
void EndOrganya()
|
||||||
{
|
{
|
||||||
//End timer
|
// End timer
|
||||||
OrganyaEndTimer();
|
OrganyaEndTimer();
|
||||||
|
|
||||||
//Release everything related to org
|
// Release everything related to org
|
||||||
OrganyaReleaseNote();
|
OrganyaReleaseNote();
|
||||||
|
|
||||||
for (int i = 0; i < MAXMELODY; i++)
|
for (int i = 0; i < MAXMELODY; i++)
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
//Below are Organya song data structures
|
//Below are Organya song data structures
|
||||||
struct NOTELIST {
|
struct NOTELIST
|
||||||
|
{
|
||||||
NOTELIST *from; //Previous address
|
NOTELIST *from; //Previous address
|
||||||
NOTELIST *to; //Next address
|
NOTELIST *to; //Next address
|
||||||
|
|
||||||
|
@ -15,7 +16,8 @@ struct NOTELIST {
|
||||||
};
|
};
|
||||||
|
|
||||||
//Track data * 8
|
//Track data * 8
|
||||||
struct TRACKDATA {
|
struct TRACKDATA
|
||||||
|
{
|
||||||
unsigned short freq; //Frequency (1000 is default)
|
unsigned short freq; //Frequency (1000 is default)
|
||||||
unsigned char wave_no; //Waveform No.
|
unsigned char wave_no; //Waveform No.
|
||||||
signed char pipi;
|
signed char pipi;
|
||||||
|
@ -26,7 +28,8 @@ struct TRACKDATA {
|
||||||
};
|
};
|
||||||
|
|
||||||
//Unique information held in songs
|
//Unique information held in songs
|
||||||
struct MUSICINFO {
|
struct MUSICINFO
|
||||||
|
{
|
||||||
unsigned short wait;
|
unsigned short wait;
|
||||||
BOOL loaded;
|
BOOL loaded;
|
||||||
BOOL playing;
|
BOOL playing;
|
||||||
|
|
|
@ -48,18 +48,18 @@ BOOL SaveProfile(const char *name)
|
||||||
const char *FLAG = "FLAG";
|
const char *FLAG = "FLAG";
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
|
|
||||||
//Get path
|
// Get path
|
||||||
if (name)
|
if (name)
|
||||||
sprintf(path, "%s/%s", gModulePath, name);
|
sprintf(path, "%s/%s", gModulePath, name);
|
||||||
else
|
else
|
||||||
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
||||||
|
|
||||||
//Open file
|
// Open file
|
||||||
fp = fopen(path, "wb");
|
fp = fopen(path, "wb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
//Set up profile
|
// Set up profile
|
||||||
memset(&profile, 0, sizeof(PROFILE));
|
memset(&profile, 0, sizeof(PROFILE));
|
||||||
memcpy(profile.code, gProfileCode, sizeof(profile.code));
|
memcpy(profile.code, gProfileCode, sizeof(profile.code));
|
||||||
memcpy(profile.FLAG, FLAG, sizeof(profile.FLAG));
|
memcpy(profile.FLAG, FLAG, sizeof(profile.FLAG));
|
||||||
|
@ -82,7 +82,7 @@ BOOL SaveProfile(const char *name)
|
||||||
memcpy(profile.permit_mapping, gMapping, sizeof(profile.permit_mapping));
|
memcpy(profile.permit_mapping, gMapping, sizeof(profile.permit_mapping));
|
||||||
memcpy(profile.flags, gFlagNPC, sizeof(profile.flags));
|
memcpy(profile.flags, gFlagNPC, sizeof(profile.flags));
|
||||||
|
|
||||||
//Write to file
|
// Write to file
|
||||||
#ifdef NONPORTABLE
|
#ifdef NONPORTABLE
|
||||||
fwrite(&profile, sizeof(PROFILE), 1, fp);
|
fwrite(&profile, sizeof(PROFILE), 1, fp);
|
||||||
#else
|
#else
|
||||||
|
@ -127,7 +127,7 @@ BOOL SaveProfile(const char *name)
|
||||||
|
|
||||||
BOOL LoadProfile(const char *name)
|
BOOL LoadProfile(const char *name)
|
||||||
{
|
{
|
||||||
//Get path
|
// Get path
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
|
@ -135,14 +135,14 @@ BOOL LoadProfile(const char *name)
|
||||||
else
|
else
|
||||||
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
||||||
|
|
||||||
//Open file
|
// Open file
|
||||||
PROFILE profile;
|
PROFILE profile;
|
||||||
|
|
||||||
FILE *fp = fopen(path, "rb");
|
FILE *fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
//Check header code
|
// Check header code
|
||||||
fread(profile.code, 8, 1, fp);
|
fread(profile.code, 8, 1, fp);
|
||||||
if (memcmp(profile.code, gProfileCode, 8))
|
if (memcmp(profile.code, gProfileCode, 8))
|
||||||
{
|
{
|
||||||
|
@ -152,7 +152,7 @@ BOOL LoadProfile(const char *name)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Read data
|
// Read data
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
memset(&profile, 0, sizeof(PROFILE));
|
memset(&profile, 0, sizeof(PROFILE));
|
||||||
#ifdef NONPORTABLE
|
#ifdef NONPORTABLE
|
||||||
|
@ -194,7 +194,7 @@ BOOL LoadProfile(const char *name)
|
||||||
#endif
|
#endif
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
//Set things
|
// Set things
|
||||||
gSelectedArms = profile.select_arms;
|
gSelectedArms = profile.select_arms;
|
||||||
gSelectedItem = profile.select_item;
|
gSelectedItem = profile.select_item;
|
||||||
gCounter = profile.counter;
|
gCounter = profile.counter;
|
||||||
|
@ -205,13 +205,13 @@ BOOL LoadProfile(const char *name)
|
||||||
memcpy(gMapping, profile.permit_mapping, sizeof(gMapping));
|
memcpy(gMapping, profile.permit_mapping, sizeof(gMapping));
|
||||||
memcpy(gFlagNPC, profile.flags, sizeof(gFlagNPC));
|
memcpy(gFlagNPC, profile.flags, sizeof(gFlagNPC));
|
||||||
|
|
||||||
//Load stage
|
// Load stage
|
||||||
ChangeMusic(profile.music);
|
ChangeMusic(profile.music);
|
||||||
InitMyChar();
|
InitMyChar();
|
||||||
if (!TransferStage(profile.stage, 0, 0, 1))
|
if (!TransferStage(profile.stage, 0, 0, 1))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
//Set character properties
|
// Set character properties
|
||||||
gMC.equip = profile.equip;
|
gMC.equip = profile.equip;
|
||||||
gMC.unit = profile.unit;
|
gMC.unit = profile.unit;
|
||||||
gMC.direct = profile.direct;
|
gMC.direct = profile.direct;
|
||||||
|
@ -229,7 +229,7 @@ BOOL LoadProfile(const char *name)
|
||||||
gMC.rect_arms.top = 32 * (gArmsData[gSelectedArms].code / 10);
|
gMC.rect_arms.top = 32 * (gArmsData[gSelectedArms].code / 10);
|
||||||
gMC.rect_arms.bottom = gMC.rect_arms.top + 16;
|
gMC.rect_arms.bottom = gMC.rect_arms.top + 16;
|
||||||
|
|
||||||
//Reset stuff
|
// Reset stuff
|
||||||
ClearFade();
|
ClearFade();
|
||||||
SetFrameMyChar();
|
SetFrameMyChar();
|
||||||
SetFrameTargetMyChar(16);
|
SetFrameTargetMyChar(16);
|
||||||
|
@ -255,19 +255,23 @@ BOOL InitializeGame()
|
||||||
if (!TransferStage(13, 200, 10, 8))
|
if (!TransferStage(13, 200, 10, 8))
|
||||||
{
|
{
|
||||||
// TODO - restore this when ghWnd is available
|
// TODO - restore this when ghWnd is available
|
||||||
/*#if defined(NONPORTABLE) && defined(WINDOWS)
|
/*
|
||||||
|
|
||||||
|
#if defined(NONPORTABLE) && defined(WINDOWS)
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
MessageBoxA(ghWnd, "ステージの読み込みに失敗", "エラー", MB_OK);
|
MessageBoxA(ghWnd, "ステージの読み込みに失敗", "エラー", MB_OK);
|
||||||
#else
|
#else
|
||||||
MessageBoxA(ghWnd, "Failed to load stage", "Error", MB_OK);
|
MessageBoxA(ghWnd, "Failed to load stage", "Error", MB_OK);
|
||||||
#endif
|
#endif
|
||||||
#else*/
|
#else
|
||||||
|
|
||||||
|
*/
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "ステージの読み込みに失敗", NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "ステージの読み込みに失敗", NULL);
|
||||||
#else
|
#else
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Failed to load stage", NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Failed to load stage", NULL);
|
||||||
#endif
|
#endif
|
||||||
//#endif
|
// #endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue