commit 78e57e1bf163d3f8b1c1c50734c18feb0005aa8f Author: Raimon Zamora Date: Mon Jan 12 14:16:33 2026 +0100 - First commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..908f4af --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Patman/* \ No newline at end of file diff --git a/compress.cpp b/compress.cpp new file mode 100644 index 0000000..0abc068 --- /dev/null +++ b/compress.cpp @@ -0,0 +1,75 @@ +#include +#include +#include + +struct actor_t +{ + uint8_t x, y, z, t; +}; + +int main(int argc, char *argv[]) +{ + FILE *f; + f = fopen("data/Cuina.map", "rb"); + for (int i=0; i<256; ++i) { + bool ignore = false; + char buffer[33]; int size; + + fread(buffer, 33, 1, f); size = buffer[0]; for (int j=0; j +#include + +#define NUM_VERSIO '0257' + // Orientacions +#define oXB 0 // Baix-Esquerra +#define oYB 1 // Baix-Dreta +#define oXA 2 // Dalt-Dreta +#define oYA 3 // Dalt-Esquerra + +#define START_X 5 +#define START_Y 5 +#define START_Z 1 +/* +#define NOM_MAPA 'Hall01.map' +#define START_ROOM 8 +#define START_X 8 +#define START_Y 5 +#define START_Z 1 +*/ + + // Tecles +#define TECLA_AMUNT 0x01 +#define TECLA_AVALL 0x02 +#define TECLA_ESQUERRA 0x04 +#define TECLA_DRETA 0x08 +#define TECLA_SALT 0x10 + +#define TECLA_WALK 0x0F + +//PSpriteInfo = ^TSpriteInfo; +struct TSpriteInfo { + uint8_t TileX, TileY, TileZ; + uint8_t TPixX, TPixY, TPixZ; + int X,Y; + int Frame; + int tipus; +}; + + + +extern bool EXIT_SIGNAL; +extern std::string PATH; +extern std::string NOM_MAPA; +extern int START_ROOM; +extern int FRAMES_ACTORS[22]; +extern TSpriteInfo LAST_POS; diff --git a/habitacions.cpp b/habitacions.cpp new file mode 100644 index 0000000..c51a020 --- /dev/null +++ b/habitacions.cpp @@ -0,0 +1,301 @@ +#include "habitacions.h" + +//uses +// uMain; + +// THab + +// THab - Constructor + +THab::THab(std::string p_FitxerMapa) +{ + Jump = false; + //VGA = p_VGA; + //Grafx = p_Grafx; + FitxerMapa = p_FitxerMapa; + HabitacioActual = START_ROOM; + Animacio = 0; + LoadMap; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; +} + + + // THab - Destructor + +THab::~THab() +{ +// pumba pumba pinyau catacroc!!! +}; + + + // { THab - Private } + +void THab::LoadMap() +{ + FILE *f; + f = fopen(FitxerMapa.c_str(), "rb"); + for (int i=0; i 2) + Grafx.Items[GFX_TILES].Draw(VGA.Surface,x,y,Habitacions[HabitacioActual].Mapa[c_x][c_y][c_z]+z); + + for (int ActorPointer=0; ActorPointer 2) then + Grafx.Items[GFX_TILES].Draw(VGA.Surface,x,y,Habitacions[HabitacioActual].Mapa[c_x,c_y,c_z]+z); + + for ActorPointer = 0 to MAX_ACTORS do + { + if (Sombres[ActorPointer].TileX = c_x) and + (Sombres[ActorPointer].TileY = c_y) and + (Sombres[ActorPointer].TileZ = c_z) then + Grafx.Items[GFX_SPRITES].DrawAlpha(VGA.Surface,Rect(Sombres[ActorPointer].X-2,Sombres[ActorPointer].Y-4,Sombres[ActorPointer].X+30,Sombres[ActorPointer].Y+28),Sombres[ActorPointer].Frame,100); + + if (Sprites[ActorPointer].TileX = c_x) and + (Sprites[ActorPointer].TileY = c_y) and + (Sprites[ActorPointer].TileZ = c_z) then + { + Grafx.Items[GFX_SPRITES].Draw(VGA.Surface,Sprites[ActorPointer].X,Sprites[ActorPointer].Y-4,Sprites[ActorPointer].Frame+FRAMES_ACTORS[Sprites[ActorPointer].Tipus]); + if (Habitacions[HabitacioActual].Flags[c_x,c_y,c_z-1] and FLAG_SOMBRA = FLAG_SOMBRA) then + Grafx.Items[GFX_SPRITES].DrawSub(VGA.Surface,Rect(Sprites[ActorPointer].X,Sprites[ActorPointer].Y-4,Sprites[ActorPointer].X+32,Sprites[ActorPointer].Y+28),Sprites[ActorPointer].Frame+FRAMES_ACTORS[Sprites[ActorPointer].Tipus],150); + }; + }; + +{ If (Habitacions[HabitacioActual].Mapa[c_x,c_y,c_z] = 55) then + { + Llums[NumLlums].x = x; Llums[NumLlums].y = y; + inc(NumLlums); + };} + }; + dec(c_x); inc(c_y); + until (c_x = c_i-1) and (c_y = MAX_Y); + }; + +// if NumLlums > 0 then For i = 0 to NumLlums-1 do +// Grafx.Items[GFX_SPRITES].DrawAdd(VGA.Surface,Rect(Llums[i].x,Llums[i].y-8,Llums[i].x+32,Llums[i].y+24),17,150); + + try + VGA.Surface.Canvas.Brush.Style = bsClear; + VGA.Surface.Canvas.Font.Color = $FFFFFF; +// VGA.Surface.Canvas.TextOut(20,10,inttostr(Sprites[0].TileX)+','+inttostr(Sprites[0].TileY)+','+inttostr(Sprites[0].TileZ)); +// VGA.Surface.Canvas.TextOut(20,20,inttostr(Sprites[0].TPixX)+','+inttostr(Sprites[0].TPixY)+','+inttostr(Sprites[0].TPixZ)); + VGA.Surface.Canvas.TextOut(20,10,inttostr(Form1.PatMan.GetInfo.TileX)+','+inttostr(Form1.PatMan.GetInfo.TileY)+','+inttostr(Form1.PatMan.GetInfo.TileZ)); + VGA.Surface.Canvas.TextOut(20,20,inttostr(Form1.PatMan.GetInfo.TPixX)+','+inttostr(Form1.PatMan.GetInfo.TPixY)+','+inttostr(Form1.PatMan.GetInfo.TPixZ)); + VGA.Surface.Canvas.TextOut(20,220,'PatMan v'+NUM_VERSIO); + finally + VGA.Surface.Canvas.Release; + }; + +}; + + +void THab::{Update; +var + i : byte; +{ + if Animacio = 3 then Animacio = 0 else inc(Animacio); + for i = 0 to MAX_ACTORS do + { + Sprites[i].TileX = 20; + Sprites[i].TileY = 20; + Sprites[i].TileZ = 20; + Sprites[i].X = 0; + Sprites[i].Y = 0; + Sprites[i].Frame = 0; + }; +}; + +void THab::}Update; +var + temp : TSpriteInfo; + punter : byte; + menor : byte; + i,j : byte; +{ + // ordenem en Z + for i = 0 to MAX_ACTORS do + { + punter = i; menor = i; + for j = i to MAX_ACTORS do if Sprites[menor].TileZ > Sprites[j].TileZ then menor = j; + temp = Sprites[punter]; Sprites[punter] = Sprites[menor]; Sprites[menor] = temp; + }; + + // ordenem en X + for i = 0 to MAX_ACTORS do + { + punter = i; menor = i; + for j = i to MAX_ACTORS do if Sprites[menor].TileX > Sprites[j].TileX then menor = j; + temp = Sprites[punter]; Sprites[punter] = Sprites[menor]; Sprites[menor] = temp; + }; + + // ordenem en Y + for i = 0 to MAX_ACTORS do + { + punter = i; menor = i; + for j = i to MAX_ACTORS do if Sprites[menor].TileY > Sprites[j].TileY then menor = j; + temp = Sprites[punter]; Sprites[punter] = Sprites[menor]; Sprites[menor] = temp; + }; + Jump = false; + + For i = 0 to MAX_ACTORS do + { + //i = 0; + Sombres[i] = Sprites[i]; + Sombres[i].Frame = 16; + while (Habitacions[HabitacioActual].Mapa[Sombres[i].TileX, Sombres[i].TileY, Sombres[i].TileZ-1] = 0) and not(Sombres[i].TileZ-1 = 0) and ((Form1.Actors.CheckMalos(Sombres[i])<14) or (Form1.Actors.CheckMalos(Sombres[i])>23)) do + { + dec(Sombres[i].TileZ); inc(Sombres[i].Y,7); + }; + if Sombres[i].TPixZ mod 4 <> 0 then inc(Sombres[i].Y,4); + }; +}; + + +void THab::EnviaInfoSprite(num: byte; Info: TSpriteInfo); +{ + Sprites[num] = Info; + if num <> 0 then exit; + if (Sprites[0].TileX = 0) and (Habitacions[HabitacioActual].Portes[1] <> 0) then + { + HabitacioActual = Habitacions[HabitacioActual].Portes[1]; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; + Jump = true; + }; + if (Sprites[0].TileX = 11) and (Habitacions[HabitacioActual].Portes[4] <> 0) then + { + HabitacioActual = Habitacions[HabitacioActual].Portes[4]; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; + Jump = true; + }; + if (Sprites[0].TileY = 0) and (Habitacions[HabitacioActual].Portes[5] <> 0) then + { + HabitacioActual = Habitacions[HabitacioActual].Portes[5]; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; + Jump = true; + }; + if (Sprites[0].TileY = 11) and (Habitacions[HabitacioActual].Portes[2] <> 0) then + { + HabitacioActual = Habitacions[HabitacioActual].Portes[2]; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; + Jump = true; + }; + if (Sprites[0].TileZ = 0) and (Habitacions[HabitacioActual].Portes[3] <> 0) then + { + HabitacioActual = Habitacions[HabitacioActual].Portes[3]; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; + Jump = true; + }; + if (Sprites[0].TileZ = 9) and (Habitacions[HabitacioActual].Portes[0] <> 0) then + { + HabitacioActual = Habitacions[HabitacioActual].Portes[0]; + Grafx.Items[GFX_TILES].Picture.LoadFromFile(PATH+Habitacions[HabitacioActual].BMP); + Grafx.Items[GFX_TILES].Restore; + Jump = true; + }; +}; + + +function THab::PucPasar(x, y, z: byte): boolean; +{ + Result = true; + if (Habitacions[HabitacioActual].Mapa[x,y,z] <> 0) or + (Habitacions[HabitacioActual].Mapa[x,y,Min(z+1,9)] <> 0) or + (Habitacions[HabitacioActual].Mapa[x,y,Min(z+2,9)] <> 0) or + (Habitacions[HabitacioActual].Mapa[x,y,Min(z+3,9)] <> 0) then result = false; +}; + + +function THab::DonamElsFlags(x, y, z: byte): byte; +{ + result = Habitacions[HabitacioActual].Flags[x,y,z-1]; +}; + + +function THab::GetHabitacioActual: byte; +{ + result = HabitacioActual; +}; + + +function THab::GetActorsInfo : TActors; +{ + result = Habitacions[HabitacioActual].Actors; +}; + + +}. diff --git a/habitacions.h b/habitacions.h new file mode 100644 index 0000000..4e5a788 --- /dev/null +++ b/habitacions.h @@ -0,0 +1,77 @@ +#pragma once + +#include "globals.h" + +#define TILE_SIZE 32 +#define TILE_X 16 +#define TILE_Y 8 +#define TILE_Z 7 + +#define MAX_HABITACIONS 256 +#define MAX_ACTORS 15 +#define MAX_X 12 +#define MAX_Y 12 +#define MAX_Z 10 + +#define GFX_TILES 0 +#define GFX_SPRITES 1 +#define GFX_FONDO 2 + +#define FLAG_MATA 0x01 +#define FLAG_SOMBRA 0x02 +#define FLAG_ANIMAT 0x04 +#define FLAG_NODEFINIT 0x08 +#define FLAG_MOVILXP 0x10 +#define FLAG_MOVILXN 0x20 +#define FLAG_MOVILYP 0x40 +#define FLAG_MOVILYN 0x80 + +// TMapa = array[0..MAX_X-1,0..MAX_Y-1,0..MAX_Z-1] of byte; + +struct TActor { + uint8_t x, y, z; + uint8_t Tipus; +}; + +// TActors = array[0..MAX_ACTORS-1] of TActor; + +struct THabitacio { + std::string Nom; + uint8_t Zona; + uint8_t Mapa[MAX_X][MAX_Y][MAX_Z]; + uint8_t Flags[MAX_X][MAX_Y][MAX_Z]; + std::string BMP; + uint8_t Portes[6]; + TActor Actors[MAX_ACTORS]; +}; + +// THabitacions = array[0..MAX_HABITACIONS-1] of THabitacio; + +class THab { + private: + //VGA : TDXDraw; + //Grafx : TDXImageList; + std::string FitxerMapa; + THabitacio Habitacions[MAX_HABITACIONS]; + uint8_t HabitacioActual; + TSpriteInfo Sprites[MAX_ACTORS]; + TSpriteInfo Sombres[MAX_ACTORS]; + uint8_t Animacio; + + void LoadMap(); + + public: + bool Jump; + + THab(std::string p_FitxerMapa); + ~THab(); + + void PintaMapa(); + void BeginUpdate(); + void EndUpdate(); + void EnviaInfoSprite(uint8_t num, TSpriteInfo Info); + bool PucPasar(uint8_t x, uint8_t y, uint8_t z); + uint8_t DonamElsFlags(uint8_t x, uint8_t y, uint8_t z); + uint8_t GetHabitacioActual(); + TActor *GetActorsInfo(); +};