/*────────────────────────────────────────────────────────────────────────── PEPE EL PINTOR Versió 1.0 Sergi Valor Martínez Juliol-Agost 1999 Versió 1.70 Build 3 Març 2000 (Windows2000) Port a C/Windows per Raimon Zamora Chanzà (Gener 2024) ──────────────────────────────────────────────────────────────────────────*/ #include "grafix.h" #include "crt.h" #include "jinput.h" //#include "pepe_vell.h" #include "midiplay.h" // const #define codi_sense_tecla 86 // jinput #define max_m_y 6 // amplaria matriu personatge #define max_m_x 6 // alçada matriu personatge #define VGA NULL #define ample 248 #define alt 192 #define max_pintura 255 #define color_pared 80 #define l0 10 #define l1 232 #define l2 182 #define l3 10 #define es_un_bloc_per_pintar 0 #define es_pepe 239 #define es_un_bloc_pintat 2 #define es_un_bicho 50 #define es_una_paret 1 #define es_casa 5 #define max_malos 3 #define amunt 0 #define avall 2 #define esquerra 3 #define dreta 1 #define verticalment 0 #define horitzontalment 1 #define no_mou 3 #define max_fondos 13 #define max_fondos_story 11 #define color_marcador_pintura_fondo 34 #define color_borde_m_p 239 #define tamany_m_p 5 #define pos_esq_m_p 266 // on comença el marcador de pintura per l'esquerra #define pos_dreta_m_p 276 // on comença el marcador de pintura per la dreta #define pos_base_m_p 180 // on comença el marcador de pintura per la base #define pos_ini_x_pepe 238 #define pos_ini_y_pepe 96 #define vides_de_pepe 5 #define blocs_fase_0 1102 #define blocs_fase_3 990 #define blocs_fase_7 778 #define blocs_fase_1 1026 #define blocs_fase_4 896 #define blocs_fase_5 989 #define blocs_fase_6 782 #define blocs_fase_2 729 #define blocs_fase_8 866 #define blocs_fase_9 800 #define blocs_fase_10 700 #define ultima_fase 10 #define color_fondo_marcador_punts 15 #define naiximent_del_malo 0 #define mos_a_pepe 1 #define pot_ple 3 #define pot_buit 2 #define vida_extra 4 #define facil 4 #define normal 2 #define dificil 0 #define Left 0 #define Right 1 #define musica_fase01 "./datos/mfase01.dat" #define musica_fase02 "./datos/mfase02.dat" #define musica_fase10 "./datos/mfase10.dat" #define musica_logo "./datos/mlogo.dat" #define musica_historia "./datos/mhist.dat" #define musica_canvi_fase "./datos/mlevelc.dat" #define musica_canvi_fase_n "./datos/mlevelcn.dat" #define musica_title "./datos/mtitle.dat" #define musica_game_over "./datos/mgover.dat" #define musica_time_attack "./datos/mtimea.dat" #define musica_final_joc "./datos/mfinalbo.dat" #define musica_final_fals "./datos/mfinalf.dat" #define musica_nit "./datos/mnit.dat" #define musica_fase_nit "./datos/mnitfase.dat" #define musica_campanes "./datos/mcampana.dat" #define musica_options "./datos/moptions.dat" #define DONE01 1 #define FINAL01 2 #define FINAL02 3 #define FINAL03 4 #define HIST01 5 #define HIST02 6 #define HIST03 7 #define HIST04 8 #define MENU 9 #define INTRO_N 10 #define INTRO_N2 11 #define LOGO 12 #define PEPE01 13 #define PEPE02 14 #define PEPE03 15 #define PEPE04 16 #define PEPE05 17 #define PEPE06 18 #define PEPE07 19 #define PEPE08 20 #define PEPE09 21 #define PEPE10 22 #define PEPE11 23 #define PEPEFINS 24 #define RECORDS 25 #define SELECT 26 #define TIME 27 #define TIME_FIN 28 #define ULT_FASE 29 #define CLASSIC 30 #define FINALF1 31 #define MENU_NIT 32 #define IN_NIT 33 #define SELECT_N 34 #define OPTIONS 35 #define MENU_S 36 #define DONE05 37 #define FONS_NIT 38 #define TITOL 39 #define CREDITSF 40 #define FINALF2 41 #define FASES 42 #define FINALN01 43 #define FINALN02 44 #define FINALN03 45 #define FINALN04 46 #define rosita_enabled 99 #define job_enabled 199 #define pepe_facil 5 #define pepe_normal 15 #define pepe_dificil 25 #define rosita_facil 6 #define rosita_normal 16 #define rosita_dificil 26 #define dream_tour 7 #define pepe_malo 0 + 56 #define d_malo1 132 + 56 #define gorro 6 + 56 #define d_malo2 138 + 56 #define pepe_gorro 12 + 56 #define d_malo3 144 + 56 #define pepe 18 + 56 #define amic 150 + 56 #define pepe_b 24 + 56 #define amic_m2 156 + 56 #define pepe_m 30 + 56 #define amic_a 162 + 56 #define pepe_m2 36 + 56 #define amic_a2 168 + 56 #define pepe_a 42 + 56 #define amic_b 174 + 56 #define pepe_a2 48 + 56 #define dib_pot 180 + 56 #define rosita3 54 + 56 #define dib_pared 186 + 56 #define rosita 60 + 56 #define dos_p 192 + 56 #define rosita2 66 + 56 #define num1 198 + 56 #define rosita_chillido 72 + 56 #define num2 204 + 56 #define rosita_m 78 + 56 #define num3 210 + 56 #define rosita_m2 84 + 56 #define num4 216 + 56 #define rosita_a 90 + 56 #define num5 222 + 56 #define rosita_a2 96 + 56 #define num6 228 + 56 #define rosita_p 102 + 56 #define num7 234 + 56 #define preso 108 + 56 #define num8 240 + 56 #define rellontge_dib 114 + 56 #define num9 246 + 56 #define rellontge_dib_x 120 + 56 #define num0 252 + 56 #define rellontge_dib_y 126 + 56 #define amic_m 314 #define tick 0 + (320 * 6) #define num_11 198 + (320 * 6) #define fletxa 9 + (320 * 6) #define lletra_a 207 + (320 * 6) #define fletxa2 18 + (320 * 6) #define lletra_b 216 + (320 * 6) #define fletxa3 27 + (320 * 6) #define lletra_c 225 + (320 * 6) #define fletxa_final01 36 + (320 * 6) #define lletra_d 234 + (320 * 6) #define fletxa_final02 45 + (320 * 6) #define lletra_e 243 + (320 * 6) #define fletxa_final03 54 + (320 * 6) #define lletra_f 252 + (320 * 6) #define fletxa_final04 63 + (320 * 6) #define lletra_g 261 + (320 * 6) #define help_1 72 + (320 * 6) #define lletra_h 270 + (320 * 6) #define help_2 81 + (320 * 6) #define lletra_i 279 + (320 * 6) #define altaveu_on 90 + (320 * 6) #define lletra_j 288 + (320 * 6) #define altaveu_off 99 + (320 * 6) #define lletra_k 297 + (320 * 6) #define num_1 108 + (320 * 6) #define lletra_l 306 + (320 * 6) #define num_2 117 + (320 * 6) #define lletra_m 0 + (320 * 15) #define num_3 126 + (320 * 6) #define lletra_n 9 + (320 * 15) #define num_4 135 + (320 * 6) #define lletra_o 18 + (320 * 15) #define num_5 144 + (320 * 6) #define lletra_p 27 + (320 * 15) #define num_6 153 + (320 * 6) #define lletra_q 36 + (320 * 15) #define num_7 162 + (320 * 6) #define lletra_r 45 + (320 * 15) #define num_8 171 + (320 * 6) #define lletra_s 54 + (320 * 15) #define num_9 180 + (320 * 6) #define lletra_t 63 + (320 * 15) #define num_0 189 + (320 * 6) #define lletra_u 72 + (320 * 15) #define lletra_y 108 + (320 * 15) #define lletra_v 81 + (320 * 15) #define lletra_z 117 + (320 * 15) #define lletra_w 90 + (320 * 15) #define lletra_parentesis_o 126 + (320 * 15) #define lletra_x 99 + (320 * 15) #define lletra_parentesis_t 135 + (320 * 15) #define lletra_dos_punts 171 + (320 * 15) #define lletra_exclamacio_o 144 + (320 * 15) #define lletra_exclamacio_t 180 + (320 * 15) #define lletra_apostrof 153 + (320 * 15) #define lletra_punt 189 + (320 * 15) #define lletra_guio 162 + (320 * 15) #define lletra_espai 198 + (320 * 15) //var // [RZC 24/01/2024] No crec que estos facen falta ara //Virscr : Ptr_pantalla; //VirScr2 : Ptr_pantalla; //VirScrSP : Ptr_pantalla; draw::surface *vaddr; // : word; draw::surface *vaddr2; // : word; draw::surface *vaddrSP; // : word; uint16_t blocs_per_pintar;// : word; uint16_t total_blocs_per_pintar;// : word; //uint16_t h, m, s, c; uint16_t temps, hora;//: word; uint16_t temps_final; // : word; uint16_t tecla_amunt_dib, tecla_avall_dib, tecla_dreta_dib, tecla_esquerra_dib; // : word; uint8_t x,y; // : byte; uint8_t i,j; // : byte; uint8_t pintura; // : byte; uint8_t que_hi_ha; // : byte; uint8_t el_que_hi_havia; // : byte; uint8_t velocitat_joc; // : byte; uint8_t dificultat; // : byte; uint8_t antiga_direccio; // : byte; uint8_t valor_del_bloc; // : byte; uint8_t cap_on_va_Pepe; // : byte; uint8_t vides; // : byte; uint8_t num_fase; // : byte; uint8_t mode_rosita, mode_amic, mode_easy, mode_normal, mode_hard; // : byte; uint8_t mode_easy_r, mode_normal_r, mode_hard_r, mode_dream_tour; // : byte; uint8_t color_pintura, color_marcador_pintura; // : byte; uint8_t R, G, B; // : byte; uint8_t volumen; // : byte; uint8_t tecla_amunt, tecla_avall, tecla_esquerra, tecla_dreta; // : byte; uint8_t contador_de_menus; // : byte; uint8_t retard_pepe; // : byte; uint8_t velocitat_pepe; // : byte; bool rosita_selected; // : boolean; bool no_queden_vides; // : boolean; bool naiximent; // : boolean; bool map; // : boolean; bool menejant; // : boolean; bool time_attack_mode; // : boolean; bool story_mode_mode; // : boolean; bool amic_selected; // : boolean; bool fletxa_final_fase; // : boolean; bool malos_quets; // : boolean; bool amb_so; // : boolean; bool donar_vida; // : boolean; bool mode_nocturne; // : boolean; bool fin_historia; // : boolean; bool eixir_del_joc; // : boolean; bool en_casa; // : boolean; bool final_fase; // : boolean; bool GM; // : boolean; bool midi; // : boolean; bool sense_rellontge; // : boolean; uint8_t pantalla[38][29]; uint8_t path[20]; // : ARRAY[1..20] of byte; char nom[20][255]; char nom2[20][255]; // : ARRAY[1..20] of string; //uint8_t *paleta; // : tpaleta; char frase[255]; // : string; uint16_t numero_G[91]; // : ARRAY [0..90] of word; int32_t puntuacio[5]; // : ARRAY [1..5] of longint; uint8_t minuts[5], segons_tabla[5]; // : ARRAY [1..5] of byte; uint16_t numero[10]; // : ARRAY [0..9] of word; int32_t punts; // : longint; int32_t contador; // : longint; struct estrela_t { uint8_t velocitat; uint16_t x, y; }; estrela_t estreles[10]; // estreles : ARRAY[1..10] of RECORD velocitat : byte; x,y : word; end; uint8_t Puerto, DMA, IRQ; // : byte; struct rellontge_t { uint8_t i, j; // : byte; bool viu; // : boolean; uint32_t temps; // : byte; }; rellontge_t rellontge; struct malo_t { uint8_t i, j; uint8_t sentit; bool viu; uint16_t dibuix; }; malo_t malo[max_malos]; /*──────────────────────────────────────────────────────────────────────────*/ void power_off(draw::surface *where) { uint16_t i; uint8_t j; draw::fadeDown(0, 0, 0, 0); draw::cls(0, where); draw::draw(where, VGA); draw::setColor(1, 63, 63, 63); for (int i = 0; i < 320; ++i) draw::putPixel(i, 100, 1, where); for (int i = 0; i <= 160; ++i) { draw::putPixel(i, 100, 0, where); draw::putPixel(320 - i, 100, 0, where); if (i % 2 == 0) draw::draw(where, VGA); } for (int i = 0; i <= 20; ++i) draw::waitVsync(); } /*──────────────────────────────────────────────────────────────────────────*/ void load_mif(int num, draw::surface *where) { draw::waitVsync(); draw::cls(0, VGA); FILE *fich = fopen("datos/graf.mif", "rb"); // Reset(fich); uint8_t num_dibuixos = fgetc(fich); // fread(&num_dibuixos, 1, 1, fich); // Read(fich,num_dibuixos); int pos = 1 + (8 * num_dibuixos) + ((num - 1) * 64768); fseek(fich, pos, SEEK_SET); fread(where->pixels, 64000, 1, fich); uint8_t paleta[768]; fread(paleta, 768, 1, fich); draw::setPalette(paleta); fclose(fich); } /*──────────────────────────────────────────────────────────────────────────*/ void save_cfg() { FILE *fich = fopen("pepe.ini", "w"); fprintf(fich, "PC SPEAKER: OFF=0, ON=1\n"); fprintf(fich, "%hhu\n", amb_so ? 1 : 0); fprintf(fich, "VOLUMEN MIDI(0-10): OFF=0, MAX=10\n"); fprintf(fich, "%hhu\n", volumen); fprintf(fich, "SYNTHESIZER: General Midi=1, FM Synthesizer=0\n"); fprintf(fich, "%hhu\n", GM ? 1 : 0); fprintf(fich, "GAME KEYS:\n"); fprintf(fich, "%hhu\n", tecla_amunt); fprintf(fich, "%hu\n", tecla_amunt_dib); fprintf(fich, "%hhu\n", tecla_avall); fprintf(fich, "%hu\n", tecla_avall_dib); fprintf(fich, "%hhu\n", tecla_dreta); fprintf(fich, "%hu\n", tecla_dreta_dib); fprintf(fich, "%hhu\n", tecla_esquerra); fprintf(fich, "%hu\n", tecla_esquerra_dib); fclose(fich); } /*──────────────────────────────────────────────────────────────────────────*/ void load_cfg() { char buffer[100]; uint8_t tmp; FILE *fich = fopen("pepe.ini", "r"); if (fich) { fgets(buffer, 100, fich); fscanf(fich, "%hhu\n", &tmp); amb_so = tmp; fgets(buffer, 100, fich); fscanf(fich, "%hhu\n", &volumen); fgets(buffer, 100, fich); fscanf(fich, "%hhu\n", &tmp); GM = tmp; fgets(buffer, 100, fich); fscanf(fich, "%hhu\n", &tecla_amunt); fscanf(fich, "%hu\n", &tecla_amunt_dib); fscanf(fich, "%hhu\n", &tecla_avall); fscanf(fich, "%hu\n", &tecla_avall_dib); fscanf(fich, "%hhu\n", &tecla_dreta); fscanf(fich, "%hu\n", &tecla_dreta_dib); fscanf(fich, "%hhu\n", &tecla_esquerra); fscanf(fich, "%hu\n", &tecla_esquerra_dib); fclose(fich); } else { volumen = 0; amb_so = false; GM = true; tecla_amunt = SDL_SCANCODE_UP; tecla_amunt_dib = 14157; tecla_avall = SDL_SCANCODE_DOWN; tecla_avall_dib = 4485; tecla_dreta = SDL_SCANCODE_RIGHT; tecla_dreta_dib = 14133; tecla_esquerra = SDL_SCANCODE_LEFT; tecla_esquerra_dib = 14109; save_cfg(); } amb_so = false; } /*──────────────────────────────────────────────────────────────────────────*/ void ini_midi(const char *midi_titol) { // [RZC 24/01/2024] [TODO] Reescritura sencera // Si està sonant una música, parar-la // Carregar la música que s'especifica (encara no playar-la) /* var aux : boolean; intents : word; begin intents := 0; if volumen>0 then begin if midi then begin audio::stopMusic; audio::unloadMusic; midi:=false; end; if GM then begin aux:=setGM; end else begin aux:=setFM; end; if aux then begin repeat until (loadMIDI(midi_titol)); SetVol(25*volumen); midi := true; end else begin volumen := 0; midi := false; end; save_cfg; end; */ } /*──────────────────────────────────────────────────────────────────────────*/ void load_records() { // [RZC 24/01/2024] [TODO] Llevar tota esta monserga i que guarde en un arxiu normal (i en el futur en JailScore) FILE *fich = fopen("datos/story.dat", "r"); for (int i = 0; i < 6; ++i) { fgets(nom[x], 255, fich); fscanf(fich, "%i\n", &puntuacio[i]); } fclose(fich); fich = fopen("datos/time.dat", "r"); for (int i = 0; i < 6; ++i) { fgets(nom2[x], 255, fich); fscanf(fich, "%hhu\n", &minuts[i]); fscanf(fich, "%hhu\n", &segons_tabla[i]); } fclose(fich); fich = fopen("datos/comp.dat", "rb"); fseek(fich, -9, SEEK_END); mode_rosita = fgetc(fich); mode_amic = fgetc(fich); mode_easy = fgetc(fich); mode_normal = fgetc(fich); mode_hard = fgetc(fich); mode_easy_r = fgetc(fich); mode_normal_r = fgetc(fich); mode_hard_r = fgetc(fich); mode_dream_tour = fgetc(fich); fclose(fich); } /*──────────────────────────────────────────────────────────────────────────*/ void save_records() { // [RZC 24/01/2024] [TODO] Llevar tota esta monserga i que guarde en un arxiu normal (i en el futur en JailScore) /* FILE *fich = fopen("datos/story.dat", "w"); for (int i = 0; i < 6; ++i) { fprintf(fich, "%s\n", nom[x]); fprintf(fich, "%i\n", &puntuacio[i]); } fclose(fich); fich = fopen("datos/time.dat", "w"); for (int i = 0; i < 6; ++i) { fprintf(fich, "%s\n", nom2[x]); fprintf(fich, "%hhu\n", &minuts[i]); fprintf(fich, "%hhu\n", &segons_tabla[i]); } fclose(fich); fich = fopen("datos/comp.dat", "wb"); fseek(fich, -9, SEEK_END); fputc(mode_rosita, fich); fputc(mode_amic, fich); fputc(mode_easy, fich); fputc(mode_normal, fich); fputc(mode_hard, fich); fputc(mode_easy_r, fich); fputc(mode_normal_r, fich); fputc(mode_hard_r, fich); fputc(mode_dream_tour, fich); fclose(fich); */ } /*──────────────────────────────────────────────────────────────────────────*/ void pinta(uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where) // offset es on comença el dibuixet en el "bitmap" de sprites, where la surface { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve x++; y++; for (int i = 0; i < 6; ++i) for (int j = 0; j < 6; ++j) if (color != 255) draw::putPixel(x+i, y+j, color, where); else if (vaddrSP->pixels[offset + i + (j * 320)] != 255) draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where); } /*──────────────────────────────────────────────────────────────────────────*/ // [RZC 24/01/0224] [NOTA] Esta funció i l'anterior son exactament iguals! void pinta_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve x++; y++; for (int i = 0; i < 6; ++i) for (int j = 0; j < 6; ++j) if (color != 255) draw::putPixel(x+i, y+j, color, where); else if (vaddrSP->pixels[offset + i + (j * 320)] != 255) draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where); } /*──────────────────────────────────────────────────────────────────────────*/ // [RZC 24/01/0224] [NOTA] Esta es igual pero els bucles van de 0 a 8 en compte de de 0 a 5 void pinta_number(uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve x++; y++; for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) if (color != 255) draw::putPixel(x+i, y+j, color, where); else if (vaddrSP->pixels[offset + i + (j * 320)] != 255) draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where); } /*──────────────────────────────────────────────────────────────────────────*/ void pinta_number2(uint16_t offset, uint8_t color, uint8_t color_determinat, uint16_t x, uint16_t y, draw::surface *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve x++; y++; for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) if (color != 255) draw::putPixel(x+i, y+j, color, where); else if ((vaddrSP->pixels[offset + i + (j * 320)] != 255) && (vaddrSP->pixels[offset + i + (j * 320)] != 254)) draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where); else if (vaddrSP->pixels[offset + i + (j * 320)] == 254) draw::putPixel(x+i, y+j, color_determinat, where); } /*──────────────────────────────────────────────────────────────────────────*/ void pinta_number_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve x++; y++; for (int i = 0; i < 9 * zoom; ++i) for (int j = 0; j < 9 * zoom; ++j) if (color != 255) draw::putPixel(x+i, y+j, color, where); else if (vaddrSP->pixels[offset + (i / zoom) + ((j / zoom) * 320)] != 255) draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + (i / zoom) + ((j / zoom) * 320)], where); } /*──────────────────────────────────────────────────────────────────────────*/ void retard(int centesimes) { uint32_t t = SDL_GetTicks() + centesimes * 10; while ((SDL_GetTicks() < t) && (!input::keyPressed(SDL_SCANCODE_SPACE))) {}; // [RZC 24/01/0224] [NOTA] Açò del midi estaba dins del bucle este anterior. Crec que és perque necessita anar omplint el buffer // if (not(audio::musicPlaying())) and (midi) then audio::playMusic; } /*──────────────────────────────────────────────────────────────────────────*/ void escriu_frase(const char *nom, uint8_t color_determinat, uint16_t x,uint16_t y, draw::surface *where, uint16_t velocitat, uint8_t mode, uint8_t mode2) { for (int i=0; i=cont; --i) { for (int j=0; j<256; ++j) nom[i][j] = nom[i-1][j]; puntuacio[i] = puntuacio[i-1]; } intro_nom(&nom[cont][0], color); puntuacio[cont] = punts; } cont++; } } // time attack if (time_attack_mode) { bool trobat = false; int cont = 1; uint16_t minuts_prov = (temps_final % 3600) / 60; uint16_t segons_prov = (temps_final % 3600) % 60; while ( !trobat && cont<6 ) { if ( minuts[cont] > minuts_prov ) trobat = true; if ( minuts[cont] = minuts_prov ) if ( segons_tabla[cont] >= segons_prov && !trobat ) trobat = true; if (trobat) { for (int i=5; i>=cont; --i) { for (int j=0; j<256; ++j) nom2[i][j] = nom2[i-1][j]; minuts[i] = minuts[i-1]; segons_tabla[i] = segons_tabla[i-1]; } intro_nom(&nom2[cont][0], color); minuts[cont] = minuts_prov; segons_tabla[cont] = segons_prov; } cont++; } } save_records(); } /*──────────────────────────────────────────────────────────────────────────*/ void text_rosita() { load_mif(PEPE01, vaddr); draw::cls(0, vaddr); escriu_frase("FELICITATS!",64, 10, 90, vaddr, 0, 0, 0); escriu_frase("HAS SUPERAT TOTS ELS NIVELLS", 64, 10, 110, vaddr, 0, 0, 0); escriu_frase("DE DIFICULTAT AMB PEPE.", 64, 10, 120, vaddr, 0, 0, 0); escriu_frase("ARA JA POTS JUGAR AMB ROSITA.", 64, 10, 130, vaddr, 0, 0, 0); escriu_frase("A ROSITA NO SE LI ACABA LA PINTURA.", 64, 10, 150, vaddr, 0, 0, 0); retard(1000); borrat_de_pantalla(vaddr); } /*──────────────────────────────────────────────────────────────────────────*/ void text_amic() { load_mif(PEPE01, vaddr); draw::cls(0, vaddr); escriu_frase("FELICITATS!", 64, 10, 90, vaddr, 0, 0, 0); escriu_frase("HAS SUPERAT TOTS ELS NIVELLS", 64, 10, 110, vaddr, 0, 0, 0); escriu_frase("DE DIFICULTAT AMB ROSITA.",64, 10, 120, vaddr, 0, 0, 0); escriu_frase("ARA JA POTS JUGAR AMB JOB.",64, 10, 130, vaddr, 0, 0, 0); escriu_frase("JOB GUANYA EL DOBLE DE PUNTS.",64, 10, 150, vaddr, 0, 0, 0); escriu_frase("A PER EL RECORD !!", 64, 10, 170, vaddr, 0, 0, 0); retard(1000); borrat_de_pantalla(vaddr); } /*──────────────────────────────────────────────────────────────────────────*/ void so_de(uint8_t quin_so) { //[RZC 24/01/2024] [TODO] Reimplementar si es vol. En la versió Pascal els sons estaven desactivats /* var a,b : word; begin case quin_so of naiximent_del_malo : begin for a:=0 to 5 do for b:=0 to 40 do begin delay(1);sound(b*200);end; nosound; end; mos_a_pepe : begin a:=10000; while a>1000 do begin sound(a);delay(1);a:=a-250;end; nosound; end; pot_ple : begin sound(5000);delay(velocitat_joc*10);nosound; end; pot_buit : begin sound(1000);delay(velocitat_joc*10);nosound; end; vida_extra : begin for a:=0 to 5 do for b:=40 to 80 do begin delay(1); sound(b*50); end; nosound; end; end; */ } /*──────────────────────────────────────────────────────────────────────────*/ void pepe_text() { load_mif(CLASSIC, vaddr); draw::waitVsync(); draw::draw(vaddr, VGA); retard(400); draw::fadeDown(0,0,0,1); //setmode(3); // pepe_clasic(); [RZC 26/01/2024] [TODO] Activar el pepe ascii //setmode(0x13); } /*──────────────────────────────────────────────────────────────────────────*/ void final_fals() { draw::surface *vaddr3 = draw::createSurface(320, 240); draw::cls(0, vaddr); load_mif(FINALF1, vaddr2); load_mif(FINALF2, vaddr3); uint8_t *paleta = draw::getPalette(); ini_midi(musica_final_fals); if (midi) audio::playMusic(); for (int i=1; i<=3; ++i) { draw::waitVsync(); draw::draw(vaddr, VGA); uint32_t t = SDL_GetTicks() + 5000; do { if (!audio::musicPlaying()) { ini_midi(musica_final_fals); if (midi) audio::playMusic(); } } while ( !input::anyKey() && SDL_GetTicks()= 22 || h <= 8) { load_mif(INTRO_N, vaddr); load_mif(INTRO_N2, vaddr2); mode_nocturne = true; } else { load_mif(TITOL, vaddr2); mode_nocturne = false; draw::waitVsync(); draw::draw(vaddr2, VGA); uint32_t t = SDL_GetTicks()+6000; do {} while (!input::anyKey() && SDL_GetTicks() 80 ) { if (!audio::musicPlaying() && midi) { ini_midi(musica_final_joc); if (midi) audio::playMusic(); } draw::draw(vaddr2, vaddr, offset, ample, alt, x, i_int); draw::waitVsync(); draw::draw(vaddr, VGA); velocitat++; if (velocitat % 5 == 0) i_int--; } if (num < 5) while (i_int > -alt) { if (!audio::musicPlaying() && midi) { ini_midi(musica_final_joc); if (midi) audio::playMusic(); } draw::draw(vaddr2, vaddr, offset, ample, alt, x, i_int); draw::waitVsync(); draw::draw(vaddr, VGA); velocitat++; if (velocitat % 5 == 0) i_int--; } } t = SDL_GetTicks()+10000; do {} while (!input::anyKey() && SDL_GetTicks()tamany_comp then error:=true; Close(fich); temp:=0; assign(fich,'datos\sprites.dat'); reset(fich); for i:=1 to filesize(fich) do begin read(fich,aux); inc(temp,aux); end; if temp<>tamany_sprites then error:=true; Close(fich); if error then begin setmode($3); Writeln('Algun fitxer ha estat modificat'); Writeln('No puc executar el programa...'); halt; end; end; */ /*----------------------------------------------------*/ void carrega_pantalla(uint8_t num) { if (num == 0) memset(pantalla, 0, 38*29); else { FILE *fich = fopen("datos/comp.dat", "r"); fseek(fich, (num-1)*38*29, SEEK_SET); fread(pantalla, 38*29, 1, fich); fclose(fich); } } /*----------------------------------------------------*/ /*──────────────────────────────────────────────────────────────────────────*/ void ini_vars(uint8_t num_fase) { malos_quets = false; sense_rellontge = true; velocitat_pepe = 5; x = pos_ini_x_pepe; y = pos_ini_y_pepe; fletxa_final_fase = false; if (num_fase == 0) vides = 0; else if (num_fase == 1) vides = vides_de_pepe; else vides = vides; // Super util pintura = max_pintura; en_casa = true; final_fase = false; rellontge.viu = false; rellontge.temps = 0; temps = 0; carrega_pantalla(num_fase); switch (num_fase) { case 0: total_blocs_per_pintar = blocs_fase_0; break; case 1: total_blocs_per_pintar = blocs_fase_1; break; case 2: total_blocs_per_pintar = blocs_fase_2; break; case 3: total_blocs_per_pintar = blocs_fase_3; break; case 4: total_blocs_per_pintar = blocs_fase_4; break; case 5: total_blocs_per_pintar = blocs_fase_5; break; case 6: total_blocs_per_pintar = blocs_fase_6; break; case 7: total_blocs_per_pintar = blocs_fase_7; break; case 8: total_blocs_per_pintar = blocs_fase_8; break; case 9: total_blocs_per_pintar = blocs_fase_9; break; case 10: total_blocs_per_pintar = blocs_fase_10; break; } blocs_per_pintar = total_blocs_per_pintar; temps = 0; velocitat_joc = 1; no_queden_vides = false; naiximent = false; map = false; // ini malos for (int i=0; i0) { // vides pinta_number(numero_G[vides], 255, 268, 169, vaddr); // punts const int i = 265; const int j = 73; pinta_number(numero_G[punts], color_fondo_marcador_punts, i, j, vaddr); pinta_number(numero_G[punts], color_fondo_marcador_punts, i+6, j, vaddr); pinta_number(numero_G[punts], color_fondo_marcador_punts, i+12, j, vaddr); pinta_number(numero_G[punts], color_fondo_marcador_punts, i+18, j, vaddr); pinta_number(numero_G[punts], color_fondo_marcador_punts, i+24, j, vaddr); pinta_number(numero_G[punts], color_fondo_marcador_punts, i+30, j, vaddr); pinta_number(numero_G[punts], color_fondo_marcador_punts, i+36, j, vaddr); pinta_number(numero_G[punts / 1000000], 255, i, j, vaddr); pinta_number(numero_G[(punts % 1000000) / 100000], 255, i+6, j, vaddr); pinta_number(numero_G[((punts % 1000000) % 100000) / 10000], 255, i+12, j, vaddr); pinta_number(numero_G[(((punts % 1000000) % 100000) % 10000) / 1000], 255, i+18, j, vaddr); pinta_number(numero_G[((((punts % 1000000) % 100000) % 10000) % 1000) / 100], 255, i+24, j, vaddr); pinta_number(numero_G[(((((punts % 1000000) % 100000) % 10000) % 1000) % 100) / 10], 255, i+30, j, vaddr); pinta_number(numero_G[(((((punts % 1000000) % 100000) % 10000) % 100) % 10)], 255, i+36, j, vaddr); } } /*──────────────────────────────────────────────────────────────────────────*/ void ini_pantalla() /* var i,j : word; i_int:integer; offset : word; VirscrFase : Ptr_pantalla; vaddrFase : Word; */ { draw::surface *vaddrFase = draw::createSurface(160, 40); //(uint8_t*)malloc(6400); // 6400??? load_mif(FASES,vaddr); draw::cls(0, vaddrFase); const uint16_t offset = ((num_fase / 6)*160)+((((num_fase-1) % 5)*40)*320); draw::draw(vaddr, vaddrFase, offset, 160, 40, 0, 0); if (!mode_nocturne) { if (num_fase>0) load_mif(path[(rand()%max_fondos_story)+1], vaddr2); else load_mif(path[13], vaddr2); } else load_mif(path[14], vaddr2); if ((num_fase==ultima_fase) && !mode_nocturne) load_mif(path[12], vaddr2); // pinta numero de fase if ( (num_fase>0) && (num_fase<10) ) pinta_number(numero_G[num_fase], 255, 1, 1, vaddr2); // pinta les pareds for (int i=0; i<38; ++i) for (int j=0; j<29; ++j) if (pantalla[i][j]==es_una_paret) pinta(dib_pared, 255, ((i+1)*6)+4, (j+2)*6, vaddr2); // pinta a Rosita i a la presó if (num_fase==ultima_fase) { pinta(rosita, 255, 16, 96, vaddr2); pinta(preso, 255, 22, 96, vaddr2); for (int i=97; i<=102; ++i) draw::putPixel(16, i, 237, vaddr2); draw::putPixel(17, 97, 237, vaddr2); draw::putPixel(22, 97, 237, vaddr2); draw::putPixel(17, 102, 237, vaddr2); draw::putPixel(22, 102, 237, vaddr2); } // pinta el marcador de pintura for (int i=pos_esq_m_p; i<=pos_dreta_m_p; ++i) for (int j=(pos_base_m_p-(pintura / tamany_m_p)); j<=pos_base_m_p; ++j) { draw::putPixel(i, j, color_marcador_pintura, vaddr2); draw::putPixel(pos_esq_m_p-1, j, color_borde_m_p, vaddr2); draw::putPixel(pos_dreta_m_p+1, j, color_borde_m_p, vaddr2); draw::putPixel(i, (pos_base_m_p-(max_pintura / tamany_m_p)-1), color_borde_m_p, vaddr2); draw::putPixel(i, (pos_base_m_p+1), color_borde_m_p, vaddr2); } // coloca la fase uint8_t *paleta = draw::getPalette(); draw::blackout(); draw::cls(0, vaddr); draw::draw(vaddr2, vaddr, 0, 249, 200, 0, 0); draw::draw(vaddr, VGA); draw::fadeUp(paleta, 0); // posa el marcador for (int j=0; j<=49; ++j) { const int i = j << 1; draw::draw(vaddr2, vaddr, 248+((99-i)*320), 72, i+1, 248, 0); draw::draw(vaddr2, vaddr, 32248, 72, i+1, 248, 199-i); draw::draw(vaddr2, vaddr, 0, 249, 200, 0, 0); draw::waitVsync(); draw::draw(vaddr, VGA); } // posa el lletrero de fase X if (story_mode_mode) for (int i=-40; i<=80; ++i) { draw::draw(vaddr2, vaddr); if (i<20) draw::draw(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); else draw::draw(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); if (i==14) SDL_Delay(2000); draw::waitVsync(); draw::draw(vaddr, VGA); } free(vaddrFase); } /*──────────────────────────────────────────────────────────────────────────*/ void level_complete() { if (midi) { audio::stopMusic(); audio::unloadMusic(); midi = false; } if (!mode_nocturne) { load_mif(DONE01, vaddr); draw::waitVsync(); draw::draw(vaddr, VGA); ini_midi(musica_canvi_fase); if (midi) audio::playMusic(); const uint32_t t = SDL_GetTicks() + 4000; do {} while( SDL_GetTicks() < t ); borrat_de_pantalla(vaddr); } else { load_mif(DONE05, vaddr); draw::waitVsync(); draw::draw(vaddr, VGA); ini_midi(musica_canvi_fase_n); if (midi) audio::playMusic(); if (midi) do {} while(audio::musicPlaying()); else for (int i=0; i<=300; ++i) draw::waitVsync(); borrat_de_pantalla(vaddr); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi = false; } } } /*──────────────────────────────────────────────────────────────────────────*/ void volcat_de_pantalla() { uint32_t segons = SDL_GetTicks()/1000; draw::draw(vaddr, vaddr2); // inicialització i comprobació de la fletxa de GO! fletxa_final_fase = true; for (int i=0; i<38; ++i) for (int j=0; j<29; ++j) if (pantalla[i][j] == es_un_bloc_per_pintar) fletxa_final_fase = false; // pinta el rellontge if (rellontge.viu) switch ((SDL_GetTicks() % 500)/125) { case 0: case 2: pinta(rellontge_dib, 255, rellontge.i, rellontge.j, vaddr2); break; case 1: pinta(rellontge_dib_x, 255, rellontge.i, rellontge.j, vaddr2); break; case 3: pinta(rellontge_dib_y, 255, rellontge.i, rellontge.j, vaddr2); break; } if ( (x==pos_ini_x_pepe) && (y==pos_ini_y_pepe) ) en_casa = true; // pinta a PEPE, ROSITA o JOB if (mode_nocturne && !rosita_selected && !amic_selected) pinta(gorro, 255, x, y-6, vaddr2); if (pintura > 0) if (rosita_selected) pinta(rosita_p, 255, x, y, vaddr2); else if (amic_selected) pinta(amic, 255, x, y, vaddr2); else if (mode_nocturne) pinta(pepe_gorro, 255, x, y, vaddr2); else pinta(pepe, 255, x, y, vaddr2); else if (amic_selected) pinta(amic_b, 255, x, y, vaddr2); else if (mode_nocturne) pinta(pepe_gorro, 255, x, y, vaddr2); else pinta(pepe_b, 255, x, y, vaddr2); if (!en_casa) pinta(dib_pot, 255, 238, 96, vaddr2); else { pinta(dib_pot, 255, 238, 96, vaddr2); if (rosita_selected) pinta(rosita_p, 255, x, y, vaddr2); else if (amic_selected) pinta(amic, 255, x, y, vaddr2); else if (mode_nocturne) pinta(pepe_gorro, 255, x, y, vaddr2); else pinta(pepe, 255, x, y, vaddr2); } // pinta a rosita en la pressó if (num_fase == ultima_fase) { if ((segons%4)==0) pinta(rosita, 255, 16, 96, vaddr2); else if ((segons%4)==1) pinta(rosita2, 255, 16, 96, vaddr2); else if ((segons%4)==2) pinta(rosita, 255, 16, 96, vaddr2); else pinta(rosita3, 255, 16, 96, vaddr2); if ( ((segons%10)==0) || ((segons%10)==1) ) { pinta(rosita_chillido, 255, 16, 96, vaddr2); pinta_number(help_1, 255, 12, 87, vaddr2); pinta_number(help_2, 255, 21, 87, vaddr2); } } // pinta el mapa if (map) for (int i=0; i<28; ++i) for (int j=0; i<29; ++j) draw::putPixel(270+i, 1+j, pantalla[i][j], vaddr2); // pinta l'altaveu if (amb_so) pinta_number(altaveu_on, 255, 2, 188, vaddr2); else pinta_number(altaveu_off, 255, 2, 188, vaddr2); // pinta la fletxa de GO! if (fletxa_final_fase) if (SDL_GetTicks()%999 < 50) { pinta_number(fletxa_final01, 255, 250, 90, vaddr2); pinta_number(fletxa_final02, 255, 259, 90, vaddr2); pinta_number(fletxa_final03, 255, 250, 99, vaddr2); pinta_number(fletxa_final04, 255, 259, 99, vaddr2); } else { pinta_number(fletxa_final01, 255, 248, 90, vaddr2); pinta_number(fletxa_final02, 255, 257, 90, vaddr2); pinta_number(fletxa_final03, 255, 248, 99, vaddr2); pinta_number(fletxa_final04, 255, 257, 99, vaddr2); } draw::waitVsync(); draw::draw(vaddr2, VGA); } /*──────────────────────────────────────────────────────────────────────────*/ void omplir_pot() { temps_final = temps; final_fase = true; for (int i=0; i<38; ++i) for (int j=0; j<29; ++j) if (pantalla[i][j] == es_un_bloc_per_pintar) final_fase = false; if (!final_fase) { pinta(pepe, color_pintura, x, y, vaddr); pantalla[(x/6)-1][(y/6)-2] = es_un_bloc_pintat; x = pos_ini_x_pepe; y = pos_ini_y_pepe; if (mode_nocturne) pinta(pepe_gorro, 255, x, y, vaddr); else pinta(pepe, 255, x, y, vaddr); //Play_WAV(sample[so_pot]); while (pintura < max_pintura) { if (pintura < max_pintura) pintura++; if (pintura < max_pintura) pintura++; if (pintura < max_pintura) pintura++; pinta_marcadors(); if (time_attack_mode) posa_el_temps(vaddr); //if ((pintura==max_pintura) || (pintura%50==0)) Play_WAV(sample[so_pot]); volcat_de_pantalla(); } //nosound(); } en_casa = true; } /*──────────────────────────────────────────────────────────────────────────*/ void pinta_un_bloc(uint8_t color, uint8_t queda_pintura) { if (antiga_direccio == cap_on_va_Pepe) { if (valor_del_bloc < 10) valor_del_bloc++; } else valor_del_bloc = 0; if (queda_pintura > 0) { //if amb_so then so_de(pot_ple); if (!rosita_selected) pintura--; pinta(pepe, color, x, y, vaddr); pantalla[(x/6)-1][(y/6)-2] = es_un_bloc_pintat; if (el_que_hi_havia == es_un_bloc_per_pintar) { blocs_per_pintar--; if (!amic_selected) punts = punts + (25-(5*dificultat)) + valor_del_bloc; else punts = punts + (((25-(5*dificultat))+valor_del_bloc)*2); if ( (punts%20000) > (25-(5*dificultat)+valor_del_bloc) ) donar_vida = true; if ( (vides<9) && story_mode_mode && donar_vida) if (punts>100) if ( (punts%20000) < (25-(5*dificultat)+valor_del_bloc) ) if (!amic_selected) { donar_vida = false; vides++; pinta_number_zoom(5, numero_G[vides], 255, 260, 150, VGA); //if (amb_so) // PlayWav(sample[so_ring]);/*so_de(vida_extra)*/ //else retard(40); } } } else if (el_que_hi_havia==es_un_bloc_pintat) { // if amb_so then so_de(pot_buit); pinta(pepe, color, x, y, vaddr); pantalla[(x/6)-1][(y/6)-2] = es_un_bloc_pintat; } else if (el_que_hi_havia == es_un_bloc_per_pintar) { //if amb_so then so_de(pot_buit); pantalla[(x/6)-1][(y/6)-2] = es_un_bloc_per_pintar; } antiga_direccio = cap_on_va_Pepe; } /*──────────────────────────────────────────────────────────────────────────*/ void animacio_mort() { //Play_WAV(sample[so_mort]); for (int i=1; i<=5; ++i) { retard(10); if (rosita_selected) pinta(rosita_m, 255, x, y, VGA); else if (amic_selected) pinta(amic_m, 255, x, y, VGA); else pinta(pepe_m, 255, x, y, VGA); // if amb_so then sound(2000); retard(10); if (rosita_selected) pinta(rosita_m2, 255, x, y, VGA); else if (amic_selected) pinta(amic_m2, 255, x, y, VGA); else pinta(pepe_m2, 255, x, y, VGA); //if amb_so then sound(1000); } //nosound(); } /*──────────────────────────────────────────────────────────────────────────*/ void animacio_alegria() { if (mode_nocturne && !rosita_selected && !amic_selected) { que_hi_ha = pantalla[((x-max_m_x) / 6)-1][((y-max_m_y) / 6)-2]; if (que_hi_ha == es_un_bloc_pintat) pinta(gorro, color_pintura, x-6, y-6, VGA); else if (que_hi_ha == es_una_paret) pinta(dib_pared, 255, x-6, y-6, VGA); pinta(gorro, 255, x, y-6, VGA); } for (int i=1; i<=10; ++i) { retard(10); if (rosita_selected) pinta(rosita_a, 255, x, y, VGA); else if (amic_selected) pinta(amic_a, 255, x, y, VGA); else if (mode_nocturne) pinta(pepe_gorro, 255, x, y, VGA); else pinta(pepe_a, 255, x, y, VGA); retard(10); if (rosita_selected) pinta(rosita_a2, 255, x, y, VGA); else if (amic_selected) pinta(amic_a2, 255, x, y, VGA); else if (mode_nocturne) pinta(pepe_gorro, 255, x, y, VGA); else pinta(pepe_a2, 255, x, y, VGA); } } /*──────────────────────────────────────────────────────────────────────────*/ void mort() { if (vides == 0) { no_queden_vides = true; pinta(pepe, color_pintura, x, y, vaddr); volcat_de_pantalla(); animacio_mort(); x = pos_ini_x_pepe; y = pos_ini_y_pepe; en_casa = true; } else { if (vides > 0) vides--; if (el_que_hi_havia == es_un_bloc_pintat) pinta(pepe, color_pintura, x, y, vaddr); volcat_de_pantalla(); //so_de(mos_a_pepe); //Play_WAV(sample[so_mort]); animacio_mort(); pantalla[(x/6)-1][(y/6)-2] = el_que_hi_havia; //es_un_bloc_pintat x = pos_ini_x_pepe; y = pos_ini_y_pepe; en_casa = true; volcat_de_pantalla(); if (mode_nocturne) pinta(pepe_gorro, 255, x, y, vaddr2); else pinta(pepe, 255, x, y, vaddr2); omplir_pot(); volcat_de_pantalla(); retard_pepe = velocitat_pepe; } } /*──────────────────────────────────────────────────────────────────────────*/ void mira_el_que_hi_ha(uint8_t cap_on_vaig) { el_que_hi_havia = que_hi_ha; switch (cap_on_vaig) { case amunt: que_hi_ha = pantalla[(x/6)-1][((y-max_m_y)/6)-2]; break; case dreta: que_hi_ha = pantalla[((x+max_m_x)/6)-1][(y/6)-2]; break; case avall: que_hi_ha = pantalla[(x/6)-1][((y+max_m_y)/6)-2]; break; case esquerra: que_hi_ha = pantalla[((x-max_m_x)/6)-1][(y/6)-2]; break; } } /*──────────────────────────────────────────────────────────────────────────*/ void ja_no_pots_eixir() { escriu_frase("JA NO POTS EIXIR", 64, 50, 96, vaddr, 10, 0, 1); animacio_mort(); x = 0; y = 0; no_queden_vides = true; } /*──────────────────────────────────────────────────────────────────────────*/ void munta_velocitat_joc() { if (velocitat_pepe < 9) velocitat_pepe++; pinta_number_zoom(6, numero_G[velocitat_pepe], 255, 110, 80, VGA); if (amb_so) { //sound(velocitat_pepe*150); retard(1); //nosound(); } } /*──────────────────────────────────────────────────────────────────────────*/ void baixa_velocitat_joc() { if (velocitat_pepe > 1) velocitat_pepe--; pinta_number_zoom(6, numero_G[velocitat_pepe], 255, 110, 80, VGA); if (amb_so) { //sound(velocitat_pepe*150); retard(1); //nosound(); } } /*──────────────────────────────────────────────────────────────────────────*/ void moure(uint8_t direccio) //var desp_pixel:byte; { cap_on_va_Pepe = direccio; switch (direccio) { case amunt: if ( ((y-max_m_y)>=l0) && (!en_casa) && (!(pantalla[(x/6)-1][((y-max_m_y) / 6)-2] == es_una_paret)) ) { mira_el_que_hi_ha(direccio); if (que_hi_ha == es_un_bicho) mort(); else { pinta_un_bloc(color_pintura, pintura); //for desp_pixel:=1 to max_m_y do begin dec(y); volcat_de_pantalla; end; y = y - max_m_y; // if not(amb_so) then *//*retard(velocitat_joc); retard_pepe = velocitat_pepe; menejant = true; pantalla[(x/6)-1][(y/6)-2] = es_pepe; } } break; case dreta: if (!en_casa && !(pantalla[((x+max_m_x)/6)-1][(y/6)-2] == es_una_paret)) if ( (x+max_m_x) <= l1 ) { mira_el_que_hi_ha(direccio); if (que_hi_ha == es_un_bicho) mort(); else { pinta_un_bloc(color_pintura,pintura); x = x + max_m_x; //if not(amb_so) then retard(velocitat_joc); retard_pepe = velocitat_pepe; menejant = true; pantalla[(x/6)-1][(y/6)-2] = es_pepe; } } else if ( (x==232) && (y==96) ) omplir_pot(); break; case avall: if ( ((y+max_m_y) <= l2) && !en_casa && !(pantalla[(x/6)-1][((y+max_m_y)/6)-2] == es_una_paret) ) { mira_el_que_hi_ha(direccio); if (que_hi_ha == es_un_bicho) mort(); else { pinta_un_bloc(color_pintura,pintura); y = y + max_m_y; //if not(amb_so) then retard(velocitat_joc); retard_pepe = velocitat_pepe; menejant = true; pantalla[(x/6)-1][(y/6)-2] = es_pepe; } } break; case esquerra: if ( ((x-max_m_x) >= l3) && !(pantalla[((x-max_m_x)/6)-1][(y/6)-2] == es_una_paret) ) { mira_el_que_hi_ha(direccio); if (en_casa && (que_hi_ha == es_un_bicho)) ja_no_pots_eixir(); if (que_hi_ha == es_un_bicho) mort(); else { pinta_un_bloc(color_pintura, pintura); x = x - max_m_x; retard_pepe = velocitat_pepe; menejant = true; pantalla[(x/6)-1][(y/6)-2] = es_pepe; } en_casa = false; } break; } pinta_marcadors(); } /*──────────────────────────────────────────────────────────────────────────*/ void ini_rellontge() { uint8_t a, b; do { a = (rand()%38); b = (rand()%29); } while (pantalla[a][b] == es_una_paret); rellontge.i = (a*6)+4; rellontge.j = (b+1)*6; rellontge.viu = true; //Play_WAV(sample[so_ring]); sense_rellontge = false; } /*──────────────────────────────────────────────────────────────────────────*/ void naix_malo(uint8_t numero) { malo[numero].viu = true; uint16_t cont = 0; uint8_t a, b; do { a = (rand()%38); b = (rand()%29); cont++; if (cont > 10000) { a = 37; b = 14; break; } } while (!((pantalla[a][b] == es_un_bloc_pintat) && (SDL_abs(a-(x/6))>5) && (SDL_abs(b-((y/6)-1))>5))); malo[numero].i = a; malo[numero].j = b; //so_de(naiximent_del_malo); //Play_WAV(sample[so_malo]); pinta(malo[numero].dibuix, 255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); } /*──────────────────────────────────────────────────────────────────────────*/ void mou_malo(uint8_t numero, uint8_t direccio) { switch (direccio) { case amunt: if ( (pantalla[malo[numero].i][malo[numero].j-1] == es_un_bloc_pintat) && (!(pantalla[malo[numero].i][malo[numero].j-1] == es_un_bicho)) ) { pinta(malo[numero].dibuix, color_pintura, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bloc_pintat; malo[numero].j--; pinta(malo[numero].dibuix, 255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bicho; } else if ( (pantalla[malo[numero].i][malo[numero].j-1] == es_pepe) && (!(en_casa)) && (pintura>0) ) mort(); else if ( (pintura==0) && (que_hi_ha == es_un_bloc_pintat) && (pantalla[malo[numero].i][malo[numero].j-1] == es_pepe) && (!(en_casa)) ) mort(); break; case avall: if ( (pantalla[malo[numero].i][malo[numero].j+1] == es_un_bloc_pintat) && (!(pantalla[malo[numero].i][malo[numero].j+1] == es_un_bicho)) ) { pinta(malo[numero].dibuix, color_pintura, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bloc_pintat; malo[numero].j++; pinta(malo[numero].dibuix, 255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bicho; } else if ( (pantalla[malo[numero].i][malo[numero].j+1] == es_pepe) && (!(en_casa)) && (pintura>0) ) mort(); else if ( (pintura==0) && (que_hi_ha == es_un_bloc_pintat) && (pantalla[malo[numero].i][malo[numero].j+1] == es_pepe) & (!(en_casa)) ) mort(); break; case dreta: if ( (pantalla[malo[numero].i+1][malo[numero].j] == es_un_bloc_pintat) && (!(pantalla[malo[numero].i+1][malo[numero].j] == es_un_bicho)) && (!((malo[numero].i+1) == 39)) ) { pinta(malo[numero].dibuix, color_pintura, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bloc_pintat; malo[numero].i++; pinta(malo[numero].dibuix,255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bicho; } else if ( (pantalla[malo[numero].i+1][malo[numero].j] == es_pepe) || ((malo[numero].i+1) == 38) ) if ( (!(en_casa)) && (pintura>0) ) mort(); else if ( (pantalla[malo[numero].i+1][malo[numero].j] == es_pepe) || ((malo[numero].i+1) == 38) ) if ( (pintura==0) && (que_hi_ha==es_un_bloc_pintat) && (pantalla[malo[numero].i+1][malo[numero].j] == es_pepe) && (!(en_casa)) ) mort(); else if ( ((malo[numero].i+1) == 38) and (malo[numero].j == 14) && (en_casa) ) ja_no_pots_eixir(); break; case esquerra: if ( (pantalla[malo[numero].i-1][malo[numero].j] == es_un_bloc_pintat) && (!(pantalla[malo[numero].i-1][malo[numero].j] == es_un_bicho)) ) { pinta(malo[numero].dibuix, color_pintura, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bloc_pintat; malo[numero].i--; pinta(malo[numero].dibuix, 255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bicho; } else if ( (pantalla[malo[numero].i-1][malo[numero].j] == es_pepe) && (!(en_casa)) && (pintura>0) ) mort(); else if ( (pintura == 0) && (que_hi_ha == es_un_bloc_pintat) && (pantalla[malo[numero].i-1][malo[numero].j] == es_pepe) && (!(en_casa)) ) mort(); break; } } /*──────────────────────────────────────────────────────────────────────────*/ void moure_malos() { for (int i=0; ix ) { mou_malo(i, esquerra); malo[i].sentit = rand()%(2+dificultat); } else if ( ((malo[i].i*6)+4)y ) { mou_malo(i, amunt); malo[i].sentit = rand()%(2+dificultat); } else if ( ((malo[i].j+1)*6)0) retard_pepe--; if (input::keyPressed(SDL_SCANCODE_KP_PLUS)) { munta_velocitat_joc(); do {} while (input::keyPressed(SDL_SCANCODE_KP_PLUS)); // [RZC 25/01/2004] [TODO] Açò no va a funcionar en SDL. Fer un keyDown i un keyPress. Revisar el tot el codi. } if (input::keyPressed(SDL_SCANCODE_KP_MINUS)) { baixa_velocitat_joc(); do {} while (input::keyPressed(SDL_SCANCODE_KP_MINUS)); } if (retard_pepe == 0) if (input::keyPressed(tecla_amunt)) moure(amunt); else if (input::keyPressed(tecla_avall)) moure(avall); else if (input::keyPressed(tecla_dreta)) moure(dreta); else if (input::keyPressed(tecla_esquerra)) moure(esquerra); if (input::keyPressed(SDL_SCANCODE_M)) { //map = !map; final_fase=true; num_fase=9; do {} while (input::keyPressed(SDL_SCANCODE_M)); } /*---------*/ /* if input::keyPressed(KeyN) then begin final_fase:=true; num_fase:=9; end; if input::keyPressed(KeyB) then final_fase:=true;*/ /*---------*/ if (input::keyPressed(SDL_SCANCODE_1)) { amb_so = false; //!amb_so do {} while (input::keyPressed(SDL_SCANCODE_1)); } if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { rellontge.temps = rellontge.temps - SDL_GetTicks(); escriu_frase("JOC DETINGUT", 147, 69, 89, vaddr2, 0, 0, 0); escriu_frase("(*ESC* PER A EIXIR)", 147, 38, 101, vaddr2, 0, 0, 0); draw::waitVsync(); draw::draw(vaddr2, VGA); do {} while (input::keyPressed(SDL_SCANCODE_ESCAPE)); do {} while (!input::anyKey()); if (input::keyPressed(SDL_SCANCODE_ESCAPE)) eixir = true; rellontge.temps = rellontge.temps + SDL_GetTicks(); } if (rellontge.viu) if ( (x == rellontge.i) && (y == rellontge.j) ) { malos_quets = true; rellontge.temps = SDL_GetTicks()+10; rellontge.viu = false; if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_campanes); if (midi) audio::playMusic(); } fer_apareixer_els_malos(); if (!malos_quets) { if (contador % velocitat_pepe == 0) moure_malos(); } else { if (SDL_GetTicks() >= rellontge.temps) { malos_quets = false; if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } if (mode_nocturne) ini_midi(musica_fase_nit); else ini_midi(musica_fase); if (midi) audio::playMusic(); } } if (!no_queden_vides) volcat_de_pantalla(); /*------------------------------*/ } while ( !( eixir || final_fase || no_queden_vides) ); if (final_fase) if (num_fase < ultima_fase) { pinta(pepe, color_pintura, x, y, VGA); x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); draw::fadeDown(0,0,0,2); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi = false; } level_complete(); num_fase++; } else if (mode_nocturne) { no_queden_vides = true; pinta(pepe, color_pintura, x, y, VGA); x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); draw::fadeDown(0,0,0,3); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } historia_final(); mode_dream_tour = dream_tour; save_records(); } else { no_queden_vides = true; pinta(pepe, color_pintura, x, y, VGA); x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); draw::fadeDown(0,0,0,3); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } if (dificultat == dificil) { historia_final(); if ( !(mode_rosita == rosita_enabled) && !(mode_amic == job_enabled) ) mode_hard = pepe_dificil; if ( (mode_rosita == rosita_enabled) && !(mode_amic == job_enabled) ) mode_hard_r = rosita_dificil; if ( !(mode_rosita == rosita_enabled) && (mode_easy == pepe_facil) && (mode_normal == pepe_normal) && (mode_hard == pepe_dificil) ) { mode_rosita = rosita_enabled; text_rosita(); } if ( (mode_rosita == rosita_enabled) && (mode_easy_r == rosita_facil) && (mode_normal_r == rosita_normal) && (mode_hard_r == rosita_dificil) ) { mode_amic = job_enabled; text_amic(); } save_records(); } else if (dificultat == normal) { final_fals(); if ( !(mode_rosita == rosita_enabled) && !(mode_amic == job_enabled) ) mode_normal = pepe_normal; if ( (mode_rosita == rosita_enabled) && !(mode_amic == job_enabled) ) mode_normal_r = rosita_normal; if ( !(mode_rosita == rosita_enabled) && (mode_easy == pepe_facil) && (mode_normal == pepe_normal) && (mode_hard == pepe_dificil) ) { mode_rosita = rosita_enabled; text_rosita(); } if ( (mode_rosita == rosita_enabled) && (mode_easy_r == rosita_facil) && (mode_normal_r == rosita_normal) && (mode_hard_r == rosita_dificil) ) { mode_amic = job_enabled; text_amic(); } save_records(); } else { final_fals(); if (!(mode_rosita == rosita_enabled) && !(mode_amic == job_enabled) ) mode_easy = pepe_facil; if ((mode_rosita == rosita_enabled) && !(mode_amic == job_enabled) ) mode_easy_r = rosita_facil; if (!(mode_rosita == rosita_enabled) && (mode_easy == pepe_facil) && (mode_normal == pepe_normal) && (mode_hard == pepe_dificil) ) { mode_rosita = rosita_enabled; text_rosita; } if (!(mode_amic == job_enabled) && (mode_rosita == rosita_enabled) && (mode_easy_r == rosita_facil) && (mode_normal_r == rosita_normal) && (mode_hard_r == rosita_dificil) ) { mode_amic = job_enabled; text_amic; } save_records(); } no_queden_vides = true; } } while (!eixir && !no_queden_vides); if (no_queden_vides) { if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } missatge_game_over(); } if (eixir) { draw::fadeDown(0,0,0,0); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } } } /*──────────────────────────────────────────────────────────────────────────*/ void time_attack() { num_fase = 0; ini_vars(num_fase); ini_pantalla(); draw::draw(vaddr2, vaddr); pinta_marcadors(); dificultat = normal; rosita_selected = false; amic_selected = false; color_pintura = 162; color_marcador_pintura = 162; draw::waitVsync(); draw::draw(vaddr, VGA); pinta_marcadors(); volcat_de_pantalla(); bool eixir = false; if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_time_attack); if (midi) audio::playMusic(); contador = 0; do {} while (!input::keyPressed(tecla_esquerra)); pilla_temps(); //------------------------------------------------------------------------------------------ do { if (!audio::musicPlaying() && midi) audio::playMusic(); contador++; if (retard_pepe > 0) retard_pepe--; menejant = false; if ( retard_pepe == 0 ) { if ( input::keyPressed(tecla_amunt) ) moure(amunt); else if ( input::keyPressed(tecla_avall) ) moure(avall); else if ( input::keyPressed(tecla_dreta) ) moure(dreta); else if ( input::keyPressed(tecla_esquerra) ) moure(esquerra); } if ( input::keyPressed(SDL_SCANCODE_1) ) { amb_so = false; //not(amb_so); do {} while(input::keyPressed(SDL_SCANCODE_1)); } if ( input::keyPressed(SDL_SCANCODE_ESCAPE) ) { eixir = true; } /*if input::keyPressed(KeyN) then final_fase:=true;*/ fer_apareixer_els_malos(); posa_el_temps(vaddr); if ( (contador % velocitat_pepe) == 0 ) moure_malos(); if ( !no_queden_vides ) volcat_de_pantalla(); } while ( !(eixir || final_fase || no_queden_vides) ); //------------------------------------------------------------------------------------------ if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } if (final_fase) { pinta(pepe, color_pintura, x, y, VGA); x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } resultat_time_attack(); } else if (eixir) { draw::fadeDown(0,0,0,0); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } } if (no_queden_vides) { missatge_game_over(); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } } } /*──────────────────────────────────────────────────────────────────────────*/ uint8_t pos, pos_dif, pos_m, cord_y; uint8_t percentatge; void ini_estreles() { draw::cls(0, vaddr); for (int i=0; i<10; ++i) { estreles[i].x = rand()%290; estreles[i].y = 1; estreles[i].velocitat = rand()%3+1; } } void fondo_estreles(draw::surface *from, draw::surface *where) { for (int i=0; i<10; ++i) { if ( (estreles[i].y + estreles[i].velocitat) > 191 ) { estreles[i].x = rand()%290; estreles[i].y = 1; estreles[i].velocitat = rand()%3+1; } else estreles[i].y = estreles[i].y + (estreles[i].velocitat); draw::draw(from, where, 26747, 9, 8, estreles[i].x, estreles[i].y); } } void actualitza_options(draw::surface *from, draw::surface *where) { draw::cls(0, vaddr2); for (int i=0; i<=3; ++i) for (int j=0; j<=5; ++j) draw::draw(vaddr, where, 48000, 50, 50, j*50, i*50); fondo_estreles(vaddr, vaddr2); draw::draw(from, where, 30400, 165, 28, 70, 5); draw::draw(from, where, 39733, 116, 18, 22, 43); if ( amb_so ) draw::draw(from, where, 40492, 25, 17, 149, 45); else draw::draw(from, where, 39557, 28, 20, 150, 42); draw::draw(from, where, 57332, 113, 19, 20, 81); if (GM) draw::draw(from, where, 51573, 107, 17, 141, 81); else draw::draw(from, where, 51684, 130, 20, 141, 81); draw::draw(from, where, 45172, 39, 20, 22, 61); switch (volumen) { case 0 : draw::draw(from, where, 45551, 32, 18, 70, 62); break; case 1 : draw::draw(from, where, 45580, 16, 18, 70, 62); break; case 2 : draw::draw(from, where, 45596, 16, 18, 70, 62); break; case 3 : draw::draw(from, where, 45611, 16, 18, 70, 62); break; case 4 : draw::draw(from, where, 45626, 16, 18, 70, 62); break; case 5 : draw::draw(from, where, 45642, 16, 18, 70, 62); break; case 6 : draw::draw(from, where, 45658, 16, 18, 70, 62); break; case 7 : draw::draw(from, where, 45673, 16, 18, 70, 62); break; case 8 : draw::draw(from, where, 45689, 16, 18, 70, 62); break; case 9 : draw::draw(from, where, 45705, 14, 18, 71, 62); break; case 10 : draw::draw(from, where, 45720, 40, 18, 70, 62); break; } draw::draw(from, where, 21673, 84, 73, 22, 117); draw::draw(vaddr, vaddr2, tecla_amunt_dib, 21, 21, 135, 110); draw::draw(vaddr, vaddr2, tecla_avall_dib, 21, 21, 135, 131); draw::draw(vaddr, vaddr2, tecla_esquerra_dib, 21, 21, 135, 152); draw::draw(vaddr, vaddr2, tecla_dreta_dib, 21, 21, 135, 173); // fletxes i ESC draw::draw(vaddr, vaddr2, 31527, 47, 24, 238, 172); // Complet + percentatge draw::draw(vaddr, vaddr2, 58405, 70, 17, 200, 120); draw::draw(vaddr, vaddr2, percentatge*29, 29, 14, 220, 142); pinta_number(fletxa3, 255, 13, cord_y, vaddr2); } void pinta_marcs(uint16_t posicio) { draw::draw(vaddr, vaddr2); for (int i=posicio; i<=posicio+75; ++i) { draw::putPixel(i, 11, 15, vaddr2); draw::putPixel(i, 12, 15, vaddr2); draw::putPixel(i, 90, 15, vaddr2); draw::putPixel(i, 91, 15, vaddr2); } for (int i=11; i<=91; ++i) { draw::putPixel(posicio, i, 15, vaddr2); draw::putPixel(posicio+1, i, 15, vaddr2); draw::putPixel(posicio+74, i, 15, vaddr2); draw::putPixel(posicio+75, i, 15, vaddr2); } if (mode_nocturne) { if (mode_dream_tour == dream_tour) pinta_number_zoom(2, tick, 255, 216, 143, vaddr2); } else if ( (pos==1) || (pos==3) ) { if (mode_easy == pepe_facil) pinta_number_zoom(2, tick, 255, 216, 118, vaddr2); if (mode_normal == pepe_normal) pinta_number_zoom(2, tick, 255, 216, 143, vaddr2); if (mode_hard == pepe_dificil) pinta_number_zoom(2, tick, 255, 216, 168, vaddr2); } else { if (mode_easy_r == rosita_facil) pinta_number_zoom(2, tick, 255, 216, 118, vaddr2); if (mode_normal_r == rosita_normal) pinta_number_zoom(2, tick, 255, 216, 143, vaddr2); if (mode_hard_r == rosita_dificil) pinta_number_zoom(2, tick, 255, 216, 168, vaddr2); } if (pos_dif == 1) pinta_number(fletxa, 255, 98, 118, vaddr2); if (pos_dif == 2) pinta_number(fletxa, 255, 98, 143, vaddr2); if (pos_dif == 3) pinta_number(fletxa, 255, 98, 168, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } void desp_marc(uint8_t direccio) { switch (direccio) { case Left: if (pos == 3) { i = 219; while (i > 136) { pinta_marcs(i); i = i - 3; if (i < 137) pinta_marcs(137); } } else if (pos == 2) { i=137; while (i > 54) { pinta_marcs(i); i = i - 3; if (i < 55) pinta_marcs(55); } } break; case Right: if (pos == 1) { i=55; while (i < 138) { pinta_marcs(i); i = i + 3; if (i > 137) pinta_marcs(137); } } else if (pos == 2) { i=137; while (i < 220) { pinta_marcs(i); i = i + 3; if (i > 219) pinta_marcs(219); } } break; } } void menu_joc() /*var temps,temps2 : word; pos,pos_dif,pos_m,cord_y : byte; i,j,a_on_pinte_el_marc : word; aux : byte; tecla_incorrecta : boolean; i_int:integer; dib_aux : word; percentatge : byte; */ { time_attack_mode = false; story_mode_mode = false; percentatge = 0; if (mode_easy == pepe_facil) percentatge++; if (mode_normal == pepe_normal) percentatge++; if (mode_hard == pepe_dificil) percentatge++; if (mode_easy_r == rosita_facil) percentatge++; if (mode_normal_r == rosita_normal) percentatge++; if (mode_hard_r == rosita_dificil) percentatge++; if (mode_dream_tour == dream_tour) percentatge++; if (mode_nocturne) load_mif(MENU_NIT, vaddr); else load_mif(MENU, vaddr); load_mif(MENU_S, vaddr2); draw::waitVsync(); draw::draw(vaddr, VGA); if (!mode_nocturne) { if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_title); if (midi) audio::playMusic(); } else { if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_nit); if (midi) audio::playMusic(); if (!midi) ini_midi(musica_nit); if (!audio::musicPlaying() && midi) audio::playMusic(); } int i = 320; if (!mode_nocturne) while (i > 20) { draw::waitVsync(); draw::draw(vaddr, VGA); draw::draw(vaddr2, VGA, 16983, 142, 26, i, 53); i-=10; if (i == 20) draw::draw(vaddr2, vaddr, 16983, 142, 26, i, 53); } i = 320; while (i > 20) { draw::waitVsync(); draw::draw(vaddr, VGA); if (!mode_nocturne) draw::draw(vaddr2, VGA, 28822, 132, 25, i, 90); else draw::draw(vaddr2, VGA, 28958, 132, 25, i, 90); i-=10; if (i == 20) if (!mode_nocturne) draw::draw(vaddr2, vaddr, 28822, 132, 25, i, 90); else draw::draw(vaddr2, vaddr, 28958, 132, 25, i, 90); } i = 320; while (i > 20) { draw::waitVsync(); draw::draw(vaddr, VGA); draw::draw(vaddr2, VGA, 40982, 152, 24, i, 128); i-=10; if (i == 20) draw::draw(vaddr2, vaddr, 40982, 152, 24, i, 128); } i = 320; while (i > 20) { draw::waitVsync(); draw::draw(vaddr, VGA); draw::draw(vaddr2, VGA, 52182, 103, 30, i, 163); i-=10; if (i == 20) draw::draw(vaddr2, vaddr, 52182, 103, 30, i, 163); } i = -35; while (i < 15) { draw::waitVsync(); draw::draw(vaddr, VGA); draw::waitVsync(); draw::draw(vaddr2, VGA, 5463, 133, 33, 23, i); i+=10; if (i == 15) draw::draw(vaddr2, vaddr, 5463, 133, 33, 23, i); } draw::waitVsync(); draw::draw(vaddr, VGA); uint32_t temps = SDL_GetTicks()/1000; uint32_t temps2; eixir_del_joc = false; pos_m = 2; pinta_number(fletxa2, 255, 13, 100, VGA); cord_y = 100; do { if (!audio::musicPlaying()) if (mode_nocturne) { ini_midi(musica_nit); if (midi) audio::playMusic(); } else { ini_midi(musica_title); if (midi) audio::playMusic(); } temps2 = SDL_GetTicks()/1000; if ( input::keyPressed(SDL_SCANCODE_DOWN) && (pos_m<4) ) { pos_m++; switch (pos_m) { case 1: cord_y = 62; break; case 2: cord_y = 100; break; case 3: cord_y = 138; break; case 4: cord_y = 174; break; } draw::draw(vaddr, vaddr2); pinta_number(fletxa2, 255, 13, cord_y, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); temps = SDL_GetTicks()/1000; temps2 = temps + 1; //Play_WAV(sample[so_fletxa]); do {} while (input::keyPressed(SDL_SCANCODE_DOWN)); } if ( input::keyPressed(SDL_SCANCODE_UP) && (pos_m>1) ) { pos_m--; if (mode_nocturne && (pos_m==1)) pos_m = 2; switch (pos_m) { case 1: cord_y = 62; break; case 2: cord_y = 100; break; case 3: cord_y = 138; break; case 4: cord_y = 174; break; } draw::draw(vaddr, vaddr2); pinta_number(fletxa2, 255, 13, cord_y, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); temps = SDL_GetTicks()/1000; temps2 = temps + 1; //Play_WAV(sample[so_fletxa]); do {} while (input::keyPressed(SDL_SCANCODE_UP)); } draw::draw(vaddr, vaddr2); if ( (temps2%2)==0 ) pinta_number(fletxa2, 255, 13, cord_y, vaddr2); else pinta_number(fletxa2, 255, 15, cord_y, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while ( !(input::keyPressed(SDL_SCANCODE_RETURN)) && !(input::keyPressed(SDL_SCANCODE_ESCAPE)) && !((temps2-temps)>=10) ); //if (input::keyPressed(SDL_SCANCODE_RETURN)) Play_WAV(sample[so_enter]); if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { pos_m = 5; audio::stopMusic(); power_off(vaddr); eixir_del_joc = true; } if ( (temps2-temps) >= 10 ) { pos_m = 5; draw::fadeDown(0,0,0,0); escriu_records(10); titol_del_joc(); } // TIME ATTACK if ( (pos_m == 1) && !mode_nocturne ) { time_attack_mode = true; draw::fadeDown(0,0,0,1); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } time_attack(); } // PEPE VELL if ( pos_m == 3 ) { draw::fadeDown(0,0,0,1); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } pepe_text(); } // STORY MODE if ( pos_m == 2 ) { borrat_de_pantalla(vaddr); do {} while (input::keyPressed(SDL_SCANCODE_RETURN)); story_mode_mode = true; rosita_selected = false; amic_selected = false; if (mode_nocturne) load_mif(SELECT_N, vaddr); else load_mif(SELECT, vaddr); if ( mode_rosita != rosita_enabled ) { for (int i=137; i<=212; ++i) for (int j=11; j<=91; j++) draw::putPixel(i, j, 0, vaddr); draw::putPixel(145, 19, 14, vaddr); draw::putPixel(197, 44, 14, vaddr); draw::putPixel(149, 78, 14, vaddr); draw::putPixel(194, 77, 14, vaddr); draw::putPixel(172, 54, 14, vaddr); draw::putPixel(198, 65, 14, vaddr); draw::putPixel(177, 38, 9, vaddr); draw::putPixel(169, 82, 9, vaddr); draw::putPixel(183, 12, 9, vaddr); draw::putPixel(139, 37, 9, vaddr); draw::putPixel(211, 81, 9, vaddr); } if ( mode_amic != job_enabled ) { for (int i=219; i<=294; ++i) for (int j=11; j<=91; ++j) draw::putPixel(i, j, 0, vaddr); draw::putPixel(228, 65, 14, vaddr); draw::putPixel(290, 26, 14, vaddr); draw::putPixel(264, 63, 14, vaddr); draw::putPixel(284, 85, 14, vaddr); draw::putPixel(262, 13, 14, vaddr); draw::putPixel(239, 46, 14, vaddr); draw::putPixel(266, 74, 9, vaddr); draw::putPixel(264, 21, 9, vaddr); draw::putPixel(248, 84, 9, vaddr); draw::putPixel(279, 87, 9, vaddr); draw::putPixel(254, 39, 9, vaddr); } draw::waitVsync(); draw::draw(vaddr, VGA); pinta_marcs(55); pos = 1; pos_dif = mode_nocturne ? 0 : 1; uint16_t a_on_pinte_el_marc = 55; draw::getColor(15, &R, &G, &B); i=0; G=0; B=0; do { i = (i+1)%127; B = SDL_abs(63-i); G = B; draw::setColor(15,R,G,B); if ( !audio::musicPlaying() && midi ) audio::playMusic(); if ( input::keyPressed(SDL_SCANCODE_LEFT) && (pos>1) ) if (!mode_nocturne) { desp_marc(Left); pos--; } if ( input::keyPressed(SDL_SCANCODE_RIGHT) && (pos<3) ) if (!mode_nocturne) { if ( (pos==1) && (mode_rosita==99) ) { desp_marc(Right); pos++; } else if ( (pos==2) && (mode_amic==199) ) { desp_marc(Right); pos++; } } if ( input::keyPressed(SDL_SCANCODE_DOWN) && (pos_dif<3) && !mode_nocturne ) { pos_dif++; pinta_marcs(a_on_pinte_el_marc); //Play_WAV(sample[so_fletxa]); do {} while (input::keyPressed(SDL_SCANCODE_DOWN)); } if ( input::keyPressed(SDL_SCANCODE_UP) && (pos_dif>1) && !mode_nocturne ) { pos_dif--; pinta_marcs(a_on_pinte_el_marc); //Play_WAV(sample[so_fletxa]); do {} while (input::keyPressed(SDL_SCANCODE_UP)); } if (pos==2) if (mode_rosita == 99) { pinta_marcs(137); a_on_pinte_el_marc = 137; } if (pos == 3) if (mode_amic == 199) { pinta_marcs(219); a_on_pinte_el_marc = 219; } if (pos == 1) { pinta_marcs(55); a_on_pinte_el_marc = 55; } } while ( !input::keyPressed(SDL_SCANCODE_RETURN) && !input::keyPressed(SDL_SCANCODE_ESCAPE) ); //if ( input::keyPressed(SDL_SCANCODE_RETURN) ) Play_WAV(sample[so_enter]); if ( input::keyPressed(SDL_SCANCODE_ESCAPE) ) pos = 4; if ( pos_dif == 1 ) dificultat = facil; if ( pos_dif == 2 ) dificultat = normal; if ( pos_dif == 3 ) dificultat = dificil; if (mode_nocturne) dificultat = normal; if ( pos == 1 ) { amic_selected = false; rosita_selected = false; color_pintura = 162; color_marcador_pintura = 162; } if ( pos == 2 ) { amic_selected = false; rosita_selected = true; color_pintura = 199; color_marcador_pintura = 199; } if ( pos == 3 ) { amic_selected = true; rosita_selected = false; color_pintura = 48; color_marcador_pintura = 48; } if ( pos == 4 ) borrat_de_pantalla(vaddr); else draw::fadeDown(0,0,0,0); if ( pos != 4 ) { if (midi && !mode_nocturne) { audio::stopMusic(); audio::unloadMusic(); midi=false; } story_mode(); } } // opcions if ( pos_m == 4 ) { ini_estreles(); pos_m = 1; if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_options); if (midi) audio::playMusic(); cord_y = 47; load_mif(OPTIONS, vaddr); actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); do { if (!audio::musicPlaying() && midi) audio::playMusic(); if ( input::keyPressed(SDL_SCANCODE_DOWN) && (pos_m<7) ) { pos_m++; switch (pos_m) { case 1: cord_y = 47; break; case 2: cord_y = 65; break; case 3: cord_y = 83; break; case 4: cord_y = 122; break; case 5: cord_y = 140; break; case 6: cord_y = 158; break; case 7: cord_y = 176; break; } //Play_WAV(sample[so_fletxa]); actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (input::keyPressed(SDL_SCANCODE_DOWN)); } if ( input::keyPressed(SDL_SCANCODE_UP) && (pos_m>1) ) { pos_m--; switch (pos_m) { case 1: cord_y = 47; break; case 2: cord_y = 65; break; case 3: cord_y = 83; break; case 4: cord_y = 122; break; case 5: cord_y = 140; break; case 6: cord_y = 158; break; case 7: cord_y = 176; break; } //Play_WAV(sample[so_fletxa]); actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (input::keyPressed(SDL_SCANCODE_UP)); } if (input::keyPressed(SDL_SCANCODE_RIGHT)) { if (pos_m == 1) { amb_so = false; // not(amb_so); if (Puerto==255) amb_so = false; //if amb_so then InitWAV(Puerto,DMA,IRQ) else EndWav; //if amb_so then arxius_wav(amb_so); } else if (pos_m == 2) { if ( volumen < 10 ) volumen++; } else if (pos_m == 3) GM = !GM; actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (input::anyKey()); } if (input::keyPressed(SDL_SCANCODE_LEFT)) { if (pos_m == 1) { amb_so = false; // not(amb_so); if (Puerto == 255) amb_so = false; //if amb_so then InitWAV(Puerto,DMA,IRQ) else EndWav; //if amb_so then arxius_wav(amb_so); } else if (pos_m == 2) { if ( volumen > 0 ) volumen--; } else if ( pos_m == 3) GM = !GM; actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (input::anyKey()); } if ( input::keyPressed(SDL_SCANCODE_RETURN) && (pos_m>3) ) { do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); //Play_WAV(sample[so_enter]); } while (input::keyPressed(SDL_SCANCODE_RETURN)); uint8_t aux = 0; uint16_t dib_aux = 23781; actualitza_options(vaddr, vaddr2); switch (pos_m) { case 4: tecla_amunt = aux; tecla_amunt_dib = dib_aux; break; case 5: tecla_avall = aux; tecla_avall_dib = dib_aux; break; case 6: tecla_esquerra = aux; tecla_esquerra_dib = dib_aux; break; case 7: tecla_dreta = aux; tecla_dreta_dib = dib_aux; break; } draw::waitVsync(); draw::draw(vaddr2, VGA); bool tecla_incorrecta; do { tecla_incorrecta = true; do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (!input::anyKey()); aux = input::getKey(); do { actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (input::anyKey()); //bool tecla_incorrecta = true; if (aux >= SDL_SCANCODE_A && aux <= SDL_SCANCODE_Z) tecla_incorrecta = false; if (aux >= SDL_SCANCODE_RIGHT && aux <= SDL_SCANCODE_UP) tecla_incorrecta = false; } while (tecla_incorrecta); switch (aux) { case SDL_SCANCODE_A : dib_aux = 4485; break; case SDL_SCANCODE_B : dib_aux = 4509; break; case SDL_SCANCODE_C : dib_aux = 4533; break; case SDL_SCANCODE_D : dib_aux = 4557; break; case SDL_SCANCODE_E : dib_aux = 4581; break; case SDL_SCANCODE_F : dib_aux = 4605; break; case SDL_SCANCODE_G : dib_aux = 4629; break; case SDL_SCANCODE_H : dib_aux = 4653; break; case SDL_SCANCODE_I : dib_aux = 4677; break; case SDL_SCANCODE_J : dib_aux = 4702; break; case SDL_SCANCODE_K : dib_aux = 4726; break; case SDL_SCANCODE_L : dib_aux = 4750; break; case SDL_SCANCODE_M : dib_aux = 4774; break; case SDL_SCANCODE_N : dib_aux = 14085; break; case SDL_SCANCODE_O : dib_aux = 14109; break; case SDL_SCANCODE_P : dib_aux = 14133; break; case SDL_SCANCODE_Q : dib_aux = 14157; break; case SDL_SCANCODE_R : dib_aux = 14181; break; case SDL_SCANCODE_S : dib_aux = 14205; break; case SDL_SCANCODE_T : dib_aux = 14229; break; case SDL_SCANCODE_U : dib_aux = 14253; break; case SDL_SCANCODE_V : dib_aux = 14277; break; case SDL_SCANCODE_W : dib_aux = 14302; break; case SDL_SCANCODE_X : dib_aux = 14326; break; case SDL_SCANCODE_Y : dib_aux = 14350; break; case SDL_SCANCODE_Z : dib_aux = 14374; break; case SDL_SCANCODE_UP : dib_aux = 23709; break; case SDL_SCANCODE_DOWN : dib_aux = 23685; break; case SDL_SCANCODE_LEFT : dib_aux = 23757; break; case SDL_SCANCODE_RIGHT : dib_aux = 23733; break; } switch (pos_m) { case 4: tecla_amunt = aux; tecla_amunt_dib = dib_aux; break; case 5: tecla_avall = aux; tecla_avall_dib = dib_aux; break; case 6: tecla_esquerra = aux; tecla_esquerra_dib = dib_aux; break; case 7: tecla_dreta = aux; tecla_dreta_dib = dib_aux; break; } actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } actualitza_options(vaddr, vaddr2); draw::waitVsync(); draw::draw(vaddr2, VGA); } while (!input::keyPressed(SDL_SCANCODE_ESCAPE)); borrat_de_pantalla(vaddr2); if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } save_cfg(); } } /*──────────────────────────────────────────────────────────────────────────*/ /*──────────────────────────────────────────────────────────────────────────*/ int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_EVERYTHING); comprobar_comp_i_sprites(); srand(SDL_GetTicks()); input::init(); //setmode(0x13); draw::init("Pepe el Pintor", 320, 200, 3); vaddr = draw::createSurface(320, 200); vaddr2 = draw::createSurface(320, 200); vaddrSP = draw::loadSurface("datos/sprites.dat"); //(320, 24);// (uint8_t *)malloc(7680); //loadPCX('datos/sprites.dat', vaddrSP); draw::loadPalette("datos/sprites.dat"); load_setup_i_versio(); ini_matrius(); load_cfg(); intro_logo(); titol_del_joc(); /* if amb_so then InitWAV(Puerto,DMA,IRQ); if amb_so then arxius_wav(TRUE);*/ do { menu_joc(); } while (!eixir_del_joc); draw::freeSurface(vaddr); draw::freeSurface(vaddr2); draw::freeSurface(vaddrSP); /* if amb_so then arxius_wav(FALSE); if amb_so then EndWAV;*/ //DesinstalarKB(); //setmode(0x3); draw::quit(); SDL_Quit(); } /* ini_midi('.\music\logo.mid'); if midi then audio::playMusic; if (not(audio::musicPlaying())) and (midi) then audio::playMusic; if midi then begin audio::stopMusic; audio::unloadMusic; midi:=false; end; */