/*────────────────────────────────────────────────────────────────────────── 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 "dos.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_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; uint8_t *vaddr; // : word; uint8_t *vaddr2; // : word; uint8_t *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(uint16_t where) { uint16_t i; uint8_t j; fadedown(0, 0, 0, 0); cls32(0, where); volcar32(where, VGA); set_color(1, 63, 63, 63); for (int i = 0; i < 320; ++i) putpixel(i, 100, 1, where); for (int i = 0; i <= 160; ++i) { putpixel(i, 100, 0, where); putpixel(320 - i, 100, 0, where); if (i % 2 == 0) volcar32(where, VGA); } for (int i = 0; i <= 20; ++i) espera_VGA(); } /*──────────────────────────────────────────────────────────────────────────*/ void load_mif(int num, uint8_t *where) { espera_VGA(); cls32(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, 64000, 1, fich); uint8_t paleta[768]; fread(paleta, 768, 1, fich); setpaleta(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(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 StopMIDI; unloadmidi; 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, uint8_t *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 // inc(x); inc(y); for (int i = 0; i < 6; ++i) for (int j = 0; j < 6; ++j) if (color != 255) where[(x + i) + ((y + j) * 320)] = color; else if (vaddrSP[offset + i + (j * 320)] != 255) where[(x + i) + ((y + j) * 320)] = vaddrSP[offset + i + (j * 320)]; } /*──────────────────────────────────────────────────────────────────────────*/ // [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, uint8_t *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve // inc(x); inc(y); for (int i = 0; i < 6; ++i) for (int j = 0; j < 6; ++j) if (color != 255) where[(x + i) + ((y + j) * 320)] = color; else if (vaddrSP[offset + i + (j * 320)] != 255) where[(x + i) + ((y + j) * 320)] = vaddrSP[offset + i + (j * 320)]; } /*──────────────────────────────────────────────────────────────────────────*/ // [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, uint8_t *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve // inc(x); inc(y); for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) if (color != 255) where[(x + i) + ((y + j) * 320)] = color; else if (vaddrSP[offset + i + (j * 320)] != 255) where[(x + i) + ((y + j) * 320)] = vaddrSP[offset + i + (j * 320)]; } /*──────────────────────────────────────────────────────────────────────────*/ void pinta_number2(uint16_t offset, uint8_t color, uint8_t color_determinat, uint16_t x, uint16_t y, uint8_t *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve // inc(x); inc(y); for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) if (color != 255) where[(x + i) + ((y + j) * 320)] = color; else if ((vaddrSP[offset + i + (j * 320)] != 255) && (vaddrSP[offset + i + (j * 320)] != 254)) where[(x + i) + ((y + j) * 320)] = vaddrSP[offset + i + (j * 320)]; else if (vaddrSP[offset + i + (j * 320)] == 254) where[(x + i) + ((y + j) * 320)] = color_determinat; } /*──────────────────────────────────────────────────────────────────────────*/ void pinta_number_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, uint8_t *where) { // [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve // inc(x); inc(y); for (int i = 0; i < 9 * zoom; ++i) for (int j = 0; j < 9 * zoom; ++j) if (color != 255) where[(x + i) + ((y + j) * 320)] = color; else if (vaddrSP[offset + (i / zoom) + ((j / zoom) * 320)] != 255) where[(x + i) + ((y + j) * 320)] = vaddrSP[offset + (i / zoom) + ((j / zoom) * 320)]; } /*──────────────────────────────────────────────────────────────────────────*/ void retard(int centesimes) { uint32_t t = SDL_GetTicks() + centesimes * 10; while ((SDL_GetTicks() < t) && (!TeclaPuls(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(playing)) and (midi) then PlayMIDI; } /*──────────────────────────────────────────────────────────────────────────*/ void escriu_frase(char *nom, uint8_t color_determinat, uint16_t x,uint16_t y, uint8_t *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], 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], color); minuts[cont] = minuts_prov; segons_tabla[cont] = segons_prov; } inc(cont); } } save_records(); } /*──────────────────────────────────────────────────────────────────────────*/ void text_rosita() { load_mif(PEPE01, vaddr); cls32(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); cls32(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); espera_vga(); volcar32(vaddr, VGA); retard(400); fadedown(0,0,0,1); setmode(3); pepe_clasic(); setmode(0x13); } /*──────────────────────────────────────────────────────────────────────────*/ void final_fals() { setupvirtual(vaddr3); cls32(0, vaddr); load_mif(FINALF1, vaddr2); load_mif(FINALF2, vaddr3); getpaleta(paleta); ini_midi(musica_final_fals); if (midi) Playmidi(); for (int i=1; i<=3; ++i) { espera_VGA(); volcar32(vaddr, VGA); uint32_t t = SDL_GetTicks() + 5000; do { if (!playing) { ini_midi(musica_final_fals); if (midi) Playmidi(); } } while ( !QteclaPuls() && 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; espera_VGA(); volcar32(vaddr2, VGA); uint32_t t = SDL_GetTicks()+6000; do {} while (!QteclaPuls() && SDL_GetTicks() 80 ) { if (!playing && midi) { ini_midi(musica_final_joc); if (midi) Playmidi(); } Put_Sprite_ICE_baix(vaddr2, vaddr, offset, ample, alt, x, i_int); espera_VGA(); volcar32(vaddr, VGA); velocitat++; if (velocitat % 5 == 0) i_int--; } if (num < 5) while (i_int > -alt) { if (!playing && midi) { ini_midi(musica_final_joc); if (midi) Playmidi(); } Put_Sprite_ICE_dalt(vaddr2, vaddr, offset, ample, alt, x, i_int); espera_VGA(); volcar32(vaddr, VGA); velocitat++; if (velocitat % 5 == 0) i_int--; } } uint32_t t = SDL_GetTicks()+10000; do {} while (!QteclaPuls() && 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; { uint8_t *vaddrFase = (uint8_t*)malloc(64000); // 6400??? load_mif(FASES,vaddr); Cls32(0, vaddrFase); offset = ((num_fase / 6)*160)+((((num_fase-1) % 5)*40)*320); PutSprite(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*6)+4, (j+1)*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) putpixel(16, i, 237, vaddr2); putpixel(17, 97, 237, vaddr2); putpixel(22, 97, 237, vaddr2); putpixel(17, 102, 237, vaddr2); 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) { putpixel(i, j, color_marcador_pintura, vaddr2); putpixel(pos_esq_m_p-1, j, color_borde_m_p, vaddr2); putpixel(pos_dreta_m_p+1, j, color_borde_m_p, vaddr2); putpixel(i, (pos_base_m_p-(max_pintura / tamany_m_p)-1), color_borde_m_p, vaddr2); putpixel(i, (pos_base_m_p+1), color_borde_m_p, vaddr2); } // coloca la fase getpaleta(paleta); blackout(); cls32(0, vaddr); PutBloc(vaddr2, 0, vaddr, 249, 200, 0, 0); volcar32(vaddr, VGA); fadeup(paleta, 0); // posa el marcador for (int j=0; j<=49; ++j) { const int i = j << 1; PutBloc(vaddr2, 248+((99-i)*320), vaddr, 72, i+1, 248, 0); PutBloc(vaddr2, 32248, vaddr, 72, i+1, 248, 199-i); PutBloc(vaddr2, 0, vaddr, 249, 200, 0, 0); espera_VGA(); volcar32(vaddr, VGA); } // posa el lletrero de fase X if (story_mode_mode) for (int i=-40; i<=80; ++i) { volcar32(vaddr2, vaddr); if (i<20) Put_Sprite_ICE_esquerra(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); else Put_Sprite_ICE_dreta(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); if (i==14) delay(2000); espera_VGA(); Volcar32(vaddr, VGA); } free(vaddrFase); } /*──────────────────────────────────────────────────────────────────────────*/ void level_complete() { if (midi) { StopMIDI(); unloadmidi(); midi = false; } if (!mode_nocturne) { load_mif(DONE01, vaddr); espera_vga(); volcar32(vaddr, VGA); ini_midi(musica_canvi_fase); if (midi) Playmidi(); const uint32_t t = SDL_GetTicks() + 4000; do {} while( SDL_GetTicks() < t ); borrat_de_pantalla(vaddr); } else { load_mif(DONE05, vaddr); espera_vga(); volcar32(vaddr, VGA); ini_midi(musica_canvi_fase_n); if (midi) Playmidi(); if (midi) do {} while(playing); else for (int i=0; i<=300; ++i) espera_VGA(); borrat_de_pantalla(vaddr); if (midi) { StopMIDI(); unloadmidi(); midi = false; } } } /*──────────────────────────────────────────────────────────────────────────*/ void volcat_de_pantalla() { volcar32(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 ((c % 48)/12) { 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 &&d !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 ((s%4)==0) pinta(rosita, 255, 16, 96, vaddr2); else if ((s%4)==1) pinta(rosita2, 255, 16, 96, vaddr2); else if ((s%4)==2) pinta(rosita, 255, 16, 96, vaddr2); else pinta(rosita3, 255, 16, 96, vaddr2); if ( ((s%10)==0) || ((s%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) put_map(pantalla, 255, 270, 1, 38, 29, 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 (c%99 < 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); } espera_vga(); volcar32(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][(y/6)-1] = 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][(y/6)-1] = 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][(y/6)-1] = 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][(y/6)-1] = 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][((y-max_m_y) / 6)-1]; 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<=1; ++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][(y/6)-1] = 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][((y-max_m_y)/6)-1]; break; case dreta: que_hi_ha = pantalla[(x+max_m_x)/6)][(y/6)-1]; break; case avall: que_hi_ha = pantalla[x/6][((y+max_m_y)/6)-1]; break; case esquerra: que_hi_ha = pantalla[(x-max_m_x) div 6][(y/6)-1]; 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][((y-max_m_y) / 6)-1] == 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][(y/6)-1] = es_pepe; } } break; case dreta: if (!en_casa && !(pantalla[(x+max_m_x)/6][(y/6)-1] == 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][(y/6)-1] = es_pepe; } } else if ( (x==232) && (y==96) ) omplir_pot(); break; case avall: if ( ((y+max_m_y) <= l2) && !en_casa && !(pantalla[x/6][((y+max_m_y)/6)-1] == 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][(y/6)-1] = es_pepe; } } break; case esquerra: if ( ((x-max_m_x) >= l3) && !(pantalla[(x-max_m_x)/6][(y/6)-1] == 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) then mort(); else { pinta_un_bloc(color_pintura, pintura); x = x - max_m_x; retard_pepe = velocitat_pepe; menejant = true; pantalla[x/6][(y/6)-1] = 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) //var a,b : byte; cont : word; { malo[numero].viu = true; 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 (teclapuls(SDL_SCANCODE_KP_PLUS)) then { munta_velocitat_joc(); do {} while (TeclaPuls(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 (teclapuls(SDL_SCANCODE_KP_MINUS)) then { baixa_velocitat_joc(); do {} while (TeclaPuls(SDL_SCANCODE_KP_MINUS)); } if (retard_pepe == 0) if (teclapuls(tecla_amunt)) moure(amunt) else if (teclapuls(tecla_avall)) moure(avall) else if (teclapuls(tecla_dreta)) moure(dreta) else if (teclapuls(tecla_esquerra)) moure(esquerra); if (TeclaPuls(SDL_SCANCODE_M)) { map = !map; do {} while (TeclaPuls(SDL_SCANCODE_M)); } /*---------*/ /* if TeclaPuls(KeyN) then begin final_fase:=true; num_fase:=9; end; if TeclaPuls(KeyB) then final_fase:=true;*/ /*---------*/ if (teclapuls(SDL_SCANCODE_1)) { amb_so = false; //!amb_so repeat until not(TeclaPuls(SDL_SCANCODE_1)); } if (teclapuls(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); espera_VGA(); volcar32(vaddr2, VGA); do {} while (TeclaPuls(SDL_SCANCODE_ESCAPE)); do {} while (!QteclaPuls()); if (TeclaPuls(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) { StopMIDI(); unloadmidi(); midi=false; } ini_midi(musica_campanes); if (midi) Playmidi(); } 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) { StopMIDI(); unloadmidi(); midi=false; } if (mode_nocturne) ini_midi(musica_fase_nit); else ini_midi(musica_fase); if (midi) Playmidi(); } } 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(); fadedown(0,0,0,2); if (midi) { StopMIDI(); unloadmidi(); 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(); fadedown(0,0,0,3); if (midi) { StopMIDI(); unloadmidi(); 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(); fadedown(0,0,0,3); if (midi) { StopMIDI(); unloadmidi(); 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) { StopMIDI(); unloadmidi(); midi=false; } missatge_game_over(); } if (eixir) { fadedown(0,0,0,0); if (midi) { StopMIDI(); unloadmidi(); midi=false; } } } /*──────────────────────────────────────────────────────────────────────────*/ void time_attack() { num_fase = 0; ini_vars(num_fase); ini_pantalla(); volcar32(vaddr2, vaddr); pinta_marcadors(); dificultat = normal; rosita_selected = false; amic_selected = false; color_pintura = 162; color_marcador_pintura = 162; espera_VGA(); volcar32(vaddr, VGA); pinta_marcadors(); volcat_de_pantalla(); bool eixir = false; if (midi) { StopMIDI(); unloadmidi(); midi=false; } ini_midi(musica_time_attack); if (midi) Playmidi(); contador = 0; do {} while (!TeclaPuls(tecla_esquerra)); pilla_temps(); //------------------------------------------------------------------------------------------ do { if (!playing && midi) PlayMIDI(); contador++; if (retard_pepe > 0) retard_pepe--; menejant = false; if ( retard_pepe == 0 ) { if ( teclapuls(tecla_amunt) ) moure(amunt); else if ( teclapuls(tecla_avall) ) moure(avall); else if ( teclapuls(tecla_dreta) ) moure(dreta); else if ( teclapuls(tecla_esquerra) ) moure(esquerra); } if ( teclapuls(SDL_SCANCODE_1) ) { amb_so = false; //not(amb_so); do {} while(TeclaPuls(SDL_SCANCODE_1)); } if ( teclapuls(SDL_SCANCODE_ESCAPE) ) { eixir = true; } /*if TeclaPuls(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) { StopMIDI(); unloadmidi(); 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) { StopMIDI(); unloadmidi(); midi=false; } resultat_time_attack(); } else if (eixir) { fadedown(0,0,0,0); if (midi) { StopMIDI(); unloadmidi(); midi=false; } } if (no_queden_vides) { missatge_game_over(); if (midi) { StopMIDI(); unloadmidi(); midi=false; } } } /*──────────────────────────────────────────────────────────────────────────*/ 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; */ void ini_estreles() { cls32(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(uint8_t *from, uint8_t *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); Putsprite(from, where, 26747, 9, 8, estreles[i].x, estreles[i].y); } } void actualitza_options(uint8_t *from, uint8_t *where) { cls32(0, vaddr2); for (int i=0; i<=3; ++i) for (int j=0; j<=5; ++j) Putsprite(vaddr, where, 48000, 50, 50, j*50, i*50); fondo_estreles(vaddr, vaddr2); Putsprite(from, where, 30400, 165, 28, 70, 5); Putsprite(from, where, 39733, 116, 18, 22, 43); if ( amb_so ) Putsprite(from, where, 40492, 25, 17, 149, 45) else Putsprite(from, where, 39557, 28, 20, 150, 42); Putsprite(from, where, 57332, 113, 19, 20, 81); if (GM) Putsprite(from, where, 51573, 107, 17, 141, 81) else Putsprite(from, where, 51684, 130, 20, 141, 81); Putsprite(from, where, 45172, 39, 20, 22, 61); switch (volumen) { case 0 : Putsprite(from, where, 45551, 32, 18, 70, 62); break; case 1 : Putsprite(from, where, 45580, 16, 18, 70, 62); break; case 2 : Putsprite(from, where, 45596, 16, 18, 70, 62); break; case 3 : Putsprite(from, where, 45611, 16, 18, 70, 62); break; case 4 : Putsprite(from, where, 45626, 16, 18, 70, 62); break; case 5 : Putsprite(from, where, 45642, 16, 18, 70, 62); break; case 6 : Putsprite(from, where, 45658, 16, 18, 70, 62); break; case 7 : Putsprite(from, where, 45673, 16, 18, 70, 62); break; case 8 : Putsprite(from, where, 45689, 16, 18, 70, 62); break; case 9 : Putsprite(from, where, 45705, 14, 18, 71, 62); break; case 10 : Putsprite(from, where, 45720, 40, 18, 70, 62); break; } Putsprite(from, where, 21673, 84, 73, 22, 117); Putsprite(vaddr, vaddr2, tecla_amunt_dib, 21, 21, 135, 110); Putsprite(vaddr, vaddr2, tecla_avall_dib, 21, 21, 135, 131); Putsprite(vaddr, vaddr2, tecla_esquerra_dib, 21, 21, 135, 152); Putsprite(vaddr, vaddr2, tecla_dreta_dib, 21, 21, 135, 173); // fletxes i ESC Putsprite(vaddr, vaddr2, 31527, 47, 24, 238, 172); // Complet + percentatge Putsprite(vaddr, vaddr2, 58405, 70, 17, 200, 120); Putsprite(vaddr, vaddr2, percentatge*29, 29, 14, 220, 142); Pinta_number(fletxa3, 255, 13, cord_y, vaddr2); } void pinta_marcs(uint16_t posicio) { volcar32(vaddr, vaddr2); for (int i=posicio; i<=posicio+75; ++i) { putpixel(i, 11, 15, vaddr2); putpixel(i, 12, 15, vaddr2); putpixel(i, 90, 15, vaddr2); putpixel(i, 91, 15, vaddr2); } for (int i=11; i<=91; ++i) { putpixel(posicio, i, 15, vaddr2); putpixel(posicio+1, i, 15, vaddr2); putpixel(posicio+74, i, 15, vaddr2); 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); espera_VGA(); volcar32(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; } } begin time_attack_mode:=false; story_mode_mode:=false; percentatge:=0; if mode_easy=pepe_facil then inc(percentatge); if mode_normal=pepe_normal then inc(percentatge); if mode_hard=pepe_dificil then inc(percentatge); if mode_easy_r=rosita_facil then inc(percentatge); if mode_normal_r=rosita_normal then inc(percentatge); if mode_hard_r=rosita_dificil then inc(percentatge); if mode_Dream_tour=Dream_tour then inc(percentatge); if mode_nocturne then load_mif(menu_nit,vaddr) else load_mif(menu,vaddr); load_mif(menu_s,vaddr2); espera_vga; volcar32(vaddr,VGA); if not(mode_nocturne) then begin if midi then begin StopMIDI; unloadmidi; midi:=false; end; ini_midi(musica_title); if midi then Playmidi; end else begin if midi then begin StopMIDI; unloadmidi; midi:=false; end; ini_midi(musica_nit); if midi then Playmidi; if not(midi) then ini_midi(musica_nit); if (not(Playing)) and (midi) then PlayMidi; end; i:=320; if not(mode_nocturne) then while (i>20) do begin espera_VGA; volcar32(vaddr,VGA); Put_Sprite_ICE_dreta(vaddr2,VGA,16983,142,26,i,53); dec(i,10); if i=20 then Put_Sprite_ICE_dreta(vaddr2,vaddr,16983,142,26,i,53); end; i:=320; while (i>20) do begin espera_VGA; volcar32(vaddr,VGA); if not(mode_nocturne) then Put_Sprite_ICE_dreta(vaddr2,VGA,28822,132,25,i,90) else Put_Sprite_ICE_dreta(vaddr2,VGA,28958,132,25,i,90); dec(i,10); if i=20 then if not(mode_nocturne) then Put_Sprite_ICE_dreta(vaddr2,vaddr,28822,132,25,i,90) else Put_Sprite_ICE_dreta(vaddr2,vaddr,28958,132,25,i,90); end; i:=320; while (i>20) do begin espera_VGA; volcar32(vaddr,VGA); Put_Sprite_ICE_dreta(vaddr2,VGA,40982,152,24,i,128); dec(i,10); if i=20 then Put_Sprite_ICE_dreta(vaddr2,vaddr,40982,152,24,i,128); end; i:=320; while (i>20) do begin espera_VGA; volcar32(vaddr,VGA); Put_Sprite_ICE_dreta(vaddr2,VGA,52182,103,30,i,163); dec(i,10); if i=20 then Put_Sprite_ICE_dreta(vaddr2,vaddr,52182,103,30,i,163); end; i_int:=-35; while (i_int<15) do begin espera_VGA; volcar32(vaddr,VGA); espera_VGA; Put_Sprite_ICE_dalt(vaddr2,VGA,5463,133,33,23,i_int); inc(i_int,10); if i_int=15 then Put_Sprite_ICE_dalt(vaddr2,vaddr,5463,133,33,23,i_int); end; espera_VGA; volcar32(vaddr, VGA); gettime(h,m,s,c); temps:=h*3600+m*60+s; eixir_del_joc:=false; pos_m:=2; pinta_number(fletxa2,255,13,100,VGA); cord_y:=100; repeat if (not(playing)) then if (mode_nocturne) then begin ini_midi(musica_nit); if midi then PlayMIDI; end else begin ini_midi(musica_title); if midi then PlayMIDI; end; gettime(h,m,s,c); temps2:=h*3600+m*60+s; if (TeclaPuls(KeyArrowDown)) and (pos_m<4) then begin inc(pos_m); case pos_m of 1:cord_y:=62; 2:cord_y:=100; 3:cord_y:=138; 4:cord_y:=174; end; volcar32(vaddr,vaddr2); pinta_number(fletxa2,255,13,cord_y,vaddr2); espera_VGA; volcar32(vaddr2,VGA); gettime(h,m,s,c); temps:=h*3600+m*60+s; temps2:=h*3600+m*60+s+1; Play_WAV (sample[so_fletxa]); repeat until not(TeclaPuls(KeyArrowDown)); end; if (TeclaPuls(KeyArrowUp)) and (pos_m>1) then begin dec(pos_m); if (mode_nocturne) and (pos_m=1) then pos_m:=2; case pos_m of 1:cord_y:=62; 2:cord_y:=100; 3:cord_y:=138; 4:cord_y:=174; end; volcar32(vaddr,vaddr2); pinta_number(fletxa2,255,13,cord_y,vaddr2); espera_VGA; volcar32(vaddr2,VGA); gettime(h,m,s,c); temps:=h*3600+m*60+s; temps2:=h*3600+m*60+s+1; Play_WAV (sample[so_fletxa]); repeat until not(TeclaPuls(KeyArrowUp)); end; volcar32(vaddr,vaddr2); if (temps2 mod 2)=0 then pinta_number(fletxa2,255,13,cord_y,vaddr2) else pinta_number(fletxa2,255,15,cord_y,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until (TeclaPuls(KeyENTER)) or (TeclaPuls(KeyESC)) or ((temps2-temps)>=10); if TeclaPuls(KeyENTER) then Play_WAV (sample[so_enter]); if teclapuls(keyESC) then begin pos_m:=5; StopMIDI; power_off(vaddr); eixir_del_joc:=true; end; if (Temps2-temps)>=10 then begin pos_m:=5; fadedown(0,0,0,0); escriu_records(10); titol_del_joc; end; // TIME ATTACK if (pos_m=1) and (not(mode_nocturne)) then begin time_attack_mode:=true; fadedown(0,0,0,1); if midi then begin StopMIDI; unloadmidi; midi:=false; end; time_attack; end; // PEPE VELL if (pos_m=3) then begin fadedown(0,0,0,1); if midi then begin StopMIDI; unloadmidi; midi:=false; end; pepe_text; end; // STORY MODE if (pos_m=2) then begin borrat_de_pantalla(vaddr); repeat until not(TeclaPuls(KeyENTER)); story_mode_mode:=true; rosita_selected:=false; amic_selected:=false; if (mode_nocturne) then load_mif(select_n,vaddr) else load_mif(select,vaddr); if not(mode_rosita=rosita_enabled) then begin for i:=137 to 212 do for j:=11 to 91 do putpixel(i,j,0,vaddr); putpixel(145,19,14,vaddr); putpixel(197,44,14,vaddr); putpixel(149,78,14,vaddr); putpixel(194,77,14,vaddr); putpixel(172,54,14,vaddr); putpixel(198,65,14,vaddr); putpixel(177,38,9,vaddr); putpixel(169,82,9,vaddr); putpixel(183,12,9,vaddr); putpixel(139,37,9,vaddr); putpixel(211,81,9,vaddr); end; if not(mode_amic=job_enabled) then begin for i:=219 to 294 do for j:=11 to 91 do putpixel(i,j,0,vaddr); putpixel(228,65,14,vaddr); putpixel(290,26,14,vaddr); putpixel(264,63,14,vaddr); putpixel(284,85,14,vaddr); putpixel(262,13,14,vaddr); putpixel(239,46,14,vaddr); putpixel(266,74,9,vaddr); putpixel(264,21,9,vaddr); putpixel(248,84,9,vaddr); putpixel(279,87,9,vaddr); putpixel(254,39,9,vaddr); end; espera_vga; volcar32(vaddr,vga); pinta_marcs(55); pos:=1; if mode_nocturne then pos_dif:=0 else pos_dif:=1; a_on_pinte_el_marc:=55; get_color(15,R,G,B); i:=0; G:=0; B:=0; repeat i:=(i+1) mod 127; i_int:=(63-i); B:=ABS(i_int); G:=B; set_color(15,R,G,B); if (not(playing)) and (midi) then PlayMIDI; if (TeclaPuls(KeyArrowLeft)) and (pos>1) then if not(mode_nocturne) then begin desp_marc(Left); dec(pos); end; if (TeclaPuls(KeyArrowRight)) and (pos<3) then if not(mode_nocturne) then begin if (pos=1) and (mode_rosita=99) then begin desp_marc(Right); inc(pos); end else if (pos=2) and (mode_amic=199) then begin desp_marc(Right); inc(pos); end; end; if (TeclaPuls(KeyArrowDown)) and (pos_dif<3) and not(mode_nocturne) then begin inc(pos_dif); pinta_marcs(a_on_pinte_el_marc); Play_WAV (sample[so_fletxa]); repeat until not(TeclaPuls(KeyArrowDown)); end; if (TeclaPuls(KeyArrowUp)) and (pos_dif>1) and not(mode_nocturne) then begin dec(pos_dif); pinta_marcs(a_on_pinte_el_marc); Play_WAV (sample[so_fletxa]); repeat until not(TeclaPuls(KeyArrowUp)); end; if pos=2 then if mode_rosita=99 then begin pinta_marcs(137); a_on_pinte_el_marc:=137; end; if pos=3 then if mode_amic=199 then begin pinta_marcs(219); a_on_pinte_el_marc:=219; end; if pos=1 then begin pinta_marcs(55); a_on_pinte_el_marc:=55; end; until (TeclaPuls(KeyENTER)) or (TeclaPuls(KeyESC)); if TeclaPuls(KeyENTER) then Play_WAV (sample[so_enter]); if TeclaPuls(KeyESC) then pos:=4; if pos_dif=1 then dificultat:=facil; if pos_dif=2 then dificultat:=normal; if pos_dif=3 then dificultat:=dificil; if mode_nocturne then dificultat:=normal; if pos=1 then begin amic_selected:=false; rosita_selected:=false; color_pintura:=162; color_marcador_pintura:=162; end; if pos=2 then begin amic_selected:=false; rosita_selected:=true; color_pintura:=199; color_marcador_pintura:=199; end; if pos=3 then begin amic_selected:=true; rosita_selected:=false; color_pintura:=48; color_marcador_pintura:=48; end; if pos=4 then borrat_de_pantalla(vaddr) else fadedown(0,0,0,0); if not(pos=4) then begin if (midi) and not(mode_nocturne) then begin StopMIDI; unloadmidi; midi:=false; end; Story_mode; end; end; // opcions if (pos_m=4) then begin ini_estreles; pos_m:=1; if midi then begin StopMIDI; unloadmidi; midi:=false; end; ini_midi(musica_options); if midi then Playmidi; cord_y := 47; load_mif(options,vaddr); actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); repeat if (not(playing)) and (midi) then PlayMIDI; if (TeclaPuls(KeyArrowDown)) and (pos_m<7) then begin inc(pos_m); case pos_m of 1:cord_y:=47; 2:cord_y:=65; 3:cord_y:=83; 4:cord_y:=122; 5:cord_y:=140; 6:cord_y:=158; 7:cord_y:=176; end; Play_WAV (sample[so_fletxa]); actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until not(TeclaPuls(KeyArrowDown)); end; if (TeclaPuls(KeyArrowUp)) and (pos_m>1) then begin dec(pos_m); case pos_m of 1:cord_y:=47; 2:cord_y:=65; 3:cord_y:=83; 4:cord_y:=122; 5:cord_y:=140; 6:cord_y:=158; 7:cord_y:=176; end; Play_WAV (sample[so_fletxa]); actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until not(TeclaPuls(KeyArrowUp)); end; if (TeclaPuls(KeyArrowRight)) then begin if (pos_m=1) then begin amb_so:=/*not(amb_so);*/false; if Puerto=255 then amb_so:=false; /*if amb_so then InitWAV(Puerto,DMA,IRQ) else EndWav; if amb_so then arxius_wav(amb_so);*/ end else if (pos_m=2) then begin if volumen<10 then inc(volumen) end else if (pos_m=3) then GM:=not(GM); actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until not(QTeclaPuls); end; if (TeclaPuls(KeyArrowLeft)) then begin if (pos_m=1) then begin amb_so:=/*not(amb_so);*/false; if Puerto=255 then amb_so:=false; /*if amb_so then InitWAV(Puerto,DMA,IRQ) else EndWav; if amb_so then arxius_wav(amb_so);*/ end else if (pos_m=2) then begin if volumen>0 then dec(volumen) end else if (pos_m=3) then GM:=not(GM); actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until not(QTeclaPuls); end; if ((TeclaPuls(KeyENTER))) and (pos_m>3) then begin repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); Play_WAV (sample[so_enter]); until not(TeclaPuls(KeyENTER)); aux := 0; dib_aux := 23781; actualitza_options(vaddr,vaddr2); case pos_m of 4 : begin tecla_amunt:=aux; tecla_amunt_dib := dib_aux; end; 5 : begin tecla_avall:=aux; tecla_avall_dib := dib_aux; end; 6 : begin tecla_esquerra:=aux; tecla_esquerra_dib := dib_aux; end; 7 : begin tecla_dreta:=aux; tecla_dreta_dib := dib_aux; end; end; espera_VGA; volcar32(vaddr2,VGA); repeat tecla_incorrecta:=true; repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until Qteclapuls; aux:=AgarrarTecla; repeat actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until not(QTeclaPuls); case aux of KeyA,KeyB,KeyC,KeyD,KeyE,KeyF,KeyG,KeyH,KeyI,KeyJ,KeyK,KeyL,KeyM,KeyN, KeyO,KeyP,KeyQ,KeyR,KeyS,KeyT,KeyU,KeyV,KeyW,KeyX,KeyY,KeyZ, KeyArrowUp,KeyArrowDown,KeyArrowLeft,KeyArrowRight : tecla_incorrecta:=false; else tecla_incorrecta:=true; end; until (not(tecla_incorrecta)); case aux of KeyA : dib_aux := 4485; KeyB : dib_aux := 4509; KeyC : dib_aux := 4533; KeyD : dib_aux := 4557; KeyE : dib_aux := 4581; KeyF : dib_aux := 4605; KeyG : dib_aux := 4629; KeyH : dib_aux := 4653; KeyI : dib_aux := 4677; KeyJ : dib_aux := 4702; KeyK : dib_aux := 4726; KeyL : dib_aux := 4750; KeyM : dib_aux := 4774; KeyN : dib_aux := 14085; KeyO : dib_aux := 14109; KeyP : dib_aux := 14133; KeyQ : dib_aux := 14157; KeyR : dib_aux := 14181; KeyS : dib_aux := 14205; KeyT : dib_aux := 14229; KeyU : dib_aux := 14253; KeyV : dib_aux := 14277; KeyW : dib_aux := 14302; KeyX : dib_aux := 14326; KeyY : dib_aux := 14350; KeyZ : dib_aux := 14374; KeyArrowUp : dib_aux := 23709; KeyArrowDown : dib_aux := 23685; KeyArrowLeft : dib_aux := 23757; KeyArrowRight : dib_aux := 23733; end; case pos_m of 4 : begin tecla_amunt:=aux; tecla_amunt_dib := dib_aux; end; 5 : begin tecla_avall:=aux; tecla_avall_dib := dib_aux; end; 6 : begin tecla_esquerra:=aux; tecla_esquerra_dib := dib_aux; end; 7 : begin tecla_dreta:=aux; tecla_dreta_dib := dib_aux; end; end; actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); end; actualitza_options(vaddr,vaddr2); espera_VGA; volcar32(vaddr2,VGA); until TeclaPuls(KeyESC); borrat_de_pantalla(vaddr2); if midi then begin StopMIDI; unloadmidi; midi:=false; end; save_cfg; end; end; /*──────────────────────────────────────────────────────────────────────────*/ /*──────────────────────────────────────────────────────────────────────────*/ int main(int argc, char *argv[]) { comprobar_comp_i_sprites(); randomize(); instalarkb(); setmode(0x13); setupvirtual(virscr, vaddr); setupvirtual(virscr2, vaddr2); getmem(virscrSP, 7680); vaddrSP = seg(virscrSP ^); loadPCX('datos/sprites.dat', vaddrSP); 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); Tancarvirtual(virscr); Tancarvirtual(virscr2); Freemem(virscrSP, 7680); /* if amb_so then arxius_wav(FALSE); if amb_so then EndWAV;*/ DesinstalarKB(); setmode(0x3); } /* ini_midi('.\music\logo.mid'); if midi then Playmidi; if (not(playing)) and (midi) then PlayMIDI; if midi then begin StopMIDI; unloadmidi; midi:=false; end; */