Initial commit
This commit is contained in:
129
engines/icb/gfx/gfxstub.cpp
Normal file
129
engines/icb/gfx/gfxstub.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/icb/gfx/gfxstub.h"
|
||||
#include "engines/icb/gfx/psx_scrn.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
int32 _selFace;
|
||||
|
||||
// Number of GPU packets to reserve
|
||||
#define PACKETMAX 2900 * 4
|
||||
// the size of a POLY_GT3 packet
|
||||
#define PACKETSIZE sizeof(POLY_GT3)
|
||||
// a full-up DR_LOAD is 17 int32s (68 bytes) and is the biggest type of packet
|
||||
#define PACKET_MAX_SIZE sizeof(DR_LOAD)
|
||||
#define PACKETMEM (PACKETMAX * PACKETSIZE)
|
||||
|
||||
// Global place to create GPU packets
|
||||
// Use a ring system, so when get to end just start again from the beginning
|
||||
GPUPACKET packets[PACKETMEM]; /* GPU PACKETS AREA */
|
||||
GPUPACKET *drawpacket;
|
||||
GPUPACKET *drawpacketStart;
|
||||
GPUPACKET *drawpacketEnd;
|
||||
|
||||
// Global double buffer index
|
||||
int32 drawBuf = 0;
|
||||
|
||||
// Global ot arrays and stuff
|
||||
OT_tag *otarray[2];
|
||||
OT_tag *drawot;
|
||||
OT_tag otlist[2][OT_SIZE];
|
||||
|
||||
// The min & max places to put Z data into the OT list
|
||||
int32 minZOTpos = 5;
|
||||
int32 maxZOTpos = OT_SIZE - 5;
|
||||
int32 nearClip = 0;
|
||||
int32 minUsedZpos = 20000;
|
||||
int32 maxUsedZpos = 0;
|
||||
|
||||
int32 g_otz_shift = 0; // 1cm accuracy
|
||||
int32 g_otz_offset;
|
||||
|
||||
// The zones for otz_shift computation
|
||||
#define OTZ_ZONE1 32000 // 1cm
|
||||
#define OTZ_ZONE2 64000 // 2cm
|
||||
#define OTZ_ZONE4 128000 // 4cm
|
||||
#define OTZ_ZONE8 256000 // 8cm
|
||||
|
||||
void InitDrawing(void) {
|
||||
// sort out the GPU packet memory
|
||||
drawpacketStart = packets;
|
||||
drawpacketEnd = packets + PACKETMEM - PACKET_MAX_SIZE * 2;
|
||||
drawpacket = drawpacketStart;
|
||||
|
||||
otarray[0] = &(otlist[0][0]);
|
||||
otarray[1] = &(otlist[1][0]);
|
||||
drawBuf = 0;
|
||||
drawot = otarray[drawBuf];
|
||||
|
||||
CLEAROTLIST(drawot, OT_SIZE);
|
||||
minZOTpos = 5;
|
||||
maxZOTpos = OT_SIZE - 5;
|
||||
nearClip = 0;
|
||||
minUsedZpos = 20000;
|
||||
maxUsedZpos = 0;
|
||||
|
||||
g_otz_shift = 0; // 1cm accuracy
|
||||
g_otz_offset = ((nearClip >> g_otz_shift) - minZOTpos);
|
||||
}
|
||||
|
||||
void drawOTList(void) {
|
||||
startDrawing();
|
||||
DrawOTag(drawot + OT_FIRST);
|
||||
endDrawing();
|
||||
CLEAROTLIST(drawot, OT_SIZE);
|
||||
}
|
||||
|
||||
void recoverFromOTcrash(void) {
|
||||
endDrawing();
|
||||
CLEAROTLIST(drawot, OT_SIZE);
|
||||
}
|
||||
|
||||
void ResetZRange(void) {
|
||||
// Reset the z-sorting values
|
||||
nearClip = minUsedZpos - 100; // last used value -1m
|
||||
int32 dz = maxUsedZpos - nearClip;
|
||||
// Simple zones for otz_shift
|
||||
if (dz < OTZ_ZONE1) // 1cm
|
||||
g_otz_shift = 0;
|
||||
else if (dz < OTZ_ZONE2) // 2cm
|
||||
g_otz_shift = 1;
|
||||
else if (dz < OTZ_ZONE4) // 4cm
|
||||
g_otz_shift = 2;
|
||||
else if (dz < OTZ_ZONE8) // 8cm
|
||||
g_otz_shift = 3;
|
||||
else
|
||||
g_otz_shift = 4; // 16cm - yuck
|
||||
|
||||
g_otz_offset = ((nearClip >> g_otz_shift) - minZOTpos);
|
||||
|
||||
minUsedZpos = 20000;
|
||||
maxUsedZpos = 0;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
117
engines/icb/gfx/gfxstub.h
Normal file
117
engines/icb/gfx/gfxstub.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
#define REVERSE_OT
|
||||
// #define FORWARD_OT
|
||||
|
||||
// For reverse OT
|
||||
#ifdef REVERSE_OT
|
||||
#define OT_FIRST OT_SIZE - 1
|
||||
#define CLEAROTLIST ClearOTagR
|
||||
#endif // #ifdef REVERSE_OT
|
||||
|
||||
#ifdef FORWARD_OT
|
||||
#define OT_FIRST 0
|
||||
#define CLEAROTLIST ClearOTag
|
||||
#endif // #ifdef FORWARD_OT
|
||||
|
||||
// The emulation of VRAM : 16-bit pixels 1024x512 big
|
||||
#define VRAM_WIDTH 1024
|
||||
#define VRAM_HEIGHT 512
|
||||
extern uint16 psxVRAM[VRAM_WIDTH * VRAM_HEIGHT];
|
||||
extern uint16 psxTP;
|
||||
|
||||
// Generic routines in gfxstub.cpp
|
||||
void InitDrawing(void);
|
||||
void drawOTList(void);
|
||||
void ResetZRange(void);
|
||||
void recoverFromOTcrash(void);
|
||||
|
||||
// External graphic routines to be supplied
|
||||
void startDrawing(void);
|
||||
void endDrawing(void);
|
||||
|
||||
// Real graphic routines
|
||||
int32 DrawSprite(int32 x0, int32 y0, int16 w, int16 h, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint8 alpha, uint16 z, void *tex);
|
||||
|
||||
// Single coloured rectangle
|
||||
int32 DrawTile(int32 x0, int32 y0, int16 w, int16 h, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z);
|
||||
|
||||
// Single flat coloured line : 2 points, 1 colour
|
||||
int32 DrawLineF2(int32 x0, int32 y0, int32 x1, int32 y1, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z);
|
||||
|
||||
// two connected lines flat coloured : 3 points, 1 colour
|
||||
int32 DrawLineF3(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z);
|
||||
|
||||
// three connected lines flat coloured : 4 points, 1 colour
|
||||
int32 DrawLineF4(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z);
|
||||
|
||||
// Single gouraud coloured line : 2 points, 2 colours
|
||||
int32 DrawLineG2(int32 x0, int32 y0, int32 x1, int32 y1, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 alpha, uint16 z);
|
||||
|
||||
// two connected lines gouraud coloured : 3 points, 3 colours
|
||||
int32 DrawLineG3(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 alpha, uint16 z);
|
||||
|
||||
// three connected lines gouraud coloured : 4 points, 4 colours
|
||||
int32 DrawLineG4(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 r3,
|
||||
uint8 g3, uint8 b3, uint8 alpha, uint16 z);
|
||||
|
||||
// Simple flat coloured triangle : 3 points, 1 colour
|
||||
int32 DrawFlatTriangle(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z);
|
||||
|
||||
// Simple flat coloured quad : 4 points, 1 colour
|
||||
int32 DrawFlatQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z);
|
||||
|
||||
// Simple gouraud coloured triangle : 3 points, 3 colours
|
||||
int32 DrawGouraudTriangle(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 alpha,
|
||||
uint16 z);
|
||||
|
||||
// Simple gouraud coloured quad : 4 points, 4 colours
|
||||
int32 DrawGouraudQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2,
|
||||
uint8 r3, uint8 g3, uint8 b3, uint8 alpha, uint16 z);
|
||||
|
||||
// Simple flat coloured triangle : 3 points, 1 colour, 3 UV's
|
||||
int32 DrawFlatTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2,
|
||||
uint8 alpha, uint16 z, void *tex);
|
||||
|
||||
// Simple flat coloured quad : 4 points, 1 colour, 4 UV's
|
||||
int32 DrawFlatQuadTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2,
|
||||
uint16 v2, uint16 u3, uint16 v3, uint8 alpha, uint16 z, void *tex);
|
||||
|
||||
// Simple gouraud coloured triangle : 3 points, 3 colours
|
||||
int32 DrawGouraudTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2,
|
||||
uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint8 alpha, uint16 z, void *tex);
|
||||
|
||||
// Simple gouraud coloured quad : 4 points, 4 colours
|
||||
int32 DrawGouraudQuadTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2,
|
||||
uint8 b2, uint8 r3, uint8 g3, uint8 b3, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint16 u3, uint16 v3, uint8 alpha,
|
||||
uint16 z, void *tex);
|
||||
|
||||
} // End of namespace ICB
|
||||
1024
engines/icb/gfx/gfxstub_dutch.cpp
Normal file
1024
engines/icb/gfx/gfxstub_dutch.cpp
Normal file
File diff suppressed because it is too large
Load Diff
89
engines/icb/gfx/gfxstub_dutch.h
Normal file
89
engines/icb/gfx/gfxstub_dutch.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_GFXSTUB_DUTCH_HH
|
||||
#define ICB_GFXSTUB_DUTCH_HH
|
||||
|
||||
namespace ICB {
|
||||
|
||||
typedef struct {
|
||||
uint32 width; // 640
|
||||
uint32 height; // 480
|
||||
uint32 stride; // width * 4
|
||||
uint8 *RGBdata; // width * height * 32-bits
|
||||
uint16 *Zdata; // width * height * 16-bits
|
||||
} RevRenderDevice;
|
||||
|
||||
typedef struct {
|
||||
int32 x, y; // fixed-point 16:16
|
||||
int32 u, v; // fixed-point 16:16
|
||||
uint32 colour; // B, G, R, alpha (low->high mem)
|
||||
} vertex2D;
|
||||
|
||||
typedef struct {
|
||||
uint32 *palette; /*[256]*/ // windows 32-bit RGB with 1 byte of padding
|
||||
uint32 width; // must be power of 2
|
||||
uint32 height; // must be power of 2
|
||||
uint8 *level[9]; // width/1 * height/1 -> width/256 * height/256
|
||||
} RevTexture;
|
||||
|
||||
class TextureHandle;
|
||||
|
||||
TextureHandle *RegisterTexture(const RevTexture *revInput);
|
||||
int32 UnregisterTexture(TextureHandle *);
|
||||
|
||||
int32 SetTextureState(TextureHandle *texture);
|
||||
int32 GetTextureState(TextureHandle *texture);
|
||||
|
||||
int32 SetRenderDevice(RevRenderDevice *renderDev);
|
||||
int32 GetRenderDevice(RevRenderDevice *renderDev);
|
||||
|
||||
// Colour is verts[0].colour
|
||||
int32 DrawFlatUnTexturedPolygon(const vertex2D *verts, int32 nVerts, uint16 z);
|
||||
|
||||
int32 DrawGouraudUnTexturedPolygon(const vertex2D *verts, int32 nVerts, uint16 z);
|
||||
|
||||
// Colour is verts[0].colour
|
||||
int32 DrawFlatTexturedPolygon(const vertex2D *verts, int32 nVerts, uint16 z);
|
||||
|
||||
int32 DrawGouraudTexturedPolygon(const vertex2D *verts, int32 nVerts, uint16 z);
|
||||
|
||||
// Colour is verts[0].colour
|
||||
int32 DrawFlatTexturedTransparentPolygon(const vertex2D *verts, int32 nVerts, uint16 z);
|
||||
|
||||
int32 DrawGouraudTexturedTransparentPolygon(const vertex2D *verts, int32 nVerts, uint16 z);
|
||||
|
||||
static const int32 GFXLIB_TRANSPARENT_COLOUR = 0xDEADBEAF;
|
||||
|
||||
// This value CANNOT be changed
|
||||
|
||||
static const int32 GFXLIB_TRANSPARENT_INDEX = 0x00000000;
|
||||
|
||||
void ClearProcessorState(void);
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef GFXSTUB_DUTCH_HH
|
||||
1479
engines/icb/gfx/gfxstub_rev.cpp
Normal file
1479
engines/icb/gfx/gfxstub_rev.cpp
Normal file
File diff suppressed because it is too large
Load Diff
48
engines/icb/gfx/gfxstub_rev_dutch.h
Normal file
48
engines/icb/gfx/gfxstub_rev_dutch.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_GFXSTUB_REV_DUTCH_HH
|
||||
#define ICB_GFXSTUB_REV_DUTCH_HH
|
||||
|
||||
#include "engines/icb/gfx/gfxstub_dutch.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
class TextureHandle {
|
||||
public:
|
||||
uint8 *pRGBA[9]; // width/1 * height/1 -> width/256 * height/256
|
||||
uint32 *palette;
|
||||
int32 w;
|
||||
int32 h;
|
||||
int32 bpp;
|
||||
};
|
||||
|
||||
RevTexture *MakeRevTexture(uint32 w, uint32 h, uint32 *palette, uint8 *img);
|
||||
void Make24palette(uint32 *outPal, uint16 *inPal);
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef GFXSTUB_REV_DUTCH_HH
|
||||
49
engines/icb/gfx/psx_anims.h
Normal file
49
engines/icb/gfx/psx_anims.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_ANIMS_HH
|
||||
#define ICB_PSX_ANIMS_HH
|
||||
|
||||
#include "engines/icb/debug.h"
|
||||
#include "engines/icb/common/px_common.h"
|
||||
#include "engines/icb/common/px_anims.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
inline PXframe_PSX *PXFrameEnOfAnim(uint32 n, PXanim_PSX *pAnim) {
|
||||
// Convert to the new schema
|
||||
ConvertPXanim(pAnim);
|
||||
if (n >= pAnim->frame_qty) {
|
||||
Real_Fatal_error("Illegal frame %d %d %s %d", n, pAnim->frame_qty);
|
||||
error("Should exit with error-code -1");
|
||||
return NULL;
|
||||
}
|
||||
return (PXframe_PSX *)((uint8 *)pAnim + FROM_LE_16(pAnim->offsets[n]));
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_ANIMS_HH
|
||||
73
engines/icb/gfx/psx_camera.cpp
Normal file
73
engines/icb/gfx/psx_camera.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/icb/gfx/psx_camera.h"
|
||||
#include "engines/icb/gfx/psx_scrn.h"
|
||||
#include "engines/icb/common/px_capri_maths.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// Make the local to screen matrix from the
|
||||
// world-screen & local-world matrices
|
||||
|
||||
// ls rot matrix = world2screen * local2world
|
||||
// ls trans vector = world2screen * local2world_trans + world2screen_trans
|
||||
void makeLSmatrix(MATRIX *ws, MATRIX *lw, MATRIX *ls) {
|
||||
VECTOR tmp;
|
||||
// Make the rotation matrix
|
||||
gte_MulMatrix0(ws, lw, ls);
|
||||
// make the ls trans vector
|
||||
// = world2screen * local2world_trans + world2screen_trans
|
||||
ApplyMatrixLV(ws, (VECTOR *)&lw->t[0], &tmp);
|
||||
ls->t[0] = tmp.vx + ws->t[0];
|
||||
ls->t[1] = tmp.vy + ws->t[1];
|
||||
ls->t[2] = tmp.vz + ws->t[2];
|
||||
}
|
||||
|
||||
// Project x has silly definitions for these so have to silly stuff
|
||||
// with y & z
|
||||
void psxWorldToFilm(const PXvector_PSX &worldpos, const psxCamera &camera, bool8 &is_onfilm, PXvector_PSX &filmpos) {
|
||||
VECTOR scrn;
|
||||
ApplyMatrixLV(const_cast<MATRIX *>(&camera.view), (VECTOR *)const_cast<PXvector_PSX *>(&worldpos), &scrn);
|
||||
scrn.vx += camera.view.t[0];
|
||||
scrn.vy += camera.view.t[1];
|
||||
scrn.vz += camera.view.t[2];
|
||||
|
||||
if (scrn.vz != 0) {
|
||||
scrn.vx = camera.focLen * scrn.vx / scrn.vz;
|
||||
scrn.vy = camera.focLen * scrn.vy / scrn.vz;
|
||||
}
|
||||
filmpos.x = scrn.vx;
|
||||
filmpos.y = -scrn.vy; // px convention is upside down y
|
||||
filmpos.z = -scrn.vz / 4; // px convention is -ve z : PSX also has zscale * 4 to make it more accurate
|
||||
|
||||
if ((scrn.vx < -SCREEN_W / 2) || (scrn.vx > SCREEN_W / 2) || (scrn.vy < -SCREEN_H / 2) || (scrn.vy > SCREEN_H / 2))
|
||||
is_onfilm = FALSE8;
|
||||
else
|
||||
is_onfilm = TRUE8;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
84
engines/icb/gfx/psx_camera.h
Normal file
84
engines/icb/gfx/psx_camera.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_CAMERA_H
|
||||
#define ICB_PSX_CAMERA_H
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
#include "engines/icb/common/px_rcutypes.h"
|
||||
#include "engines/icb/common/px_common.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
#define PSX_CAMERA_ID "CAM"
|
||||
#define PSX_CAMERA_SCHEMA 2
|
||||
|
||||
#define PSX_WEATHER_NONE 0
|
||||
#define PSX_WEATHER_SNOW 1
|
||||
#define PSX_WEATHER_RAIN 2
|
||||
|
||||
typedef struct {
|
||||
MATRIX view;
|
||||
uint16 focLen;
|
||||
} psxPCcameraOld;
|
||||
|
||||
typedef struct {
|
||||
MATRIX view;
|
||||
uint16 focLen;
|
||||
int32 pos[3];
|
||||
} psxPCcamera;
|
||||
|
||||
typedef struct {
|
||||
float m[3][3];
|
||||
float t[3];
|
||||
float fov;
|
||||
int32 width;
|
||||
int32 height;
|
||||
} psxFloatCamera;
|
||||
|
||||
typedef struct {
|
||||
char id[4];
|
||||
int32 schema;
|
||||
MATRIX view;
|
||||
int32 pan;
|
||||
uint16 focLen;
|
||||
int32 weatherType;
|
||||
int32 lightning;
|
||||
int32 windx;
|
||||
int32 windy;
|
||||
int32 windz;
|
||||
int32 particleCount;
|
||||
} psxCamera;
|
||||
|
||||
// Useful camera and co-ordinate system based maths
|
||||
|
||||
void makeLSmatrix(MATRIX *ws, MATRIX *lw, MATRIX *ls);
|
||||
|
||||
void psxWorldToFilm(const PXvector_PSX &worldpos, const psxCamera &camera, bool8 &is_onfilm, PXvector_PSX &filmpos);
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_CAMERA_H
|
||||
97
engines/icb/gfx/psx_clut.h
Normal file
97
engines/icb/gfx/psx_clut.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_CLUT_H
|
||||
#define ICB_PSX_CLUT_H
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// Where the actor cluts go
|
||||
#define CHARACTER_CLUT_X (0)
|
||||
#define CHARACTER_CLUT_Y (240)
|
||||
|
||||
// Where the actor alternate cluts go
|
||||
#define CHARACTER_ALTERNATE_CLUT_X (512)
|
||||
#define CHARACTER_ALTERNATE_CLUT_Y (500)
|
||||
|
||||
// Where the background goes
|
||||
#define BACKGROUND_CLUT_X (0)
|
||||
#define BACKGROUND_CLUT_Y (496)
|
||||
|
||||
// Where the icons put their CLUT's
|
||||
#define ICONS_CLUT_X (0)
|
||||
#define ICONS_CLUT_Y (497)
|
||||
|
||||
// Where the text CLUT lives
|
||||
#define TEXT_CLUT_X (0)
|
||||
#define TEXT_CLUT_Y (498)
|
||||
|
||||
// Where the layer Z-map CLUT lives
|
||||
#define LAYERS_ZMAP_CLUT_X (0)
|
||||
#define LAYERS_ZMAP_CLUT_Y (499)
|
||||
|
||||
// Where the solid layers CLUT lives
|
||||
#define LAYERS_SOLID_CLUT_X (0)
|
||||
#define LAYERS_SOLID_CLUT_Y (500)
|
||||
|
||||
// Where the solid layers CLUT lives
|
||||
#define LAYERS_SOLIDFG_CLUT_X (0)
|
||||
#define LAYERS_SOLIDFG_CLUT_Y (501)
|
||||
|
||||
// Where the semi-trans additive CLUT lives
|
||||
#define LAYERS_SEMIADD_CLUT_X (0)
|
||||
#define LAYERS_SEMIADD_CLUT_Y (502)
|
||||
|
||||
// Where the semi-trans average CLUT lives
|
||||
#define LAYERS_SEMIAVG_CLUT_X (0)
|
||||
#define LAYERS_SEMIAVG_CLUT_Y (503)
|
||||
|
||||
// Where the remora sprites CLUT lives
|
||||
#define REMORA_SPRITE_CLUT_X (0)
|
||||
#define REMORA_SPRITE_CLUT_Y (504)
|
||||
|
||||
// Where the props put their CLUT's
|
||||
#define PROPS_CLUT_X (256)
|
||||
#define PROPS_CLUT_Y (240)
|
||||
#define PROPS_CLUT_MAX_Y (255)
|
||||
|
||||
// Where the layer CLUT's live
|
||||
#define LAYER_CLUT_X (512 + 128)
|
||||
#define LAYER_CLUT_MAX_Y (511)
|
||||
|
||||
// Where the PSX debug font lives
|
||||
#define FNTLOAD_X (768)
|
||||
#define FNTLOAD_Y (256)
|
||||
|
||||
// Where the text characters get loaded into
|
||||
#define TEXT_FONT_X (512)
|
||||
#define TEXT_FONT_Y (240)
|
||||
#define TEXT_FONT_MAX_X (1024)
|
||||
#define TEXT_FONT_MAX_Y (256)
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_CLUT_H
|
||||
39
engines/icb/gfx/psx_light.h
Normal file
39
engines/icb/gfx/psx_light.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_LIGHT_H
|
||||
#define ICB_PSX_LIGHT_H
|
||||
|
||||
namespace ICB {
|
||||
|
||||
typedef struct psxLight {
|
||||
int32 vx, vy, vz;
|
||||
int32 r, g, b; // don't need to be int's but makes life easier
|
||||
} psxLight;
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_LIGHT_H
|
||||
76
engines/icb/gfx/psx_ot.h
Normal file
76
engines/icb/gfx/psx_ot.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_OT_H
|
||||
#define ICB_PSX_OT_H
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// By default setup for a reverse OT
|
||||
#if defined FORWARD_OT
|
||||
#define OT_LAST OT_SIZE - 1
|
||||
#define OT_FIRST 0
|
||||
#define OT_DIRECTION 1
|
||||
#else
|
||||
#define OT_LAST 0
|
||||
#define OT_FIRST OT_SIZE - 1
|
||||
#define OT_DIRECTION -1
|
||||
#endif // #if defined FORWARD_OT
|
||||
|
||||
// Where to put the DR_LOAD primitives in the OT list
|
||||
#define DRLOAD_OT OT_FIRST
|
||||
|
||||
// Where to put the profiling bars
|
||||
#ifdef PROFILE_FIRST
|
||||
#define PROFILE_OT OT_FIRST
|
||||
#else
|
||||
#define PROFILE_OT (OT_LAST - OT_DIRECTION)
|
||||
#endif
|
||||
|
||||
// Where to put the BG sprites in the OT list
|
||||
#define OT_BG (OT_FIRST + OT_DIRECTION)
|
||||
|
||||
// Where to put the PROP sprites in the OT list
|
||||
#define OT_PROPS (OT_BG + OT_DIRECTION)
|
||||
|
||||
// Where to put the LAYER sprites in the OT list
|
||||
#define OT_LAYERS (OT_PROPS + OT_DIRECTION)
|
||||
|
||||
// Where to put the text
|
||||
#define OT_TEXT (OT_LAST - OT_DIRECTION - OT_DIRECTION - OT_DIRECTION)
|
||||
|
||||
// Where to put the mission based darkening semi-trans tile
|
||||
#define OT_DARKEN (OT_TEXT + OT_DIRECTION)
|
||||
|
||||
// Where to put the icons
|
||||
#define OT_ICONS (OT_TEXT)
|
||||
|
||||
// Where to put the set gfx fade up/down tiles
|
||||
#define OT_GFX (OT_DARKEN - OT_DIRECTION)
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_OT_H
|
||||
94
engines/icb/gfx/psx_pcdefines.h
Normal file
94
engines/icb/gfx/psx_pcdefines.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_PCDEFINES_H
|
||||
#define ICB_PSX_PCDEFINES_H
|
||||
|
||||
#include "common/types.h"
|
||||
|
||||
namespace ICB {
|
||||
// make our own equivalents
|
||||
typedef struct MATRIX {
|
||||
int16 m[3][3]; /* 3x3 rotation matrix */
|
||||
int16 pad;
|
||||
int32 t[3]; /* transfer vector */
|
||||
MATRIX() { pad = 0; }
|
||||
} MATRIX;
|
||||
|
||||
typedef struct MATRIXPC {
|
||||
int32 m[3][3]; /* 3x3 rotation matrix */
|
||||
int32 pad;
|
||||
int32 t[3]; /* transfer vector */
|
||||
MATRIXPC() { pad = 0; }
|
||||
} MATRIXPC;
|
||||
|
||||
/* int32 word type 3D vector */
|
||||
typedef struct VECTOR {
|
||||
int32 vx, vy;
|
||||
int32 vz, pad;
|
||||
VECTOR() { pad = 0; }
|
||||
} VECTOR;
|
||||
|
||||
/* short word type 3D vector */
|
||||
typedef struct SVECTOR {
|
||||
int16 vx, vy;
|
||||
int16 vz, pad;
|
||||
} SVECTOR;
|
||||
|
||||
/* short word type 3D vector - PC version */
|
||||
typedef struct SVECTORPC {
|
||||
int32 vx, vy;
|
||||
int32 vz, pad;
|
||||
} SVECTORPC;
|
||||
|
||||
typedef struct CVECTOR {
|
||||
/* color type vector */
|
||||
uint8 r, g, b, cd;
|
||||
} CVECTOR;
|
||||
|
||||
typedef struct {/* 2D short vector */
|
||||
short vx, vy;
|
||||
} DVECTOR;
|
||||
|
||||
typedef uint8 PACKET;
|
||||
|
||||
//-=- Definitions -=-//
|
||||
#ifndef ONE
|
||||
#define ONE 4096
|
||||
#endif
|
||||
#define PSX_SCREEN_WIDTH 512
|
||||
#define PSX_SCREEN_HEIGHT 240
|
||||
|
||||
//-=- Macros -=-//
|
||||
#define __nint__(x) (((x) > 0) ? int((x) + 0.5) : int((x)-0.5))
|
||||
|
||||
#define getTPage(tp, abr, x, y) ((((tp)&0x3) << 7) | (((abr)&0x3) << 5) | (((y)&0x100) >> 4) | (((x)&0x3ff) >> 6) | (((y)&0x200) << 2))
|
||||
|
||||
#define getClut(x, y) ((y << 6) | ((x >> 4) & 0x3f))
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // __PSX_PcDefines_H__
|
||||
542
engines/icb/gfx/psx_pcgpu.cpp
Normal file
542
engines/icb/gfx/psx_pcgpu.cpp
Normal file
@@ -0,0 +1,542 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
#include "engines/icb/gfx/psx_pcgpu.h"
|
||||
#include "engines/icb/gfx/psx_poly.h"
|
||||
#include "engines/icb/gfx/gfxstub.h"
|
||||
|
||||
#include "common/textconsole.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// Defaults for the OT list
|
||||
#define UNLINKED_ADDR (reinterpret_cast<void *>(static_cast<uintptr>(0xDEADBEAF)))
|
||||
#define UNLINKED_LEN (0x6666)
|
||||
|
||||
// For storing user data in the OT entry e.g. texture pointer
|
||||
void *OTusrData;
|
||||
|
||||
// No ABR support : at the moment
|
||||
uint16 psxTP;
|
||||
|
||||
// The emulation of VRAM : 16-bit pixels 1024x512 big
|
||||
uint16 psxVRAM[VRAM_WIDTH * VRAM_HEIGHT];
|
||||
|
||||
// Set VRAM to a certain colour
|
||||
int32 ClearImage(RECT16 *rect, uint8 r, uint8 g, uint8 b) {
|
||||
uint16 colour;
|
||||
int32 x, y;
|
||||
int32 i;
|
||||
|
||||
// Convert 24-bit colour to 15-bit
|
||||
colour = (uint16)((r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10));
|
||||
|
||||
for (y = rect->y; y < rect->y + rect->h; y++) {
|
||||
for (x = rect->x; x < rect->x + rect->w; x++) {
|
||||
i = x + y * VRAM_WIDTH;
|
||||
psxVRAM[i] = colour;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Fill VRAM with data
|
||||
uint16 LoadClut(uint32 *clut, int32 x, int32 y) {
|
||||
RECT16 rect;
|
||||
setRECT(&rect, (int16)x, (int16)y, 256, 1);
|
||||
LoadImage(&rect, clut);
|
||||
return (uint16)getClut(x, y);
|
||||
}
|
||||
|
||||
// Fill VRAM with data
|
||||
int32 LoadImage(RECT16 *rect, uint32 *p) {
|
||||
int32 x, y, i;
|
||||
uint16 *p16 = (uint16 *)p;
|
||||
|
||||
for (y = rect->y; y < rect->y + rect->h; y++) {
|
||||
for (x = rect->x; x < rect->x + rect->w; x++) {
|
||||
i = x + y * VRAM_WIDTH;
|
||||
psxVRAM[i] = *p16;
|
||||
p16++;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Move data around within VRAM
|
||||
int32 MoveImage(RECT16 *rect, int32 x, int32 y) {
|
||||
int32 x0, y0, i0;
|
||||
int32 x1, y1, i1;
|
||||
|
||||
y1 = y;
|
||||
for (y0 = rect->y; y0 < rect->y + rect->h; y0++) {
|
||||
x1 = x;
|
||||
for (x0 = rect->x; x0 < rect->x + rect->w; x0++) {
|
||||
i0 = x0 + y0 * VRAM_WIDTH;
|
||||
i1 = x1 + y1 * VRAM_WIDTH;
|
||||
psxVRAM[i1] = psxVRAM[i0];
|
||||
x1++;
|
||||
}
|
||||
y1++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Setup the linked list for the OT tags from back to the front
|
||||
OT_tag *ClearOTagR(OT_tag *ot, uint32 size) {
|
||||
int32 i = size - 1;
|
||||
while (i > 0) {
|
||||
ot[i].addr = (void *)&ot[i - 1];
|
||||
ot[i].len = UNLINKED_LEN;
|
||||
i--;
|
||||
}
|
||||
ot[0].addr = UNLINKED_ADDR;
|
||||
ot[0].len = UNLINKED_LEN;
|
||||
return ot;
|
||||
}
|
||||
|
||||
// Setup the linked list for the OT tags from front to back
|
||||
OT_tag *ClearOTag(OT_tag *ot, uint32 size) {
|
||||
uint32 i = 0;
|
||||
while (i < (size - 1)) {
|
||||
ot[i].addr = (void *)&ot[i + 1];
|
||||
ot[i].len = UNLINKED_LEN;
|
||||
|
||||
i++;
|
||||
}
|
||||
ot[size - 1].addr = UNLINKED_ADDR;
|
||||
ot[size - 1].len = UNLINKED_LEN;
|
||||
return ot;
|
||||
}
|
||||
|
||||
int32 nPrims;
|
||||
|
||||
// Draw the damm things
|
||||
void DrawOTag(OT_tag *ot) {
|
||||
OT_tag *prim = ot;
|
||||
nPrims = 0;
|
||||
|
||||
while (prim->addr != UNLINKED_ADDR) {
|
||||
if (prim->len != UNLINKED_LEN) {
|
||||
DrawPrim((void *)prim);
|
||||
}
|
||||
// Move to the next link in the chain
|
||||
prim = (OT_tag *)(prim->addr);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the base primitive
|
||||
|
||||
// Should also be checking the lengths to make sure we haven't
|
||||
// got corrupt data
|
||||
void DrawPrim(void *prim) {
|
||||
P_TAG *p = (P_TAG *)prim;
|
||||
uint32 code = p->code;
|
||||
uint32 len = p->len;
|
||||
uint16 z0 = p->z0;
|
||||
void *usr = p->usr;
|
||||
uint8 alpha = 0x00;
|
||||
|
||||
// Catch special primitives
|
||||
// DR_TPAGE
|
||||
if ((code & 0xe1) == 0xe1) {
|
||||
psxTP = (uint16)(*((uint32 *)&(p->r0)) & 0xFFFF);
|
||||
len -= GPUSIZE_DR_TPAGE; // we have used one word of data up
|
||||
// Move the pointer onto the correct place
|
||||
p++; // move past the P_TAG
|
||||
|
||||
// handle multiple primitives in one block
|
||||
code = p->code;
|
||||
if (len > 0) {
|
||||
len -= GPUSIZE_TAG;
|
||||
}
|
||||
|
||||
// Get the base alpha value
|
||||
alpha = ((P_HEADER *)(p))->code;
|
||||
// Modify that based on tbe ABR value
|
||||
uint8 abr = (uint8)((psxTP >> 5) & 0x3);
|
||||
if (abr == 0) {
|
||||
// alpha is 0-64, so 32 is average
|
||||
alpha = 0xC0 | 0x20; // average of background + foreground
|
||||
} else if (abr == 1)
|
||||
alpha = 0x40; // additive
|
||||
else if (abr == 2)
|
||||
alpha = 0x80; // subtractive
|
||||
else if (abr == 3)
|
||||
// alpha is 0-64 : no error checking
|
||||
alpha |= 0xC0; // alpha blend
|
||||
else
|
||||
alpha = 0x00; // ignore any other modes
|
||||
}
|
||||
|
||||
nPrims++;
|
||||
// Decode the primitive type and then respond appropiately
|
||||
// Mask off the primitive modifiers (bottom two bits)
|
||||
// bit 0 = shade text
|
||||
// bit 1 = semi-trans
|
||||
switch (code & 0xFC) {
|
||||
// Flat Coloured Rectangle
|
||||
// TILE: code:0x60 length:4
|
||||
case GPUCODE_TILE: {
|
||||
TILE *pr = (TILE *)p;
|
||||
if (len != GPUSIZE_TILE) {
|
||||
warning("Primitive %p length %d != TILE length %d\n", prim, (uint32)len, GPUSIZE_TILE);
|
||||
return;
|
||||
}
|
||||
DrawTile(pr->x0, pr->y0, pr->w, pr->h, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Rectangle 1 pixel width & height
|
||||
// TILE_1: code:0x68 length:3
|
||||
case GPUCODE_TILE_1: {
|
||||
TILE_1 *pr = (TILE_1 *)p;
|
||||
if (len != GPUSIZE_TILE_1) {
|
||||
warning("Primitive %p length %d != TILE_1 length %d\n", prim, (uint32)len, GPUSIZE_TILE_1);
|
||||
return;
|
||||
}
|
||||
DrawTile(pr->x0, pr->y0, 1, 1, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Rectangle 8 pixel width & height
|
||||
// TILE_8: code:0x70 length:3
|
||||
case GPUCODE_TILE_8: {
|
||||
TILE_8 *pr = (TILE_8 *)p;
|
||||
if (len != GPUSIZE_TILE_8) {
|
||||
warning("Primitive %p length %d != TILE_8 length %d\n", prim, (uint32)len, GPUSIZE_TILE_8);
|
||||
return;
|
||||
}
|
||||
DrawTile(pr->x0, pr->y0, 8, 8, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Rectangle 16 pixel width & height
|
||||
// TILE_16: code:0x78 length:3
|
||||
case GPUCODE_TILE_16: {
|
||||
TILE_16 *pr = (TILE_16 *)p;
|
||||
if (len != GPUSIZE_TILE_16) {
|
||||
warning("Primitive %p length %d != TILE_16 length %d\n", prim, (uint32)len, GPUSIZE_TILE_16);
|
||||
return;
|
||||
}
|
||||
DrawTile(pr->x0, pr->y0, 16, 16, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured single line
|
||||
// LineF2 = code: 0x40 length:4
|
||||
case GPUCODE_LINE_F2: {
|
||||
LINE_F2 *pr = (LINE_F2 *)p;
|
||||
if (len != GPUSIZE_LINE_F2) {
|
||||
warning("Primitive %p length %d != LineF2 length %d\n", prim, (uint32)len, GPUSIZE_LINE_F2);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "LineF2: (%d,%d) (%d,%d) RGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
DrawLineF2(pr->x0, pr->y0, pr->x1, pr->y1, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured double line (not closed)
|
||||
// LineF3 = code: 0x48 length:6
|
||||
case GPUCODE_LINE_F3: {
|
||||
LINE_F3 *pr = (LINE_F3 *)p;
|
||||
if (len != GPUSIZE_LINE_F3) {
|
||||
warning("Primitive %p length %d != LineF3 length %d\n", prim, (uint32)len, GPUSIZE_LINE_F3);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "LineF3: (%d,%d) (%d,%d) (%d,%d) RGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2,
|
||||
pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
DrawLineF3(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured triple line (not closed)
|
||||
// LineF4 = code: 0x4c length:7
|
||||
case GPUCODE_LINE_F4: {
|
||||
LINE_F4 *pr = (LINE_F4 *)p;
|
||||
if (len != GPUSIZE_LINE_F4) {
|
||||
warning("Primitive %p length %d != LineF4 length %d\n", prim, (uint32)len, GPUSIZE_LINE_F4);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "LineF4: (%d,%d) (%d,%d) (%d,%d) (%d %d) RGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->x2, pr->y2, pr->x3, pr->y3,
|
||||
pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
DrawLineF4(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->x3, pr->y3, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
|
||||
// Gouraud Coloured single line
|
||||
// LineG2 = code: 0x50 length:5
|
||||
case GPUCODE_LINE_G2: {
|
||||
LINE_G2 *pr = (LINE_G2 *)p;
|
||||
if (len != GPUSIZE_LINE_G2) {
|
||||
warning("Primitive %p length %d != LineG2 length %d\n", prim, (uint32)len, GPUSIZE_LINE_G2);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "LineG2: (%d,%d) (%d,%d) RGB0:%d %d %d RGB1:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1 );
|
||||
*/
|
||||
DrawLineG2(pr->x0, pr->y0, pr->x1, pr->y1, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Gouraud Coloured double line (not closed)
|
||||
// LineG3 = code: 0x58 length:8
|
||||
case GPUCODE_LINE_G3: {
|
||||
LINE_G3 *pr = (LINE_G3 *)p;
|
||||
if (len != GPUSIZE_LINE_G3) {
|
||||
warning("Primitive %p length %d != LineG3 length %d\n", prim, (uint32)len, GPUSIZE_LINE_G3);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "LineG3: (%d,%d) (%d,%d) (%d,%d) RGB0:%d %d %d RGB1:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2,
|
||||
pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1 );
|
||||
*/
|
||||
DrawLineG3(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, pr->r2, pr->g2, pr->b2, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Gouraud Coloured triple line (not closed)
|
||||
// LineG4 = code: 0x5c length:10
|
||||
case GPUCODE_LINE_G4: {
|
||||
LINE_G4 *pr = (LINE_G4 *)p;
|
||||
if (len != GPUSIZE_LINE_G4) {
|
||||
warning("Primitive %p length %d != LineG4 length %d\n", prim, (uint32)len, GPUSIZE_LINE_G4);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "LineG4: (%d,%d) (%d,%d) (%d,%d) (%d %d) \
|
||||
RGB0:%d %d %d RGB1:%d %d %d RGB2:%d %d %d RGB3:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->x2, pr->y2, pr->x3, pr->y3,
|
||||
pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1,
|
||||
pr->r2, pr->g2, pr->b2, pr->r3, pr->g3, pr->b3 );
|
||||
*/
|
||||
DrawLineG4(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->x3, pr->y3, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, pr->r2, pr->g2, pr->b2, pr->r3, pr->g3,
|
||||
pr->b3, alpha, z0);
|
||||
break;
|
||||
}
|
||||
|
||||
// Flat Coloured Non-textured triangle
|
||||
// PolyF3 = code:0x20 length:5
|
||||
case GPUCODE_POLY_F3: {
|
||||
POLY_F3 *pr = (POLY_F3 *)p;
|
||||
if (len != GPUSIZE_POLY_F3) {
|
||||
warning("Primitive %p length %d != PolyF3 length %d\n", prim, (uint32)len, GPUSIZE_POLY_F3);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyF3: (%d,%d) (%d,%d) (%d,%d) RGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2,
|
||||
pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
DrawFlatTriangle(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
|
||||
// Flat Coloured Non-textured quad
|
||||
// PolyF4 = code:0x28 length:6
|
||||
case GPUCODE_POLY_F4: {
|
||||
POLY_F4 *pr = (POLY_F4 *)p;
|
||||
if (len != GPUSIZE_POLY_F4) {
|
||||
warning("Primitive %p length %d != PolyF4 length %d\n", prim, (uint32)len, GPUSIZE_POLY_F4);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyF4: (%d,%d) (%d,%d) (%d,%d) (%d %d) RGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->x2, pr->y2, pr->x3, pr->y3,
|
||||
pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
DrawFlatQuad(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->x3, pr->y3, pr->r0, pr->g0, pr->b0, alpha, z0);
|
||||
break;
|
||||
}
|
||||
|
||||
// Gouraud Coloured Non-textured triangle
|
||||
// PolyG3 = code:0x30 length:7
|
||||
case GPUCODE_POLY_G3: {
|
||||
POLY_G3 *pr = (POLY_G3 *)p;
|
||||
if (len != GPUSIZE_POLY_G3) {
|
||||
warning("Primitive %p length %d != PolyG3 length %d\n", prim, (uint32)len, GPUSIZE_POLY_G3);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyG3: (%d,%d) (%d,%d) (%d,%d) \
|
||||
RGB0:%d %d %d RGB1:%d %d %d RGB2:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2,
|
||||
pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1,
|
||||
pr->r2, pr->g2, pr->b2 );
|
||||
*/
|
||||
DrawGouraudTriangle(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, pr->r2, pr->g2, pr->b2, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Gouraud Coloured Non-textured quad
|
||||
// PolyG4 = code:0x38 length:9
|
||||
case GPUCODE_POLY_G4: {
|
||||
POLY_G4 *pr = (POLY_G4 *)p;
|
||||
if (len != GPUSIZE_POLY_G4) {
|
||||
warning("Primitive %p length %d != PolyG4 length %d\n", prim, (uint32)len, GPUSIZE_POLY_G4);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyG4: (%d,%d) (%d,%d) (%d,%d) (%d %d) \
|
||||
RGB0:%d %d %d RGB1:%d %d %d RGB2:%d %d %d RGB3:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->x2, pr->y2, pr->x3, pr->y3,
|
||||
pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1,
|
||||
pr->r2, pr->g2, pr->b2, pr->r3, pr->g3, pr->b3 );
|
||||
*/
|
||||
DrawGouraudQuad(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->x3, pr->y3, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, pr->r2, pr->g2, pr->b2, pr->r3,
|
||||
pr->g3, pr->b3, alpha, z0);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Textured triangle
|
||||
// PolyFT3 = code:0x24 length:8
|
||||
case GPUCODE_POLY_FT3: {
|
||||
POLY_FT3 *pr = (POLY_FT3 *)p;
|
||||
if (len != GPUSIZE_POLY_FT3) {
|
||||
warning("Primitive %p length %d != PolyFT3 length %d\n", prim, (uint32)len, GPUSIZE_POLY_FT3);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyFT3: (%d,%d) (%d,%d) (%d,%d)\n(%d,%d) (%d,%d) (%d,%d)\nRGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2,
|
||||
pr->u0, pr->v0, pr->u1, pr->v1, pr->u2, pr->v2,
|
||||
pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
DrawFlatTriangleTextured(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->r0, pr->g0, pr->b0, pr->u0, pr->v0, pr->u1, pr->v1, pr->u2, pr->v2, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Textured quad
|
||||
// PolyFT4 = code:0x2c length:10
|
||||
case GPUCODE_POLY_FT4: {
|
||||
POLY_FT4 *pr = (POLY_FT4 *)p;
|
||||
if (len != GPUSIZE_POLY_FT4) {
|
||||
warning("Primitive %p length %d != PolyFT4 length %d\n", prim, (uint32)len, GPUSIZE_POLY_FT4);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyFT4: (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n(%d,%d) (%d,%d) (%d,%d) (%d,%d)\nRGB0:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->x2, pr->y2, pr->x3, pr->y3,
|
||||
pr->u0, pr->v0, pr->u1, pr->v1,
|
||||
pr->u2, pr->u2, pr->u3, pr->u3,
|
||||
pr->r0, pr->g0, pr->b0 );
|
||||
*/
|
||||
|
||||
DrawFlatQuadTextured(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->x3, pr->y3, pr->r0, pr->g0, pr->b0, pr->u0, pr->v0, pr->u1, pr->v1, pr->u2, pr->v2, pr->u3,
|
||||
pr->v3, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
// Gouraud Coloured Textured triangle
|
||||
// PolyGT3 = code:0x34 length:10
|
||||
case GPUCODE_POLY_GT3: {
|
||||
POLY_GT3 *pr = (POLY_GT3 *)p;
|
||||
if (len != GPUSIZE_POLY_GT3) {
|
||||
warning("Primitive %p length %d != PolyGT3 length %d\n", prim, (uint32)len, GPUSIZE_POLY_GT3);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyGT3: (%d,%d) (%d,%d) (%d,%d)\n(%d,%d) (%d,%d) (%d,%d)\nRGB0:%d %d %d RGB1:%d %d %d RGB2:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2,
|
||||
pr->u0, pr->v0, pr->u1, pr->v1, pr->u2, pr->v2,
|
||||
pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1,
|
||||
pr->r2, pr->g2, pr->b2 );
|
||||
*/
|
||||
|
||||
DrawGouraudTriangleTextured(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, pr->r2, pr->g2, pr->b2, pr->u0, pr->v0,
|
||||
pr->u1, pr->v1, pr->u2, pr->v2, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
// Gouraud Coloured Textured quad
|
||||
// PolyGT4 = code:0x3c length:13
|
||||
case GPUCODE_POLY_GT4: {
|
||||
POLY_GT4 *pr = (POLY_GT4 *)p;
|
||||
if (len != GPUSIZE_POLY_GT4) {
|
||||
warning("Primitive %p length %d != PolyGT4 length %d\n", prim, (uint32)len, GPUSIZE_POLY_GT4);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf( "PolyGT4: (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n(%d,%d) (%d,%d) (%d,%d) (%d,%d)\nRGB0:%d %d %d RGB1:%d %d %d RGB2:%d %d $d RGB3:%d %d %d\n",
|
||||
pr->x0, pr->y0, pr->x1, pr->y1,
|
||||
pr->x2, pr->y2, pr->x3, pr->y3,
|
||||
pr->u0, pr->v0, pr->u1, pr->v1,
|
||||
pr->u2, pr->u2, pr->u3, pr->u3,
|
||||
pr->r0, pr->g0, pr->b0,
|
||||
pr->r1, pr->g1, pr->b1,
|
||||
pr->r2, pr->g2, pr->b2,
|
||||
pr->r3, pr->g3, pr->b3 );
|
||||
*/
|
||||
DrawGouraudQuadTextured(pr->x0, pr->y0, pr->x1, pr->y1, pr->x2, pr->y2, pr->x3, pr->y3, pr->r0, pr->g0, pr->b0, pr->r1, pr->g1, pr->b1, pr->r2, pr->g2, pr->b2,
|
||||
pr->r3, pr->g3, pr->b3, pr->u0, pr->v0, pr->u1, pr->v1, pr->u2, pr->v2, pr->u3, pr->v3, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Textured Tile
|
||||
// SPRT = code:0x64 length:5
|
||||
case GPUCODE_SPRT: {
|
||||
SPRT *pr = (SPRT *)p;
|
||||
if (len != GPUSIZE_SPRT) {
|
||||
warning("Primitive %p length %d != SPRT length %d\n", prim, (uint32)len, GPUSIZE_SPRT);
|
||||
return;
|
||||
}
|
||||
DrawSprite(pr->x0, pr->y0, pr->w, pr->h, pr->r0, pr->g0, pr->b0, pr->u0, pr->v0, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Textured Tile 8 pixels x 8 pixels
|
||||
// SPRT_8 = code:0x74 length:4
|
||||
case GPUCODE_SPRT_8: {
|
||||
SPRT_8 *pr = (SPRT_8 *)p;
|
||||
if (len != GPUSIZE_SPRT_8) {
|
||||
warning("Primitive %p length %d != SPRT_8 length %d\n", prim, (uint32)len, GPUSIZE_SPRT_8);
|
||||
return;
|
||||
}
|
||||
DrawSprite(pr->x0, pr->y0, 8, 8, pr->r0, pr->g0, pr->b0, pr->u0, pr->v0, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
// Flat Coloured Textured Tile 16 pixels x 16 pixels
|
||||
// SPRT_16 = code:0x7c length:4
|
||||
case GPUCODE_SPRT_16: {
|
||||
SPRT_16 *pr = (SPRT_16 *)p;
|
||||
if (len != GPUSIZE_SPRT_16) {
|
||||
warning("Primitive %p length %d != SPRT_16 length %d\n", prim, (uint32)len, GPUSIZE_SPRT_16);
|
||||
return;
|
||||
}
|
||||
DrawSprite(pr->x0, pr->y0, 16, 16, pr->r0, pr->g0, pr->b0, pr->u0, pr->v0, alpha, z0, usr);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
warning("Unknown Primitive\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
628
engines/icb/gfx/psx_pcgpu.h
Normal file
628
engines/icb/gfx/psx_pcgpu.h
Normal file
@@ -0,0 +1,628 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_LIBGPU_H_
|
||||
#define ICB_LIBGPU_H_
|
||||
|
||||
namespace ICB {
|
||||
|
||||
|
||||
// For storing user data in the OT entry e.g. texture pointer
|
||||
extern void *OTusrData;
|
||||
|
||||
#define OTSetUser(usr) OTusrData = (usr)
|
||||
|
||||
// For choosing which texture to store in the OT list
|
||||
#define ChooseTexture(texture) OTSetUser((texture))
|
||||
|
||||
/*
|
||||
* Primitive list:
|
||||
*
|
||||
* Name |Size*1|Shade |Vertex |Texture| Function
|
||||
* ---------+------+-------+-------+-------+------------------------
|
||||
* POLY_F3 | 6 |Flat | 3 |OFF | Flat Triangle
|
||||
* POLY_FT3 | 9 |Flat | 3 |ON | Flat Textured Triangle
|
||||
* POLY_G3 | 8 |Gouraud| 3 |OFF | Gouraud Triangle
|
||||
* POLY_GT3 |11 |Gouraud| 3 |ON | Gouraud Textured Triangle
|
||||
* POLY_F4 | 7 |Flat | 4 |OFF | Flat Quadrangle
|
||||
* POLY_FT4 |11 |Flat | 4 |ON | Flat Textured Quadrangle
|
||||
* POLY_G4 |10 |Gouraud| 4 |OFF | Gouraud Quadrangle
|
||||
* POLY_GT4 |14 |Gouraud| 4 |ON | Gouraud Textured Quadrangle
|
||||
* ---------+------+-------+-------+-------+------------------------
|
||||
* LINE_F2 | 5 |Flat | 2 | - | unconnected Flat Line
|
||||
* LINE_G2 | 6 |Gouraud| 2 | - | unconnected Gouraud Line
|
||||
* LINE_F3 | 7 |Flat | 3 | - | 3-connected Flat Line
|
||||
* LINE_G3 | 9 |Gouraud| 3 | - | 3-connected Gouraud Line
|
||||
* LINE_F4 | 8 |Flat | 4 | - | 4-connected Flat Line
|
||||
* LINE_G4 |11 |Gouraud| 4 | - | 4-connected Gouraud Line
|
||||
* ---------+------+-------+-------+-------+------------------------
|
||||
* SPRT | 6 |Flat | 1 |ON | free size Sprite
|
||||
* SPRT_16 | 5 |Flat | 1 |ON | 16x16 Sprite
|
||||
* SPRT_8 | 5 |Flat | 1 |ON | 8x8 Sprite
|
||||
* ---------+------+-------+-------+-------+------------------------
|
||||
* TILE | 5 |Flat | 1 |OFF | free size Sprite
|
||||
* TILE_16 | 4 |Flat | 1 |OFF | 16x16 Sprite
|
||||
* TILE_8 | 4 |Flat | 1 |OFF | 8x8 Sprite
|
||||
* TILE_1 | 4 |Flat | 1 |OFF | 1x1 Sprite
|
||||
* ---------+------+-------+-------+-------+------------------------
|
||||
* DR_TWIN | 3 | - | - | - | Texture Window
|
||||
* DR_AREA | 3 | - | - | - | Drawing Area
|
||||
* DR_OFFSET| 3 | - | - | - | Drawing Offset
|
||||
* DR_MODE | 3 | - | - | - | Drawing Mode
|
||||
* DR_ENV |16 | - | - | - | Drawing Environment
|
||||
* DR_MOVE | 6 | - | - | - | MoveImage
|
||||
* DR_LOAD |17 | - | - | - | LoadImage
|
||||
* DR_TPAGE | 2 | - | - | - | Drawing TPage
|
||||
* DR_STP | 3 | - | - | - | Drawing STP
|
||||
*
|
||||
* *1: in int32-word
|
||||
*
|
||||
* Texture Attributes:
|
||||
* abr: ambient rate
|
||||
* abr 0 1 2 3
|
||||
* -------------------------------------
|
||||
* Front 0.5 1.0 0.5 -1.0
|
||||
* Back 0.5 1.0 1.0 1.0
|
||||
*
|
||||
* tp: texture mode
|
||||
* tp 0 1 2
|
||||
* -----------------------------
|
||||
* depth 4bit 8bit 16bit
|
||||
* color CLUT CLUT DIRECT
|
||||
*/
|
||||
|
||||
/*
|
||||
* Time-out Cycle
|
||||
*/
|
||||
#define WAIT_TIME 0x800000
|
||||
|
||||
/*
|
||||
* General Macros
|
||||
*/
|
||||
#define limitRange(x, l, h) ((x) = ((x) < (l) ? (l) : (x) > (h) ? (h) : (x)))
|
||||
|
||||
/*
|
||||
* Set/Add Vector/Rectangle Attributes
|
||||
*/
|
||||
#define setVector(v, _x, _y, _z) (v)->vx = _x, (v)->vy = _y, (v)->vz = _z
|
||||
|
||||
#define applyVector(v, _x, _y, _z, op) (v)->vx op _x, (v)->vy op _y, (v)->vz op _z
|
||||
|
||||
#define copyVector(v0, v1) (v0)->vx = (v1)->vx, (v0)->vy = (v1)->vy, (v0)->vz = (v1)->vz
|
||||
|
||||
#define addVector(v0, v1) (v0)->vx += (v1)->vx, (v0)->vy += (v1)->vy, (v0)->vz += (v1)->vz
|
||||
|
||||
#define dumpVector(str, v) GPU_printf("%s=(%d,%d,%d)\n", str, (v)->vx, (v)->vy, (v)->vz)
|
||||
|
||||
#define dumpMatrix(x) \
|
||||
GPU_printf("\t%5d,%5d,%5d\n", (x)->m[0][0], (x)->m[0][1], (x)->m[0][2]), GPU_printf("\t%5d,%5d,%5d\n", (x)->m[1][0], (x)->m[1][1], (x)->m[1][2]), \
|
||||
GPU_printf("\t%5d,%5d,%5d\n", (x)->m[2][0], (x)->m[2][1], (x)->m[2][2])
|
||||
|
||||
#define setRECT(r, _x, _y, _w, _h) (r)->x = (_x), (r)->y = (_y), (r)->w = (_w), (r)->h = (_h)
|
||||
|
||||
/*
|
||||
* Set Primitive Attributes
|
||||
*/
|
||||
#define setTPage(p, tp, abr, x, y) ((p)->tpage = getTPage(tp, abr, x, y))
|
||||
|
||||
#define setClut(p, x, y) ((p)->clut = getClut(x, y))
|
||||
|
||||
/*
|
||||
* Set Primitive Colors
|
||||
*/
|
||||
#define setRGB0(p, _r0, _g0, _b0) (p)->r0 = _r0, (p)->g0 = _g0, (p)->b0 = _b0
|
||||
|
||||
#define setRGB1(p, _r1, _g1, _b1) (p)->r1 = _r1, (p)->g1 = _g1, (p)->b1 = _b1
|
||||
|
||||
#define setRGB2(p, _r2, _g2, _b2) (p)->r2 = _r2, (p)->g2 = _g2, (p)->b2 = _b2
|
||||
|
||||
#define setRGB3(p, _r3, _g3, _b3) (p)->r3 = _r3, (p)->g3 = _g3, (p)->b3 = _b3
|
||||
|
||||
/*
|
||||
* Set Primitive Screen Points
|
||||
*/
|
||||
#define setXY0(p, _x0, _y0) (p)->x0 = (_x0), (p)->y0 = (_y0)
|
||||
|
||||
#define setXY2(p, _x0, _y0, _x1, _y1) (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1)
|
||||
|
||||
#define setXY3(p, _x0, _y0, _x1, _y1, _x2, _y2) (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1), (p)->x2 = (_x2), (p)->y2 = (_y2)
|
||||
|
||||
#define setXY4(p, _x0, _y0, _x1, _y1, _x2, _y2, _x3, _y3) \
|
||||
(p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1), (p)->x2 = (_x2), (p)->y2 = (_y2), (p)->x3 = (_x3), (p)->y3 = (_y3)
|
||||
|
||||
#define setXYWH(p, _x0, _y0, _w, _h) \
|
||||
(p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x0) + (_w), (p)->y1 = (_y0), (p)->x2 = (_x0), (p)->y2 = (_y0) + (_h), (p)->x3 = (_x0) + (_w), (p)->y3 = (_y0) + (_h)
|
||||
|
||||
/*
|
||||
* Set Primitive Width/Height
|
||||
*/
|
||||
#define setWH(p, _w, _h) (p)->w = _w, (p)->h = _h
|
||||
|
||||
/*
|
||||
* Set Primitive Texture Points
|
||||
*/
|
||||
#define setUV0(p, _u0, _v0) (p)->u0 = (_u0), (p)->v0 = (_v0)
|
||||
|
||||
#define setUV3(p, _u0, _v0, _u1, _v1, _u2, _v2) (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u1), (p)->v1 = (_v1), (p)->u2 = (_u2), (p)->v2 = (_v2)
|
||||
|
||||
#define setUV4(p, _u0, _v0, _u1, _v1, _u2, _v2, _u3, _v3) \
|
||||
(p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u1), (p)->v1 = (_v1), (p)->u2 = (_u2), (p)->v2 = (_v2), (p)->u3 = (_u3), (p)->v3 = (_v3)
|
||||
|
||||
#define setUVWH(p, _u0, _v0, _w, _h) \
|
||||
(p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u0) + (_w), (p)->v1 = (_v0), (p)->u2 = (_u0), (p)->v2 = (_v0) + (_h), (p)->u3 = (_u0) + (_w), (p)->v3 = (_v0) + (_h)
|
||||
|
||||
/*
|
||||
* Primitive Handling Macros
|
||||
*/
|
||||
#define setusr(p, _usr) (((P_TAG *)(p))->usr = (void *)(_usr))
|
||||
#define setz(p, _z) (((P_TAG *)(p))->z0 = (uint16)(_z))
|
||||
#define setlen(p, _len) (((P_TAG *)(p))->len = (uint8)(_len))
|
||||
#define setaddr(p, _addr) (((P_TAG *)(p))->addr = (void *)(_addr))
|
||||
#define setcode(p, _code) (((P_TAG *)(p))->code = (uint8)(_code))
|
||||
|
||||
#define getlen(p) (uint8)(((P_TAG *)(p))->len)
|
||||
#define getcode(p) (uint8)(((P_TAG *)(p))->code)
|
||||
#define getaddr(p) (void *)(((P_TAG *)(p))->addr)
|
||||
|
||||
#define nextPrim(p) (void *)(((P_TAG *)(p))->addr)
|
||||
#define isendprim(p) ((((P_TAG *)(p))->addr) == (void *)UINTPTR_MAX)
|
||||
|
||||
#define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p), setz(p, 0), setusr(p, 0)
|
||||
#define addPrimZ(ot, p, z0) setaddr(p, getaddr(ot)), setaddr(ot, p), setz(p, z0), setusr(p, 0)
|
||||
#define addPrimZUsr(ot, p, z0, usr) setaddr(p, getaddr(ot)), setaddr(ot, p), setz(p, z0), setusr(p, usr)
|
||||
#define addPrims(ot, p0, p1) setaddr(p1, getaddr(ot)), setaddr(ot, p0)
|
||||
|
||||
#define catPrim(p0, p1) setaddr(p0, p1)
|
||||
#define termPrim(p) setaddr(p, (void *)UINTPTR_MAX)
|
||||
|
||||
#define setSemiTrans(p, abe) ((abe) ? setcode(p, getcode(p) | 0x02) : setcode(p, getcode(p) & ~0x02))
|
||||
|
||||
#define setShadeTex(p, tge) ((tge) ? setcode(p, getcode(p) | 0x01) : setcode(p, getcode(p) & ~0x01))
|
||||
|
||||
#define getTPage(tp, abr, x, y) ((((tp)&0x3) << 7) | (((abr)&0x3) << 5) | (((y)&0x100) >> 4) | (((x)&0x3ff) >> 6) | (((y)&0x200) << 2))
|
||||
|
||||
#define getClut(x, y) ((y << 6) | ((x >> 4) & 0x3f))
|
||||
|
||||
#define dumpTPage(tpage) \
|
||||
GPU_printf("tpage: (%d,%d,%d,%d)\n", ((tpage) >> 7) & 0x003, ((tpage) >> 5) & 0x003, ((tpage) << 6) & 0x7c0, (((tpage) << 4) & 0x100) + (((tpage) >> 2) & 0x200))
|
||||
|
||||
#define dumpClut(clut) GPU_printf("clut: (%d,%d)\n", (clut & 0x3f) << 4, (clut >> 6))
|
||||
|
||||
#define _get_mode(dfe, dtd, tpage) ((0xe1000000) | ((dtd) ? 0x0200 : 0) | ((dfe) ? 0x0400 : 0) | ((tpage)&0x9ff))
|
||||
|
||||
#define setDrawTPage(p, dfe, dtd, tpage) setlen(p, 1), ((uint32 *)(p))[2] = _get_mode(dfe, dtd, tpage)
|
||||
|
||||
#define _get_tw(tw) \
|
||||
(tw ? ((0xe2000000) | ((((tw)->y & 0xff) >> 3) << 15) | ((((tw)->x & 0xff) >> 3) << 10) | (((~((tw)->h - 1) & 0xff) >> 3) << 5) | (((~((tw)->w - 1) & 0xff) >> 3))) : 0)
|
||||
|
||||
#define setTexWindow(p, tw) setlen(p, 2), ((uint32 *)(p))[1] = _get_tw(tw), ((uint32 *)(p))[2] = 0
|
||||
|
||||
#define _get_len(rect) (((rect)->w * (rect)->h + 1) / 2 + 4)
|
||||
|
||||
#define setDrawLoad(pt, rect) \
|
||||
(_get_len(rect) <= 16) ? ((setlen(pt, _get_len(rect))), ((pt)->code[0] = 0xa0000000), ((pt)->code[1] = *((uint32 *)&(rect)->x)), \
|
||||
((pt)->code[2] = *((uint32 *)&(rect)->w)), ((pt)->p[_get_len(rect) - 4] = 0x01000000)) \
|
||||
: ((setlen(pt, 0)))
|
||||
|
||||
/* Primitive Lentgh Code */
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* */
|
||||
#define setPolyF3(p) setlen(p, 4 + 3), setcode(p, 0x20)
|
||||
#define setPolyFT3(p) setlen(p, 7 + 3), setcode(p, 0x24)
|
||||
#define setPolyG3(p) setlen(p, 6 + 3), setcode(p, 0x30)
|
||||
#define setPolyGT3(p) setlen(p, 9 + 3), setcode(p, 0x34)
|
||||
#define setPolyF4(p) setlen(p, 5 + 4), setcode(p, 0x28)
|
||||
#define setPolyFT4(p) setlen(p, 9 + 4), setcode(p, 0x2c)
|
||||
#define setPolyG4(p) setlen(p, 8 + 4), setcode(p, 0x38)
|
||||
#define setPolyGT4(p) setlen(p, 12 + 4), setcode(p, 0x3c)
|
||||
|
||||
#define setSprt8(p) setlen(p, 3 + 1), setcode(p, 0x74)
|
||||
#define setSprt16(p) setlen(p, 3 + 1), setcode(p, 0x7c)
|
||||
#define setSprt(p) setlen(p, 4 + 1), setcode(p, 0x64)
|
||||
|
||||
#define setTile1(p) setlen(p, 2 + 1), setcode(p, 0x68)
|
||||
#define setTile8(p) setlen(p, 2 + 1), setcode(p, 0x70)
|
||||
#define setTile16(p) setlen(p, 2 + 1), setcode(p, 0x78)
|
||||
#define setTile(p) setlen(p, 3 + 1), setcode(p, 0x60)
|
||||
#define setLineF2(p) setlen(p, 3 + 2), setcode(p, 0x40)
|
||||
#define setLineG2(p) setlen(p, 4 + 2), setcode(p, 0x50)
|
||||
#define setLineF3(p) setlen(p, 5 + 3), setcode(p, 0x48), (p)->pad = 0x55555555
|
||||
#define setLineG3(p) setlen(p, 7 + 3), setcode(p, 0x58), (p)->pad = 0x55555555, (p)->p2 = 0
|
||||
#define setLineF4(p) setlen(p, 6 + 4), setcode(p, 0x4c), (p)->pad = 0x55555555
|
||||
#define setLineG4(p) setlen(p, 9 + 4), setcode(p, 0x5c), (p)->pad = 0x55555555, (p)->p2 = 0, (p)->p3 = 0
|
||||
|
||||
/*
|
||||
* Rectangle:
|
||||
*/
|
||||
typedef struct {
|
||||
int16 x, y; /* offset point on VRAM */
|
||||
int16 w, h; /* width and height */
|
||||
} RECT16;
|
||||
|
||||
typedef struct {
|
||||
int32 x, y; /* offset point on VRAM */
|
||||
int32 w, h; /* width and height */
|
||||
} RECT32;
|
||||
|
||||
typedef struct {
|
||||
void *addr;
|
||||
uint16 len;
|
||||
uint16 z0;
|
||||
void *usr;
|
||||
uint8 r0, g0, b0, code;
|
||||
} P_TAG;
|
||||
|
||||
typedef struct { uint8 r0, g0, b0, code; } P_CODE;
|
||||
|
||||
typedef struct {
|
||||
void *addr;
|
||||
uint16 len;
|
||||
uint16 z0;
|
||||
void *usr;
|
||||
uint8 r0, g0, b0, code;
|
||||
} OT_tag;
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
} P_HEADER;
|
||||
|
||||
/*
|
||||
* Environment
|
||||
*/
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[15];
|
||||
} DR_ENV; /* Packed Drawing Environment */
|
||||
|
||||
typedef struct {
|
||||
RECT16 clip; /* clip area */
|
||||
int16 ofs[2]; /* drawing offset */
|
||||
RECT16 tw; /* texture window */
|
||||
uint16 tpage; /* texture page */
|
||||
uint8 dtd; /* dither flag (0:off, 1:on) */
|
||||
uint8 dfe; /* flag to draw on display area (0:off 1:on) */
|
||||
uint8 isbg; /* enable to auto-clear */
|
||||
uint8 r0, g0, b0; /* initital background color */
|
||||
DR_ENV dr_env; /* reserved */
|
||||
} DRAWENV;
|
||||
|
||||
typedef struct {
|
||||
RECT16 disp; /* display area */
|
||||
RECT16 screen; /* display start point */
|
||||
uint8 isinter; /* interlace 0: off 1: on */
|
||||
uint8 isrgb24; /* RGB24 bit mode */
|
||||
uint8 pad0, pad1; /* reserved */
|
||||
} DISPENV;
|
||||
|
||||
/*
|
||||
* Polygon Primitive Definitions
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
} POLY_F3; /* Flat Triangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
int32 x3, y3;
|
||||
} POLY_F4; /* Flat Quadrangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
int32 x1, y1;
|
||||
uint16 u1, v1;
|
||||
int32 x2, y2;
|
||||
uint16 u2, v2;
|
||||
} POLY_FT3; /* Flat Textured Triangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
int32 x1, y1;
|
||||
uint16 u1, v1;
|
||||
int32 x2, y2;
|
||||
uint16 u2, v2;
|
||||
int32 x3, y3;
|
||||
uint16 u3, v3;
|
||||
} POLY_FT4; /* Flat Textured Quadrangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, pad1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, pad2;
|
||||
int32 x2, y2;
|
||||
} POLY_G3; /* Gouraud Triangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, pad1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, pad2;
|
||||
int32 x2, y2;
|
||||
uint8 r3, g3, b3, pad3;
|
||||
int32 x3, y3;
|
||||
} POLY_G4; /* Gouraud Quadrangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
uint16 u1, v1;
|
||||
uint8 r2, g2, b2, p2;
|
||||
int32 x2, y2;
|
||||
uint16 u2, v2;
|
||||
} POLY_GT3; /* Gouraud Textured Triangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
uint16 u1, v1;
|
||||
uint8 r2, g2, b2, p2;
|
||||
int32 x2, y2;
|
||||
uint16 u2, v2;
|
||||
uint8 r3, g3, b3, p3;
|
||||
int32 x3, y3;
|
||||
uint16 u3, v3;
|
||||
} POLY_GT4; /* Gouraud Textured Quadrangle */
|
||||
|
||||
/*
|
||||
* Line Primitive Definitions
|
||||
*/
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
} LINE_F2; /* Unconnected Flat Line */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
} LINE_G2; /* Unconnected Gouraud Line */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
uint32 pad;
|
||||
} LINE_F3; /* 2 connected Flat Line */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, p2;
|
||||
int32 x2, y2;
|
||||
uint32 pad;
|
||||
} LINE_G3; /* 2 connected Gouraud Line */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
int32 x3, y3;
|
||||
uint32 pad;
|
||||
} LINE_F4; /* 3 connected Flat Line Quadrangle */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, p2;
|
||||
int32 x2, y2;
|
||||
uint8 r3, g3, b3, p3;
|
||||
int32 x3, y3;
|
||||
uint32 pad;
|
||||
} LINE_G4; /* 3 connected Gouraud Line */
|
||||
|
||||
/*
|
||||
* Sprite Primitive Definitions
|
||||
*/
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
int16 w, h;
|
||||
} SPRT; /* free size Sprite */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
} SPRT_16; /* 16x16 Sprite */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint16 u0, v0;
|
||||
} SPRT_8; /* 8x8 Sprite */
|
||||
|
||||
/*
|
||||
* Tile Primitive Definitions
|
||||
*/
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int16 w, h;
|
||||
} TILE; /* free size Tile */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
} TILE_16; /* 16x16 Tile */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
} TILE_8; /* 8x8 Tile */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
} TILE_1; /* 1x1 Tile */
|
||||
|
||||
/*
|
||||
* Special Primitive Definitions
|
||||
*/
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[2];
|
||||
} DR_MODE; /* Drawing Mode */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[2];
|
||||
} DR_TWIN; /* Texture Window */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[2];
|
||||
} DR_AREA; /* Drawing Area */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[2];
|
||||
} DR_OFFSET; /* Drawing Offset */
|
||||
|
||||
typedef struct {/* MoveImage */
|
||||
P_TAG tag;
|
||||
uint32 code[5];
|
||||
} DR_MOVE;
|
||||
|
||||
typedef struct {/* LoadImage */
|
||||
P_TAG tag;
|
||||
uint32 code[3];
|
||||
uint32 p[13];
|
||||
} DR_LOAD;
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[1];
|
||||
} DR_TPAGE; /* Drawing TPage */
|
||||
|
||||
typedef struct {
|
||||
P_TAG tag;
|
||||
uint32 code[2];
|
||||
} DR_STP; /* Drawing STP */
|
||||
|
||||
/*
|
||||
* Font Stream Parameters
|
||||
*/
|
||||
#define FNT_MAX_ID 8 /* max number of stream ID */
|
||||
#define FNT_MAX_SPRT 1024 /* max number of sprites in all streams */
|
||||
|
||||
/*
|
||||
* Multi-purpose Sony-TMD primitive
|
||||
*/
|
||||
typedef struct {
|
||||
uint32 id;
|
||||
uint8 r0, g0, b0, p0; /* Color of vertex 0 */
|
||||
uint8 r1, g1, b1, p1; /* Color of vertex 1 */
|
||||
uint8 r2, g2, b2, p2; /* Color of vertex 2 */
|
||||
uint8 r3, g3, b3, p3; /* Color of vertex 3 */
|
||||
uint16 tpage, clut; /* texture page ID, clut ID */
|
||||
uint8 u0, v0, u1, v1; /* texture corner point */
|
||||
uint8 u2, v2, u3, v3;
|
||||
|
||||
/* independent vertex model */
|
||||
SVECTOR x0, x1, x2, x3; /* 3D corner point */
|
||||
SVECTOR n0, n1, n2, n3; /* 3D corner normal vector */
|
||||
|
||||
/* Common vertex model */
|
||||
SVECTOR *v_ofs; /* offset to vertex database */
|
||||
SVECTOR *n_ofs; /* offset to normal database */
|
||||
|
||||
uint16 vert0, vert1; /* index of vertex */
|
||||
uint16 vert2, vert3;
|
||||
uint16 norm0, norm1; /* index of normal */
|
||||
uint16 norm2, norm3;
|
||||
|
||||
} TMD_PRIM;
|
||||
|
||||
/*
|
||||
* Multi-purpose TIM image
|
||||
*/
|
||||
typedef struct {
|
||||
uint32 mode; /* pixel mode */
|
||||
RECT16 *crect; /* CLUT rectangle on frame buffer */
|
||||
uint32 *caddr; /* CLUT address on main memory */
|
||||
RECT16 *prect; /* texture image rectangle on frame buffer */
|
||||
uint32 *paddr; /* texture image address on main memory */
|
||||
} TIM_IMAGE;
|
||||
|
||||
extern int32 LoadImage(RECT16 *rect, uint32 *p);
|
||||
extern OT_tag *ClearOTag(OT_tag *ot, uint32 n);
|
||||
extern OT_tag *ClearOTagR(OT_tag *ot, uint32 n);
|
||||
extern void DrawOTag(OT_tag *p);
|
||||
extern void DrawPrim(void *p);
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif /* _LIBGPU_H_ */
|
||||
245
engines/icb/gfx/psx_pchmd.h
Normal file
245
engines/icb/gfx/psx_pchmd.h
Normal file
@@ -0,0 +1,245 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_PCHMD_H
|
||||
#define ICB_PSX_PCHMD_H
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
const int32 HMD_FUS3 = 0x00000048; // Flat, Un-textured, Self-Luminous Triangle
|
||||
const int32 HMD_FTS3 = 0x00000049; // Flat, Textured, Self-Luminous Triangle
|
||||
const int32 HMD_GUS3 = 0x0000004c; // Gouraud, Un-textured, Self-Luminous Triangle
|
||||
const int32 HMD_GTS3 = 0x0000004d; // Gouraud, Textured, Self-Luminous Triangle
|
||||
|
||||
const int32 HMD_FUL3 = 0x00000008; // Flat, Un-textured, Lit Triangle
|
||||
const int32 HMD_FTL3 = 0x00000009; // Flat, Textured, Lit Triangle
|
||||
const int32 HMD_GUL3 = 0x0000000c; // Gouraud, Un-textured, Lit Triangle
|
||||
const int32 HMD_GTL3 = 0x0000000d; // Gouraud, Textured, Lit Triangle
|
||||
|
||||
const int32 TRIANGLE = 0x00000666; // Just 3 vertices for shadow polygon
|
||||
|
||||
const int32 HMD_FUS3_SIZE = 3;
|
||||
const int32 HMD_GUS3_SIZE = 5;
|
||||
const int32 HMD_FTS3_SIZE = 5;
|
||||
const int32 HMD_GTS3_SIZE = 7;
|
||||
const int32 HMD_FUL3_SIZE = 3;
|
||||
const int32 HMD_GUL3_SIZE = 4;
|
||||
const int32 HMD_FTL3_SIZE = 5;
|
||||
const int32 HMD_GTL3_SIZE = 6;
|
||||
const int32 TRIANGLE_SIZE = 2;
|
||||
|
||||
int32 decodeHMDpolygon(uint32 primType, uint32 pcplatform, uint32 *&pp, uint32 &code0, uint32 &r0, uint32 &g0, uint32 &b0, uint32 &code1, uint32 &r1, uint32 &g1, uint32 &b1, uint32 &code2, uint32 &r2,
|
||||
uint32 &g2, uint32 &b2, uint32 &u0, uint32 &v0, uint32 &u1, uint32 &v1, uint32 &u2, uint32 &v2, uint32 &cba, uint32 &cx, uint32 &cy, uint32 &tsb, uint32 &tp, uint32 &n0, uint32 &vert0,
|
||||
uint32 &n1, uint32 &vert1, uint32 &n2, uint32 &vert2, uint32 dump);
|
||||
|
||||
// Handy structures for decoding polygon information
|
||||
|
||||
// Flat, Un-textured, Self-Luminous Triangle
|
||||
// Each polygon is 3 32-bit WORDS
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 8-bits | 8-bits
|
||||
// 0x20 | Blue | Green | Red
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// vp1 | vp0
|
||||
// pad | vp2
|
||||
typedef struct PolyFUS3 {
|
||||
uint8 r0, g0, b0, code0;
|
||||
uint16 vp0, vp1;
|
||||
uint16 vp2, pad;
|
||||
} PolyFUS3;
|
||||
|
||||
// Gouraud, Un-textured, Self-Luminous Triangle
|
||||
// Each polygon is 5 32-bit WORDS
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 8-bits | 8-bits
|
||||
// 0x30 | Blue0 | Green0 | Red0
|
||||
// 0x30 | Blue1 | Green1 | Red1
|
||||
// 0x30 | Blue2 | Green2 | Red2
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// vp1 | vp0
|
||||
// pad | vp2
|
||||
typedef struct PolyGUS3 {
|
||||
uint8 r0, g0, b0, code0;
|
||||
uint8 r1, g1, b1, code1;
|
||||
uint8 r2, g2, b2, code2;
|
||||
uint16 vp0, vp1;
|
||||
uint16 vp2, pad;
|
||||
} PolyGUS3;
|
||||
|
||||
// Flat, Textured, Self-Luminous Triangle
|
||||
// Each polygon is 5 32-bit WORDS
|
||||
// Structure is :
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 8-bits | 8-bits
|
||||
// 0x24 | Blue | Green | Red
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// cba | v0 | u0
|
||||
// tsb | v1 | u1
|
||||
// vp0 | v2 | u2
|
||||
// --------------------------
|
||||
// vp2 | vp1
|
||||
typedef struct PolyFTS3 {
|
||||
uint8 r0, g0, b0, code0;
|
||||
uint8 u0, v0;
|
||||
uint16 cba;
|
||||
uint8 u1, v1;
|
||||
uint16 tsb;
|
||||
uint8 u2, v2;
|
||||
uint16 vp0;
|
||||
uint16 vp1, vp2;
|
||||
} PolyFTS3;
|
||||
|
||||
// Gouraud, Textured, Self-Luminous Triangle
|
||||
// Each polygon is 7 32-bit WORDS
|
||||
// Structure is :
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 8-bits | 8-bits
|
||||
// 0x34 | Blue0 | Green0 | Red0
|
||||
// 0x34 | Blue1 | Green1 | Red1
|
||||
// 0x34 | Blue2 | Green2 | Red2
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// cba | v0 | u0
|
||||
// tsb | v1 | u1
|
||||
// vp0 | v2 | u2
|
||||
// --------------------------
|
||||
// vp2 | vp2
|
||||
typedef struct PolyGTS3 {
|
||||
uint8 r0, g0, b0, code0;
|
||||
uint8 r1, g1, b1, code1;
|
||||
uint8 r2, g2, b2, code2;
|
||||
uint8 u0, v0;
|
||||
uint16 cba;
|
||||
uint8 u1, v1;
|
||||
uint16 tsb;
|
||||
uint8 u2, v2;
|
||||
uint16 vp0;
|
||||
uint16 vp1, vp2;
|
||||
} PolyGTS3;
|
||||
|
||||
// Flat, Un-textured, Lit Triangle
|
||||
// Each polygon is 3 32-bit WORDS
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 8-bits | 8-bits
|
||||
// 0x20 | Blue | Green | Red
|
||||
// 16-bits | 16-bits
|
||||
// ------------------
|
||||
// vp0 | np0
|
||||
// vp2 | vp1
|
||||
typedef struct PolyFUL3 {
|
||||
uint8 r0, g0, b0, code0;
|
||||
uint16 np0, vp0;
|
||||
uint16 vp1, vp2;
|
||||
} PolyFUL3;
|
||||
|
||||
// Gouraud, Un-textured, Lit Triangle
|
||||
// Each polygon is 4 32-bit WORDS
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 8-bits | 8-bits
|
||||
// 0x20 | Blue | Green | Red
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// vp0 | np0
|
||||
// vp1 | np1
|
||||
// vp2 | np2
|
||||
typedef struct PolyGUL3 {
|
||||
uint8 r0, g0, b0, code0;
|
||||
uint16 np0, vp0;
|
||||
uint16 np1, vp1;
|
||||
uint16 np2, vp2;
|
||||
} PolyGUL3;
|
||||
|
||||
// Flat, Textured, Lit Triangle
|
||||
// Each polygon is 5 32-bit WORDS
|
||||
// Structure is :
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// cba | v0 | u0
|
||||
// tsb | v1 | u1
|
||||
// pad | v2 | u2
|
||||
// --------------------------
|
||||
// vp0 | np0
|
||||
// vp2 | vp1
|
||||
typedef struct PolyFTL3 {
|
||||
uint8 u0, v0;
|
||||
uint16 cba;
|
||||
uint8 u1, v1;
|
||||
uint16 tsb;
|
||||
uint8 u2, v2;
|
||||
uint16 pad;
|
||||
uint16 np0, vp0;
|
||||
uint16 vp1, vp2;
|
||||
} PolyFTL3;
|
||||
|
||||
// Gouraud, Textured, Lit Triangle
|
||||
// Each polygon is 6 32-bit WORDS
|
||||
// Structure is :
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 16-bits | 8-bits | 8-bits
|
||||
// --------------------------
|
||||
// cba | v0 | u0
|
||||
// tsb | v1 | u1
|
||||
// pad | v2 | u2
|
||||
// --------------------------
|
||||
// vp0 | np0
|
||||
// vp1 | np1
|
||||
// vp2 | np2
|
||||
//
|
||||
typedef struct PolyGTL3 {
|
||||
uint8 u0, v0;
|
||||
uint16 cba;
|
||||
uint8 u1, v1;
|
||||
uint16 tsb;
|
||||
uint8 u2, v2;
|
||||
uint16 pad;
|
||||
uint16 np0, vp0;
|
||||
uint16 np1, vp1;
|
||||
uint16 np2, vp2;
|
||||
} PolyGTL3;
|
||||
|
||||
#if (_PSX == 0) || (_PSX_ON_PC == 1)
|
||||
|
||||
void MatrixToAngles(MATRIX *A, SVECTOR *rotvec);
|
||||
|
||||
#endif // #if (_PSX==0) || (_PSX_ON_PC==1)
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_PCHMD_H
|
||||
316
engines/icb/gfx/psx_poly.h
Normal file
316
engines/icb/gfx/psx_poly.h
Normal file
@@ -0,0 +1,316 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_DEANPOLY_H
|
||||
#define ICB_DEANPOLY_H
|
||||
|
||||
namespace ICB {
|
||||
|
||||
#define GPUCODE_MODE_SHADE_TEX (1 << 0)
|
||||
#define GPUCODE_MODE_SEMI_TRANS (1 << 1)
|
||||
|
||||
// GPU Primitive codes. Please remember that 3 and 4 point lines require the pad field setting to 0x55555555.
|
||||
#define GPUCODE_POLY_F3 (0x20)
|
||||
#define GPUCODE_POLY_FT3 (0x24)
|
||||
#define GPUCODE_POLY_G3 (0x30)
|
||||
#define GPUCODE_POLY_GT3 (0x34)
|
||||
#define GPUCODE_POLY_F4 (0x28)
|
||||
#define GPUCODE_POLY_FT4 (0x2c)
|
||||
#define GPUCODE_POLY_G4 (0x38)
|
||||
#define GPUCODE_POLY_GT4 (0x3c)
|
||||
|
||||
#define GPUCODE_SPRT (0x64)
|
||||
#define GPUCODE_SPRT_8 (0x74)
|
||||
#define GPUCODE_SPRT_16 (0x7c)
|
||||
|
||||
#define GPUCODE_TILE (0x60)
|
||||
#define GPUCODE_TILE_1 (0x68)
|
||||
#define GPUCODE_TILE_8 (0x70)
|
||||
#define GPUCODE_TILE_16 (0x78)
|
||||
|
||||
#define GPUCODE_LINE_F2 (0x40)
|
||||
#define GPUCODE_LINE_G2 (0x50)
|
||||
#define GPUCODE_LINE_F3 (0x48)
|
||||
#define GPUCODE_LINE_G3 (0x58)
|
||||
#define GPUCODE_LINE_F4 (0x4c)
|
||||
#define GPUCODE_LINE_G4 (0x5c)
|
||||
|
||||
#define GPUSIZE_POLY_F3 (4 + 3)
|
||||
#define GPUSIZE_POLY_FT3 (7 + 3)
|
||||
#define GPUSIZE_POLY_G3 (6 + 3)
|
||||
#define GPUSIZE_POLY_GT3 (9 + 3)
|
||||
#define GPUSIZE_POLY_F4 (5 + 4)
|
||||
#define GPUSIZE_POLY_FT4 (9 + 4)
|
||||
#define GPUSIZE_POLY_G4 (8 + 4)
|
||||
#define GPUSIZE_POLY_GT4 (12 + 4)
|
||||
|
||||
#define GPUSIZE_SPRT (4 + 1)
|
||||
#define GPUSIZE_SPRT_8 (3 + 1)
|
||||
#define GPUSIZE_SPRT_16 (3 + 1)
|
||||
|
||||
#define GPUSIZE_TILE (3 + 1)
|
||||
#define GPUSIZE_TILE_1 (2 + 1)
|
||||
#define GPUSIZE_TILE_8 (2 + 1)
|
||||
#define GPUSIZE_TILE_16 (2 + 1)
|
||||
|
||||
#define GPUSIZE_LINE_F2 (3 + 2)
|
||||
#define GPUSIZE_LINE_G2 (4 + 2)
|
||||
#define GPUSIZE_LINE_F3 (5 + 3)
|
||||
#define GPUSIZE_LINE_G3 (7 + 3)
|
||||
#define GPUSIZE_LINE_F4 (6 + 4)
|
||||
#define GPUSIZE_LINE_G4 (9 + 4)
|
||||
|
||||
#define GPUSIZE_DR_TPAGE (1)
|
||||
#define GPUSIZE_TAG (4)
|
||||
|
||||
#define GPUSIZE_TPOLY_F3 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_F3 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TPOLY_F4 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_F4 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TPOLY_G3 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_G3 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TPOLY_G4 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_G4 + GPUSIZE_TAG)
|
||||
|
||||
#define GPUSIZE_TLINE_F2 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_F3 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TLINE_G2 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_G2 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TLINE_F3 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_F3 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TLINE_G3 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_G3 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TLINE_F4 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_F4 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TLINE_G4 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_G4 + GPUSIZE_TAG)
|
||||
|
||||
#define GPUSIZE_TSPRT (GPUSIZE_DR_TPAGE + GPUSIZE_SPRT + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TSPRT_8 (GPUSIZE_DR_TPAGE + GPUSIZE_SPRT_8 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TSPRT_16 (GPUSIZE_DR_TPAGE + GPUSIZE_SPRT_16 + GPUSIZE_TAG)
|
||||
|
||||
#define GPUSIZE_TTILE (GPUSIZE_DR_TPAGE + GPUSIZE_TILE + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TTILE_1 (GPUSIZE_DR_TPAGE + GPUSIZE_TILE_1 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TTILE_8 (GPUSIZE_DR_TPAGE + GPUSIZE_TILE_8 + GPUSIZE_TAG)
|
||||
#define GPUSIZE_TTILE_16 (GPUSIZE_DR_TPAGE + GPUSIZE_TILE_16 + GPUSIZE_TAG)
|
||||
|
||||
#define setTcode(p, tc) (*(uint32 *)&(((P_TAG *)(p))->r0) = (uint32)(tc))
|
||||
|
||||
#define zeroTagPoly(p) (setaddr((&(p)->tag_poly), 0), setlen((&(p)->tag_poly), 0) = 0)
|
||||
|
||||
#define setlen(p, _len) (((P_TAG *)(p))->len = (uint8)(_len))
|
||||
|
||||
#define setTDrawTPageSize(p, s) setlen((p), (s)), setTcode((p), _get_mode(0, 1, 0))
|
||||
|
||||
#define setTDrawTPage(p) setTDrawTPageSize((p), 1)
|
||||
|
||||
#define setTPolyF3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F3), setcode(&((p)->tag_poly), GPUCODE_POLY_F3), zeroTagPoly((p))
|
||||
#define setTPolyF4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F4), setcode(&((p)->tag_poly), GPUCODE_POLY_F4), zeroTagPoly((p))
|
||||
|
||||
#define setTPolyG3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G3), setcode(&((p)->tag_poly), GPUCODE_POLY_G3), zeroTagPoly((p))
|
||||
#define setTPolyG4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G4), setcode(&((p)->tag_poly), GPUCODE_POLY_G4), zeroTagPoly((p))
|
||||
|
||||
#define setTLineF2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F2), setcode(&((p)->tag_poly), GPUCODE_LINE_F2), zeroTagPoly((p))
|
||||
#define setTLineG2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G2), setcode(&((p)->tag_poly), GPUCODE_LINE_G2), zeroTagPoly((p))
|
||||
#define setTLineF3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F3), setcode(&((p)->tag_poly), GPUCODE_LINE_F3), zeroTagPoly((p)), ((p)->pad) = 0x55555555
|
||||
#define setTLineG3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G3), setcode(&((p)->tag_poly), GPUCODE_LINE_G3), zeroTagPoly((p)), ((p)->pad) = 0x55555555
|
||||
#define setTLineF4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F4), setcode(&((p)->tag_poly), GPUCODE_LINE_F4), zeroTagPoly((p)), ((p)->pad) = 0x55555555
|
||||
#define setTLineG4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G4), setcode(&((p)->tag_poly), GPUCODE_LINE_G4), zeroTagPoly((p)), ((p)->pad) = 0x55555555
|
||||
|
||||
#define setTSprt(p) setTDrawTPageSize((p), GPUSIZE_TSPRT), setcode(&((p)->tag_poly), GPUCODE_SPRT), zeroTagPoly((p))
|
||||
#define setTSprt8(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_8), setcode(&((p)->tag_poly), GPUCODE_SPRT_8), zeroTagPoly((p))
|
||||
#define setTSprt16(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_16), setcode(&((p)->tag_poly), GPUCODE_SPRT_16), zeroTagPoly((p))
|
||||
|
||||
#define setTTile(p) setTDrawTPageSize((p), GPUSIZE_TTILE), setcode(&((p)->tag_poly), GPUCODE_TILE), zeroTagPoly((p))
|
||||
#define setTTile1(p) setTDrawTPageSize((p), GPUSIZE_TTILE_1), setcode(&((p)->tag_poly), GPUCODE_TILE_1), zeroTagPoly((p))
|
||||
#define setTTile8(p) setTDrawTPageSize((p), GPUSIZE_TTILE_8), setcode(&((p)->tag_poly), GPUCODE_TILE_8), zeroTagPoly((p))
|
||||
#define setTTile16(p) setTDrawTPageSize((p), GPUSIZE_TTILE_16), setcode(&((p)->tag_poly), GPUCODE_TILE_16), zeroTagPoly((p))
|
||||
|
||||
#define setTSemiTrans(p, abe) setSemiTrans(&((p)->tag_poly), (abe))
|
||||
#define setTABRMode(p, abr) setTcode((p), _get_mode(0, 1, (abr << 5)))
|
||||
#define setTSprtTPage(p, tp) setTcode((p), _get_mode(0, 1, (tp)))
|
||||
#define setTSprtTPageABR(p, t, a) setTcode((p), _get_mode(0, 1, (((t)&0x19f) | ((a) << 5))))
|
||||
|
||||
#define addPrimSize(ot, p, size) (p)->tag = ((*(ot)) | ((size) << 24)), *((ot)) = (((uint32)(p) << 8) >> 8)
|
||||
|
||||
typedef struct __tpoly_f3 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
} TPOLY_F3; // Flat Triangle with ABR control
|
||||
|
||||
typedef struct __tpoly_f4 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
int32 x3, y3;
|
||||
} TPOLY_F4; // Flat Quadrangle with ABR control
|
||||
|
||||
typedef struct __tpoly_g3 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, pad1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, pad2;
|
||||
int32 x2, y2;
|
||||
} TPOLY_G3; // Gouraud Triangle with ABR control
|
||||
|
||||
typedef struct __tpoly_g4 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, pad1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, pad2;
|
||||
int32 x2, y2;
|
||||
uint8 r3, g3, b3, pad3;
|
||||
int32 x3, y3;
|
||||
} TPOLY_G4; // Gouraud Quadrangle with ABR control
|
||||
|
||||
typedef struct __tline_f2 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
} TLINE_F2; // Unconnected Flat Line with ABR control
|
||||
|
||||
typedef struct __tline_g2 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
} TLINE_G2; // Unconnected Gouraud Line with ABR control
|
||||
|
||||
typedef struct __tline_f3 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
uint32 pad;
|
||||
} TLINE_F3; // 2 connected Flat Line with ABR control
|
||||
|
||||
typedef struct __tline_g3 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, p2;
|
||||
int32 x2, y2;
|
||||
uint32 pad;
|
||||
} TLINE_G3; // 2 connected Gouraud Line with ABR control
|
||||
|
||||
typedef struct __tline_f4 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int32 x1, y1;
|
||||
int32 x2, y2;
|
||||
int32 x3, y3;
|
||||
uint32 pad;
|
||||
} TLINE_F4; // 3 connected Flat Line Quadrangle with ABR control
|
||||
|
||||
typedef struct __tline_g4 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 r1, g1, b1, p1;
|
||||
int32 x1, y1;
|
||||
uint8 r2, g2, b2, p2;
|
||||
int32 x2, y2;
|
||||
uint8 r3, g3, b3, p3;
|
||||
int32 x3, y3;
|
||||
uint32 pad;
|
||||
} TLINE_G4; // 3 connected Gouraud Line with ABR control
|
||||
|
||||
// Sprite Primitive Definitions
|
||||
typedef struct __tsprt {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 u0, v0;
|
||||
uint16 clut;
|
||||
int16 w, h;
|
||||
} TSPRT; // Free size Sprite with TPage/ABR control
|
||||
|
||||
typedef struct __tsprt_16 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 u0, v0;
|
||||
uint16 clut;
|
||||
} TSPRT_16; // 16x16 Sprite with TPage/ABR control
|
||||
|
||||
typedef struct __tsprt_8 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
uint8 u0, v0;
|
||||
uint16 clut;
|
||||
} TSPRT_8; // 8x8 Sprite with TPage/ABR control
|
||||
|
||||
typedef struct __ttile {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
int16 w, h;
|
||||
} TTILE; // free size Tile with ABR control
|
||||
|
||||
typedef struct __ttile16 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
} TTILE_16; // 16x16 Tile with ABR control
|
||||
|
||||
typedef struct __ttile_8 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
} TTILE_8; // 8x8 Tile with ABR control
|
||||
|
||||
typedef struct __ttile_1 {
|
||||
P_TAG tag;
|
||||
OT_tag tag_poly;
|
||||
uint8 r0, g0, b0, code;
|
||||
int32 x0, y0;
|
||||
} TTILE_1; // 1x1 Tile with ABR control
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // __DEANPOLY_H
|
||||
334
engines/icb/gfx/psx_props.h
Normal file
334
engines/icb/gfx/psx_props.h
Normal file
@@ -0,0 +1,334 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_PROPS_H
|
||||
#define ICB_PSX_PROPS_H
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
|
||||
#define PSXPL_SCHEMA 4
|
||||
#define PSXPL_ID "PLF"
|
||||
|
||||
#include "engines/icb/gfx/psx_zlayers.h"
|
||||
#include "engines/icb/common/px_bitmap_psx.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// schema 0 file format is
|
||||
/*
|
||||
uint32 schema;
|
||||
uint32 propQty;
|
||||
uint32 cmQty;
|
||||
uint32 cmOffsets[nCms]; // cmOffsets[nCms];
|
||||
propcmStruct props[propQty];
|
||||
{
|
||||
char* name;
|
||||
uint32 stateQty;
|
||||
}
|
||||
// This is the actual construction matrix and where the cmOffsets point to
|
||||
cmStruct cm[cmQty];
|
||||
{
|
||||
uint32 propQty; // currently always 1 but is likely to change
|
||||
uint32 propNameOffset;
|
||||
uint32 width; // how many bits in the CM table
|
||||
uint32 stateQty; // how many states
|
||||
uint32 statePtrs[stateQty]; // points to a psxPropLayers struct
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 w, h;
|
||||
uint32 n;
|
||||
uint32 zoverlayOffset; // relative bytes from state start to zoverlay
|
||||
uint32 zOffset; // relative bytes from state start to z data;
|
||||
uint16 palette[256];
|
||||
uint8 rgbData[w*h]
|
||||
uint8 zdata[w*h];
|
||||
psxZOverlay layers[n]
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 dZScale, dZShift;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// schema 1 file format is
|
||||
/*
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 propQty;
|
||||
uint32 cmQty;
|
||||
uint32 cmOffsets[nCms]; // cmOffsets[nCms];
|
||||
propcmStruct props[propQty];
|
||||
{
|
||||
char* name;
|
||||
uint32 stateQty;
|
||||
}
|
||||
// This is the actual construction matrix and where the cmOffsets point to
|
||||
cmStruct cm[cmQty];
|
||||
{
|
||||
uint32 propQty; // currently always 1 but is likely to change
|
||||
uint32 propNameOffset;
|
||||
uint32 width; // how many bits in the CM table
|
||||
uint32 stateQty; // how many states
|
||||
uint32 statePtrs[stateQty]; // points to a psxPropLayers struct
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 w, h;
|
||||
uint32 n;
|
||||
uint32 zoverlayOffset; // relative bytes from state start to zoverlay
|
||||
uint32 zOffset; // relative bytes from state start to z data;
|
||||
_pxPSXBitmap bitmap; // compress PSX Bitmap format inc. palette
|
||||
uint8 zdata[w*h];
|
||||
psxZOverlay layers[n]
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 dZScale, dZShift;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// schema 2 file format is
|
||||
/*
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 propQty;
|
||||
uint32 propOffsets[propQty]; // propOffsets[propQty];
|
||||
psxPropInfo propInfo[propQty];
|
||||
{
|
||||
char* name;
|
||||
uint32 stateQty;
|
||||
}
|
||||
psxProp props[propQty];
|
||||
{
|
||||
uint32 stateQty; // how many states
|
||||
uint32 propNameOffset;
|
||||
uint32 statePtrs[stateQty]; // points to a psxPropState struct
|
||||
psxPropState propStates[stateQty];
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 w, h;
|
||||
uint16 nPropRGBsprites;
|
||||
uint16 nBgRGBsprites;
|
||||
_pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// schema 3 file format is
|
||||
/*
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 propQty;
|
||||
uint32 propOffsets[propQty]; // propOffsets[propQty];
|
||||
psxPropInfo propInfo[propQty];
|
||||
{
|
||||
char* name;
|
||||
uint32 stateQty;
|
||||
}
|
||||
psxProp props[propQty];
|
||||
{
|
||||
uint32 stateQty; // how many states
|
||||
uint32 propNameOffset;
|
||||
uint32 statePtrs[stateQty]; // points to a psxPropState struct
|
||||
psxPropState propStates[stateQty];
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 w, h;
|
||||
uint16 nPropRGBsprites;
|
||||
uint16 nBgRGBsprites;
|
||||
uint32 zMicroOffset;
|
||||
uint32 propBitmapOffset;
|
||||
psxZMacroFrag zMacro[nPropRGBsprites];
|
||||
psxZMicroFrag zMicro[nMicroFrags];
|
||||
_pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// schema 4 file format is
|
||||
/*
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 propQty;
|
||||
uint32 propOffsets[propQty]; // propOffsets[propQty];
|
||||
psxPropInfo propInfo[propQty];
|
||||
{
|
||||
char* name;
|
||||
uint32 stateQty;
|
||||
}
|
||||
psxProp props[propQty];
|
||||
{
|
||||
uint32 stateQty; // how many states
|
||||
uint32 propNameOffset;
|
||||
uint32 statePtrs[stateQty]; // points to a psxPropState struct
|
||||
psxPropState propStates[stateQty];
|
||||
{
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 w, h;
|
||||
|
||||
uint16 nPropZsprites;
|
||||
uint16 nPropFGZsprites;
|
||||
uint16 nPropBGZsprites;
|
||||
uint16 padding;
|
||||
|
||||
uint16 nPropRGBsprites;
|
||||
uint16 nBgRGBsprites;
|
||||
uint32 zMicroOffset;
|
||||
uint32 propBitmapOffset;
|
||||
psxZMacroFrag zMacro[nPropRGBsprites];
|
||||
psxZMicroFrag zMicro[nMicroFrags];
|
||||
_pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// z information about the macroscopic fragments
|
||||
// (which are the RGB tiles within the psxBitmap structure)
|
||||
// plus hooks into the microscopic z-data information
|
||||
//
|
||||
// These are currently a maximum of 64x64 big
|
||||
typedef struct psxZMacroFrag {
|
||||
uint32 realzs; // in real z-coordinates e.g. not culled z-data for prop drawing order
|
||||
uint16 zs, ze;
|
||||
uint16 microStart;
|
||||
uint16 nMicro;
|
||||
} psxZMacroFrag;
|
||||
|
||||
// z information about the microscopic fragments
|
||||
// (which are the RGB tiles split into smaller tiles (very simple binary sub-division) until the z-range
|
||||
// within the tile is within a tolerance - and so the microscopic fragment can be drawn at a single z value
|
||||
//
|
||||
// These microscopic tiles use x,y relative to the macroscopic fragment to save on bit storage for x,y
|
||||
// e.g. gets it down to two int's instead of 3 !
|
||||
typedef struct psxZMicroFrag {
|
||||
uint16 zs, ze; // store zs & ze just because otherwise we have a short of padding !
|
||||
uint8 xoff, yoff;
|
||||
uint8 w, h;
|
||||
} psxZMicroFrag;
|
||||
|
||||
// The most basic information about a prop which current is just its name
|
||||
typedef struct psxPropInfo { char *name; } psxPropInfo;
|
||||
|
||||
// This structure is overlaid ontop of the prop file which is read
|
||||
// in from disc/CD
|
||||
typedef struct psxProp {
|
||||
uint32 propNameOffset; // pointer to where the name is stored
|
||||
uint32 stateQty; // how many states
|
||||
uint32 statePtrs[1]; // statePtrs[stateQty]
|
||||
} psxProp;
|
||||
|
||||
typedef struct psxPropState {
|
||||
int16 xs, xe;
|
||||
int16 ys, ye;
|
||||
uint16 zs, ze;
|
||||
uint16 w, h;
|
||||
|
||||
uint16 nPropZsprites;
|
||||
uint16 nPropFGZsprites;
|
||||
uint16 nPropBGZsprites;
|
||||
uint16 padding;
|
||||
|
||||
uint16 nPropRGBsprites;
|
||||
uint16 nBgRGBsprites;
|
||||
|
||||
uint32 zMicroOffset;
|
||||
uint32 propBitmapOffset;
|
||||
psxZMacroFrag zMacro[1];
|
||||
|
||||
inline psxZMacroFrag *GetZMacroFragPtr(void);
|
||||
inline psxZMicroFrag *GetZMicroFragPtr(void);
|
||||
inline _pxPSXBitmap *GetPropBitmapPtr(void);
|
||||
|
||||
psxPropState() { ; }
|
||||
|
||||
private:
|
||||
// Make '=' and copy constructor private to stop accidental assignment.
|
||||
psxPropState(const psxPropState &) { ; }
|
||||
void operator=(const psxPropState &) { ; }
|
||||
|
||||
} psxPropState;
|
||||
|
||||
inline psxZMacroFrag *psxPropState::GetZMacroFragPtr(void) { return zMacro; }
|
||||
|
||||
inline psxZMicroFrag *psxPropState::GetZMicroFragPtr(void) {
|
||||
psxZMicroFrag *zMicro = (psxZMicroFrag *)((uint8 *)this + zMicroOffset);
|
||||
return zMicro;
|
||||
}
|
||||
|
||||
inline _pxPSXBitmap *psxPropState::GetPropBitmapPtr(void) {
|
||||
_pxPSXBitmap *propBitmap = (_pxPSXBitmap *)((uint8 *)this + propBitmapOffset);
|
||||
return propBitmap;
|
||||
}
|
||||
|
||||
// Note these cannot be well represented by a C struct
|
||||
// as they are full of variable length arrays
|
||||
typedef struct psxPLfile {
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 propQty;
|
||||
uint32 propOffsets[1];
|
||||
|
||||
inline psxProp *GetProp(uint32 prop);
|
||||
inline uint32 GetPropStateQty(uint32 prop);
|
||||
inline char *GetPropName(uint32 prop);
|
||||
inline psxPropState *GetPropState(uint32 prop, uint32 state);
|
||||
} psxPLfile;
|
||||
|
||||
inline psxProp *psxPLfile::GetProp(uint32 prop) { return (psxProp *)((uint8 *)id + propOffsets[prop]); }
|
||||
|
||||
inline uint32 psxPLfile::GetPropStateQty(uint32 prop) {
|
||||
psxProp *pProp = GetProp(prop);
|
||||
return pProp->stateQty;
|
||||
}
|
||||
|
||||
inline char *psxPLfile::GetPropName(uint32 prop) {
|
||||
psxProp *pProp = GetProp(prop);
|
||||
return (id + pProp->propNameOffset);
|
||||
}
|
||||
|
||||
inline psxPropState *psxPLfile::GetPropState(uint32 prop, uint32 state) {
|
||||
psxProp *pProp = GetProp(prop);
|
||||
return (psxPropState *)((uint8 *)id + pProp->statePtrs[state]);
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_PROPS_H
|
||||
68
engines/icb/gfx/psx_pxactor.h
Normal file
68
engines/icb/gfx/psx_pxactor.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_PXACTOR_H
|
||||
#define ICB_PSX_PXACTOR_H
|
||||
|
||||
#include "engines/icb/gfx/psx_pcgpu.h"
|
||||
#include "engines/icb/common/px_common.h"
|
||||
#include "engines/icb/shadow.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
typedef struct psxActor {
|
||||
// The true position in x,y,z space i.e. minus the render correction
|
||||
PXvector_PSX truePos;
|
||||
// The true rotation i.e. minus the render correction (pan_adjust)
|
||||
SVECTOR trueRot;
|
||||
|
||||
// The actors render : local to world matrix
|
||||
MATRIX lw;
|
||||
SVECTOR rot;
|
||||
SVECTOR pos;
|
||||
int32 style;
|
||||
|
||||
// Screen position
|
||||
SVECTOR sPos;
|
||||
|
||||
// Bounding box on the screen
|
||||
SVECTOR bboxScrn[8];
|
||||
|
||||
// Min & max corners of the bounding box
|
||||
SVECTOR minBbox;
|
||||
SVECTOR maxBbox;
|
||||
|
||||
// Shadow bounding boxes
|
||||
SVECTOR shadowBox[MAX_SHADOWS][8];
|
||||
SVECTOR shadowMinBox[MAX_SHADOWS];
|
||||
SVECTOR shadowMaxBox[MAX_SHADOWS];
|
||||
uint32 nShadows;
|
||||
|
||||
} psxActor;
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_PXACTOR_H
|
||||
237
engines/icb/gfx/psx_scrn.h
Normal file
237
engines/icb/gfx/psx_scrn.h
Normal file
@@ -0,0 +1,237 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_SCRN_H
|
||||
#define ICB_PSX_SCRN_H
|
||||
|
||||
#include "engines/icb/psx_config.h"
|
||||
#include "engines/icb/gfx/psx_pcgpu.h"
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
#include "engines/icb/gfx/psx_ot.h"
|
||||
|
||||
#include "common/util.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
typedef struct DoubleBuffer {
|
||||
DRAWENV draw; /* drawing environment */
|
||||
DISPENV disp; /* display environment */
|
||||
} DoubleBuffer;
|
||||
|
||||
#define SCREEN_W 640
|
||||
#define SCREEN_H 480
|
||||
|
||||
#define MIN_SCREEN_X (0)
|
||||
#define MAX_SCREEN_X (SCREEN_W - 1)
|
||||
#define MIN_SCREEN_Y (0)
|
||||
#define MAX_SCREEN_Y (SCREEN_H - 1)
|
||||
#define MSG_X 20
|
||||
#define MSG_Y (SCREEN_H - 40)
|
||||
|
||||
#define MSG_W SCREEN_W
|
||||
#define MSG_H 10
|
||||
|
||||
// Length of the OT
|
||||
#define OT_LENGTH 16 // bit length of OT
|
||||
|
||||
#define OT_SIZE (1 << OT_LENGTH)
|
||||
|
||||
// The PSX Data-cache which is 1KB big
|
||||
#define D_CACHE getScratchAddr(0)
|
||||
#define D_CACHE_SIZE 1024
|
||||
|
||||
// Number of DR_LOAD primitives to allocate
|
||||
// #define MAX_DRLOADS 2048
|
||||
|
||||
// Screen position for 0,0
|
||||
extern int32 scrn_ox;
|
||||
extern int32 scrn_oy;
|
||||
|
||||
// Global double buffer and drawing functions
|
||||
void SwapDoubleBuffer(void);
|
||||
void SwapBufferIndex(void);
|
||||
void DrawDisplayList(int32 buf);
|
||||
void Init_display(int32 w, int32 h, int32 x1, int32 y1, int32 x2, int32 y2, int32 ox, int32 oy, int32 clear);
|
||||
void RenderCycle(void);
|
||||
|
||||
// Global double buffer and drawing variables
|
||||
|
||||
extern OT_tag *otarray[2];
|
||||
extern OT_tag *drawot;
|
||||
|
||||
extern int32 drawBuf;
|
||||
extern int32 dont_set_dispbuf;
|
||||
extern DoubleBuffer db[2];
|
||||
extern DoubleBuffer *pdb;
|
||||
extern uint32 reloadFont;
|
||||
extern int32 global_use_otlist;
|
||||
|
||||
// A global array place in which to create GPU packets
|
||||
typedef uint8 GPUPACKET;
|
||||
extern GPUPACKET *drawpacket;
|
||||
extern GPUPACKET *drawpacketStart;
|
||||
extern GPUPACKET *drawpacketEnd;
|
||||
|
||||
// For tracking the maximum number of packets used
|
||||
extern int32 globalPacketMax;
|
||||
extern int32 packetsUsed;
|
||||
|
||||
// How much to shift & then offset the z values from gte to
|
||||
// put them into the otlist
|
||||
extern int32 g_otz_shift;
|
||||
extern int32 g_otz_offset;
|
||||
|
||||
// Enable/disable updating of the auto-sliding & scaling min,max z position
|
||||
extern int32 update_minmaxzpos;
|
||||
|
||||
// Global graphics options for z-clipping and camera scalings
|
||||
extern int32 minZOTpos;
|
||||
extern int32 maxZOTpos;
|
||||
extern int32 minUsedZpos;
|
||||
extern int32 maxUsedZpos;
|
||||
extern int32 nearClip;
|
||||
|
||||
#if (_PSX_ON_PC == 0) && (_PSX == 1)
|
||||
|
||||
// Number of GPU packets to reserve
|
||||
#define PACKETMAX 1500
|
||||
// the size of a POLY_GT3 packet
|
||||
#define PACKETSIZE sizeof(POLY_GT3)
|
||||
// a full-up DR_LOAD is 17 int32s (68 bytes) and is the biggest type of packet
|
||||
#define PACKET_MAX_SIZE sizeof(DR_LOAD)
|
||||
#define PACKETMEM (PACKETMAX * PACKETSIZE)
|
||||
|
||||
// this is the nick pelling speed-up bit
|
||||
|
||||
#define set3(_r0, _r1) __asm__ volatile("swl %1, 2( %0 )" : : "r"(_r0), "r"(_r1) : "memory")
|
||||
|
||||
static inline uint32 get3(void *_r0) {
|
||||
register uint32 t;
|
||||
__asm__ volatile("lwl %0, 2( %1 )" : "=r"(t) : "r"(_r0) : "memory");
|
||||
return t;
|
||||
}
|
||||
|
||||
#ifdef setaddr
|
||||
#undef setaddr
|
||||
#undef getaddr
|
||||
#undef addPrim
|
||||
#undef addPrims
|
||||
#endif
|
||||
|
||||
#define setaddr(_p0, _p1) set3((_p0), ((uint32)(_p1)) << 8)
|
||||
#define getaddr(_p) (get3(_p) >> 8)
|
||||
|
||||
static inline void addPrim(uint32 *ot, void *p) {
|
||||
uint32 tmp = get3(ot); // lwl
|
||||
setaddr(ot, p); // sll, swl
|
||||
set3(p, tmp); // swl
|
||||
}
|
||||
|
||||
static inline void addPrims(uint32 *ot, void *p0, void *p1) {
|
||||
uint32 tmp = get3(ot); // lwl
|
||||
setaddr(ot, p0); // sll, swl
|
||||
set3(p1, tmp); // swl
|
||||
}
|
||||
|
||||
#endif // #if (_PSX_ON_PC == 0) && (_PSX==1)
|
||||
|
||||
// Cheers to Nick Pelling for this excellent mySetDrawLoad
|
||||
// This one is a straight forward inline version of SetDrawLoad
|
||||
// and adds the DR_FLUSH onto the end
|
||||
static inline void mySetDrawLoad(DR_LOAD *p, RECT16 *r, int32 length) {
|
||||
p->code[0] = (uint32)(0xA0 << 24); // 0xA0000000
|
||||
p->code[1] = *((uint32 *)r);
|
||||
p->code[2] = *((uint32 *)r + 1);
|
||||
setlen(p, (1 + 2 + 1 + length)); // code=1 RECT=2 DR_FLUSH=1 data=length
|
||||
p->p[length] = 0x01 << 24; // DR_FLUSH
|
||||
}
|
||||
|
||||
// This one is just like SetDrawLoad but does not add the DR_FLUSH on the end
|
||||
static inline void mySetDrawLoadNoFlush(DR_LOAD *p, RECT16 *r, int32 length) {
|
||||
p->code[0] = (uint32)(0xA0 << 24); // 0xA0000000
|
||||
p->code[1] = *((uint32 *)r);
|
||||
p->code[2] = *((uint32 *)r + 1);
|
||||
setlen(p, (1 + 2 + length)); // code=1 RECT=2 data=length
|
||||
p->p[length] = 0x01 << 24; // DR_FLUSH
|
||||
}
|
||||
|
||||
// Handy function for using the packets global array
|
||||
static inline void myAddPacket(int32 len) {
|
||||
// Advance to next spot :
|
||||
// can still fail e.g. add a small packet then try to add a large packet
|
||||
drawpacket += len;
|
||||
if (drawpacket >= drawpacketEnd) {
|
||||
drawpacket = drawpacketStart;
|
||||
}
|
||||
}
|
||||
|
||||
// Handy function for putting a DR_LOAD into the packets global array
|
||||
static inline void myAddDRLOAD(RECT16 *r, uint32 *pot, int32 length) {
|
||||
mySetDrawLoad((DR_LOAD *)drawpacket, r, length);
|
||||
addPrim(pot, drawpacket);
|
||||
myAddPacket(((5 + length) << 2));
|
||||
}
|
||||
|
||||
// Handy function for putting a DR_LOAD into the packets global array
|
||||
// but without adding a DR_FLUSH onto the end
|
||||
static inline void myAddDRLOADNoFlush(RECT16 *r, uint32 *pot, int32 length) {
|
||||
mySetDrawLoadNoFlush((DR_LOAD *)drawpacket, r, length);
|
||||
addPrim(pot, drawpacket);
|
||||
myAddPacket(((4 + length) << 2));
|
||||
}
|
||||
|
||||
// Little to convert a z-value into an OT position
|
||||
static inline int32 myMakeOTPosition(int32 z0) {
|
||||
int32 z1 = (z0 >> g_otz_shift) - g_otz_offset;
|
||||
|
||||
minUsedZpos = MIN(z0, minUsedZpos);
|
||||
maxUsedZpos = MAX(z0, maxUsedZpos);
|
||||
|
||||
z1 = MAX(minZOTpos, z1);
|
||||
z1 = MIN(maxZOTpos, z1);
|
||||
|
||||
return z1;
|
||||
}
|
||||
|
||||
// My own add prim function which automatically computes the correct
|
||||
// index in the OT and also performs simple near,far z clipping
|
||||
static inline int32 myAddPrimClip(int32 z0, void *primitive) {
|
||||
int32 otpos = myMakeOTPosition(z0);
|
||||
if (otpos == -1)
|
||||
return -1; // ignore out of clipping range
|
||||
|
||||
#if (_PSX_ON_PC == 1) || (_PSX == 0)
|
||||
z0 = z0 >> 2; // Divide z by 4 so it matches background units
|
||||
addPrimZUsr(drawot + otpos, primitive, z0, OTusrData);
|
||||
#else
|
||||
addPrim(drawot + otpos, primitive);
|
||||
#endif
|
||||
return otpos;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_SCRN_H
|
||||
274
engines/icb/gfx/psx_tman.cpp
Normal file
274
engines/icb/gfx/psx_tman.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/icb/common/px_common.h"
|
||||
#include "engines/icb/debug.h"
|
||||
#include "engines/icb/gfx/psx_tman.h"
|
||||
#include "engines/icb/gfx/psx_clut.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
TextureManager::TextureManager() { Init(0, 0, 0, 0); }
|
||||
|
||||
TextureManager::TextureManager(short nx0, short ny0, short nx1, short ny1) { Init(nx0, ny0, nx1, ny1); }
|
||||
|
||||
void TextureManager::Init(short nx0, short ny0, short nx1, short ny1) {
|
||||
x0 = nx0;
|
||||
y0 = ny0;
|
||||
x1 = nx1;
|
||||
y1 = ny1;
|
||||
tileW = (int16)((x1 - x0) / N_TILES_X);
|
||||
tileH = (int16)((y1 - y0) / N_TILES_Y);
|
||||
nSlotsUsed = 0;
|
||||
nPalettesUsed = 0;
|
||||
int32 t;
|
||||
for (t = 0; t < MAX_NUMBER_TILES; t++) {
|
||||
inuse[t] = 0;
|
||||
}
|
||||
int32 s;
|
||||
for (s = 0; s < MAX_NUMBER_SLOTS; s++) {
|
||||
tSlots[s].id = 0;
|
||||
tSlots[s].age = 0;
|
||||
}
|
||||
for (s = 0; s < MAX_NUMBER_PALETTES; s++) {
|
||||
pSlots[s].id = 0;
|
||||
pSlots[s].age = 0;
|
||||
}
|
||||
}
|
||||
|
||||
TextureManager::~TextureManager() {}
|
||||
|
||||
TextureInfo *TextureManager::FindTexture(uint32 id, uint32 age) {
|
||||
uint32 s;
|
||||
TextureInfo *slot = tSlots;
|
||||
for (s = 0; s < MAX_NUMBER_SLOTS; s++) {
|
||||
if (slot->id == id) {
|
||||
slot->age = age;
|
||||
return slot;
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
// printf( "Texture %X not found", id );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TextureInfo *TextureManager::AddTexture(uint32 * /*tim_ptr*/, uint32 id, uint32 age, uint16 imgW, uint16 imgH) {
|
||||
// printf( "Adding Texture %X", id );
|
||||
if (id == 0) {
|
||||
Message_box("AddTexture 0 ID");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Try to find a slot for it
|
||||
uint32 t = 0;
|
||||
uint32 s = 0;
|
||||
uint32 purges = 0;
|
||||
|
||||
uint32 oldest;
|
||||
uint32 fitted = 0;
|
||||
TextureInfo *slot;
|
||||
uint32 xt = 0;
|
||||
uint32 yt = 0;
|
||||
uint32 ntx0 = (imgW + tileW - 1) / tileW;
|
||||
uint32 nty0 = (imgH + tileH - 1) / tileH;
|
||||
|
||||
uint32 x, y;
|
||||
uint32 xend, yend;
|
||||
uint32 dy = N_TILES_X;
|
||||
uint32 place0, place;
|
||||
while (fitted == 0) {
|
||||
xt = 0;
|
||||
yt = 0;
|
||||
for (t = 0; t < MAX_NUMBER_TILES; t++) {
|
||||
if (inuse[t] == 0) {
|
||||
// Found a slot which isn't in use
|
||||
// Does it fit into a single tile
|
||||
if ((imgW <= tileW) && (imgH <= tileH)) {
|
||||
fitted = 1;
|
||||
inuse[t] = 1;
|
||||
break;
|
||||
} else {
|
||||
// Covers more than one tile
|
||||
// Can it physically fit in ?
|
||||
xend = xt + ntx0;
|
||||
yend = yt + nty0;
|
||||
if ((xend <= N_TILES_X) && (yend <= N_TILES_Y)) {
|
||||
|
||||
// so need to check all the tiles that would be occupied
|
||||
place0 = xt + yt * dy;
|
||||
for (y = yt; y < yend; y++) {
|
||||
place = place0;
|
||||
for (x = xt; x < xend; x++) {
|
||||
if (inuse[place] == 1) {
|
||||
// printf("x %d y %d place %d NOTOK", x, y, place );
|
||||
break;
|
||||
}
|
||||
place++;
|
||||
}
|
||||
if (x != xend)
|
||||
break;
|
||||
place0 += dy;
|
||||
}
|
||||
if (y == yend) {
|
||||
// Hey its ok
|
||||
fitted = 1;
|
||||
// Mark the tiles as being used
|
||||
place0 = xt + yt * dy;
|
||||
for (y = yt; y < yend; y++) {
|
||||
place = place0;
|
||||
for (x = xt; x < xend; x++) {
|
||||
inuse[place] = 1;
|
||||
place++;
|
||||
}
|
||||
place0 += dy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
xt++;
|
||||
if (xt == N_TILES_X) {
|
||||
xt = 0;
|
||||
yt++;
|
||||
// ERROR
|
||||
if (yt > N_TILES_Y) {
|
||||
Message_box("BAD yt");
|
||||
yt = N_TILES_Y - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Oh dear couldn't find a slot for it
|
||||
// Have to purge out the oldest resource
|
||||
if (t == MAX_NUMBER_TILES) {
|
||||
slot = tSlots;
|
||||
purges = MAX_NUMBER_SLOTS;
|
||||
oldest = 0xFFFFFFFF;
|
||||
for (s = 0; s < MAX_NUMBER_SLOTS; s++) {
|
||||
// Only look at slots with id != 0
|
||||
if (slot->id != 0) {
|
||||
if (slot->age < oldest) {
|
||||
oldest = slot->age;
|
||||
purges = s;
|
||||
}
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
// ERROR
|
||||
if (purges == MAX_NUMBER_SLOTS) {
|
||||
Message_box("bad purges");
|
||||
purges = 0;
|
||||
}
|
||||
// Purge
|
||||
tSlots[purges].id = 0;
|
||||
tSlots[purges].age = 0;
|
||||
// Now more tricky reset the inuse flags
|
||||
RECT16 *pr = &(tSlots[purges].r);
|
||||
uint32 tx = (pr->x - x0) / tileW;
|
||||
uint32 ty = (pr->y - y0) / tileH;
|
||||
uint32 ntx = pr->w / tileW;
|
||||
uint32 nty = pr->h / tileH;
|
||||
if (ntx == 0)
|
||||
ntx = 1;
|
||||
if (nty == 0)
|
||||
nty = 1;
|
||||
|
||||
// printf( "tx %d ty %d ntx %d nty %d", tx, ty, ntx, nty );
|
||||
place0 = tx + ty * dy;
|
||||
for (y = ty; y < (ty + nty); y++) {
|
||||
place = place0;
|
||||
for (x = tx; x < (tx + ntx); x++) {
|
||||
inuse[place] = 0;
|
||||
place++;
|
||||
}
|
||||
place0 += dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A slot has been found for it : hooray
|
||||
slot = tSlots;
|
||||
for (s = 0; s < MAX_NUMBER_SLOTS; s++) {
|
||||
// Find the first slot with id 0
|
||||
if (slot->id == 0)
|
||||
break;
|
||||
slot++;
|
||||
}
|
||||
if (s == MAX_NUMBER_SLOTS) {
|
||||
Message_box("BAD slot");
|
||||
slot = tSlots;
|
||||
s = 0;
|
||||
}
|
||||
slot->id = id;
|
||||
slot->age = age;
|
||||
if (xt > N_TILES_X) {
|
||||
Message_box("bad xt %d", xt);
|
||||
}
|
||||
if (yt > N_TILES_Y) {
|
||||
Message_box("bad yt %d", yt);
|
||||
}
|
||||
slot->r.x = (int16)(xt * tileW + x0);
|
||||
slot->r.y = (int16)(yt * tileH + y0);
|
||||
slot->r.w = imgW;
|
||||
slot->r.h = imgH;
|
||||
slot->tsb = (int16)getTPage(1, 0, slot->r.x, slot->r.y); // 8-bit, b+f
|
||||
slot->cba = (int16)getClut(CHARACTER_CLUT_X, (CHARACTER_CLUT_Y + s));
|
||||
slot->uoffset = (uint8)(slot->r.x - ((slot->tsb & 0xF) << 6));
|
||||
slot->voffset = (uint8)(slot->r.y - (((slot->tsb >> 4) & 0x1) << 8));
|
||||
return slot;
|
||||
}
|
||||
|
||||
void TextureManager::PurgeAll(void) { Init(x0, y0, x1, y1); }
|
||||
|
||||
PaletteInfo *TextureManager::FindPalette(uint32 id, uint32 age) {
|
||||
uint32 s;
|
||||
PaletteInfo *slot = pSlots;
|
||||
for (s = 0; s < MAX_NUMBER_SLOTS; s++) {
|
||||
if (slot->id == id) {
|
||||
slot->age = age;
|
||||
return slot;
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PaletteInfo *TextureManager::AddPalette(uint32 * /*clut_ptr*/, uint32 id, uint32 age) {
|
||||
if (nPalettesUsed < MAX_NUMBER_PALETTES) {
|
||||
PaletteInfo *slot = &(pSlots[nPalettesUsed]);
|
||||
slot->x = CHARACTER_ALTERNATE_CLUT_X;
|
||||
slot->y = (int16)(CHARACTER_ALTERNATE_CLUT_Y + nPalettesUsed);
|
||||
slot->cba = (int16)getClut(slot->x, slot->y);
|
||||
slot->id = id;
|
||||
slot->age = age;
|
||||
|
||||
nPalettesUsed++;
|
||||
return slot;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
91
engines/icb/gfx/psx_tman.h
Normal file
91
engines/icb/gfx/psx_tman.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_PSX_TMAN_H
|
||||
#define ICB_PSX_TMAN_H
|
||||
|
||||
#include "engines/icb/gfx/psx_pcgpu.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
#define MAX_NUMBER_SLOTS 8
|
||||
#define MAX_NUMBER_PALETTES 10
|
||||
|
||||
#define N_TILES_X 4
|
||||
#define N_TILES_Y 4
|
||||
|
||||
#define MAX_NUMBER_TILES (N_TILES_X * N_TILES_Y)
|
||||
|
||||
typedef struct TextureInfo {
|
||||
// DO NOT CHANGE THIS SECTION OF THE STRUCTURE
|
||||
// AS PSX ASSMEBLER ROUTINES RELY ON IT BEING LIKE THIS
|
||||
int16 tsb; // tpf | abr | texture_page = getTpate( tpf, abr, x, y );
|
||||
int16 cba; // cy | cx = getClut(cx,cy)
|
||||
uint8 uoffset;
|
||||
uint8 voffset;
|
||||
int16 padding;
|
||||
// DO WHAT YOU LIKE FROM HERE ONWARDS
|
||||
uint32 id;
|
||||
uint32 age;
|
||||
RECT16 r;
|
||||
} TextureInfo;
|
||||
|
||||
typedef struct PaletteInfo {
|
||||
uint32 id;
|
||||
uint32 age;
|
||||
int16 x;
|
||||
int16 y;
|
||||
int16 cba; // cy | cx = getClut(cx,cy)
|
||||
int16 padding;
|
||||
} PaletteInfo;
|
||||
|
||||
class TextureManager {
|
||||
public:
|
||||
TextureManager();
|
||||
TextureManager(int16 nx0, int16 ny0, int16 nx1, int16 ny1);
|
||||
~TextureManager();
|
||||
void Init(int16 nx0, int16 ny0, int16 nx1, int16 ny1);
|
||||
TextureInfo *FindTexture(uint32 id, uint32 age);
|
||||
TextureInfo *AddTexture(uint32 *tim_ptr, uint32 id, uint32 age, uint16 imgW, uint16 imgH);
|
||||
|
||||
PaletteInfo *FindPalette(uint32 id, uint32 age);
|
||||
PaletteInfo *AddPalette(uint32 *clut_ptr, uint32 id, uint32 age);
|
||||
|
||||
void PurgeAll(void);
|
||||
|
||||
TextureInfo tSlots[MAX_NUMBER_SLOTS];
|
||||
PaletteInfo pSlots[MAX_NUMBER_PALETTES];
|
||||
uint8 inuse[MAX_NUMBER_TILES];
|
||||
int16 x0, y0;
|
||||
int16 x1, y1;
|
||||
uint16 tileW, tileH;
|
||||
uint32 nSlotsUsed;
|
||||
uint32 nPalettesUsed;
|
||||
};
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef PSX_TMAN_H
|
||||
244
engines/icb/gfx/rab_api.cpp
Normal file
244
engines/icb/gfx/rab_api.cpp
Normal file
@@ -0,0 +1,244 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/icb/common/px_common.h"
|
||||
#include "engines/icb/common/px_rcutypes.h"
|
||||
#include "engines/icb/gfx/rab_api.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// Decompress the FrameData into the CurrentFrame data storage
|
||||
// e.g. undo the delta compression or replace the zero ignored
|
||||
// values with zero
|
||||
Bone_Frame *RabAPIObject::GetFrame(RabAPI *rab, const int32 f) {
|
||||
Bone_Frame *curFrm = GetCurrentFrame(rab);
|
||||
Bone_Frame *prevFrm = nullptr;
|
||||
|
||||
if (f != rab->currentFrame) {
|
||||
// Decode and decompress the data from the animation frame into
|
||||
// the current frame
|
||||
FrameData *frm = GetFrameData(rab, f);
|
||||
|
||||
uint32 b, i;
|
||||
uint32 nt = frm->nThings;
|
||||
int8 *data = frm->data;
|
||||
|
||||
// For deltas we need the previous frame
|
||||
if ((frm->typeSize & DataTypeDeltas) != 0) {
|
||||
prevFrm = GetFrame(rab, f - 1);
|
||||
int32 dcvx;
|
||||
int32 dcvy;
|
||||
int32 dcvz;
|
||||
int32 prevVx;
|
||||
int32 prevVy;
|
||||
int32 prevVz;
|
||||
int32 curVx;
|
||||
int32 curVy;
|
||||
int32 curVz;
|
||||
int32 temp;
|
||||
int32 prevCrot;
|
||||
int32 nBits = 0;
|
||||
int32 min;
|
||||
int32 mask;
|
||||
int32 storeZero;
|
||||
int32 dataSize;
|
||||
|
||||
// So just need to add on the deltas to the previous frame !
|
||||
{
|
||||
dataSize = (frm->typeSize & DataSizeBitMask);
|
||||
switch (dataSize) {
|
||||
case 3: {
|
||||
nBits = DELTA_24_NBITS;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
nBits = DELTA_16_NBITS;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
nBits = DELTA_8_NBITS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
min = (1 << (nBits - 1));
|
||||
mask = (1 << nBits) - 1;
|
||||
storeZero = frm->typeSize & DataStoreZero;
|
||||
for (i = 0; i < nt; i++) {
|
||||
// The data is not aligned so need to do memcpy
|
||||
temp = 0;
|
||||
|
||||
if (storeZero == 0) {
|
||||
b = (int32)(*data);
|
||||
data++;
|
||||
} else {
|
||||
b = i;
|
||||
}
|
||||
byte *tempSrc = (byte *)data;
|
||||
byte *tempDst = (byte *)&temp;
|
||||
for (int t = 0; t < dataSize; t++) {
|
||||
#ifdef SCUMM_LITTLE_ENDIAN
|
||||
tempDst[t] = tempSrc[t];
|
||||
#else
|
||||
tempDst[t] = tempSrc[dataSize - t - 1];
|
||||
#endif
|
||||
}
|
||||
|
||||
// The previous compressed angles
|
||||
prevCrot = FROM_LE_32(prevFrm->bones[b].crot);
|
||||
prevVx = (prevCrot >> COMP_VX_SHIFT) & COMP_VX_MASK;
|
||||
prevVy = (prevCrot >> COMP_VY_SHIFT) & COMP_VY_MASK;
|
||||
prevVz = (prevCrot >> COMP_VZ_SHIFT) & COMP_VZ_MASK;
|
||||
|
||||
// The signed deltas
|
||||
dcvz = (temp & mask) << COMP_EXTRA_SHIFT;
|
||||
dcvz = dcvz - min;
|
||||
|
||||
temp = temp >> nBits;
|
||||
dcvy = (temp & mask) << COMP_EXTRA_SHIFT;
|
||||
dcvy = dcvy - min;
|
||||
|
||||
temp = temp >> nBits;
|
||||
dcvx = (temp & mask) << COMP_EXTRA_SHIFT;
|
||||
dcvx = dcvx - min;
|
||||
|
||||
// Add on the deltas
|
||||
curVx = prevVx + dcvx;
|
||||
curVy = prevVy + dcvy;
|
||||
curVz = prevVz + dcvz;
|
||||
|
||||
// Correct for being -ve !
|
||||
if (curVx < 0)
|
||||
curVx += (COMP_DELTA_RANGE);
|
||||
if (curVy < 0)
|
||||
curVy += (COMP_DELTA_RANGE);
|
||||
if (curVz < 0)
|
||||
curVz += (COMP_DELTA_RANGE);
|
||||
if (curVx >= (COMP_DELTA_RANGE))
|
||||
curVx -= (COMP_DELTA_RANGE);
|
||||
if (curVy >= (COMP_DELTA_RANGE))
|
||||
curVy -= (COMP_DELTA_RANGE);
|
||||
if (curVz >= (COMP_DELTA_RANGE))
|
||||
curVz -= (COMP_DELTA_RANGE);
|
||||
|
||||
// Pack up the deltas
|
||||
temp = 0;
|
||||
temp = (curVx << COMP_VX_SHIFT);
|
||||
// y = 10-bits into middle rot
|
||||
temp |= (curVy << COMP_VY_SHIFT);
|
||||
// z = 10-bits into lower rot
|
||||
temp |= (curVz << COMP_VZ_SHIFT);
|
||||
|
||||
// Store the deltas in the currentFrame structure
|
||||
curFrm->bones[b].crot = TO_LE_32(temp);
|
||||
data += dataSize;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// switch type stuff on the type of the compressed data
|
||||
switch (frm->typeSize) {
|
||||
case ALL_ANGLES_32_TYPESIZE: {
|
||||
for (b = 0; b < nt; b++) {
|
||||
// The data is not aligned so need to do memcpy
|
||||
byte *tempSrc = (byte *)data;
|
||||
byte *tempDst = (byte *)&(curFrm->bones[b].crot);
|
||||
for (uint t = 0; t < sizeof(CompTriplet); t++) {
|
||||
#ifdef SCUMM_LITTLE_ENDIAN
|
||||
tempDst[t] = tempSrc[t];
|
||||
#else
|
||||
tempDst[t] = tempSrc[sizeof(CompTriplet) - t - 1];
|
||||
#endif
|
||||
}
|
||||
data += ALL_ANGLES_32_BYTE_SIZE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NONZERO_ANGLES_32_TYPESIZE: {
|
||||
// Zero out the angles first
|
||||
for (b = 0; b < rab->nBones; b++) {
|
||||
curFrm->bones[b].crot = TO_LE_32(ZERO_ANGLE);
|
||||
}
|
||||
// Then update the angles which are non-zero
|
||||
for (i = 0; i < nt; i++) {
|
||||
b = (int32)(*data);
|
||||
byte *tempSrc = (byte *)data + 1;
|
||||
byte *tempDst = (byte *)&(curFrm->bones[b].crot);
|
||||
for (uint t = 0; t < sizeof(CompTriplet); t++) {
|
||||
#ifdef SCUMM_LITTLE_ENDIAN
|
||||
tempDst[t] = tempSrc[t];
|
||||
#else
|
||||
tempDst[t] = tempSrc[sizeof(CompTriplet) - t - 1];
|
||||
#endif
|
||||
}
|
||||
data += NONZERO_ANGLES_32_BYTE_SIZE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: { return nullptr; }
|
||||
}
|
||||
}
|
||||
curFrm->poseBone.tx = FROM_LE_16(frm->poseBone.tx);
|
||||
curFrm->poseBone.ty = FROM_LE_16(frm->poseBone.ty);
|
||||
curFrm->poseBone.tz = FROM_LE_16(frm->poseBone.tz);
|
||||
curFrm->poseBone.parent = FROM_LE_16(frm->poseBone.parent);
|
||||
rab->currentFrame = (uint8)f;
|
||||
}
|
||||
|
||||
return curFrm;
|
||||
}
|
||||
|
||||
// Compress an SVECTOR ( uint16 vx,vy,vz, pad; ) -> uint32
|
||||
// by dividing the angles (12-bits 0-4095) by four to make them 10-bits
|
||||
int32 CompressSVECTOR(SVECTOR rotin, CompTriplet *rotout) {
|
||||
int16 vx = rotin.vx;
|
||||
int16 vy = rotin.vy;
|
||||
int16 vz = rotin.vz;
|
||||
|
||||
// Make the angles +ve
|
||||
if (vx < 0)
|
||||
vx += 4096;
|
||||
if (vy < 0)
|
||||
vy += 4096;
|
||||
if (vz < 0)
|
||||
vz += 4096;
|
||||
|
||||
// Reduce to 10-bits
|
||||
vx = (int16)((vx >> COMP_ANGLE_SHIFT) & COMP_VX_MASK);
|
||||
vy = (int16)((vy >> COMP_ANGLE_SHIFT) & COMP_VY_MASK);
|
||||
vz = (int16)((vz >> COMP_ANGLE_SHIFT) & COMP_VZ_MASK);
|
||||
|
||||
// Pack into a single int32
|
||||
// x = 10-bits into upper rot
|
||||
int32 temp = (vx << COMP_VX_SHIFT);
|
||||
// y = 10-bits into middle rot
|
||||
temp |= (vy << COMP_VY_SHIFT);
|
||||
// z = 10-bits into lower rot
|
||||
temp |= (vz << COMP_VZ_SHIFT);
|
||||
|
||||
*rotout = temp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
187
engines/icb/gfx/rab_api.h
Normal file
187
engines/icb/gfx/rab_api.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_RAB_API_HH
|
||||
#define ICB_RAB_API_HH
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
#include "engines/icb/gfx/rap_api.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
// The output file format for the .rab file
|
||||
#define RAB_API_SCHEMA 7
|
||||
#define RAB_API_ID "RAB"
|
||||
|
||||
// All the different animation frame types used during the
|
||||
// compression process
|
||||
#define ALL_ANGLES_32_BYTE_SIZE (4)
|
||||
#define ALL_DELTAS_24_BYTE_SIZE (3)
|
||||
#define ALL_DELTAS_16_BYTE_SIZE (2)
|
||||
#define ALL_DELTAS_8_BYTE_SIZE (1)
|
||||
|
||||
#define NONZERO_ANGLES_32_BYTE_SIZE (5)
|
||||
#define NONZERO_DELTAS_24_BYTE_SIZE (4)
|
||||
#define NONZERO_DELTAS_16_BYTE_SIZE (3)
|
||||
#define NONZERO_DELTAS_8_BYTE_SIZE (2)
|
||||
|
||||
#define ZERO_ANGLE (0)
|
||||
|
||||
#define DELTA_24_NBITS (8)
|
||||
#define DELTA_16_NBITS (5)
|
||||
#define DELTA_8_NBITS (2)
|
||||
|
||||
#define DELTA_24_ZERO (((1 << (DELTA_24_NBITS - 1)) << (DELTA_24_NBITS + DELTA_24_NBITS)) | ((1 << (DELTA_24_NBITS - 1)) << (DELTA_24_NBITS)) | (1 << (DELTA_24_NBITS - 1)))
|
||||
#define DELTA_16_ZERO (((1 << (DELTA_16_NBITS - 1)) << (DELTA_16_NBITS + DELTA_16_NBITS)) | ((1 << (DELTA_16_NBITS - 1)) << (DELTA_16_NBITS)) | (1 << (DELTA_16_NBITS - 1)))
|
||||
#define DELTA_8_ZERO (((1 << (DELTA_8_NBITS - 1)) << (DELTA_8_NBITS + DELTA_8_NBITS)) | ((1 << (DELTA_8_NBITS - 1)) << (DELTA_8_NBITS)) | (1 << (DELTA_8_NBITS - 1)))
|
||||
|
||||
// Animation frame structures with max memory pre-allocated in them
|
||||
// For use in the converter
|
||||
//
|
||||
// The animation frame structure is either:
|
||||
//
|
||||
// i) store ALL values OR store just non-zero values + bone ID
|
||||
// ii) store orientations OR store deltas from the previous frame
|
||||
// iii) use 8, 16, 24, 32-bits to store values
|
||||
typedef struct FrameHeader {
|
||||
BoneLink poseBone;
|
||||
uint8 typeSize;
|
||||
uint8 nThings;
|
||||
} FrameHeader;
|
||||
|
||||
// The typeSize bit masks
|
||||
//
|
||||
// DataTypeBit : 0 = Compressed Angle Triplet, 1 = Delta Triplet
|
||||
// DataStoreZeroBit : 0 = don't store zero values, 1 = store zero values
|
||||
// DataSizeBits 3 bits : size in bytes of the data value stored (1,2,3,4)
|
||||
|
||||
// Most significant bit
|
||||
#define DataTypeMask (1 << 7)
|
||||
#define DataTypeDeltas (1 << 7)
|
||||
#define DataTypeAngles (0)
|
||||
|
||||
// Next one down
|
||||
#define DataStoreZeroMask (1 << 6)
|
||||
#define DataStoreZero (1 << 6)
|
||||
#define DataDontStoreZero (0)
|
||||
|
||||
// Lower nibble is DataSizeBits
|
||||
#define DataSizeBitMask (0xF)
|
||||
|
||||
#define ALL_ANGLES_32_TYPESIZE (DataTypeAngles | DataStoreZero | 4)
|
||||
#define ALL_DELTAS_24_TYPESIZE (DataTypeDeltas | DataStoreZero | 3)
|
||||
#define ALL_DELTAS_16_TYPESIZE (DataTypeDeltas | DataStoreZero | 2)
|
||||
#define ALL_DELTAS_8_TYPESIZE (DataTypeDeltas | DataStoreZero | 1)
|
||||
|
||||
#define NONZERO_ANGLES_32_TYPESIZE (DataTypeAngles | DataDontStoreZero | 4)
|
||||
#define NONZERO_DELTAS_24_TYPESIZE (DataTypeDeltas | DataDontStoreZero | 3)
|
||||
#define NONZERO_DELTAS_16_TYPESIZE (DataTypeDeltas | DataDontStoreZero | 2)
|
||||
#define NONZERO_DELTAS_8_TYPESIZE (DataTypeDeltas | DataDontStoreZero | 1)
|
||||
|
||||
// Basic angle triplet compression packs 3x12-bits into 3x10-bits
|
||||
#define COMP_ANGLE_RANGE (1 << 10)
|
||||
#define COMP_ANGLE_SHIFT (2)
|
||||
#define COMP_VX_SHIFT (20)
|
||||
#define COMP_VY_SHIFT (10)
|
||||
#define COMP_VZ_SHIFT (0)
|
||||
#define COMP_VX_MASK (0x3FF)
|
||||
#define COMP_VY_MASK (0x3FF)
|
||||
#define COMP_VZ_MASK (0x3FF)
|
||||
|
||||
#define COMP_EXTRA_SHIFT (0)
|
||||
#define COMP_DELTA_RANGE (COMP_ANGLE_RANGE)
|
||||
|
||||
// Generic frame data structure
|
||||
typedef struct FrameData {
|
||||
BoneLink poseBone; // the animated bone for the pose object
|
||||
uint8 typeSize; // FrameHeader but don't want compiler alignment bollocks
|
||||
uint8 nThings;
|
||||
int8 data[1]; // data[n] : n depends on compression used store frame
|
||||
} FrameData;
|
||||
|
||||
typedef struct MatrixHierarchy {
|
||||
MATRIX matrix;
|
||||
MatrixHierarchy *parent;
|
||||
} MatrixHierarchy;
|
||||
|
||||
typedef struct MatrixHierarchyPC {
|
||||
MATRIXPC matrix;
|
||||
MatrixHierarchyPC *parent;
|
||||
} MatrixHierarchyPC;
|
||||
|
||||
typedef uint32 CompTriplet;
|
||||
|
||||
typedef struct LinkedMatrix {
|
||||
CompTriplet crot; // compresseed angle triplet 10-bits per angle
|
||||
} LinkedMatrix;
|
||||
|
||||
typedef struct Bone_Frame {
|
||||
BoneLink poseBone; // the animated bone for the pose object
|
||||
LinkedMatrix bones[1]; // actually LinkedMatrix rot[nBones]
|
||||
} Bone_Frame;
|
||||
|
||||
typedef struct {
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint16 nFrames;
|
||||
uint8 nBones; // nBones must match the RAP file nBones value
|
||||
uint8 currentFrame; // the current frame of animation stored
|
||||
|
||||
// byte offsets from start of the file
|
||||
uint32 currentFrameOffset;
|
||||
|
||||
// byte offsets from start of the file
|
||||
uint32 frameOffsets[1]; // nFrames of them
|
||||
} RabAPI;
|
||||
|
||||
typedef struct _RabAPIObject {
|
||||
static Bone_Frame *GetFrame(RabAPI *rab, const int32 f);
|
||||
|
||||
static Bone_Frame *GetCurrentFrame(RabAPI *rab) { return (Bone_Frame *)((uint8 *)(rab->id + FROM_LE_32(rab->currentFrameOffset))); }
|
||||
|
||||
static FrameData *GetFrameData(RabAPI *rab, const int32 f) { return (FrameData *)((uint8 *)(rab->id + FROM_LE_32(rab->frameOffsets[f]))); }
|
||||
|
||||
} RabAPIObject;
|
||||
|
||||
// Compress an SVECTOR ( uint16 vx,vy,vz, pad; ) -> uint32
|
||||
// by dividing the angles (12-bits 0-4095) by four to make them 10-bits
|
||||
int32 CompressSVECTOR(SVECTOR rotin, uint32 *rotout);
|
||||
|
||||
// Uncompress an SVECTOR ( uint32 -> uint16 vx,vy,vz, pad; )
|
||||
// by multiplying the angles (10-bits 0-1023) by four to make them 12-bits
|
||||
inline void ExpandSVECTOR(CompTriplet rotin, SVECTOR *rotout) {
|
||||
// Make the angles back up from the compressed 32-bit value
|
||||
// x = ( upper 10-bits from part1 ) * 4
|
||||
rotout->vx = (int16)(((int16)(rotin >> COMP_VX_SHIFT) & COMP_VX_MASK) << COMP_ANGLE_SHIFT);
|
||||
// y = ( middle 10-bits from part1 ) * 4
|
||||
rotout->vy = (int16)(((int16)(rotin >> COMP_VY_SHIFT) & COMP_VY_MASK) << COMP_ANGLE_SHIFT);
|
||||
// z = ( lower 10-bits from part1 ) * 4
|
||||
rotout->vz = (int16)(((int16)(rotin >> COMP_VZ_SHIFT) & COMP_VZ_MASK) << COMP_ANGLE_SHIFT);
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef RAB_API_HH
|
||||
182
engines/icb/gfx/rap_api.h
Normal file
182
engines/icb/gfx/rap_api.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_RAP_API_HH
|
||||
#define ICB_RAP_API_HH
|
||||
|
||||
#include "engines/icb/gfx/psx_pcdefines.h"
|
||||
|
||||
#include "common/endian.h"
|
||||
|
||||
namespace ICB {
|
||||
|
||||
#define RAP_API_SCHEMA 10
|
||||
|
||||
#define RAP_API_ID "RAP"
|
||||
|
||||
// A bone-bone link
|
||||
// tx, ty, tz : is translation
|
||||
// parent : is the parent bone ID
|
||||
// = nBones means no linkage
|
||||
typedef struct BoneLink {
|
||||
int16 tx, ty, tz;
|
||||
uint16 parent;
|
||||
} BoneLink;
|
||||
|
||||
// A simple vertex description
|
||||
typedef struct Vertex {
|
||||
int16 vx, vy, vz;
|
||||
uint16 vertId;
|
||||
} Vertex;
|
||||
|
||||
// A vertex-bone link
|
||||
typedef struct VertexLink {
|
||||
int16 vx, vy, vz; // the position in bone co-ordinate frame
|
||||
int16 primId; // bone id - -ve number means no bone just "local" frame
|
||||
uint32 vertId; // vertex id
|
||||
} VertexLink;
|
||||
|
||||
// A weighted vertex-bone link
|
||||
typedef struct WeightedVertexLink {
|
||||
VertexLink link;
|
||||
uint32 weight; // % weight (fixed-point int scaled to weightScale)
|
||||
} WeightedVertexLink;
|
||||
|
||||
// Each polygon is 6 32-bit WORDS
|
||||
// Bit 31 ----> Bit 0
|
||||
//
|
||||
// 8-bits | 8-bits | 16-bits
|
||||
// --------------------------
|
||||
// u0 | v0 | cba
|
||||
// u1 | v1 | tsb
|
||||
// u2 | v2 | pad
|
||||
// --------------------------
|
||||
// n0 | v0
|
||||
// n1 | v1
|
||||
// n2 | v2
|
||||
//
|
||||
// u0, v0 = u,v of vertex 0 : 0-255
|
||||
// u1, v1 = u,v of vertex 1 : 0-255
|
||||
// u2, v2 = u,v of vertex 2 : 0-255
|
||||
// cba = weird PSX flag, giving the VRAM x,y of the CLUT to use
|
||||
// tsb = weird PSX flag, giving the VRAM texture page to use
|
||||
// pad = padding !
|
||||
//
|
||||
// n0, v0 = index into the normal and vertex pool for normal/vertex 0
|
||||
// n1, v1 = index into the normal and vertex pool for normal/vertex 1
|
||||
// n2, v2 = index into the normal and vertex pool for normal/vertex 2
|
||||
//
|
||||
// The .rap file format
|
||||
//
|
||||
// Notice, how poor ANSI C/C++ is at its representation
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 platform;
|
||||
uint32 worldScaleShift;
|
||||
uint32 weightScaleShift;
|
||||
uint32 bothScaleShift;
|
||||
uint32 nNone;
|
||||
uint32 nSingle;
|
||||
uint32 nMultiple;
|
||||
uint32 nFUS3;
|
||||
uint32 nGUS3;
|
||||
uint32 nFTS3;
|
||||
uint32 nGTS3;
|
||||
uint32 nFUL3;
|
||||
uint32 nGUL3;
|
||||
uint32 nFTL3;
|
||||
uint32 nGTL3;
|
||||
uint16 nTRI3;
|
||||
uint16 nFrames;
|
||||
uint32 nAnimTypes;
|
||||
uint32 animPolySize; // in bytes
|
||||
uint16 nBones;
|
||||
int8 jawBone; // -1 - means not there
|
||||
int8 neckBone; // - 1 - means not there
|
||||
uint32 singleLinkOffset; // in bytes
|
||||
uint32 multiLinkOffset; // in bytes
|
||||
uint32 FUS3offset; // in bytes
|
||||
uint32 GUS3offset; // in bytes
|
||||
uint32 FTS3offset; // in bytes
|
||||
uint32 GTS3offset; // in bytes
|
||||
uint32 FUL3offset; // in bytes
|
||||
uint32 GUL3offset; // in bytes
|
||||
uint32 FTL3offset; // in bytes
|
||||
uint32 GTL3offset; // in bytes
|
||||
uint16 TRI3offset; // in bytes
|
||||
uint16 animPolyOffset; // in bytes
|
||||
uint32 normalOffset; // in bytes
|
||||
uint32 boneOffset; // in bytes
|
||||
Vertex noneLinkData[1]; // Vertex noLinkData[nNone];
|
||||
} RapAPI;
|
||||
|
||||
class RapAPIObject {
|
||||
public:
|
||||
static Vertex *GetNoneLinkPtr(RapAPI *rap) { return rap->noneLinkData; }
|
||||
|
||||
static VertexLink *GetSingleLinkPtr(RapAPI *rap) { return (VertexLink *)(rap->id + rap->singleLinkOffset); }
|
||||
|
||||
static WeightedVertexLink *GetMultiLinkPtr(RapAPI *rap) { return (WeightedVertexLink *)(rap->id + rap->multiLinkOffset); }
|
||||
|
||||
static uint32 *GetFUS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FUS3offset); }
|
||||
static uint32 *GetGUS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GUS3offset); }
|
||||
static uint32 *GetFTS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FTS3offset); }
|
||||
static uint32 *GetGTS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GTS3offset); }
|
||||
static uint32 *GetFUL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FUL3offset); }
|
||||
static uint32 *GetGUL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GUL3offset); }
|
||||
static uint32 *GetFTL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FTL3offset); }
|
||||
static uint32 *GetGTL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GTL3offset); }
|
||||
static uint32 *GetTRI3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->TRI3offset); }
|
||||
static uint32 *GetNormalPtr(RapAPI *rap) { return (uint32 *)(rap->id + rap->normalOffset); }
|
||||
static BoneLink *GetBonePtr(RapAPI *rap) { return (BoneLink *)(rap->id + rap->boneOffset); }
|
||||
static uint32 *GetBoneHashPtr(RapAPI *rap) {
|
||||
BoneLink *bPtr = GetBonePtr(rap);
|
||||
return (uint32 *)(bPtr + rap->nBones);
|
||||
}
|
||||
static uint32 *GetAnimPolyPtr(RapAPI *rap) {
|
||||
return (uint32 *)(rap->id + rap->animPolyOffset);
|
||||
|
||||
}
|
||||
static uint32 *GetAnimPolyFrame(RapAPI *rap, int32 frame) {
|
||||
return (uint32 *)(rap->id + rap->animPolyOffset + rap->nAnimTypes * 2 * sizeof(uint32) + frame * rap->animPolySize);
|
||||
}
|
||||
};
|
||||
|
||||
inline void ConvertRAP(RapAPI *rap) {
|
||||
// Do we need to do any conversion ?
|
||||
if (FROM_LE_32(rap->schema) == RAP_API_SCHEMA)
|
||||
return;
|
||||
|
||||
// You can't so a schema check will fail !
|
||||
return;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef RAP_API_HH
|
||||
226
engines/icb/gfx/rlp_api.h
Normal file
226
engines/icb/gfx/rlp_api.h
Normal file
@@ -0,0 +1,226 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1999-2000 Revolution Software Ltd.
|
||||
* This code is based on source code created by Revolution Software,
|
||||
* used with permission.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICB_RLP_API_H
|
||||
#define ICB_RLP_API_H
|
||||
|
||||
namespace ICB {
|
||||
|
||||
#define RLP_PROP_NAME_LENGTH 32
|
||||
#define RLP_SHADE_NAME_LENGTH 8
|
||||
#define RLP_LAMP_NAME_LENGTH 16
|
||||
|
||||
#define MAX_NUMBER_SHADE_STATES 128
|
||||
|
||||
#define RLP_API_SCHEMA 10
|
||||
#define RLP_API_ID "RLP"
|
||||
|
||||
#define EDGE_ONE 0x1
|
||||
#define EDGE_TWO 0x2
|
||||
#define EDGE_THREE 0x4
|
||||
#define EDGE_FOUR 0x8
|
||||
#define EDGE_ALL_VISIBLE (EDGE_ONE | EDGE_TWO | EDGE_THREE | EDGE_FOUR)
|
||||
|
||||
// schema 2
|
||||
// ========
|
||||
// if (anu==0) then ans = ane = 0
|
||||
// if (afu==0) then afs=afe=ATTEN_MAX_DISTANCE
|
||||
|
||||
// schema 3
|
||||
// ========
|
||||
// ambient scaled down from 0-4096 to 0-255
|
||||
|
||||
// schema 4
|
||||
// ========
|
||||
// m: multiplier scaled down from 0-4096 to 0-128
|
||||
// illegal beam_angles OR illegal beam_softness
|
||||
// disables beam_enable + WARNING should be an error,
|
||||
// but then need artist to fix the model(s)
|
||||
// An error will be enabled after big demo to Sony
|
||||
// beam_angle & beam_softness converted to cos's of half angle
|
||||
// ans, ane, afs, afe : pre-multiplied to be square distances
|
||||
|
||||
// schema 5
|
||||
// ========
|
||||
// added ID "RPL" to the strucure
|
||||
|
||||
// schema 6
|
||||
// ========
|
||||
// reduced ATTEN_MAX_DISTANCE to prevent integer overflow from (128*1024)->(128*128)
|
||||
|
||||
// schema 7
|
||||
// ========
|
||||
// supported the bs & ba parameters for DIRECT lights
|
||||
|
||||
// Lights are ignored beyond this distance
|
||||
// Note, the square gets stored, so make it (1<<31)/2
|
||||
#define ATTEN_MAX_DISTANCE (1 << 15)
|
||||
|
||||
// 180 degrees is the maximum size for any kind of beam angles
|
||||
#define MAX_BEAM_ANGLE (4096 / 2)
|
||||
|
||||
// schema 9
|
||||
// ========
|
||||
// added the decay parameter
|
||||
typedef struct PSXrgb { uint16 r, g, b, v; } PSXrgb;
|
||||
|
||||
#define OMNI_LIGHT (0)
|
||||
#define SPOT_LIGHT (1)
|
||||
#define DIRECT_LIGHT (2)
|
||||
|
||||
#define DECAY_NONE (0)
|
||||
#define DECAY_INV (1)
|
||||
#define DECAY_INV_SQR (2)
|
||||
|
||||
// Trial and error has shown the 3DS MAX decay law constant is this
|
||||
#define RLP_DECAY_CONSTANT (50)
|
||||
// The decay law is:
|
||||
// DECAY_NONE: m = 1.0;
|
||||
// DECAY_INV: m = ( 1.0/ (distance/factor) )
|
||||
// DECAY_INV_SQR: m = ( 1.0/ (distance/factor)^2 )
|
||||
|
||||
typedef struct PSXLampState {
|
||||
PSXrgb c; // colour not pre-multiplied
|
||||
VECTOR pos; // world position of the lamp
|
||||
int16 vx; // x-direction
|
||||
int16 vy; // y-direction
|
||||
int16 vz; // z-direction
|
||||
uint16 m; // fixed-point int 128 = 1.0 (0=off)
|
||||
uint32 ans2; // atten_near_start^2
|
||||
uint32 ane2; // atten_near_end^2
|
||||
uint32 afs2; // atten_far_start^2
|
||||
uint32 afe2; // atten_far_end^2
|
||||
} PSXLampState;
|
||||
|
||||
typedef struct PSXLamp {
|
||||
uint8 nStates;
|
||||
uint8 type; // light_type (0=OMNI,1=SPOT,2=DIRECT)
|
||||
uint8 anu; // atten_near_use
|
||||
uint8 afu; // atten_far_use
|
||||
|
||||
int32 ba; // cos(beam_angle/2) fixed-point int 4096 = 1.0
|
||||
int32 bs; // cos(beam_softness/2) fixed-point int 4096 = 1.0
|
||||
|
||||
uint32 decay; // decay parameter (0=none,1=inverse,2=inverse-squared)
|
||||
uint16 w; // width in cm
|
||||
uint16 b; // bounce factor : fixed-point int 128 = 1.0 (0=off)
|
||||
char lamp_name[RLP_LAMP_NAME_LENGTH]; // for debugging purposes will go in final version
|
||||
char prop_name[RLP_PROP_NAME_LENGTH];
|
||||
PSXLampState states[1]; // actually PSXLampState states[nStates];
|
||||
} PSXLamp;
|
||||
|
||||
// A triangle
|
||||
typedef struct ShadeTriangle {
|
||||
uint32 vEdge; // bit-flag saying if edge 0,1,2 are visible
|
||||
SVECTOR l01; // line vertex 0 -> vertex 1
|
||||
SVECTOR l12; // line vertex 1 -> vertex 2
|
||||
SVECTOR l20; // line vertex 2 -> vertex 0
|
||||
SVECTOR n01; // normal to plane & line 01
|
||||
SVECTOR n12; // normal to plane & line 12
|
||||
SVECTOR n20; // normal to plane & line 20
|
||||
SVECTOR pn; // plane normal
|
||||
int32 d; // plane distance
|
||||
int32 n01dots0; // n01 . vertex 0
|
||||
int32 n12dots1; // n12 . vertex 1
|
||||
int32 n20dots2; // n20 . vertex 2
|
||||
} ShadeTriangle;
|
||||
|
||||
// A quad
|
||||
typedef struct ShadeQuad {
|
||||
uint32 vEdge; // bit-flag saying if edge 0,1,2,3 are visible
|
||||
SVECTOR l01; // line vertex 0 -> vertex 1
|
||||
SVECTOR l12; // line vertex 1 -> vertex 2
|
||||
SVECTOR l23; // line vertex 2 -> vertex 3
|
||||
SVECTOR l30; // line vertex 3 -> vertex 0
|
||||
SVECTOR n01; // normal to plane & line 01
|
||||
SVECTOR n12; // normal to plane & line 12
|
||||
SVECTOR n23; // normal to plane & line 23
|
||||
SVECTOR n30; // normal to plane & line 30
|
||||
SVECTOR pn; // plane normal
|
||||
int32 d; // plane distance
|
||||
int32 n01dots0; // n01 . vertex 0
|
||||
int32 n12dots1; // n12 . vertex 1
|
||||
int32 n23dots2; // n23 . vertex 2
|
||||
int32 n30dots3; // n30 . vertex 3
|
||||
} ShadeQuad;
|
||||
|
||||
typedef struct PSXShade {
|
||||
char shade_name[RLP_SHADE_NAME_LENGTH];
|
||||
char prop_name[RLP_PROP_NAME_LENGTH];
|
||||
uint32 nStates;
|
||||
ShadeQuad states[1]; // ShadeQuad states[nStates]
|
||||
} PSXShade;
|
||||
|
||||
// For use with pre-processing converter
|
||||
typedef struct ShadeInfo {
|
||||
char shade_name[RLP_SHADE_NAME_LENGTH];
|
||||
char prop_name[RLP_PROP_NAME_LENGTH];
|
||||
uint32 nStates;
|
||||
ShadeQuad states[MAX_NUMBER_SHADE_STATES];
|
||||
} ShadeInfo;
|
||||
|
||||
typedef struct rlp_API {
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint8 nLamps;
|
||||
uint8 nShades;
|
||||
uint16 shadeOffsetsOffset;
|
||||
PSXrgb ambient;
|
||||
// Byte offsets
|
||||
uint32 lampOffsets[1]; // actually lampOffsets[nLamps]
|
||||
inline PSXLamp *GetLamp(const int32 l);
|
||||
inline uint32 *GetShadeOffsets(void);
|
||||
inline PSXShade *GetShade(const int32 s);
|
||||
} rlp_API;
|
||||
|
||||
inline PSXLamp *rlp_API::GetLamp(const int32 l) { return (PSXLamp *)(id + lampOffsets[l]); }
|
||||
|
||||
inline uint32 *rlp_API::GetShadeOffsets(void) { return (uint32 *)(id + shadeOffsetsOffset); }
|
||||
|
||||
inline PSXShade *rlp_API::GetShade(const int32 s) {
|
||||
uint32 *shadeOffsets = GetShadeOffsets();
|
||||
return (PSXShade *)(id + shadeOffsets[s]);
|
||||
}
|
||||
|
||||
typedef struct rlp_API_9 {
|
||||
char id[4];
|
||||
uint32 schema;
|
||||
uint32 nLamps;
|
||||
PSXrgb ambient;
|
||||
// Byte offsets
|
||||
uint32 lampOffsets[1]; // actually lampOffsets[nLamps]
|
||||
// PSXLamp lamps[nLamps]
|
||||
} rlp_API_9;
|
||||
|
||||
// Convert from API schema 9 to API schema 10
|
||||
inline void ConvertRLP(rlp_API *rlp) {
|
||||
if (rlp->schema == RLP_API_SCHEMA)
|
||||
return;
|
||||
}
|
||||
|
||||
} // End of namespace ICB
|
||||
|
||||
#endif // #ifndef RLP_API_H
|
||||
Reference in New Issue
Block a user