- Afegit modul de sequencia (història).

- Reemplaçades músiques per MIDIs
This commit is contained in:
2019-12-13 17:36:59 +01:00
parent 60af56270f
commit 6ee8830244
12 changed files with 306 additions and 31 deletions

BIN
data.jrf

Binary file not shown.

19
info.h
View File

@@ -6,12 +6,25 @@
#define ESTAT_MENU 2 #define ESTAT_MENU 2
#define ESTAT_OPCIONS 3 #define ESTAT_OPCIONS 3
#define ESTAT_SELECT 4 #define ESTAT_SELECT 4
#define ESTAT_JOC 5 #define ESTAT_SEQUENCIA 5
#define ESTAT_LEVELCOMPLETE 6 #define ESTAT_JOC 6
#define ESTAT_MORT 7 #define ESTAT_LEVELCOMPLETE 7
#define ESTAT_MORT 8
#define SENSE_OPCIO -1
#define MODE_FACIL 0
#define MODE_NORMAL 1
#define MODE_DIFICIL 2
#define PERSONATGE_PEPE 0
#define PERSONATGE_ROSITA 1
#define PERSONATGE_JOB 2
struct Info { struct Info {
int estat_joc; int estat_joc;
bool rosita_enabled; bool rosita_enabled;
bool job_enabled; bool job_enabled;
int dificultat;
int personatge;
}; };

View File

@@ -206,6 +206,12 @@ void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) {
main_palette[index].b = b << 2; main_palette[index].b = b << 2;
} }
void JD8_SetPaletteColor(Uint8 index, Uint8 other) {
main_palette[index].r = main_palette[other].r;
main_palette[index].g = main_palette[other].g;
main_palette[index].b = main_palette[other].b;
}
void JD8_FadeOut() { void JD8_FadeOut() {
for( int j = 0; j < 32; j++ ) { for( int j = 0; j < 32; j++ ) {
for( int i = 0; i < 256; i++ ) { for( int i = 0; i < 256; i++ ) {

View File

@@ -50,6 +50,7 @@ void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel );
void JD8_PutPixel(int x, int y, Uint8 pixel); void JD8_PutPixel(int x, int y, Uint8 pixel);
void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b); void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b);
void JD8_SetPaletteColor(Uint8 index, Uint8 other);
void JD8_FadeOut(); void JD8_FadeOut();
bool JD8_FadeOutAsync(); bool JD8_FadeOutAsync();

View File

@@ -6,6 +6,7 @@
#include "modulestaticscreen.h" #include "modulestaticscreen.h"
#include "modulemenu.h" #include "modulemenu.h"
#include "moduleselect.h" #include "moduleselect.h"
#include "modulesequence.h"
#include "time.h" #include "time.h"
#include <string> #include <string>
@@ -36,9 +37,11 @@ int main( int argc, char* args[] ) {
JS_Init(); JS_Init();
Info info; Info info;
info.estat_joc = ESTAT_ICEKAS; info.estat_joc = ESTAT_ICEKAS; // ESTAT_SEQUENCIA; // ESTAT_ICEKAS;
info.rosita_enabled = false; info.rosita_enabled = false;
info.job_enabled = false; info.job_enabled = false;
info.dificultat = MODE_FACIL;
info.personatge = PERSONATGE_PEPE;
FILE* ini = fopen("trick.ini", "rb"); FILE* ini = fopen("trick.ini", "rb");
if (ini != NULL) { if (ini != NULL) {
@@ -70,6 +73,12 @@ int main( int argc, char* args[] ) {
info.estat_joc = moduleSelect->Go(); info.estat_joc = moduleSelect->Go();
delete moduleSelect; delete moduleSelect;
break; break;
case ESTAT_SEQUENCIA:
ModuleSequence * moduleSequence;
moduleSequence = new ModuleSequence(&info);
info.estat_joc = moduleSequence->Go();
delete moduleSequence;
break;
} }
} }

View File

@@ -22,7 +22,7 @@ ModuleMenu::~ModuleMenu(void) {
int ModuleMenu::Go() { int ModuleMenu::Go() {
JS_LoadMusic("mtitle.xm"); JS_LoadMusic("mtitle.mid");
JS_PlayMusic(-1); JS_PlayMusic(-1);
JD8_Surface fondo = JD8_LoadSurface("menu.gif"); JD8_Surface fondo = JD8_LoadSurface("menu.gif");

View File

@@ -7,14 +7,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string> #include <string>
#define SENSE_OPCIO -1
#define OPCIO_FACIL 0
#define OPCIO_NORMAL 1
#define OPCIO_DIFICIL 2
#define OPCIO_PEPE 0
#define OPCIO_ROSITA 1
#define OPCIO_JOB 2
ModuleSelect::ModuleSelect(Info* info) { ModuleSelect::ModuleSelect(Info* info) {
this->info = info; this->info = info;
} }
@@ -86,9 +78,9 @@ int ModuleSelect::Go() {
while (!JG_ShouldUpdate()) { JI_Update(); } while (!JG_ShouldUpdate()) { JI_Update(); }
} }
int opcio_seleccionada = OPCIO_FACIL; int opcio_seleccionada = this->info->dificultat;
int opcio_triada = SENSE_OPCIO; int opcio_triada = SENSE_OPCIO;
int personatge_seleccionat = OPCIO_PEPE; int personatge_seleccionat = this->info->personatge;
bool fletxa_amunt_pulsada = false; bool fletxa_amunt_pulsada = false;
bool fletxa_avall_pulsada = false; bool fletxa_avall_pulsada = false;
bool fletxa_esquerra_pulsada = false; bool fletxa_esquerra_pulsada = false;
@@ -172,14 +164,9 @@ int ModuleSelect::Go() {
if (JG_Quitting()) { if (JG_Quitting()) {
return ESTAT_EIXIR; return ESTAT_EIXIR;
} } else {
else { this->info->dificultat = opcio_triada;
/* switch (opcio_triada) { this->info->personatge = personatge_seleccionat;
case OPCIO_TIMEATTACK: return ESTAT_LOGO; break; return ESTAT_SEQUENCIA;
case OPCIO_WORLDTOUR: return ESTAT_MENU; break;
case OPCIO_CLASSICMODE: return ESTAT_MENU; break;
case OPCIO_OPTIONS: return ESTAT_MENU; break;
}*/
return ESTAT_JOC;
} }
} }

229
modulesequence.cpp Normal file
View File

@@ -0,0 +1,229 @@
#include "modulesequence.h"
#include "jgame.h"
#include "jdraw8.h"
#include "jinput.h"
#include "jsound.h"
#include <stdlib.h>
#include <string>
JD8_Surface gfx = nullptr;
JD8_Surface fondo = nullptr;
JD8_Palette pal = nullptr;
ModuleSequence::ModuleSequence(Info* info) {
this->info = info;
gfx = nullptr;
fondo = nullptr;
pal = nullptr;
}
ModuleSequence::~ModuleSequence(void) {
}
int ModuleSequence::Go() {
JS_LoadMusic("mhist.mid");
JS_PlayMusic(-1);
gfx = JD8_LoadSurface("sprites.gif");
JD8_ClearScreen(0);
JD8_Flip();
fondo = JD8_LoadSurface("hist01.gif");
pal = JD8_LoadPalette("hist01.gif");
this->FadeIn();
this->ShowText(40, 90, 2, 10, "QUE BON DIA FA NO CREUS PEPE");
this->ShowText(50, 80, 10, 10, "EEEE..SS..SSIII.SI");
this->ShowText(140, 140, 2, 10, "[SEMPRE QUE M^ACOSTE", "A PEPE ES POSA RARO\\");
JD8_Blit(fondo);
JD8_Flip();
this->Wait(200);
this->FadeOut();
JD8_FreeSurface(fondo);
free(pal);
if (!JG_Quitting()) {
fondo = JD8_LoadSurface("hist02.gif");
pal = JD8_LoadPalette("hist02.gif");
this->FadeIn();
this->ShowText(100, 140, 10, 10, "AAAAY a");
this->ShowText(100, 55, 3, 10, "JA T^HE PILLAT PEPE");
this->ShowText(145, 125, 2, 1, "AUXILIa");
JD8_Blit(fondo);
JD8_Flip();
this->Wait(200);
this->FadeOut();
JD8_FreeSurface(fondo);
free(pal);
}
if (!JG_Quitting()) {
fondo = JD8_LoadSurface("hist03.gif");
pal = JD8_LoadPalette("hist03.gif");
this->FadeIn();
this->ShowText(50, 80, 5, 10, "ARA ROSITA ES MEUA");
this->ShowText(50, 80, 5, 10, "SI VOLS ACONSEGUIR_LA", "HAURAS DE SEGUIR_ME", "PER TOT EL MONb");
this->ShowText(60, 80, 5, 1, "JA JA JA JA JA aa");
JD8_Blit(fondo);
JD8_Flip();
this->Wait(200);
this->FadeOut();
JD8_FreeSurface(fondo);
free(pal);
}
if (!JG_Quitting()) {
fondo = JD8_LoadSurface("hist04.gif");
pal = JD8_LoadPalette("hist04.gif");
this->FadeIn();
this->ShowText(120, 60, 2, 5, "AJUDA^M PEPEa");
this->ShowText(50, 50, 7, 50, "MALEIT SIGUES", "ET TROBAREbbb");
this->FadeOut();
JD8_FreeSurface(fondo);
free(pal);
}
// FREE EVERYTHING
JD8_FreeSurface(gfx);
if (JG_Quitting()) {
return ESTAT_EIXIR;
} else {
return ESTAT_JOC;
}
}
void ModuleSequence::FadeIn() {
JD8_Blit(fondo);
JG_SetUpdateTicks(1);
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting()) {
while (!JG_ShouldUpdate()) { JI_Update(); }
}
}
void ModuleSequence::FadeOut() {
JG_SetUpdateTicks(2);
while (!JD8_FadeOutAsync() && !JG_Quitting()) {
while (!JG_ShouldUpdate()) { JI_Update(); }
}
}
void ModuleSequence::ShowText(int x, int y, int color, int speed, char * text1, char * text2, char * text3) {
bool eixir = false;
JG_SetUpdateTicks(10);
JD8_SetPaletteColor(254, color);
// mod 35
// A (65) = 23 -> char - 42
// Special chars: ( ) <20> ' - : ! .
// [ \ ] ^ _ ` a b
int tamany_text1 = strlen(text1);
int temps_total = tamany_text1 * speed;
int temps_inicial = JG_GetCycleCounter();
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
JD8_Blit(fondo);
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
for (int i = 0; i <= num_chars_actual; i++) {
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
if (text1[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i+1) * 8, y, gfx, (char_actual % 35) * 9, 6+floorf(char_actual / 35) * 9, 9, 9, 255);
}
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
JD8_Flip();
}
if (eixir) {
for (int i = 0; i <= tamany_text1; i++) {
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
if (text1[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
}
if (text2 != NULL) {
int tamany_text2 = strlen(text2);
temps_total = tamany_text2 * speed;
temps_inicial = JG_GetCycleCounter();
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
JD8_Blit(fondo);
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
for (int i = 0; i <= tamany_text1; i++) {
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
if (text1[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
for (int i = 0; i <= num_chars_actual; i++) {
int char_actual = text2[i] - 42; if (char_actual < 0) char_actual = 57;
if (text2[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y+10, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
JD8_Flip();
}
if (eixir) {
for (int i = 0; i <= tamany_text2; i++) {
int char_actual = text2[i] - 42; if (char_actual < 0) char_actual = 57;
if (text2[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y + 10, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
}
if (text3 != NULL) {
int tamany_text3 = strlen(text3);
temps_total = tamany_text3 * speed;
temps_inicial = JG_GetCycleCounter();
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
JD8_Blit(fondo);
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
for (int i = 0; i <= tamany_text1; i++) {
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
if (text1[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
for (int i = 0; i <= tamany_text2; i++) {
int char_actual = text2[i] - 42; if (char_actual < 0) char_actual = 57;
if (text2[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y+10, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
for (int i = 0; i <= num_chars_actual; i++) {
int char_actual = text3[i] - 42; if (char_actual < 0) char_actual = 57;
if (text3[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y + 20, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
JD8_Flip();
}
for (int i = 0; i <= tamany_text3; i++) {
int char_actual = text3[i] - 42; if (char_actual < 0) char_actual = 57;
if (text3[i] == '.') char_actual = 56;
JD8_BlitCK(x + (i + 1) * 8, y + 20, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
}
JD8_Flip();
}
}
JD8_Flip();
Wait(200);
}
void ModuleSequence::Wait(int time) {
bool eixir = false;
int temps_inicial = JG_GetCycleCounter();
while ((JG_GetCycleCounter() - temps_inicial < time) && !eixir) {
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
}
}

22
modulesequence.h Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include "info.h"
class ModuleSequence {
public:
ModuleSequence(Info* info);
~ModuleSequence(void);
int Go();
private:
Info * info;
void FadeIn();
void FadeOut();
void ShowText(int x, int y, int color, int speed, char* text1, char* text2 = nullptr, char* text3 = nullptr);
void Wait(int time);
};

View File

@@ -46,7 +46,7 @@ void ModuleStaticScreen::doIcekas() {
bool eixir = false; bool eixir = false;
JS_LoadMusic("mlogo.xm"); JS_LoadMusic("mlogo.mid");
JS_PlayMusic(1); JS_PlayMusic(1);
JD8_Surface gfx = JD8_LoadSurface( "logo.gif" ); JD8_Surface gfx = JD8_LoadSurface( "logo.gif" );

View File

@@ -89,6 +89,7 @@
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="modulemenu.cpp" /> <ClCompile Include="modulemenu.cpp" />
<ClCompile Include="moduleselect.cpp" /> <ClCompile Include="moduleselect.cpp" />
<ClCompile Include="modulesequence.cpp" />
<ClCompile Include="modulestaticscreen.cpp" /> <ClCompile Include="modulestaticscreen.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -100,6 +101,7 @@
<ClInclude Include="jsound.h" /> <ClInclude Include="jsound.h" />
<ClInclude Include="modulemenu.h" /> <ClInclude Include="modulemenu.h" />
<ClInclude Include="moduleselect.h" /> <ClInclude Include="moduleselect.h" />
<ClInclude Include="modulesequence.h" />
<ClInclude Include="modulestaticscreen.h" /> <ClInclude Include="modulestaticscreen.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@@ -45,6 +45,9 @@
<ClCompile Include="moduleselect.cpp"> <ClCompile Include="moduleselect.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="modulesequence.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="info.h"> <ClInclude Include="info.h">
@@ -74,5 +77,8 @@
<ClInclude Include="moduleselect.h"> <ClInclude Include="moduleselect.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="modulesequence.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>