- Jo que se, moltes coses

This commit is contained in:
2024-01-29 06:59:46 +01:00
parent a690619865
commit 3832fdf5e4
13 changed files with 1068 additions and 399 deletions

View File

@@ -8,13 +8,10 @@
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 "pepe_vell.h"
#include "midiplay.h"
// const
@@ -271,9 +268,9 @@
//VirScrSP : Ptr_pantalla;
uint8_t *vaddr; // : word;
uint8_t *vaddr2; // : word;
uint8_t *vaddrSP; // : word;
draw::surface *vaddr; // : word;
draw::surface *vaddr2; // : word;
draw::surface *vaddrSP; // : word;
uint16_t blocs_per_pintar;// : word;
uint16_t total_blocs_per_pintar;// : word;
@@ -367,7 +364,7 @@ malo_t malo[max_malos];
/*──────────────────────────────────────────────────────────────────────────*/
void power_off(uint8_t *where)
void power_off(draw::surface *where)
{
uint16_t i;
uint8_t j;
@@ -394,7 +391,7 @@ void power_off(uint8_t *where)
}
/*──────────────────────────────────────────────────────────────────────────*/
void load_mif(int num, uint8_t *where)
void load_mif(int num, draw::surface *where)
{
draw::waitVsync();
draw::cls(0, VGA);
@@ -404,7 +401,7 @@ void load_mif(int num, uint8_t *where)
// 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);
fread(where->pixels, 64000, 1, fich);
uint8_t paleta[768];
fread(paleta, 768, 1, fich);
draw::setPalette(paleta);
@@ -597,72 +594,72 @@ var aux : boolean; intents : word;
}
/*──────────────────────────────────────────────────────────────────────────*/
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
void pinta(uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where) // offset es on comença el dibuixet en el "bitmap" de sprites, where la surface
{
// [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve
// 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] 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)
draw::putPixel(x+i, y+j, color, where);
else if (vaddrSP->pixels[offset + i + (j * 320)] != 255)
draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where);
}
/*──────────────────────────────────────────────────────────────────────────*/
// [RZC 24/01/0224] [NOTA] Esta funció i l'anterior son exactament iguals!
void pinta_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, uint8_t *where)
void pinta_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where)
{
// [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve
// 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] 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)
draw::putPixel(x+i, y+j, color, where);
else if (vaddrSP->pixels[offset + i + (j * 320)] != 255)
draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where);
}
/*──────────────────────────────────────────────────────────────────────────*/
// [RZC 24/01/0224] [NOTA] Esta es igual pero els bucles van de 0 a 8 en compte de de 0 a 5
void pinta_number(uint16_t offset, uint8_t color, uint16_t x, uint16_t y, 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)
void pinta_number(uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where)
{
// [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve
// 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;
draw::putPixel(x+i, y+j, color, where);
else if (vaddrSP->pixels[offset + i + (j * 320)] != 255)
draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where);
}
/*──────────────────────────────────────────────────────────────────────────*/
void pinta_number_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, uint8_t *where)
void pinta_number2(uint16_t offset, uint8_t color, uint8_t color_determinat, uint16_t x, uint16_t y, draw::surface *where)
{
// [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve
// inc(x); inc(y);
for (int i = 0; i < 9; ++i)
for (int j = 0; j < 9; ++j)
if (color != 255)
draw::putPixel(x+i, y+j, color, where);
else if ((vaddrSP->pixels[offset + i + (j * 320)] != 255) && (vaddrSP->pixels[offset + i + (j * 320)] != 254))
draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + i + (j * 320)], where);
else if (vaddrSP->pixels[offset + i + (j * 320)] == 254)
draw::putPixel(x+i, y+j, color_determinat, where);
}
/*──────────────────────────────────────────────────────────────────────────*/
void pinta_number_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, uint16_t y, draw::surface *where)
{
// [RZC 24/01/0224] [NOTA] No entenc perqué s'incrementa 1 a les coordenades on anem a pintar. Per ara ho lleve
// 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)];
draw::putPixel(x+i, y+j, color, where);
else if (vaddrSP->pixels[offset + (i / zoom) + ((j / zoom) * 320)] != 255)
draw::putPixel(x+i, y+j, vaddrSP->pixels[offset + (i / zoom) + ((j / zoom) * 320)], where);
}
/*──────────────────────────────────────────────────────────────────────────*/
@@ -675,7 +672,7 @@ void retard(int centesimes)
}
/*──────────────────────────────────────────────────────────────────────────*/
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)
void escriu_frase(const char *nom, uint8_t color_determinat, uint16_t x,uint16_t y, draw::surface *where, uint16_t velocitat, uint8_t mode, uint8_t mode2)
{
for (int i=0; i<strlen(nom); ++i)
{
@@ -726,7 +723,7 @@ void escriu_frase(char *nom, uint8_t color_determinat, uint16_t x,uint16_t y, ui
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_o; break;
case '!' : quina_lletra = lletra_exclamacio_t; break;
case '*' : quina_lletra = lletra_apostrof; break;
case '.' : quina_lletra = lletra_punt; break;
@@ -745,7 +742,7 @@ void escriu_frase(char *nom, uint8_t color_determinat, uint16_t x,uint16_t y, ui
}
/*──────────────────────────────────────────────────────────────────────────*/
void borrar_frase(int temps, uint8_t *zona_mem1, uint8_t *zona_mem2)
void borrar_frase(int temps, draw::surface *zona_mem1, draw::surface *zona_mem2)
{
retard(temps);
draw::draw(zona_mem1, zona_mem2);
@@ -754,7 +751,7 @@ void borrar_frase(int temps, uint8_t *zona_mem1, uint8_t *zona_mem2)
}
/*──────────────────────────────────────────────────────────────────────────*/
void borrat_de_pantalla(uint8_t *where)
void borrat_de_pantalla(draw::surface *where)
{
for (int i = 0; i < 32; ++i)
{
@@ -1084,7 +1081,7 @@ void pepe_text()
/*──────────────────────────────────────────────────────────────────────────*/
void final_fals()
{
uint8_t *vaddr3 = draw::newSurface(320, 240);
draw::surface *vaddr3 = draw::createSurface(320, 240);
draw::cls(0, vaddr);
load_mif(FINALF1, vaddr2);
load_mif(FINALF2, vaddr3);
@@ -1183,7 +1180,7 @@ void final_fals()
draw::fadeDown(0,0,0,0);
if (midi) { audio::stopMusic(); audio::unloadMusic(); midi = false; }
draw::deleteSurface(vaddr3);
draw::freeSurface(vaddr3);
}
/*──────────────────────────────────────────────────────────────────────────*/
@@ -1428,7 +1425,7 @@ void credits()
}
}
uint32_t t = SDL_GetTicks()+10000;
t = SDL_GetTicks()+10000;
do {} while (!input::anyKey() && SDL_GetTicks()<t);
draw::fadeDown(0,0,0,3);
@@ -1442,18 +1439,18 @@ void credits()
}
/*──────────────────────────────────────────────────────────────────────────*/
void reixa(uint16_t posx, uint8_t longitud, uint8_t *where)
void reixa(uint16_t posx, uint8_t longitud, draw::surface *where)
{
draw::line(posx, 30, posx, 197-longitud, 0, where);
draw::line(posx+1, 30, posx+1, 197-longitud, 0, where);
draw::line(posx+2, 30, posx+2, 198-longitud, 0, where);
draw::line(posx+3, 30, posx+3, 198-longitud, 0, where);
draw::line(posx+4, 30, posx+4, 199-longitud, 0, where);
draw::line(posx+5, 30, posx+5, 199-longitud, 0, where);
draw::line(posx+6, 30, posx+6, 198-longitud, 0, where);
draw::line(posx+7, 30, posx+7, 198-longitud, 0, where);
draw::line(posx+8, 30, posx+8, 197-longitud, 0, where);
draw::line(posx+9, 30, posx+9, 197-longitud, 0, where);
draw::vline(posx, 30, 197-longitud, 0, where);
draw::vline(posx+1, 30, 197-longitud, 0, where);
draw::vline(posx+2, 30, 198-longitud, 0, where);
draw::vline(posx+3, 30, 198-longitud, 0, where);
draw::vline(posx+4, 30, 199-longitud, 0, where);
draw::vline(posx+5, 30, 199-longitud, 0, where);
draw::vline(posx+6, 30, 198-longitud, 0, where);
draw::vline(posx+7, 30, 198-longitud, 0, where);
draw::vline(posx+8, 30, 197-longitud, 0, where);
draw::vline(posx+9, 30, 197-longitud, 0, where);
}
/*──────────────────────────────────────────────────────────────────────────*/
@@ -1482,11 +1479,12 @@ void historia_final()
}
if (mode_nocturne) retard(200); else retard(600);
draw::fadeDown(0,0,0,0);
free(paleta);
// dibuix 2
if (mode_nocturne) load_mif(FINALN02, vaddr); else load_mif(FINAL02, vaddr);
draw::setColor(1,32,0,0);
uint8_t *paleta = draw::getPalette();
paleta = draw::getPalette();
draw::blackout();
draw::waitVsync();
draw::draw(vaddr, VGA);
@@ -1500,13 +1498,14 @@ void historia_final()
}
if (!mode_nocturne) retard(600);
draw::fadeDown(0,0,0,0);
free(paleta);
// dibuix 3
if (mode_nocturne) load_mif(FINALN03, vaddr); else load_mif(FINAL03, vaddr);
draw::setColor(253,39, 0,48);
draw::setColor(254, 0,63, 6);
draw::setColor(255, 0, 3,63);
uint8_t *paleta = draw::getPalette();
paleta = draw::getPalette();
draw::blackout();
draw::waitVsync();
draw::draw(vaddr, VGA);
@@ -1533,6 +1532,7 @@ void historia_final()
} while (!input::anyKey() && SDL_GetTicks()<t);
draw::fadeDown(0,0,0,0);
free(paleta);
// dibuix 4
if (mode_nocturne)
@@ -1546,7 +1546,7 @@ void historia_final()
retard(600);
draw::fadeDown(0,0,0,0);
}
free(paleta);
credits();
}
@@ -1557,7 +1557,7 @@ void pilla_temps()
}
/*──────────────────────────────────────────────────────────────────────────*/
void posa_el_temps(uint8_t *where)
void posa_el_temps(draw::surface *where)
{
//gettime(h1,m1,s1,c1);
temps = (SDL_GetTicks() / 1000) - hora;
@@ -1921,7 +1921,7 @@ var i,j : word;
vaddrFase : Word;
*/
{
uint8_t *vaddrFase = (uint8_t*)malloc(6400); // 6400???
draw::surface *vaddrFase = draw::createSurface(320, 20); //(uint8_t*)malloc(6400); // 6400???
load_mif(FASES,vaddr);
draw::cls(0, vaddrFase);
@@ -3115,7 +3115,7 @@ uint8_t percentatge;
}
}
void fondo_estreles(uint8_t *from, uint8_t *where)
void fondo_estreles(draw::surface *from, draw::surface *where)
{
for (int i=0; i<10; ++i)
{
@@ -3132,7 +3132,7 @@ uint8_t percentatge;
}
void actualitza_options(uint8_t *from, uint8_t *where)
void actualitza_options(draw::surface *from, draw::surface *where)
{
draw::cls(0, vaddr2);
@@ -3863,7 +3863,7 @@ void menu_joc()
draw::draw(vaddr2, VGA);
} while (input::anyKey());
bool tecla_incorrecta = true;
//bool tecla_incorrecta = true;
if (aux >= SDL_SCANCODE_A && aux <= SDL_SCANCODE_Z) tecla_incorrecta = false;
if (aux >= SDL_SCANCODE_RIGHT && aux <= SDL_SCANCODE_UP) tecla_incorrecta = false;
@@ -3945,6 +3945,8 @@ void menu_joc()
/*──────────────────────────────────────────────────────────────────────────*/
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
comprobar_comp_i_sprites();
srand(SDL_GetTicks());
@@ -3952,12 +3954,13 @@ int main(int argc, char *argv[])
input::init();
//setmode(0x13);
draw::init();
draw::init("Pepe el Pintor", 320, 200, 3);
vaddr = draw::newSurface(320, 240);
vaddr2 = draw::newSurface(320, 240);
vaddr = draw::createSurface(320, 200);
vaddr2 = draw::createSurface(320, 200);
vaddrSP = draw::loadSurface("datos/sprites.dat"); //(320, 24);// (uint8_t *)malloc(7680);
//loadPCX('datos/sprites.dat', vaddrSP);
draw::loadPalette("datos/sprites.dat");
load_setup_i_versio();
@@ -3978,9 +3981,9 @@ int main(int argc, char *argv[])
} while (!eixir_del_joc);
draw::deleteSurface(vaddr);
draw::deleteSurface(vaddr2);
draw::deleteSurface(vaddrSP);
draw::freeSurface(vaddr);
draw::freeSurface(vaddr2);
draw::freeSurface(vaddrSP);
/* if amb_so then arxius_wav(FALSE);
if amb_so then EndWAV;*/
@@ -3988,6 +3991,8 @@ int main(int argc, char *argv[])
//DesinstalarKB();
//setmode(0x3);
draw::quit();
SDL_Quit();
}
/*