diff --git a/data.jrf b/data.jrf index 0fb4bb5..10faae7 100644 Binary files a/data.jrf and b/data.jrf differ diff --git a/info.h b/info.h index 1ab7625..83a85c8 100644 --- a/info.h +++ b/info.h @@ -1,17 +1,30 @@ #pragma once -#define ESTAT_EIXIR -1 -#define ESTAT_ICEKAS 0 -#define ESTAT_LOGO 1 -#define ESTAT_MENU 2 -#define ESTAT_OPCIONS 3 -#define ESTAT_SELECT 4 -#define ESTAT_JOC 5 -#define ESTAT_LEVELCOMPLETE 6 -#define ESTAT_MORT 7 +#define ESTAT_EIXIR -1 +#define ESTAT_ICEKAS 0 +#define ESTAT_LOGO 1 +#define ESTAT_MENU 2 +#define ESTAT_OPCIONS 3 +#define ESTAT_SELECT 4 +#define ESTAT_SEQUENCIA 5 +#define ESTAT_JOC 6 +#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 { int estat_joc; bool rosita_enabled; bool job_enabled; + int dificultat; + int personatge; }; diff --git a/jdraw8.cpp b/jdraw8.cpp index a74988e..7df4f90 100644 --- a/jdraw8.cpp +++ b/jdraw8.cpp @@ -206,6 +206,12 @@ void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) { 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() { for( int j = 0; j < 32; j++ ) { for( int i = 0; i < 256; i++ ) { diff --git a/jdraw8.h b/jdraw8.h index 9014449..fce4db1 100644 --- a/jdraw8.h +++ b/jdraw8.h @@ -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_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b); +void JD8_SetPaletteColor(Uint8 index, Uint8 other); void JD8_FadeOut(); bool JD8_FadeOutAsync(); diff --git a/main.cpp b/main.cpp index 4056cdf..1bed702 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,7 @@ #include "modulestaticscreen.h" #include "modulemenu.h" #include "moduleselect.h" +#include "modulesequence.h" #include "time.h" #include @@ -36,9 +37,11 @@ int main( int argc, char* args[] ) { JS_Init(); Info info; - info.estat_joc = ESTAT_ICEKAS; + info.estat_joc = ESTAT_ICEKAS; // ESTAT_SEQUENCIA; // ESTAT_ICEKAS; info.rosita_enabled = false; info.job_enabled = false; + info.dificultat = MODE_FACIL; + info.personatge = PERSONATGE_PEPE; FILE* ini = fopen("trick.ini", "rb"); if (ini != NULL) { @@ -70,6 +73,12 @@ int main( int argc, char* args[] ) { info.estat_joc = moduleSelect->Go(); delete moduleSelect; break; + case ESTAT_SEQUENCIA: + ModuleSequence * moduleSequence; + moduleSequence = new ModuleSequence(&info); + info.estat_joc = moduleSequence->Go(); + delete moduleSequence; + break; } } diff --git a/modulemenu.cpp b/modulemenu.cpp index 850afe1..a0a110d 100644 --- a/modulemenu.cpp +++ b/modulemenu.cpp @@ -22,7 +22,7 @@ ModuleMenu::~ModuleMenu(void) { int ModuleMenu::Go() { - JS_LoadMusic("mtitle.xm"); + JS_LoadMusic("mtitle.mid"); JS_PlayMusic(-1); JD8_Surface fondo = JD8_LoadSurface("menu.gif"); diff --git a/moduleselect.cpp b/moduleselect.cpp index 53c4f1b..e031723 100644 --- a/moduleselect.cpp +++ b/moduleselect.cpp @@ -7,14 +7,6 @@ #include #include -#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) { this->info = info; } @@ -86,9 +78,9 @@ int ModuleSelect::Go() { while (!JG_ShouldUpdate()) { JI_Update(); } } - int opcio_seleccionada = OPCIO_FACIL; + int opcio_seleccionada = this->info->dificultat; int opcio_triada = SENSE_OPCIO; - int personatge_seleccionat = OPCIO_PEPE; + int personatge_seleccionat = this->info->personatge; bool fletxa_amunt_pulsada = false; bool fletxa_avall_pulsada = false; bool fletxa_esquerra_pulsada = false; @@ -172,14 +164,9 @@ int ModuleSelect::Go() { if (JG_Quitting()) { return ESTAT_EIXIR; - } - else { -/* switch (opcio_triada) { - case OPCIO_TIMEATTACK: return ESTAT_LOGO; break; - case OPCIO_WORLDTOUR: return ESTAT_MENU; break; - case OPCIO_CLASSICMODE: return ESTAT_MENU; break; - case OPCIO_OPTIONS: return ESTAT_MENU; break; - }*/ - return ESTAT_JOC; + } else { + this->info->dificultat = opcio_triada; + this->info->personatge = personatge_seleccionat; + return ESTAT_SEQUENCIA; } } diff --git a/modulesequence.cpp b/modulesequence.cpp new file mode 100644 index 0000000..2a8f385 --- /dev/null +++ b/modulesequence.cpp @@ -0,0 +1,229 @@ +#include "modulesequence.h" + +#include "jgame.h" +#include "jdraw8.h" +#include "jinput.h" +#include "jsound.h" +#include +#include + +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: ( ) ¡ ' - : ! . + // [ \ ] ^ _ ` 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; } } + } +} diff --git a/modulesequence.h b/modulesequence.h new file mode 100644 index 0000000..25635ef --- /dev/null +++ b/modulesequence.h @@ -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); +}; diff --git a/modulestaticscreen.cpp b/modulestaticscreen.cpp index ed8da2a..5b8d309 100644 --- a/modulestaticscreen.cpp +++ b/modulestaticscreen.cpp @@ -46,7 +46,7 @@ void ModuleStaticScreen::doIcekas() { bool eixir = false; - JS_LoadMusic("mlogo.xm"); + JS_LoadMusic("mlogo.mid"); JS_PlayMusic(1); JD8_Surface gfx = JD8_LoadSurface( "logo.gif" ); diff --git a/pepe.vcxproj b/pepe.vcxproj index 4408a1f..7a7a72f 100644 --- a/pepe.vcxproj +++ b/pepe.vcxproj @@ -89,6 +89,7 @@ + @@ -100,6 +101,7 @@ + diff --git a/pepe.vcxproj.filters b/pepe.vcxproj.filters index 256a29c..454ff5b 100644 --- a/pepe.vcxproj.filters +++ b/pepe.vcxproj.filters @@ -45,6 +45,9 @@ Source Files + + Source Files + @@ -74,5 +77,8 @@ Header Files + + Header Files + \ No newline at end of file