Merge pull request #37 from GabrielRavier/feature/improveOToR

Improve O to R
This commit is contained in:
Clownacy 2019-06-17 15:48:46 +00:00 committed by GitHub
commit f9b498c51c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 169 additions and 140 deletions

View file

@ -80,7 +80,7 @@ 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;
} }
@ -88,13 +88,15 @@ void OrganyaReleaseNote()
} }
// Wave playing and loading // Wave playing and loading
typedef struct { typedef struct
{
short wave_size; short wave_size;
short oct_par; short oct_par;
short oct_size; short oct_size;
} 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
@ -154,8 +156,10 @@ 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)
{ {
for (int j = 0; j < 8; j++) { for (int j = 0; j < 8; j++)
for (int i = 0; i < 2; i++) { {
for (int i = 0; i < 2; i++)
{
lpORGANBUFFER[track][j][i]->SetFrequency(((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000)); lpORGANBUFFER[track][j][i]->SetFrequency(((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000));
} }
} }
@ -305,14 +309,17 @@ 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;
} }
@ -429,9 +436,14 @@ void LoadOrganya(const char *name)
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)
{ {
@ -446,7 +458,8 @@ void LoadOrganya(const char *name)
info.repeat_x = READ_LE32(p); info.repeat_x = READ_LE32(p);
info.end_x = READ_LE32(p); info.end_x = READ_LE32(p);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++)
{
info.tdata[i].freq = READ_LE16(p); info.tdata[i].freq = READ_LE16(p);
info.tdata[i].wave_no = *p++; info.tdata[i].wave_no = *p++;
const signed char pipi = *p++; const signed char pipi = *p++;
@ -457,9 +470,11 @@ void LoadOrganya(const char *name)
// 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 // The first note from is NULL
if (info.tdata[j].note_num == 0) { if (info.tdata[j].note_num == 0)
{
info.tdata[j].note_list = NULL; info.tdata[j].note_list = NULL;
continue; continue;
} }
@ -471,7 +486,8 @@ void LoadOrganya(const char *name)
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++;
@ -483,31 +499,36 @@ void LoadOrganya(const char *name)
// 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++;
} }

View file

@ -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;

View file

@ -255,13 +255,18 @@ 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