Files
pepe_port/pepe2000_utf8.cpp

3929 lines
134 KiB
C++

/*──────────────────────────────────────────────────────────────────────────
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;
uint8_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 = 16;
tecla_amunt_dib = 14157;
tecla_avall = 30;
tecla_avall_dib = 4485;
tecla_dreta = 25;
tecla_dreta_dib = 14133;
tecla_esquerra = 24;
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<strlen(nom); ++i)
{
if ((mode2 == 0) & (TeclaPuls(SDL_SCANCODE_SPACE))) break;
if (mode == 0) volcar32(VGA, where);
uint16_t quina_lletra;
switch (nom[i]) {
case 'A' : quina_lletra = lletra_a; break;
case 'B' : quina_lletra = lletra_b; break;
case 'C' : quina_lletra = lletra_c; break;
case 'D' : quina_lletra = lletra_d; break;
case 'E' : quina_lletra = lletra_e; break;
case 'F' : quina_lletra = lletra_f; break;
case 'G' : quina_lletra = lletra_g; break;
case 'H' : quina_lletra = lletra_h; break;
case 'I' : quina_lletra = lletra_i; break;
case 'J' : quina_lletra = lletra_j; break;
case 'K' : quina_lletra = lletra_k; break;
case 'L' : quina_lletra = lletra_l; break;
case 'M' : quina_lletra = lletra_m; break;
case 'N' : quina_lletra = lletra_n; break;
case 'O' : quina_lletra = lletra_o; break;
case 'P' : quina_lletra = lletra_p; break;
case 'Q' : quina_lletra = lletra_q; break;
case 'R' : quina_lletra = lletra_r; break;
case 'S' : quina_lletra = lletra_s; break;
case 'T' : quina_lletra = lletra_t; break;
case 'U' : quina_lletra = lletra_u; break;
case 'V' : quina_lletra = lletra_v; break;
case 'W' : quina_lletra = lletra_w; break;
case 'X' : quina_lletra = lletra_x; break;
case 'Y' : quina_lletra = lletra_y; break;
case 'Z' : quina_lletra = lletra_z; break;
case '0' : quina_lletra = num_0; break;
case '1' : quina_lletra = num_1; break;
case '2' : quina_lletra = num_2; break;
case '3' : quina_lletra = num_3; break;
case '4' : quina_lletra = num_4; break;
case '5' : quina_lletra = num_5; break;
case '6' : quina_lletra = num_6; break;
case '7' : quina_lletra = num_7; break;
case '8' : quina_lletra = num_8; break;
case '9' : quina_lletra = num_9; break;
case ' ' : quina_lletra = lletra_espai; break;
case ':' : quina_lletra = lletra_dos_punts; break;
case '(' : quina_lletra = lletra_parentesis_o; break;
case ')' : quina_lletra = lletra_parentesis_t; break;
case '¡' : quina_lletra = lletra_exclamacio_o; break;
case '!' : quina_lletra = lletra_exclamacio_t; break;
case '*' : quina_lletra = lletra_apostrof; break;
case '.' : quina_lletra = lletra_punt; break;
case '-' : quina_lletra = lletra_guio; break;
}
pinta_number2(quina_lletra, 255, color_determinat,x+(i*8),y,where);
retard(velocitat);
if (mode==0)
{
espera_VGA();
volcar32(where,VGA);
}
}
}
/*──────────────────────────────────────────────────────────────────────────*/
void borrar_frase(int temps, uint8_t *zona_mem1, uint8_t *zona_mem2)
{
retard(temps);
volcar32(zona_mem1, zona_mem2);
espera_VGA();
volcar32(zona_mem2, VGA);
}
/*──────────────────────────────────────────────────────────────────────────*/
void borrat_de_pantalla(uint8_t *where)
{
for (int i = 0; i < 32; ++i)
{
for (int j = 0; j < 200; ++j)
{
putpixel(i, j, 0, where);
putpixel(i + 32, j, 0, where);
putpixel(i + 288, j, 0, where);
putpixel(i + 64, j, 0, where);
putpixel(i + 96, j, 0, where);
putpixel(i + 128, j, 0, where);
putpixel(i + 160, j, 0, where);
putpixel(i + 192, j, 0, where);
putpixel(i + 224, j, 0, where);
putpixel(i + 256, j, 0, where);
}
espera_vga();
volcar32(where, VGA);
}
}
/*──────────────────────────────────────────────────────────────────────────*/
void intro_nom(char **nom, uint8_t color)
{
volcar32(VGA, vaddr);
(*nom)[0] = 0;
uint8_t lletra = 0;
uint16_t x = 210;
uint16_t y = 45;
escriu_frase("ENHORABONA", color, 110, 10, vaddr, 0, 0, 1);
escriu_frase("HAS ACONSEGUIT", color, 92, 20, vaddr, 0, 0, 1);
escriu_frase("UN NOU RECORD", color, 97, 30, vaddr, 0, 0, 1);
escriu_frase("INTRODUEIX EL TEU NOM:", color, 35, 45, vaddr, 0, 0, 1);
char quina_lletra[2]; quina_lletra[1] = 0;
do
{
if (QteclaPuls())
{
uint8_t aux = agarrartecla();
while (QteclaPuls()) {};
lletra++;
switch (aux)
{
case SDL_SCANCODE_A : quina_lletra[0] = 'A'; break;
case SDL_SCANCODE_B : quina_lletra[0] = 'B'; break;
case SDL_SCANCODE_C : quina_lletra[0] = 'C'; break;
case SDL_SCANCODE_D : quina_lletra[0] = 'D'; break;
case SDL_SCANCODE_E : quina_lletra[0] = 'E'; break;
case SDL_SCANCODE_F : quina_lletra[0] = 'F'; break;
case SDL_SCANCODE_G : quina_lletra[0] = 'G'; break;
case SDL_SCANCODE_H : quina_lletra[0] = 'H'; break;
case SDL_SCANCODE_I : quina_lletra[0] = 'I'; break;
case SDL_SCANCODE_J : quina_lletra[0] = 'J'; break;
case SDL_SCANCODE_K : quina_lletra[0] = 'K'; break;
case SDL_SCANCODE_L : quina_lletra[0] = 'L'; break;
case SDL_SCANCODE_M : quina_lletra[0] = 'M'; break;
case SDL_SCANCODE_N : quina_lletra[0] = 'N'; break;
case SDL_SCANCODE_O : quina_lletra[0] = 'O'; break;
case SDL_SCANCODE_P : quina_lletra[0] = 'P'; break;
case SDL_SCANCODE_Q : quina_lletra[0] = 'Q'; break;
case SDL_SCANCODE_R : quina_lletra[0] = 'R'; break;
case SDL_SCANCODE_S : quina_lletra[0] = 'S'; break;
case SDL_SCANCODE_T : quina_lletra[0] = 'T'; break;
case SDL_SCANCODE_U : quina_lletra[0] = 'U'; break;
case SDL_SCANCODE_V : quina_lletra[0] = 'V'; break;
case SDL_SCANCODE_W : quina_lletra[0] = 'W'; break;
case SDL_SCANCODE_X : quina_lletra[0] = 'X'; break;
case SDL_SCANCODE_Y : quina_lletra[0] = 'Y'; break;
case SDL_SCANCODE_Z : quina_lletra[0] = 'Z'; break;
case SDL_SCANCODE_SPACE : quina_lletra[0] = ' '; break;
case SDL_SCANCODE_RETURN : quina_lletra[0] = 0; break;
}
escriu_frase(quina_lletra, color, x, y, vaddr, 0, 0, 0);
x += 8;
(*nom)[lletra] = quina_lletra[0];
}
} while ( (lletra < 8) && (quina_lletra[0]!=0) );
cls32(color, vaddr2);
espera_VGA();
volcar32(vaddr2, VGA);
espera_VGA();
volcar32(vaddr, VGA);
retard(50);
}
/*──────────────────────────────────────────────────────────────────────────*/
void escriu_records(uint8_t segons)
{
load_mif(RECORDS, vaddr2);
volcar32(vaddr2, vaddr);
espera_VGA();
volcar32(vaddr2, VGA);
// story mode
if ( story_mode_mode || (!story_mode_mode && !time_attack_mode) )
{
escriu_frase("- WORLD TOUR SCORE -", 1, 42, 30, vaddr, 0, 0, 1);
int i = 150;
for (int x=1; x<6; ++x)
{
int j = x*20+50;
escriu_frase(nom[x], 2, 60, x*20+50, vaddr, 0, 0, 1);
uint8_t num = (((((puntuacio[x] % 1000000) % 100000) % 10000) % 100) % 10);
if (num != 0)
{
pinta_number(numero_G[num], 255, i+36, j, vaddr);
num = (((((puntuacio[x] % 1000000) % 100000) % 10000) % 1000) % 100) / 10;
if (num != 0)
{
pinta_number(numero_G[num], 255, i+30, j, vaddr);
num = ((((puntuacio[x] % 1000000) % 100000) % 10000) % 1000) / 100;
if (num != 0)
{
pinta_number(numero_G[num], 255, i+24, j, vaddr);
num = (((puntuacio[x] % 1000000) % 100000) % 10000) / 1000;
if (num != 0)
{
pinta_number(numero_G[num], 255, i+18, j, vaddr);
num = ((puntuacio[x] % 1000000) % 100000) / 10000;
if (num != 0)
{
pinta_number(numero_G[num], 255, i+12, j, vaddr);
num = (puntuacio[x] % 1000000) / 100000;
if (num != 0)
{
pinta_number(numero_G[num], 255, i+6, j, vaddr);
num = puntuacio[x] / 1000000;
if (num != 0) pinta_number(numero_G[num], 255, i, j, vaddr);
}
}
}
}
}
}
espera_VGA();
volcar32(vaddr, VGA);
}
espera_VGA();
volcar32(vaddr, VGA);
uint32_t t = SDL_GetTicks()+(segons*1000);
while (!QteclaPuls() && SDL_GetTicks()<t) {}
}
// time attack
if (time_attack_mode || (!story_mode_mode && !time_attack_mode) )
{
volcar32(vaddr2, vaddr);
espera_VGA();
volcar32(vaddr2, VGA);
escriu_frase("- TIME ATTACK BEST TIMES -", 1, 20, 30, vaddr, 0, 0, 1);
int i = 150;
for (int x=1; i<6; ++i)
{
int j = x*20+50;
escriu_frase(nom2[x], 2, 60, x*20+50, vaddr, 0, 0, 1);
pinta_number(numero_G[minuts[x]], 255, i, j, vaddr);
pinta_number(num_11, 255, i+6, j, vaddr);
pinta_number(numero_G[segons_tabla[x] / 10], 255, i+12, j, vaddr);
pinta_number(numero_G[segons_tabla[x] % 10], 255, i+18, j, vaddr);
espera_VGA();
volcar32(vaddr, VGA);
}
espera_VGA();
volcar32(vaddr, VGA);
uint32_t t = SDL_GetTicks()+(segons*1000);
while (!QteclaPuls() && SDL_GetTicks()<t) {}
}
borrat_de_pantalla(vaddr);
}
/*──────────────────────────────────────────────────────────────────────────*/
void gestio_records(uint8_t color)
{
// world tour
if (story_mode_mode)
{
bool trobat = false;
int cont = 1;
while ( !trobat && cont<6 )
{
if ( puntuacio[cont] < punts && !trobat) trobat = true;
if (trobat)
{
for (int i=5; 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()<t );
espera_VGA();
volcar32(vaddr3, VGA);
setpaleta(paleta);
//Play_WAV(sample[so_bomba]);
if (i<3) fadedown(0,0,0,0);
}
PutSprite(vaddr2, vaddr, 8683, 234, 151, 43, 27);
espera_VGA();
volcar32(vaddr, VGA);
setpaleta(paleta);
for (int i=1; i<= 2; ++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()<t);
espera_VGA();
volcar32(vaddr3, VGA);
//Play_WAV(sample[so_bomba]);
t = SDL_GetTicks() + 1000;
do
{
if (!playing)
{
ini_midi(musica_final_fals);
if (midi) Playmidi();
}
} while (!QteclaPuls() && SDL_GetTicks()<t);
}
PutSprite(vaddr2, vaddr, 400, 138, 26, 170, 148);
PutSprite(vaddr2, vaddr3, 400, 138, 26, 170, 148);
int i=0;
do
{
i++;
espera_VGA();
volcar32(vaddr, VGA);
uint32_t t = SDL_GetTicks() + 5000;
do
{
if (!playing)
{
ini_midi(musica_final_fals);
if midi then Playmidi;
}
} while (!QteclaPuls() && SDL_GetTicks()<t);
espera_VGA();
volcar32(vaddr3,VGA);
//Play_WAV (sample[so_bomba]);
t = SDL_GetTicks() + 2000;
do
{
if (!playing)
{
ini_midi(musica_final_fals);
if (midi) Playmidi();
}
} while (!QteclaPuls() && SDL_GetTicks()<t);
} while (!Qteclapuls() && i<3);
fadedown(0,0,0,0);
if (midi)
{
StopMIDI;
unloadmidi;
midi = false;
}
Tancarvirtual(virscr3);
}
/*──────────────────────────────────────────────────────────────────────────*/
void intro_logo()
{
//[RZC 24/01/2024] [TODO] Arreglar el tema de les paletes. Ací i en tots els llocs: Quines fan falta, inicialització (i finalització),
// els colors ja no van de 0 a 63, sino de 0 a 255...
load_mif(LOGO, vaddr);
getpaleta(paleta);
for (int i=1; i<256; ++i) set_color(i,63,63,63);
uint8_t paleta_blanca[256][3];
getpaleta(paleta_blanca);
setpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
ini_midi(musica_logo);
if (midi) Playmidi();
fadeup(paleta, 1);
//[RZC 24/01/2024] [TODO] Arreglar TOTS els do whiles amb getticks que hi han. Al final son Waits de temps i tecla pulsada.
uint32_t t = SDL_GetTicks()+6000;
do {} while (!QteclaPuls() && SDL_GetTicks()<t);
fadeup(paleta_blanca, 1);
fadedown(0,0,0,0);
if (midi)
{
StopMIDI();
unloadmidi();
midi = false;
}
}
/*──────────────────────────────────────────────────────────────────────────*/
void titol_del_joc()
/*var
salta_intro : boolean;
i : word; j : byte;
R,G,B : byte;
temps, temps2 : word;
*/
{
bool salta_intro = false; // [RZC 24/01/2024] [NOTA] Mirant el codi no pareix que 'salta_intro' faça res...
uint8_t h = get_hours();
if ( h >= 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()<t);
}
if (mode_nocturne)
{
if (!midi) ini_midi(musica_nit);
if (!playing && midi) Playmidi();
int i = 0;
do
{
if ( !playing && midi ) PlayMIDI();
int j = 0;
while ( j<100 )
{
espera_VGA();
j++;
}
espera_VGA();
volcar32(vaddr2, VGA);
j = 0;
while ( j<100 )
{
espera_VGA();
j++;
}
espera_VGA();
volcar32(vaddr, VGA);
i++;
} while ( i<=10 && !QteclaPuls() );
if (QteclaPuls()) salta_intro = true;
}
if (TeclaPuls(SDL_SCANCODE_SPACE)) salta_intro = true;
fadedown(0,0,0,0);
}
/*──────────────────────────────────────────────────────────────────────────*/
void historia()
{
if (mode_nocturne)
{
cls32(0, VGA);
load_mif(IN_NIT, vaddr);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
if ( !playing && midi ) Playmidi();
fadeup(paleta, 0);
retard(300);
fadedown(0,0,0,0);
}
else
{
fin_historia = false;
cls32(0, VGA);
load_mif(HIST01, vaddr);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
ini_midi(musica_historia);
if (midi) Playmidi();
fadeup(paleta, 0);
escriu_frase("QUE BON DIA FA NO CREUS PEPE", 2, 40, 90, vaddr2, 10, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("EEEE..SS..SSIII.SI", 10, 50, 80, vaddr2, 10, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("(SEMPRE QUE M*ACOSTE", 2, 140, 140, vaddr2, 10, 0, 0);
escriu_frase("A PEPE ES POSA RARO)", 2, 140, 150, vaddr2, 10, 0, 0);
borrar_frase(150, vaddr, vaddr2);
retard(200);
if (QTeclaPuls()) fin_historia = true;
fadedown(0,0,0,0);
if (!fin_historia)
{
load_mif(HIST02, vaddr);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
fadeup(paleta, 0);
escriu_frase("AAAAY !", 10, 100, 140, vaddr2, 0, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("JA T*HE PILLAT PEPE", 3, 100, 55, vaddr2, 10, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("AUXILI!", 2, 145, 125, vaddr2, 0, 0, 0);
borrar_frase(150, vaddr, vaddr2);
retard(200);
}
if (QTeclaPuls()) fin_historia = true;
fadedown(0,0,0,0);
if (!fin_historia)
{
load_mif(HIST03, vaddr);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
fadeup(paleta, 0);
escriu_frase("ARA ROSITA ES MEUA", 5, 50, 80, vaddr2, 10, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("SI VOLS ACONSEGUIR-LA", 5, 50, 80, vaddr2, 10, 0, 0);
escriu_frase("HAURAS DE SEGUIR-ME", 5, 50, 90, vaddr2, 10, 0, 0);
escriu_frase("PER TOT EL MON.", 5, 50, 100, vaddr2, 10, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("JA JA JA JA JA !!", 5, 60, 80, vaddr2, 0, 0, 0);
borrar_frase(150, vaddr, vaddr2);
retard(200);
}
if (QTeclaPuls()) fin_historia = true;
fadedown(0,0,0,0);
if (!fin_historia)
{
load_mif(HIST04, vaddr);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
fadeup(paleta, 0);
escriu_frase("AJUDA*M PEPE!", 2, 120, 60, vaddr2, 5, 0, 0);
borrar_frase(150, vaddr, vaddr2);
escriu_frase("MALEIT SIGUES", 7, 50, 50, vaddr2, 60, 0, 0);
escriu_frase("ET TROBARE...", 7, 50, 60, vaddr2, 40, 0, 0);
retard(200);
}
fadedown(0,0,0,0);
}
}
/*──────────────────────────────────────────────────────────────────────────*/
void credits()
{
load_mif(CREDITSF, vaddr2);
cls32(0, vaddr);
uint32_t t = SDL_GetTicks()+3000;
do {} while (!QteclaPuls() && SDL_GetTicks()<t);
for (int num=1; num<=5; ++num)
{
int x, y, w, h;
switch (num)
{
case 1: x = 95; y = 18; w = 124; h = 31; break;
case 2: x = 92; y = 48; w = 134; h = 67; break;
case 3: x = 107; y = 115; w = 98; h = 24; break;
case 4: x = 113; y = 138; w = 86; h = 13; break;
case 5: x = 51; y = 151; w = 213; h = 30; break;
}
int i_int = 200;
uint32_t velocitat = 0;
uint16_t offset = x+(y*320);
while ( i_int > 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()<t);
fadedown(0,0,0,3);
if (midi)
{
StopMIDI();
unloadmidi();
midi = false;
}
}
/*──────────────────────────────────────────────────────────────────────────*/
void reixa(uint16_t posx, uint8_t longitud, uint8_t *where)
{
line(posx, 30, posx, 197-longitud, 0, where);
line(posx+1, 30, posx+1, 197-longitud, 0, where);
line(posx+2, 30, posx+2, 198-longitud, 0, where);
line(posx+3, 30, posx+3, 198-longitud, 0, where);
line(posx+4, 30, posx+4, 199-longitud, 0, where);
line(posx+5, 30, posx+5, 199-longitud, 0, where);
line(posx+6, 30, posx+6, 198-longitud, 0, where);
line(posx+7, 30, posx+7, 198-longitud, 0, where);
line(posx+8, 30, posx+8, 197-longitud, 0, where);
line(posx+9, 30, posx+9, 197-longitud, 0, where);
}
/*──────────────────────────────────────────────────────────────────────────*/
void historia_final();
{
cls32(0, VGA);
ini_midi(musica_final_joc);
if (midi) Playmidi();
// dibuix 1
if (mode_nocturne) load_mif(FINALN01, vaddr) else load_mif(FINAL01, vaddr);
getpaleta(paleta);
blackout();
volcar32(vaddr, vaddr2);
if (mode_nocturne) for (int i=0; i<=3; ++i) reixa(100+(i*40), 0, vaddr2);
espera_VGA();
volcar32(vaddr2, VGA);
fadeup(paleta, 0);
if (mode_nocturne)
for (int j=0; j<=166; ++j)
{
volcar32(vaddr, vaddr2);
for (int i=0; i<=3; ++i) reixa(100+(i*40)+(j % 2), j, vaddr2);
espera_VGA(); espera_VGA();
volcar32(vaddr2, VGA);
}
if (mode_nocturne) retard(200) else retard(600);
fadedown(0,0,0,0);
// dibuix 2
if (mode_nocturne) load_mif(FINALN02, vaddr) else load_mif(FINAL02, vaddr);
set_color(1,32,0,0);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
fadeup(paleta, 0);
if (mode_nocturne)
for (int i=0; i<=200; ++i)
{
j = 63 - SDL_abs(32 - (i%64));
set_color(1, j, 0, 0);
espera_VGA(); espera_VGA(); espera_VGA(); espera_VGA();
}
if (!mode_nocturne) retard(600);
fadedown(0,0,0,0);
// dibuix 3
if (mode_nocturne) load_mif(FINALN03, vaddr) else load_mif(FINAL03, vaddr);
set_color(253,39, 0,48);
set_color(254, 0,63, 6);
set_color(255, 0, 3,63);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
fadeup(paleta, 0);
uint32_t t = SDL_GetTicks()+10000;
do
{
retard(10);
espera_VGA();
set_color(253,39, 0,48);
set_color(254, 0,63, 6);
set_color(255, 0, 3,63);
retard(10);
espera_VGA();
set_color(253, 0, 3,63);
set_color(254,39, 0,48);
set_color(255, 0,63, 6);
retard(10);
espera_VGA();
set_color(253, 0,63, 6);
set_color(254, 0, 3,63);
set_color(255,39, 0,48);
} while (!QteclaPuls() && SDL_GetTicks()<t);
fadedown(0,0,0,0);
// dibuix 4
if (mode_nocturne)
{
load_mif(FINALN04, vaddr);
getpaleta(paleta);
blackout();
espera_VGA();
volcar32(vaddr, VGA);
fadeup(paleta, 0);
retard(600);
fadedown(0,0,0,0);
}
credits();
}
/*──────────────────────────────────────────────────────────────────────────*/
procedure put_map(uint8_t *nom;color:byte; x,y: word;i,j: byte; desti:word);
/* nom : nom de la matriu; color: 255 = original o color;
x,y = posició pantalla; i,j = tamany matriu; desti = VGA o vaddr)*/
var a,b:word;
begin
for a:=x+1 to x+i do
for b:=y+1 to y+j do
begin
if color<>255 then putpixel(a,b,color,desti)
else putpixel(a,b,nom[a-x,b-y],desti);
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure pilla_temps;
begin
gettime(h,m,s,c);
hora := (s)+(m*60)+(h*3600);
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure posa_el_temps(where:word);
var
h1,m1,s1,c1,minuts,segons,i : word;
begin
gettime(h1,m1,s1,c1);
/*temps:=temps+(((h1-h)*24)+((m1-m)*60)+(s1-s));*/
/*if (s1-s)>0 then temps:=temps+(100-c+c1) else temps:=temps+(c1-c);*/
temps := (s1)+(m1*60)+(h1*3600) - hora;
minuts :=(temps) div 60;
segons :=(temps) mod 60;
i:= 255;
pinta_number(num_0,180,i,82,where);
pinta_number(num_0,180,i+12,82,where);
pinta_number(num_0,180,i+18,82,where);
pinta_number(num_11,255,i+6,82,where);
pinta_number(numero_G[minuts],255,i,82,where);
pinta_number(numero_G[segons div 10],255,i+12,82,where);
pinta_number(numero_G[segons mod 10],255,i+18,82,where);
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure resultat_time_attack;
var i,minuts,segons : word;
begin
fadedown(0,0,0,1);
load_mif(time_fin,vaddr2);
volcar32(vaddr2,vaddr);
ini_midi(musica_game_over);
if midi then Playmidi;
minuts:=(temps_final mod 3600) div 60;
segons:=(temps_final mod 3600) mod 60;
i:=180;
pinta_number_zoom(4,numero_G[minuts],255,i,126,vaddr);
pinta_number_zoom(4,num_11,255,i+6*4,126,vaddr);
pinta_number_zoom(4,numero_G[segons div 10],255,i+12*4,126,vaddr);
pinta_number_zoom(4,numero_G[segons mod 10],255,i+18*4,126,vaddr);
espera_vga;
volcar32(vaddr,VGA);
retard(300);
gestio_records(43);
retard(100);
escriu_records(10);
borrat_de_pantalla(vaddr);
save_records;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure missatge_game_over;
var
i,j : word;
k : byte;
num1,num2,num3,num4,num5,num6,num7 : byte;
begin
fadedown(0,0,0,2);
load_mif(pepefins,vaddr);
ini_midi(musica_game_over);
if midi then Playmidi;
if time_attack_mode then for i:=50 to 280 do
for j:=130 to 190 do putpixel(i,j,239,vaddr);
if story_mode_mode then
begin
volcar32(vaddr,vaddr2);
for i:=50 to 280 do
for j:=130 to 190 do putpixel(i,j,239,vaddr2);
espera_VGA;
volcar32(vaddr2,VGA);
retard(200);
end;
if story_mode_mode then
begin
i:=125/*135*/;
j:=170;
num1:=punts div 1000000;
num2:=(punts mod 1000000) div 100000;
num3:=((punts mod 1000000) mod 100000) div 10000;
num4:=(((punts mod 1000000) mod 100000) mod 10000) div 1000;
num5:=((((punts mod 1000000) mod 100000) mod 10000) mod 1000) div 100;
num6:=(((((punts mod 1000000) mod 100000) mod 10000) mod 1000) mod 100) div 10;
num7:=(((((punts mod 1000000) mod 100000) mod 10000) mod 100) mod 10);
if num1<>0 then pinta_number(numero_G[num1],255,i,j,vaddr);
if (num2<>0) or (num1<>0) then pinta_number(numero_G[num2],255,i+6,j,vaddr);
if (num3<>0) or (num2<>0) or (num1<>0) then pinta_number(numero_G[num3],255,i+12,j,vaddr);
if (num4<>0) or (num3<>0) or (num2<>0) or (num1<>0) then pinta_number(numero_G[num4],255,i+18,j,vaddr);
if (num5<>0) or (num4<>0) or (num3<>0) or (num2<>0) or (num1<>0) then pinta_number(numero_G[num5],255,i+24,j,vaddr);
if (num6<>0) or (num5<>0) or (num4<>0) or (num3<>0) or (num2<>0) or (num1<>0)
then pinta_number(numero_G[num6],255,i+30,j,vaddr);
if (num7<>0) or (num6<>0) or (num5<>0) or (num4<>0) or (num3<>0) or (num2<>0) or (num1<>0)
then pinta_number(numero_G[num7],255,i+36,j,vaddr);
/*pinta_number(numero_G[num1],255,i,j,vaddr);
pinta_number(numero_G[num2],255,i+6,j,vaddr);
pinta_number(numero_G[num3],255,i+12,j,vaddr);
pinta_number(numero_G[num4],255,i+18,j,vaddr);
pinta_number(numero_G[num5],255,i+24,j,vaddr);
pinta_number(numero_G[num6],255,i+30,j,vaddr);
pinta_number(numero_G[num7],255,i+36,j,vaddr);*/
end;
espera_vga;
volcar32(vaddr,VGA);
retard(300);
if story_mode_mode then gestio_records(144);
fadedown(0,0,0,0);
escriu_records(10);
borrat_de_pantalla(vaddr);
vides:=0;
no_queden_vides:=true;
save_records;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure comprobar_comp_i_sprites;
const
tamany_comp = 2415;
tamany_sprites = 968792;
var
fich : file of byte;
i : word;
temp : longint;
aux : byte;
error : boolean;
begin
temp:=0;
error:=false;
assign(fich,'datos\comp.dat');
reset(fich);
for i:=1 to filesize(fich)-9 do
begin
read(fich,aux);
inc(temp,aux);
end;
if temp<>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;
/*──────────────────────────────────────────────────────────────────────────*/
procedure ini_vars(num_fase:byte);
/*----------------------------------------------------*/
procedure carrega_pantalla(num:byte);
var
fich : file of byte;
i,j,k : byte;
temp : byte;
begin
if num = 0 then for i:=1 to 38 do for j:=1 to 29 do pantalla[i,j]:=0
else begin
Assign(fich,'datos/comp.dat');
Reset(fich);
for k:=1 to num do
begin
for i:=1 to 38 do
begin
for j:=1 to 29 do
begin
read(fich,temp);
pantalla[i,j] := temp;
end;
end;
end;
Close(fich);
end;
end;
/*----------------------------------------------------*/
begin
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 then vides:=0
else if num_fase=1 then vides:=vides_de_pepe
else vides:=vides;
pintura:=max_pintura;
en_casa:=true;
final_fase:=false;
rellontge.viu := false;
rellontge.temps := 0;
temps := 0;
carrega_pantalla(num_fase);
case num_fase of
0 : total_blocs_per_pintar:=blocs_fase_0;
1 : total_blocs_per_pintar:=blocs_fase_1;
2 : total_blocs_per_pintar:=blocs_fase_2;
3 : total_blocs_per_pintar:=blocs_fase_3;
4 : total_blocs_per_pintar:=blocs_fase_4;
5 : total_blocs_per_pintar:=blocs_fase_5;
6 : total_blocs_per_pintar:=blocs_fase_6;
7 : total_blocs_per_pintar:=blocs_fase_7;
8 : total_blocs_per_pintar:=blocs_fase_8;
9 : total_blocs_per_pintar:=blocs_fase_9;
10 : total_blocs_per_pintar:=blocs_fase_10;
end;
blocs_per_pintar:=total_blocs_per_pintar;
temps:=0;
velocitat_joc:=1;
no_queden_vides:=false;
naiximent:=false;
map:=false;
/* ini malos */
if num_fase=ultima_fase then
begin
for i:=1 to max_malos do
begin
malo[i].viu:=false;
end;
malo[1].dibuix:=d_malo1;
malo[2].dibuix:=d_malo2;
malo[3].dibuix:=pepe_malo;
end
else begin
for i:=1 to max_malos do
begin
malo[i].viu:=false;
end;
malo[1].dibuix:=d_malo1;
malo[2].dibuix:=d_malo2;
malo[3].dibuix:=d_malo3;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure ini_matrius;
begin
/* fondos */
path[1]:=pepe01;
path[2]:=pepe02;
path[3]:=pepe03;
path[4]:=pepe04;
path[5]:=pepe05;
path[6]:=pepe06;
path[7]:=pepe07;
path[8]:=pepe08;
path[9]:=pepe09;
path[10]:=pepe10;
path[11]:=pepe11;
path[12]:=ult_fase;
path[13]:=time;
path[14]:=fons_nit;
/* matriu de numeros */
numero[0]:=num0;
numero[1]:=num1;
numero[2]:=num2;
numero[3]:=num3;
numero[4]:=num4;
numero[5]:=num5;
numero[6]:=num6;
numero[7]:=num7;
numero[8]:=num8;
numero[9]:=num9;
numero_G[0]:=num_0;
numero_G[1]:=num_1;
numero_G[2]:=num_2;
numero_G[3]:=num_3;
numero_G[4]:=num_4;
numero_G[5]:=num_5;
numero_G[6]:=num_6;
numero_G[7]:=num_7;
numero_G[8]:=num_8;
numero_G[9]:=num_9;
numero_G[10]:=num_11;
load_records;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure pinta_marcadors;
var i,j : word;
begin
/* pintura */
for i:=pos_esq_m_p to pos_dreta_m_p do
for j:= (pos_base_m_p-(max_pintura div tamany_m_p)) to pos_base_m_p do
putpixel(i,j,color_marcador_pintura_fondo,vaddr);
for i:=pos_esq_m_p to pos_dreta_m_p do
for j:= (pos_base_m_p-(pintura div tamany_m_p)) to pos_base_m_p do
putpixel(i,j,color_marcador_pintura,vaddr);
if pintura=0 then
for i:=pos_esq_m_p to pos_dreta_m_p do
for j:= (pos_base_m_p-(pintura div tamany_m_p)) to pos_base_m_p do
putpixel(i,(pos_base_m_p),color_marcador_pintura_fondo,vaddr);
if num_fase>0 then
begin
/* vides */
pinta_number(numero_G[vides],255,268,169,vaddr);
/* punts */
i:=265;
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 div 1000000],255,i,j,vaddr);
pinta_number(numero_G[(punts mod 1000000) div 100000],255,i+6,j,vaddr);
pinta_number(numero_G[((punts mod 1000000) mod 100000) div 10000],255,i+12,j,vaddr);
pinta_number(numero_G[(((punts mod 1000000) mod 100000) mod 10000) div 1000],255,i+18,j,vaddr);
pinta_number(numero_G[((((punts mod 1000000) mod 100000) mod 10000) mod 1000) div 100],255,i+24,j,vaddr);
pinta_number(numero_G[(((((punts mod 1000000) mod 100000) mod 10000) mod 1000) mod 100) div 10],255,i+30,j,vaddr);
pinta_number(numero_G[(((((punts mod 1000000) mod 100000) mod 10000) mod 100) mod 10)],255,i+36,j,vaddr);
/* blocs */
/*pinta(numero[blocs_per_pintar],239,i,60,vaddr);
pinta(numero[blocs_per_pintar],239,i+4,60,vaddr);
pinta(numero[blocs_per_pintar],239,i+8,60,vaddr);
pinta(numero[blocs_per_pintar],239,i+12,60,vaddr);
pinta(numero[blocs_per_pintar div 1000],255,i,60,vaddr);
pinta(numero[((blocs_per_pintar mod 1000) div 100)],255,i+4,60,vaddr);
pinta(numero[(((blocs_per_pintar mod 1000) mod 100) div 10)],255,i+8,60,vaddr);
pinta(numero[(((blocs_per_pintar mod 1000) mod 100) mod 10)],255,i+12,60,vaddr);*/
/* altaveu */
/*if amb_so then
begin
pinta_number(altaveu_on,255,1,189,vaddr);
end
else begin
pinta_number(altaveu_off,255,1,189,vaddr);
end;*/
/* mapa */
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure ini_pantalla;
var i,j : word;
i_int:integer;
offset : word;
VirscrFase : Ptr_pantalla;
vaddrFase : Word;
begin
getmem(virscrFase,6400);
vaddrFase:=seg(virscrFase^);
load_mif(fases,vaddr);
Cls32(0,vaddrFase);
offset:=((num_fase div 6)*160)+((((num_fase-1) mod 5)*40)*320);
PutSprite(vaddr,vaddrFase,offset,160,40,0,0);
if not(mode_nocturne) then
begin
if num_fase>0 then load_mif(path[random(max_fondos_story)+1],vaddr2)
else load_mif(path[13],vaddr2);
end
else load_mif(path[14],vaddr2);
if (num_fase=ultima_fase) and not(mode_nocturne) then load_mif(path[12],vaddr2);
/* pinta numero de fase */
if (num_fase>0) and (num_fase<10) then pinta_number(numero_G[num_fase],255,1,1,vaddr2);
/* pinta les pareds */
for i:=1 to 38 do
for j:=1 to 29 do
if pantalla[i,j]=es_una_paret then pinta(dib_pared,255,(i*6)+4,(j+1)*6,vaddr2)
/*put_matrix(pepe,color_pared,(i*6)+4,(j+1)*6,6,6,vaddr2)*/;
/* pinta a Rosita i a la presó */
if num_fase=ultima_fase then
begin
pinta(rosita,255,16,96,vaddr2);
pinta(preso,255,22,96,vaddr2);
for i:=97 to 102 do 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);
end;
/* pinta el marcador de pintura */
for i:=pos_esq_m_p to pos_dreta_m_p do
for j:= (pos_base_m_p-(pintura div tamany_m_p)) to pos_base_m_p do
begin
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 div tamany_m_p)-1),color_borde_m_p,vaddr2);
putpixel(i,(pos_base_m_p+1),color_borde_m_p,vaddr2);
end;
/* 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 j:=0 to 49 do
begin
i:=j shl 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);
end;
/* posa el lletrero de fase X */
if story_mode_mode then
for i_int:=-40 to 80 do
begin
volcar32(vaddr2,vaddr);
if i_int<20 then Put_Sprite_ICE_esquerra(vaddrFase,vaddr,0,160,40,i_int shl 2,80)
else Put_Sprite_ICE_dreta(vaddrFase,vaddr,0,160,40,i_int shl 2,80);
if i_int=14 then delay(2000);
espera_VGA;
Volcar32(vaddr,VGA);
end;
Freemem(virscrFase,6400);
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure level_complete;
var i,temps,temps2 : word;
begin
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
if not(mode_nocturne) then
begin
load_mif(done01,vaddr);
espera_vga;
volcar32(vaddr,VGA);
ini_midi(musica_canvi_fase);
if midi then Playmidi;
Gettime(h,m,s,c);
temps:=h*3600+m*60+s;
Repeat
Gettime(h,m,s,c);
temps2:=h*3600+m*60+s;
until /*(QteclaPuls) or*/ ((temps2-temps)>=4);
borrat_de_pantalla(vaddr);
end
else begin
load_mif(done05,vaddr);
espera_vga;
volcar32(vaddr,VGA);
ini_midi(musica_canvi_fase_n);
if midi then Playmidi;
if midi then repeat until not(playing)
else for i:=0 to 300 do espera_VGA;
borrat_de_pantalla(vaddr);
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure volcat_de_pantalla;
begin
volcar32(vaddr,vaddr2);
/* inicialització i comprobació de la fletxa de GO! */
fletxa_final_fase := true;
for i:=1 to 38 do
for j:=1 to 29 do
if (pantalla[i,j]=es_un_bloc_per_pintar) then fletxa_final_fase:=false;
/* pinta el rellontge */
if rellontge.viu then
case (c mod 50) of
0..12 : pinta(rellontge_dib,255,rellontge.i,rellontge.j,vaddr2);
13..25 : pinta(rellontge_dib_X,255,rellontge.i,rellontge.j,vaddr2);
26..37 : pinta(rellontge_dib,255,rellontge.i,rellontge.j,vaddr2);
38..49 : pinta(rellontge_dib_Y,255,rellontge.i,rellontge.j,vaddr2);
end;
if (x=pos_ini_x_pepe) and (y=pos_ini_y_pepe) then en_casa:=true;
/* pinta a PEPE, ROSITA o JOB */
if (mode_nocturne) and (not(rosita_selected)) and (not(amic_selected)) then pinta(gorro,255,x,y-6,vaddr2);
if pintura>0 then if rosita_selected then pinta(rosita_p,255,x,y,vaddr2)
else if amic_selected then pinta(amic,255,x,y,vaddr2)
else if mode_nocturne then pinta(pepe_gorro,255,x,y,vaddr2)
else pinta(pepe,255,x,y,vaddr2)
else if amic_selected then pinta(amic_b,255,x,y,vaddr2)
else if mode_nocturne then pinta(pepe_gorro,255,x,y,vaddr2)
else pinta(pepe_b,255,x,y,vaddr2);
if not(en_casa) then pinta(dib_pot,255,238,96,vaddr2)
else begin
pinta(dib_pot,255,238,96,vaddr2);
if rosita_selected then pinta(rosita_p,255,x,y,vaddr2)
else if amic_selected then pinta(amic,255,x,y,vaddr2)
else if mode_nocturne then pinta(pepe_gorro,255,x,y,vaddr2)
else pinta(pepe,255,x,y,vaddr2);
end;
/* pinta a rosita en la pressó */
if num_fase=ultima_fase then
begin
if (s mod 4)=0 then pinta(rosita,255,16,96,vaddr2)
else if (s mod 4)=1 then pinta(rosita2,255,16,96,vaddr2)
else if (s mod 4)=2 then pinta(rosita,255,16,96,vaddr2)
else pinta(rosita3,255,16,96,vaddr2);
if ((s mod 10)=0) or ((s mod 10)=1) then
begin
pinta(rosita_chillido,255,16,96,vaddr2);
pinta_number(help_1,255,12,87,vaddr2);
pinta_number(help_2,255,21,87,vaddr2);
end;
end;
/* pinta el mapa */
if map then put_map(pantalla,255,270,1,38,29,vaddr2);
/* pinta l'altaveu */
if amb_so then 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 then
if (c mod 99 < 50) then
begin
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);
end
else begin
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);
end;
espera_vga;
volcar32(vaddr2,VGA);
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure omplir_pot;
var i,j : byte;
begin
temps_final:=temps;
final_fase:=true;
for i:=1 to 38 do
for j:=1 to 29 do
if pantalla[i,j]=es_un_bloc_per_pintar
/*if blocs_per_pintar=0*/ then final_fase:=false;
if not(final_fase) then
begin
pinta(pepe,color_pintura,x,y,vaddr);
pantalla[(x div 6),((y div 6)-1)]:=es_un_bloc_pintat;
x:=pos_ini_x_pepe;
y:=pos_ini_y_pepe;
if mode_nocturne then pinta(pepe_gorro,255,x,y,vaddr)
else pinta(pepe,255,x,y,vaddr);
Play_WAV (sample[so_pot]);
while pintura<max_pintura do
begin
if pintura<max_pintura then inc(pintura);
if pintura<max_pintura then inc(pintura);
if pintura<max_pintura then inc(pintura);
pinta_marcadors;
if time_attack_mode then posa_el_temps(vaddr);
if ((pintura=Max_pintura) or (pintura mod 50=0))
then /*sound(pintura*7);*/Play_WAV (sample[so_pot]);
volcat_de_pantalla;
end;
nosound;
end;
en_casa:=true;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure pinta_un_bloc(color:byte;queda_pintura:byte);
begin
if antiga_direccio=cap_on_va_Pepe then
begin if valor_del_bloc<10 then inc(valor_del_bloc); end
else valor_del_bloc:=0;
if queda_pintura>0 then
begin
/*if amb_so then so_de(pot_ple);*/
if not(rosita_selected) then dec(pintura);
pinta(pepe,color,x,y,vaddr);
pantalla[(x div 6),((y div 6)-1)]:=es_un_bloc_pintat;
if el_que_hi_havia=es_un_bloc_per_pintar then
begin
dec(blocs_per_pintar);
if not(amic_selected) then punts:=punts+(25-(5*dificultat))+valor_del_bloc
else punts:=punts+(((25-(5*dificultat))+valor_del_bloc)*2);
if (punts mod 20000)>(25-(5*dificultat)+valor_del_bloc) then donar_vida:=true;
if (vides<9) and (story_mode_mode) and (donar_vida) then if punts>100 then
if (punts mod 20000)<(25-(5*dificultat)+valor_del_bloc) then
if not(amic_selected) then
begin
donar_vida:=false;
inc(vides);
pinta_number_zoom(5,numero_G[vides],255,260,150,VGA);
if amb_so then PlayWav(sample[so_ring])/*so_de(vida_extra)*/
else retard(40);
end;
end;
end
else if el_que_hi_havia=es_un_bloc_pintat then
begin
/*if amb_so then so_de(pot_buit);*/
pinta(pepe,color,x,y,vaddr);
pantalla[(x div 6),((y div 6)-1)]:=es_un_bloc_pintat;
end
else if el_que_hi_havia=es_un_bloc_per_pintar then
begin
/*if amb_so then so_de(pot_buit);*/
pantalla[(x div 6),((y div 6)-1)]:=es_un_bloc_per_pintar;
end;
antiga_direccio:=cap_on_va_Pepe;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure animacio_mort;
var i: byte;
begin
Play_WAV (sample[so_mort]);
for i:=1 to 5 do
begin
retard(10);
if rosita_selected then pinta(rosita_m,255,x,y,VGA)
else if amic_selected then 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 then pinta(rosita_m2,255,x,y,VGA)
else if amic_selected then pinta(amic_m2,255,x,y,VGA)
else pinta(pepe_m2,255,x,y,VGA);
/*if amb_so then sound(1000);*/
end;
nosound;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure animacio_alegria;
var i: byte;
begin
if (mode_nocturne) and
(not(rosita_selected)) and
(not(amic_selected)) then
begin
que_hi_ha:=pantalla[((x-max_m_x) div 6),(((y-max_m_y) div 6)-1)];
if que_hi_ha=es_un_bloc_pintat then pinta(gorro,color_pintura,x-6,y-6,VGA)
else if que_hi_ha=es_una_paret then pinta(dib_pared,255,x-6,y-6,VGA);
pinta(gorro,255,x,y-6,VGA);
end;
for i:=1 to 10 do
begin
retard(10);
if rosita_selected then pinta(rosita_a,255,x,y,VGA)
else if amic_selected then pinta(amic_a,255,x,y,VGA)
else if mode_nocturne then pinta(pepe_gorro,255,x,y,VGA)
else pinta(pepe_a,255,x,y,VGA);
retard(10);
if rosita_selected then pinta(rosita_a2,255,x,y,VGA)
else if amic_selected then pinta(amic_a2,255,x,y,VGA)
else if mode_nocturne then pinta(pepe_gorro,255,x,y,VGA)
else pinta(pepe_a2,255,x,y,VGA);
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure mort;
begin
if vides=0 then
begin
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;
end
else begin
if vides>0 then dec(vides);
if el_que_hi_havia=es_un_bloc_pintat then pinta(pepe,color_pintura,x,y,vaddr);
volcat_de_pantalla;
/*so_de(mos_a_pepe);*/Play_WAV (sample[so_mort]);
animacio_mort;
pantalla[(x div 6),(y div 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 then pinta(pepe_gorro,255,x,y,vaddr2)
else pinta(pepe,255,x,y,vaddr2);
omplir_pot;
volcat_de_pantalla;
retard_pepe:=velocitat_pepe;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure mira_el_que_hi_ha(cap_on_vaig:byte);
begin
el_que_hi_havia:=que_hi_ha;
case cap_on_vaig of
amunt:que_hi_ha:=pantalla[(x div 6),(((y-max_m_y) div 6)-1)];
dreta:que_hi_ha:=pantalla[((x+max_m_x) div 6),((y div 6)-1)];
avall:que_hi_ha:=pantalla[(x div 6),(((y+max_m_y) div 6)-1)];
esquerra:que_hi_ha:=pantalla[((x-max_m_x) div 6),((y div 6)-1)];
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure ja_no_pots_eixir;
begin
escriu_frase('JA NO POTS EIXIR',64,50,96,vaddr,10,0,1);
animacio_mort;
x:=0;
y:=0;
no_queden_vides:=true;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure munta_velocitat_joc;
begin
if velocitat_pepe<9 then inc(velocitat_pepe);
pinta_number_zoom(6,numero_G[velocitat_pepe],255,110,80,VGA);
if amb_so then
begin
sound(velocitat_pepe*150);
retard(1);
nosound;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure baixa_velocitat_joc;
begin
if velocitat_pepe>1 then dec(velocitat_pepe);
pinta_number_zoom(6,numero_G[velocitat_pepe],255,110,80,VGA);
if amb_so then
begin
sound(velocitat_pepe*150);
retard(1);
nosound;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure moure(direccio:byte);
var desp_pixel:byte;
begin
cap_on_va_Pepe:=direccio;
case direccio of
amunt:if ((y-max_m_y)>=l0) and (not(en_casa))
and (not(pantalla[(x div 6),(((y-max_m_y) div 6)-1)]=es_una_paret)) then
begin
mira_el_que_hi_ha(direccio);
if que_hi_ha=es_un_bicho then mort
else begin
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 div 6),((y div 6)-1)]:=es_pepe;
end;
end;
dreta:begin
if (not(en_casa))
and (not(pantalla[((x+max_m_x) div 6),((y div 6)-1)]=es_una_paret)) then
if ((x+max_m_x)<=l1) then
begin
mira_el_que_hi_ha(direccio);
if que_hi_ha=es_un_bicho then mort
else begin
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 div 6),((y div 6)-1)]:=es_pepe;
end;
end
else if (x=232) and (y=96) /*and (pintura<max_pintura)*/ then omplir_pot;
end;
avall:if ((y+max_m_y)<=l2) and (not(en_casa))
and (not(pantalla[(x div 6),(((y+max_m_y) div 6)-1)]=es_una_paret)) then
begin
mira_el_que_hi_ha(direccio);
if que_hi_ha=es_un_bicho then mort
else begin
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 div 6),((y div 6)-1)]:=es_pepe;
end;
end;
esquerra:if ((x-max_m_x)>=l3)
and (not(pantalla[((x-max_m_x) div 6),((y div 6)-1)]=es_una_paret)) then
begin
mira_el_que_hi_ha(direccio);
if (en_casa) and (que_hi_ha=es_un_bicho) then ja_no_pots_eixir;
/*if en_casa then x:=x-max_m_x
else*/
if /*(not(en_casa)) and*/ (que_hi_ha=es_un_bicho) then mort
else begin
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 div 6),((y div 6)-1)]:=es_pepe;
end;
en_casa:=false;
end;
end;
pinta_marcadors;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure ini_rellontge;
var a,b : byte;
begin
/*randomize;*/
repeat
a:=random(38)+1;
b:=random(29)+1;
until not(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;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure naix_malo(numero:byte);
var a,b : byte; cont : word;
begin
malo[numero].viu:=true;
/*randomize;*/
cont := 0;
repeat
a:=random(38)+1;
b:=random(29)+1;
inc(cont); if cont>10000 then begin a:=38; b:=15; break; end;
until (pantalla[a,b]=es_un_bloc_pintat) and (abs(a-(x div 6))>5) and (abs(b-((y div 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);
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure mou_malo(numero,direccio:byte);
begin
case direccio of
amunt:if (pantalla[malo[numero].i,malo[numero].j-1]=es_un_bloc_pintat)
and (not(pantalla[malo[numero].i,malo[numero].j-1]=es_un_bicho)) then
begin
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;
dec(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;
end
else if (pantalla[malo[numero].i,malo[numero].j-1]=es_pepe)
and (not(en_casa))
and (pintura>0) then mort
else if (pintura=0)
and (que_hi_ha=es_un_bloc_pintat)
and (pantalla[malo[numero].i,malo[numero].j-1]=es_pepe)
and (not(en_casa)) then mort;
avall:if (pantalla[malo[numero].i,malo[numero].j+1]=es_un_bloc_pintat)
and (not(pantalla[malo[numero].i,malo[numero].j+1]=es_un_bicho)) then
begin
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;
inc(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;
end
else if (pantalla[malo[numero].i,malo[numero].j+1]=es_pepe)
and (not(en_casa))
and (pintura>0) then mort
else if (pintura=0)
and (que_hi_ha=es_un_bloc_pintat)
and (pantalla[malo[numero].i,malo[numero].j+1]=es_pepe)
and (not(en_casa)) then mort;
dreta:if (pantalla[malo[numero].i+1,malo[numero].j]=es_un_bloc_pintat)
and (not(pantalla[malo[numero].i+1,malo[numero].j]=es_un_bicho))
and (not((malo[numero].i+1)=39)) then
begin
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;
inc(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;
end
else if (pantalla[malo[numero].i+1,malo[numero].j]=es_pepe)
or ((malo[numero].i+1)=39) then
if (not(en_casa))
and (pintura>0) then mort
else if (pantalla[malo[numero].i+1,malo[numero].j]=es_pepe)
or ((malo[numero].i+1)=39) then
if (pintura=0)
and (que_hi_ha=es_un_bloc_pintat)
and (pantalla[malo[numero].i+1,malo[numero].j]=es_pepe)
and (not(en_casa)) then mort
else if ((malo[numero].i+1)=39) and (malo[numero].j=15) and (en_casa) then ja_no_pots_eixir;
esquerra:if (pantalla[malo[numero].i-1,malo[numero].j]=es_un_bloc_pintat)
and (not(pantalla[malo[numero].i-1,malo[numero].j]=es_un_bicho)) then
begin
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;
dec(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;
end
else if (pantalla[malo[numero].i-1,malo[numero].j]=es_pepe)
and (not(en_casa))
and (pintura>0) then mort
else if (pintura=0)
and (que_hi_ha=es_un_bloc_pintat)
and (pantalla[malo[numero].i-1,malo[numero].j]=es_pepe)
and (not(en_casa)) then mort;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure moure_malos;
begin
for i:=1 to max_malos do
if malo[i].viu then
begin
/*randomize;*/
case malo[i].sentit of
horitzontalment:if ((malo[i].i*6)+4)>x then
begin
mou_malo(i,esquerra);
malo[i].sentit:=random(2+dificultat);
end
else if ((malo[i].i*6)+4)<x then
begin
mou_malo(i,dreta);
malo[i].sentit:=random(2+dificultat);
end
else malo[i].sentit:=verticalment;
verticalment:if ((malo[i].j+1)*6)>y then
begin
mou_malo(i,amunt);
malo[i].sentit:=random(2+dificultat);
end
else if ((malo[i].j+1)*6)<y then
begin
mou_malo(i,avall);
malo[i].sentit:=random(2+dificultat);
end
else malo[i].sentit:=horitzontalment;
2,3,4,5:malo[i].sentit:=random(2+dificultat);
end;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure fer_apareixer_els_malos;
begin
if blocs_per_pintar=((total_blocs_per_pintar div 4)*3) then
if not(malo[1].viu) then naix_malo(1);
if blocs_per_pintar=((total_blocs_per_pintar div 4)*2) then
if not(malo[2].viu) then naix_malo(2);
/* rellontge */
if story_mode_mode then
if blocs_per_pintar=(total_blocs_per_pintar div 3) then
if (not(rellontge.viu)) and (sense_rellontge) and (num_fase<10) then ini_rellontge;
/* malo 3 */
if (num_fase=10) or (dificultat=dificil) or (mode_nocturne) then
if blocs_per_pintar=(total_blocs_per_pintar div 4) then
if not(malo[3].viu) then naix_malo(3);
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure load_setup_i_versio;
var
x:word;
fichbyte : file of byte;
fich : text;
S,P: PathStr;
const color=80;
begin
espera_VGA;
cls32(226,VGA);
escriu_frase('PEPE EL PINTOR',color,20,20,vaddr,0,0,1);
escriu_frase('VERSIO 1.70 BUILD 3',color,20,30,vaddr,0,0,1);
S := FSearch('setup.ini','');
if S = '' then escriu_frase('SETUP.INI NO ENCONTRAT',198,20,100,vaddr,0,0,1)
else begin
Assign(fich,'setup.ini');
Reset(fich);
while not EOF(fich) do
begin
readln(fich,Puerto);
readln(fich,DMA);
readln(fich,IRQ);
end;
Close(fich);
escriu_frase('SETUP.INI CARREGAT AMB EXIT',color,20,100,vaddr,0,0,1);
end;
S := FSearch('story.dat','datos');
if S = '' then
begin
escriu_frase('GENERANT RECORDS',198,20,110,vaddr,0,0,1);
nom[1] := 'SERGI'; puntuacio[1] := 200000;
nom[2] := 'PEPE'; puntuacio[2] := 150000;
nom[3] := 'ICEKAS'; puntuacio[3] := 125000;
nom[4] := 'ROSITA'; puntuacio[4] := 100000;
nom[5] := 'JOB'; puntuacio[5] := 50000;
Assign(fich,'datos\story.dat');
Rewrite(fich);
x:=1;
while x<6 do
begin
writeln(fich,nom[x]);
writeln(fich,puntuacio[x]);
inc(x);
end;
Close(fich);
end;
P := FSearch('time.dat','datos');
if P = '' then
begin
escriu_frase('GENERANT RECORDS',198,20,110,vaddr,0,0,1);
nom2[1] := 'SERGI'; minuts[1] := 1; segons_tabla[1] := 45;
nom2[2] := 'PEPE'; minuts[2] := 2; segons_tabla[2] := 00;
nom2[3] := 'ICEKAS'; minuts[3] := 2; segons_tabla[3] := 10;
nom2[4] := 'ROSITA'; minuts[4] := 2; segons_tabla[4] := 20;
nom2[5] := 'JOB'; minuts[5] := 2; segons_tabla[5] := 30;
Assign(fich,'datos\time.dat');
Rewrite(fich);
x:=1;
while x<6 do
begin
writeln(fich,nom2[x]);
writeln(fich,minuts[x]);
writeln(fich,segons_tabla[x]);
inc(x);
end;
Close(fich);
end;
load_records;
if (S<>'') and (P<>'') then
escriu_frase('DATOS DEL JOC CARREGATS',color,20,110,vaddr,0,0,1);
escriu_frase('PULSA UNA TECLA PER A CONTINUAR...',color,20,180,vaddr,0,0,1);
Repeat until QteclaPuls;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure story_mode;
var
eixir : boolean;
s_vella : byte;
musica_fase:string;
begin
historia;
num_fase:=1;
repeat
contador:=0;
ini_vars(num_fase);
case num_fase of
1,3,5,7,9 : musica_fase:=musica_fase01;
2,4,6,8 : musica_fase:=musica_fase02;
10 : musica_fase:=musica_fase10;
end;
if num_fase=1 then punts:=0;
/*if not(mode_nocturne) then pantalla_presentacio(num_fase);*/
ini_pantalla;
volcar32(vaddr2,vaddr);
pinta_marcadors;
eixir:=false;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
if mode_nocturne then ini_midi(musica_fase_nit)
else ini_midi(musica_fase);
if midi then Playmidi;
/*------------------------------*/
repeat
if (not(playing)) and (midi) then PlayMIDI;
s_vella := s;
gettime(h,m,s,c);
menejant:=false;
inc(contador);
if retard_pepe>0 then dec(retard_pepe);
if teclapuls(KeyKeypadPlus) then
begin
munta_velocitat_joc;
repeat until not(TeclaPuls(KeyKeypadPlus));
end;
if teclapuls(KeyKeypadminus) then
begin
baixa_velocitat_joc;
repeat until not(TeclaPuls(KeyKeypadMinus));
end;
if retard_pepe=0 then
if teclapuls(tecla_amunt) then moure(amunt)
else if teclapuls(tecla_avall) then moure(avall)
else if teclapuls(tecla_dreta) then moure(dreta)
else if teclapuls(tecla_esquerra) then moure(esquerra);
if TeclaPuls(KeyM) then begin map:=not(map); repeat until not(TeclaPuls(KeyM)); end;
/*---------*/
/* if TeclaPuls(KeyN) then
begin
final_fase:=true;
num_fase:=9;
end;
if TeclaPuls(KeyB) then final_fase:=true;*/
/*---------*/
if teclapuls(Key1) then
begin
amb_so:=/*not(amb_so);*/false;
repeat until not(TeclaPuls(Key1));
end;
if teclapuls(KeyESC) then
begin
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);
repeat until not(TeclaPuls(KeyESC));
repeat until (QteclaPuls);
if TeclaPuls(KeyESC) then eixir:=true;
end;
if rellontge.viu then
if (x = rellontge.i) and (y = rellontge.j) then
begin
malos_quets := true;
rellontge.temps := 0;
rellontge.viu := false;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
ini_midi(musica_campanes);
if midi then Playmidi;
end;
fer_apareixer_els_malos;
if not(malos_quets) then
begin
if contador mod velocitat_pepe = 0 then moure_malos
end
else begin
if (s_vella<>s) then inc(rellontge.temps);
if rellontge.temps = 10 then
begin
malos_quets:=false;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
if mode_nocturne then ini_midi(musica_fase_nit)
else ini_midi(musica_fase);
if midi then Playmidi;
end;
end;
if not(no_queden_vides) then volcat_de_pantalla;
/*------------------------------*/
until (eixir) or (final_fase) or (no_queden_vides);
if final_fase then if num_fase<ultima_fase then
begin
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 then begin StopMIDI; unloadmidi; midi:=false; end;
level_complete;
inc(num_fase);
end
else if mode_nocturne then
begin
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 then begin StopMIDI; unloadmidi; midi:=false; end;
historia_final;
mode_Dream_Tour:=Dream_Tour;
save_records;
end
else begin
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 then begin StopMIDI; unloadmidi; midi:=false; end;
if dificultat=dificil then
begin
historia_final;
if not(mode_rosita=rosita_enabled) and not(mode_amic=job_enabled) then mode_hard:=pepe_dificil;
if (mode_rosita=rosita_enabled) and not(mode_amic=job_enabled) then mode_hard_r:=rosita_dificil;
if not(mode_rosita=rosita_enabled) and
(mode_easy=pepe_facil) and
(mode_normal=pepe_normal) and
(mode_hard=pepe_dificil) then
begin
mode_rosita:=rosita_enabled;
text_rosita;
end;
if (mode_rosita=rosita_enabled) and
(mode_easy_r=rosita_facil) and
(mode_normal_r=rosita_normal) and
(mode_hard_r=rosita_dificil) then
begin
mode_amic:=job_enabled;
text_amic;
end;
save_records;
end
else if dificultat=normal then
begin
final_fals;
if not(mode_rosita=rosita_enabled) and not(mode_amic=job_enabled) then mode_normal:=pepe_normal;
if (mode_rosita=rosita_enabled) and not(mode_amic=job_enabled) then mode_normal_r:=rosita_normal;
if not(mode_rosita=rosita_enabled) and
(mode_easy=pepe_facil) and
(mode_normal=pepe_normal) and
(mode_hard=pepe_dificil) then
begin
mode_rosita:=rosita_enabled;
text_rosita;
end;
if (mode_rosita=rosita_enabled) and
(mode_easy_r=rosita_facil) and
(mode_normal_r=rosita_normal) and
(mode_hard_r=rosita_dificil) then
begin
mode_amic:=job_enabled;
text_amic;
end;
save_records;
end
else begin
final_fals;
if not(mode_rosita=rosita_enabled) and not(mode_amic=job_enabled) then mode_easy:=pepe_facil;
if (mode_rosita=rosita_enabled) and not(mode_amic=job_enabled) then mode_easy_r:=rosita_facil;
if not(mode_rosita=rosita_enabled) and
(mode_easy=pepe_facil) and
(mode_normal=pepe_normal) and
(mode_hard=pepe_dificil) then
begin
mode_rosita:=rosita_enabled;
text_rosita;
end;
if not(mode_amic=job_enabled) and
(mode_rosita=rosita_enabled) and
(mode_easy_r=rosita_facil) and
(mode_normal_r=rosita_normal) and
(mode_hard_r=rosita_dificil) then
begin
mode_amic:=job_enabled;
text_amic;
end;
save_records;
end;
no_queden_vides:=true;
end;
until (eixir) or (no_queden_vides);
if no_queden_vides then
begin
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
missatge_game_over;
end;
if (eixir) then
begin
fadedown(0,0,0,0);
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure time_attack;
var
eixir : boolean;
begin
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;
eixir:=false;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
ini_midi(musica_time_attack);
if midi then Playmidi;
contador:=0;
repeat until TeclaPuls(tecla_esquerra);
pilla_temps;
/*------------------------------*/
repeat
if (not(playing)) and (midi) then PlayMIDI;
inc(contador);
if retard_pepe>0 then dec(retard_pepe);
menejant:=false;
if retard_pepe=0 then begin
if teclapuls(tecla_amunt) then moure(amunt)
else if teclapuls(tecla_avall) then moure(avall)
else if teclapuls(tecla_dreta) then moure(dreta)
else if teclapuls(tecla_esquerra) then moure(esquerra);
end;
if teclapuls(Key1) then
begin
amb_so:=/*not(amb_so);*/false;
repeat until not(TeclaPuls(Key1));
end;
if teclapuls(KeyESC) then
begin
eixir:=true;
end;
/*if TeclaPuls(KeyN) then final_fase:=true;*/
fer_apareixer_els_malos;
posa_el_temps(vaddr);
if (contador mod velocitat_pepe) = 0 then moure_malos;
if not(no_queden_vides) then volcat_de_pantalla;
/*------------------------------*/
until (eixir) or (final_fase) or (no_queden_vides);
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
if final_fase then
begin
pinta(pepe,color_pintura,x,y,VGA);
x:=pos_ini_x_pepe;
y:=pos_ini_y_pepe;
animacio_alegria;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
resultat_time_attack;
end
else if (eixir) then
begin
fadedown(0,0,0,0);
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
end;
if no_queden_vides then
begin
missatge_game_over;
if midi then begin StopMIDI; unloadmidi; midi:=false; end;
end;
end;
/*──────────────────────────────────────────────────────────────────────────*/
procedure 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;
procedure ini_estreles;
var i : byte;
begin
cls32(0,vaddr);
for i:=1 to 10 do
begin
estreles[i].x:=random(290);
estreles[i].y:=1;
estreles[i].velocitat:=random(3)+1;
end;
end;
procedure fondo_estreles(from,where:word);
var
i,a,b : byte;
begin
for i:=1 to 10 do
begin
if (estreles[i].y + estreles[i].velocitat) > 191 then
begin
estreles[i].x := random(290);
estreles[i].y := 1;
estreles[i].velocitat := random(3) + 1;
end
else estreles[i].y := estreles[i].y + (estreles[i].velocitat);
Putsprite(from,where,26747,9,8,estreles[i].x,estreles[i].y);
end;
end;
procedure actualitza_options(from,where:word);
var i,j:byte;
begin
cls32(0,vaddr2);
for i:=0 to 3 do
for j:=0 to 5 do 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 then 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 then 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);
case volumen of
0 : Putsprite(from,where,45551,32,18,70,62);
1 : Putsprite(from,where,45580,16,18,70,62);
2 : Putsprite(from,where,45596,16,18,70,62);
3 : Putsprite(from,where,45611,16,18,70,62);
4 : Putsprite(from,where,45626,16,18,70,62);
5 : Putsprite(from,where,45642,16,18,70,62);
6 : Putsprite(from,where,45658,16,18,70,62);
7 : Putsprite(from,where,45673,16,18,70,62);
8 : Putsprite(from,where,45689,16,18,70,62);
9 : Putsprite(from,where,45705,14,18,71,62);
10 : Putsprite(from,where,45720,40,18,70,62);
end;
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);
end;
procedure pinta_marcs(posicio:word);
var
i : word;
begin
volcar32(vaddr,vaddr2);
for i:=posicio to posicio+75 do
begin
putpixel(i,11,15,vaddr2);
putpixel(i,12,15,vaddr2);
putpixel(i,90,15,vaddr2);
putpixel(i,91,15,vaddr2);
end;
for i:=11 to 91 do
begin
putpixel(posicio,i,15,vaddr2);
putpixel(posicio+1,i,15,vaddr2);
putpixel(posicio+74,i,15,vaddr2);
putpixel(posicio+75,i,15,vaddr2);
end;
if mode_nocturne then
begin
if mode_Dream_Tour=Dream_tour then pinta_number_zoom(2,tick,255,216,143,vaddr2);
end
else if (pos=1) or (pos=3) then
begin
if mode_easy=pepe_facil then pinta_number_zoom(2,tick,255,216,118,vaddr2);
if mode_normal=pepe_normal then pinta_number_zoom(2,tick,255,216,143,vaddr2);
if mode_hard=pepe_dificil then pinta_number_zoom(2,tick,255,216,168,vaddr2);
end
else begin
if mode_easy_r=rosita_facil then pinta_number_zoom(2,tick,255,216,118,vaddr2);
if mode_normal_r=rosita_normal then pinta_number_zoom(2,tick,255,216,143,vaddr2);
if mode_hard_r=rosita_dificil then pinta_number_zoom(2,tick,255,216,168,vaddr2);
end;
if pos_dif=1 then pinta_number(fletxa,255,98,118,vaddr2);
if pos_dif=2 then pinta_number(fletxa,255,98,143,vaddr2);
if pos_dif=3 then pinta_number(fletxa,255,98,168,vaddr2);
espera_VGA;
volcar32(vaddr2,VGA);
end;
procedure desp_marc(direccio:byte);
begin
case direccio of
Left: if pos=3 then
begin
i:=219;
while i>136 do
begin
pinta_marcs(i);
i:=i-3;
if i<137 then pinta_marcs(137);
end;
end
else if pos=2 then
begin
i:=137;
while i>54 do
begin
pinta_marcs(i);
i:=i-3;
if i<55 then pinta_marcs(55);
end;
end;
Right:if pos=1 then
begin
i:=55;
while i<138 do
begin
pinta_marcs(i);
i:=i+3;
if i>137 then pinta_marcs(137);
end;
end
else if pos=2 then
begin
i:=137;
while i<220 do
begin
pinta_marcs(i);
i:=i+3;
if i>219 then pinta_marcs(219);
end;
end;
end;
end;
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;
*/