#include "modules.h" #include "jgame.h" #include "jdraw8.h" #include "jinput.h" #include "jsound.h" #include #include #include "info.h" namespace module { namespace sequence { JD8_Surface gfx = nullptr; JD8_Surface fondo = nullptr; JD8_Surface fondo_temp = nullptr; JD8_Palette pal = nullptr; void fadeIn() { JD8_Blit(fondo); JG_SetUpdateTicks(1); while (!JD8_FadeToPalAsync(pal) && !JG_Quitting()) { while (!JG_ShouldUpdate()) { JI_Update(); } } } void fadeOut() { JG_SetUpdateTicks(2); while (!JD8_FadeOutAsync() && !JG_Quitting()) { while (!JG_ShouldUpdate()) { JI_Update(); } } } void drawChar(int x, int y, char char_actual) { char_actual -= 42; if (char_actual < 0) char_actual = 57; if (char_actual == 4) char_actual = 56; JD8_BlitCKToSurface(x, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, fondo_temp, 255); } void 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; } } } } void showText(int x, int y, int color, int speed, const char * text1, const char * text2 = NULL, const char * text3 = NULL) { bool eixir = false; fondo_temp = JD8_NewSurface(); JD8_BlitToSurface(0, 0, fondo, 0, 0, 320, 200, fondo_temp); JD8_Blit(fondo_temp); JG_SetUpdateTicks(10); JD8_SetPaletteColor(254, color); // mod 35 // A (65) = 23 -> char - 42 // Special chars: ( ) � ' - : ! . // [ \ ] ^ _ ` a b int tamany_text = strlen(text1); int temps_total = tamany_text * speed; int temps_inicial = JG_GetCycleCounter(); while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) { int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed; drawChar(x + (num_chars_actual + 1) * 8, y, text1[num_chars_actual]); while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } } JD8_Blit(fondo_temp); JD8_Flip(); } if (eixir) for (int i = 0; i <= tamany_text; i++) drawChar(x + (i + 1) * 8, y, text1[i]); if (text2 != NULL) { tamany_text = strlen(text2); temps_total = tamany_text * speed; temps_inicial = JG_GetCycleCounter(); while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) { int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed; drawChar(x + (num_chars_actual + 1) * 8, y+10, text2[num_chars_actual]); while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } } JD8_Blit(fondo_temp); JD8_Flip(); } if (eixir) for (int i = 0; i <= tamany_text; i++) drawChar(x + (i + 1) * 8, y+10, text2[i]); if (text3 != NULL) { tamany_text = strlen(text3); temps_total = tamany_text * speed; temps_inicial = JG_GetCycleCounter(); while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) { int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed; drawChar(x + (num_chars_actual + 1) * 8, y+20, text3[num_chars_actual]); while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } } JD8_Blit(fondo_temp); JD8_Flip(); } if (eixir) for (int i = 0; i <= tamany_text; i++) drawChar(x + (i + 1) * 8, y+10, text3[i]); } } JD8_Blit(fondo_temp); JD8_Flip(); wait(200); } void 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"); fadeIn(); showText(40, 90, 2, 10, "QUE BON DIA FA NO CREUS PEPE"); showText(50, 80, 10, 10, "EEEE..SS..SSIII.SI"); showText(140, 140, 2, 10, "[SEMPRE QUE M^ACOSTE", "A PEPE ES POSA RARO\\"); wait(200); fadeOut(); JD8_FreeSurface(fondo); free(pal); if (!JG_Quitting()) { fondo = JD8_LoadSurface("hist02.gif"); pal = JD8_LoadPalette("hist02.gif"); fadeIn(); showText(100, 140, 10, 10, "AAAAY a"); showText(100, 55, 3, 10, "JA T^HE PILLAT PEPE"); showText(145, 125, 2, 1, "AUXILIa"); wait(200); fadeOut(); JD8_FreeSurface(fondo); free(pal); } if (!JG_Quitting()) { fondo = JD8_LoadSurface("hist03.gif"); pal = JD8_LoadPalette("hist03.gif"); fadeIn(); showText(50, 80, 5, 10, "ARA ROSITA ES MEUA"); showText(50, 80, 5, 10, "SI VOLS ACONSEGUIR_LA", "HAURAS DE SEGUIR_ME", "PER TOT EL MONb"); showText(60, 80, 5, 1, "JA JA JA JA JA aa"); wait(200); fadeOut(); JD8_FreeSurface(fondo); free(pal); } if (!JG_Quitting()) { fondo = JD8_LoadSurface("hist04.gif"); pal = JD8_LoadPalette("hist04.gif"); fadeIn(); showText(120, 60, 2, 5, "AJUDA^M PEPEa"); showText(50, 50, 7, 50, "MALEIT SIGUES", "ET TROBAREbbb"); fadeOut(); JD8_FreeSurface(fondo); free(pal); } // FREE EVERYTHING JD8_FreeSurface(gfx); if (JG_Quitting()) { info::estat_joc = ESTAT_EIXIR; } else { info::estat_joc = ESTAT_MENU; } } } }