Merge pull request #95 from h4570/assert

Add assertions
This commit is contained in:
Sandro Sobczyński
2021-05-26 19:39:08 +02:00
committed by GitHub
26 changed files with 176 additions and 276 deletions
+4
View File
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Unit tests - Unit tests
- Assert
### Changed
- All PRINT_LOG and PRINT_ERR to consoleLog() and assertMsg()
## [1.31.2] - 2021-02-06 ## [1.31.2] - 2021-02-06
+6 -10
View File
@@ -52,16 +52,12 @@ void Engine::setDefaultScreen()
void Engine::init(Game *t_game, u32 t_gifPacketSize) void Engine::init(Game *t_game, u32 t_gifPacketSize)
{ {
if (isInitialized) assertMsg(!isInitialized, "Engine was already initialized!");
PRINT_ERR("Already initialized!"); game = t_game;
else renderer = new Renderer(t_gifPacketSize, &screen);
{ isInitialized = true;
game = t_game; game->onInit();
renderer = new Renderer(t_gifPacketSize, &screen); gameLoop();
isInitialized = true;
game->onInit();
gameLoop();
}
} }
/** Do not call this method. This is used in gameLoop() to maintain multithreading */ /** Do not call this method. This is used in gameLoop() to maintain multithreading */
+2 -4
View File
@@ -167,10 +167,8 @@ public:
void removeLinkById(const u32 &t_id) void removeLinkById(const u32 &t_id)
{ {
s32 index = getIndexOfLink(t_id); s32 index = getIndexOfLink(t_id);
if (index != -1) assertMsg(index != -1, "Cant remove link, because it was not found!");
removeLinkByIndex(index); removeLinkByIndex(index);
else
PRINT_ERR("Cant remove link, because it was not found!");
} }
private: private:
@@ -119,10 +119,8 @@ public:
const void removeById(const u32 &t_texId) const void removeById(const u32 &t_texId)
{ {
s32 index = getIndexOf(t_texId); s32 index = getIndexOf(t_texId);
if (index != -1) assertMsg(index != -1, "Cant remove texture, because it was not found!");
removeByIndex(index); removeByIndex(index);
else
PRINT_ERR("Cant remove texture, because it was not found!");
} }
private: private:
+12 -8
View File
@@ -11,14 +11,16 @@
#ifndef _TYRA_DEBUG_ #ifndef _TYRA_DEBUG_
#define _TYRA_DEBUG_ #define _TYRA_DEBUG_
#include <tamtypes.h> #ifdef NDEBUG
#include <math3d.h> #define consoleLog(message) ((void)0)
#include <stdio.h> #define assertMsg(condition, message) ((void)0)
#else // IF Debug
#include <stdio.h>
class Debug class Debug
{ {
public: public:
static void errTrap(char *t_text, char *t_file) static void trap(const char *t_text, const char *t_file)
{ {
printf("\n"); printf("\n");
printf("====================================\n"); printf("====================================\n");
@@ -29,8 +31,10 @@ public:
; ;
} }
}; };
#define consoleLog(message) printf("LOG: " message " (" __FILE__ ")\n")
#define assertMsg(condition, message) \
if (!(condition)) \
Debug::trap(message, __FILE__)
#endif // NDEBUG
#define PRINT_LOG(TEXT) printf("LOG: " TEXT " (" __FILE__ ")\n") #endif // _TYRA_DEBUG_
#define PRINT_ERR(TEXT) Debug::errTrap(TEXT, __FILE__)
#endif
+2 -10
View File
@@ -38,12 +38,7 @@ void BmpLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
delete[] path_part1; delete[] path_part1;
delete[] path_part2; delete[] path_part2;
FILE *file = fopen(path, "rb"); FILE *file = fopen(path, "rb");
assertMsg(file != NULL, "Failed to load .bmp file!");
if (file == NULL)
{
PRINT_ERR("Failed to load .bmp file!");
return;
}
unsigned char header[54]; unsigned char header[54];
fread(header, sizeof(unsigned char), 54, file); fread(header, sizeof(unsigned char), 54, file);
@@ -53,10 +48,7 @@ void BmpLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
u32 bits = (u32)header[28]; u32 bits = (u32)header[28];
u32 dataOffset = (u32)header[10]; u32 dataOffset = (u32)header[10];
if (bits != 24) assertMsg(bits == 24, "Invalid bits per pixel in .bmp file - expected 24!");
{
PRINT_ERR("Invalid bits per pixel in .bmp file - expected 24!");
}
o_texture.setSize(width, height, TEX_TYPE_RGB); o_texture.setSize(width, height, TEX_TYPE_RGB);
printf("BMPLoader - width: %d | height: %d | bits: %d\n", width, height, bits); printf("BMPLoader - width: %d | height: %d | bits: %d\n", width, height, bits);
+3 -4
View File
@@ -36,11 +36,10 @@ DffLoader::~DffLoader() {}
void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT) void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
{ {
PRINT_LOG("Loading dff file"); consoleLog("Loading dff file");
char *path = String::createConcatenated("host:", t_filename); char *path = String::createConcatenated("host:", t_filename);
FILE *file = fopen(path, "rb"); FILE *file = fopen(path, "rb");
if (file == NULL) assertMsg(file != NULL, "Failed to load .dff file!");
PRINT_ERR("Failed to load .dff file!");
fseek(file, 0L, SEEK_END); fseek(file, 0L, SEEK_END);
long fileSize = ftell(file); long fileSize = ftell(file);
u8 data[fileSize]; u8 data[fileSize];
@@ -50,7 +49,7 @@ void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
serialize(o_result, t_invertT, data, t_scale); serialize(o_result, t_invertT, data, t_scale);
o_result->calculateBoundingBoxes(); o_result->calculateBoundingBoxes();
delete[] path; delete[] path;
PRINT_LOG("Dff file loaded!"); consoleLog("Dff file loaded!");
} }
// void DffLoader::im_not_used_anywhere(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT) // void DffLoader::im_not_used_anywhere(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
+4 -13
View File
@@ -44,7 +44,7 @@ int MEM_fread(char *buf, size_t size, size_t n, const FILE *f)
*/ */
MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWithoutExtension, float t_scale, u8 t_invertT) MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWithoutExtension, float t_scale, u8 t_invertT)
{ {
PRINT_LOG("Loading new MD2 file"); consoleLog("Loading new MD2 file");
char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension); char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension);
char *part2 = String::createConcatenated("host:", part1); char *part2 = String::createConcatenated("host:", part1);
char *finalPath = String::createConcatenated(part2, ".md2"); // "folder/object.md2" char *finalPath = String::createConcatenated(part2, ".md2"); // "folder/object.md2"
@@ -53,20 +53,11 @@ MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWith
md2_t header; md2_t header;
FILE *file = fopen(finalPath, "rb"); FILE *file = fopen(finalPath, "rb");
assertMsg(file != NULL, "Failed to load .md2 file!");
if (file == NULL)
{
PRINT_ERR("Failed to load .md2 file!");
return NULL;
}
fread((char *)&header, sizeof(md2_t), 1, file); fread((char *)&header, sizeof(md2_t), 1, file);
if ((header.ident != MD2_IDENT) && (header.version != MD2_VERSION)) assertMsg((header.ident == MD2_IDENT) && (header.version == MD2_VERSION), "This MD2 file was not in correct format!");
{
PRINT_ERR("This MD2 file was not in correct format!");
return NULL;
}
u32 framesCount = header.num_frames; u32 framesCount = header.num_frames;
u32 vertexCount = header.num_xyz; u32 vertexCount = header.num_xyz;
@@ -147,7 +138,7 @@ MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWith
} }
} }
PRINT_LOG("MD2 file loaded!"); consoleLog("MD2 file loaded!");
delete[] finalPath; delete[] finalPath;
o_framesCount = framesCount; o_framesCount = framesCount;
for (u32 i = 0; i < framesCount; i++) for (u32 i = 0; i < framesCount; i++)
+8 -16
View File
@@ -30,8 +30,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
{ {
char *path = String::createConcatenated("host:", t_filename); char *path = String::createConcatenated("host:", t_filename);
FILE *file = fopen(path, "rb"); FILE *file = fopen(path, "rb");
if (file == NULL) assertMsg(file != NULL, "Failed to load .obj file!");
PRINT_ERR("Failed to load .obj file!");
allocateObjMemory(file, o_result); allocateObjMemory(file, o_result);
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
u32 verticesI = 0, cordsI = 0, normalsI = 0, faceI = 0, vertexIndex[3], coordIndex[3], normalIndex[3]; u32 verticesI = 0, cordsI = 0, normalsI = 0, faceI = 0, vertexIndex[3], coordIndex[3], normalIndex[3];
@@ -112,26 +111,19 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
/** Failed, checking configuration V//VN */ /** Failed, checking configuration V//VN */
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", x, x, x, x, x, x); newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", x, x, x, x, x, x);
fsetpos(file, &start); fsetpos(file, &start);
if (newerMatches == 6) assertMsg(newerMatches == 6, "Unknown .obj face for .obj file!");
{ /** Configuration confirmed. */
/** Configuration confirmed. */ newerMatches = fscanf(file, "%d//%d %d//%d %d//%d",
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", &vertexIndex[0], &normalIndex[0],
&vertexIndex[0], &normalIndex[0], &vertexIndex[1], &normalIndex[1],
&vertexIndex[1], &normalIndex[1], &vertexIndex[2], &normalIndex[2]);
&vertexIndex[2], &normalIndex[2]);
}
else
{
/**Unknown configuration.*/
PRINT_ERR("Unknown .obj face for .obj file!");
}
} }
break; break;
} }
break; break;
default: default:
{ {
PRINT_ERR("Unknown faces format in .obj file!"); assertMsg(true == false, "Unknown faces format in .obj file!");
break; break;
} }
} }
+5 -18
View File
@@ -40,9 +40,7 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
delete[] path_part2; delete[] path_part2;
FILE *file = fopen(path, "rb"); FILE *file = fopen(path, "rb");
assertMsg(file != NULL, "Failed to open .png file!");
if (file == NULL)
PRINT_ERR("Failed to open .png file!");
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
@@ -52,26 +50,15 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
int bit_depth, color_type, interlace_type; int bit_depth, color_type, interlace_type;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
assertMsg(png_ptr, "PNG struct info init failed(1)!");
if (!png_ptr)
PRINT_ERR("PNG struct info init failed(1)!");
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
assertMsg(info_ptr, "PNG struct info init failed(2)!");
if (!info_ptr) assertMsg(!setjmp(png_jmpbuf(png_ptr)), "PNG reader fatal error!");
PRINT_ERR("PNG struct info init failed(2)!");
if (setjmp(png_jmpbuf(png_ptr)))
PRINT_ERR("PNG reader fatal error!");
png_init_io(png_ptr, file); png_init_io(png_ptr, file);
png_set_sig_bytes(png_ptr, sig_read); png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr); png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL); png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
png_set_strip_16(png_ptr); png_set_strip_16(png_ptr);
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
@@ -98,7 +85,7 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
type = TEX_TYPE_RGB; type = TEX_TYPE_RGB;
break; break;
default: default:
PRINT_ERR("This png format is not supported! RGB/RGBA only."); assertMsg(true == false, "This png format is not supported! RGB/RGBA only.");
} }
o_texture.setSize(width, height, type); o_texture.setSize(width, height, type);
+19 -32
View File
@@ -70,9 +70,8 @@ void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, con
void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, const u32 &t_framesCount, const u8 &t_invertT) void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, const u32 &t_framesCount, const u8 &t_invertT)
{ {
if (t_framesCount == 0) assertMsg(t_framesCount != 0, "Frames count cannot be 0!");
PRINT_ERR("Frames count cannot be 0!"); if (t_framesCount == 1)
else if (t_framesCount == 1)
loadObj(t_subfolder, t_objFile, t_scale, t_invertT); loadObj(t_subfolder, t_objFile, t_scale, t_invertT);
else else
{ {
@@ -132,39 +131,27 @@ void Mesh::loadFrom(const Mesh &t_mesh)
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame) void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame)
{ {
if (framesCount > 1) assertMsg(framesCount > 0, "Cant play animation, because no mesh data was loaded!");
{ assertMsg(framesCount != 1, "Cant play animation, because this mesh have only one frame.");
if (t_endFrame >= framesCount) assertMsg(t_endFrame < framesCount, "End frame value is too high. Valid range: (0, getFramesCount()-1)");
PRINT_ERR("End frame value is too high. Valid range: (0, getFramesCount()-1)"); animState.startFrame = t_startFrame;
animState.startFrame = t_startFrame; animState.endFrame = t_endFrame;
animState.endFrame = t_endFrame; if (animState.currentFrame == t_startFrame)
if (animState.currentFrame == t_startFrame) animState.nextFrame = t_endFrame;
animState.nextFrame = t_endFrame; else
else animState.nextFrame = t_startFrame;
animState.nextFrame = t_startFrame;
}
else if (framesCount == 0)
PRINT_ERR("Cant play animation, because no mesh data was loaded!");
else if (framesCount == 1)
PRINT_ERR("Cant play animation, because this mesh have only one frame.");
} }
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame, const u32 &t_stayFrame) void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame, const u32 &t_stayFrame)
{ {
if (framesCount > 1) assertMsg(framesCount > 0, "Cant play animation, because no mesh data was loaded!");
{ assertMsg(framesCount != 1, "Cant play animation, because this mesh have only one frame.");
if (t_endFrame >= framesCount) assertMsg(t_endFrame < framesCount, "End frame value is too high. Valid range: (0, getFramesCount()-1)");
PRINT_ERR("End frame value is too high. Valid range: (0, getFramesCount()-1)"); animState.startFrame = t_startFrame;
animState.startFrame = t_startFrame; animState.endFrame = t_endFrame;
animState.endFrame = t_endFrame; animState.isStayFrameSet = true;
animState.isStayFrameSet = true; animState.stayFrame = t_stayFrame;
animState.stayFrame = t_stayFrame; animState.nextFrame = t_startFrame;
animState.nextFrame = t_startFrame;
}
else if (framesCount == 0)
PRINT_ERR("Cant play animation, because no mesh data was loaded!");
else if (framesCount == 1)
PRINT_ERR("Cant play animation, because this mesh have only one frame.");
} }
void Mesh::animate() void Mesh::animate()
+5 -23
View File
@@ -52,11 +52,7 @@ MeshFrame::~MeshFrame()
void MeshFrame::allocateSTs(const u32 &t_val) void MeshFrame::allocateSTs(const u32 &t_val)
{ {
if (_areSTsAllocated) assertMsg(!_areSTsAllocated, "Can't allocate STs, because were already set!");
{
PRINT_ERR("Can't allocate STs, because were already set!");
return;
}
stsCount = t_val; stsCount = t_val;
sts = new Point[t_val]; sts = new Point[t_val];
_areSTsAllocated = true; _areSTsAllocated = true;
@@ -64,11 +60,7 @@ void MeshFrame::allocateSTs(const u32 &t_val)
void MeshFrame::allocateVertices(const u32 &t_val) void MeshFrame::allocateVertices(const u32 &t_val)
{ {
if (_areVerticesAllocated) assertMsg(!_areVerticesAllocated, "Can't allocate vertices, because were already set!");
{
PRINT_ERR("Can't allocate vertices, because were already set!");
return;
}
vertexCount = t_val; vertexCount = t_val;
vertices = new Vector3[t_val]; vertices = new Vector3[t_val];
_areVerticesAllocated = true; _areVerticesAllocated = true;
@@ -76,11 +68,7 @@ void MeshFrame::allocateVertices(const u32 &t_val)
void MeshFrame::allocateNormals(const u32 &t_val) void MeshFrame::allocateNormals(const u32 &t_val)
{ {
if (_areNormalsAllocated) assertMsg(!_areNormalsAllocated, "Can't allocate normals, because were already set!");
{
PRINT_ERR("Can't allocate normals, because were already set!");
return;
}
normalsCount = t_val; normalsCount = t_val;
normals = new Vector3[t_val]; normals = new Vector3[t_val];
_areNormalsAllocated = true; _areNormalsAllocated = true;
@@ -88,11 +76,7 @@ void MeshFrame::allocateNormals(const u32 &t_val)
void MeshFrame::allocateMaterials(const u32 &t_val) void MeshFrame::allocateMaterials(const u32 &t_val)
{ {
if (_areMaterialsAllocated) assertMsg(!_areMaterialsAllocated, "Can't allocate materials, because were already set!");
{
PRINT_ERR("Can't allocate materials, because were already set!");
return;
}
materialsCount = t_val; materialsCount = t_val;
materials = new MeshMaterial[t_val]; materials = new MeshMaterial[t_val];
_areMaterialsAllocated = true; _areMaterialsAllocated = true;
@@ -100,9 +84,7 @@ void MeshFrame::allocateMaterials(const u32 &t_val)
void MeshFrame::calculateBoundingBoxes() void MeshFrame::calculateBoundingBoxes()
{ {
if (!_areVerticesAllocated) assertMsg(_areVerticesAllocated, "Can't calculate bounding box, because vertices were not allocated!");
PRINT_ERR("Can't calculate bounding box, because vertices were not allocated!");
for (u32 i = 0; i < materialsCount; i++) for (u32 i = 0; i < materialsCount; i++)
materials->calculateBoundingBox(vertices, vertexCount); materials->calculateBoundingBox(vertices, vertexCount);
+4 -12
View File
@@ -52,11 +52,7 @@ MeshMaterial::~MeshMaterial()
void MeshMaterial::allocateFaces(const u32 &t_val) void MeshMaterial::allocateFaces(const u32 &t_val)
{ {
if (_areFacesAllocated) assertMsg(!_areFacesAllocated, "Can't allocate faces, because were already set!");
{
PRINT_ERR("Can't allocate faces, because were already set!");
return;
}
facesCount = t_val; facesCount = t_val;
stFaces = new u32[t_val]; stFaces = new u32[t_val];
normalFaces = new u32[t_val]; normalFaces = new u32[t_val];
@@ -66,11 +62,7 @@ void MeshMaterial::allocateFaces(const u32 &t_val)
void MeshMaterial::setName(char *t_val) void MeshMaterial::setName(char *t_val)
{ {
if (_isNameSet) assertMsg(!_isNameSet, "Can't set name, because was already set!");
{
PRINT_ERR("Can't set name, because was already set!");
return;
}
name = String::createCopy(t_val); name = String::createCopy(t_val);
_isNameSet = true; _isNameSet = true;
} }
@@ -143,8 +135,8 @@ void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
boundingBox[7].set(hiX, hiY, hiZ); boundingBox[7].set(hiX, hiY, hiZ);
_isBoundingBoxCalculated = true; _isBoundingBoxCalculated = true;
//BoundingBox is declared on the heap to prevent any ill-formed default // BoundingBox is declared on the heap to prevent any ill-formed default
//constructor instantiated BoundingBox objects. // constructor instantiated BoundingBox objects.
boundingBoxObj = new BoundingBox(boundingBox); boundingBoxObj = new BoundingBox(boundingBox);
} }
+3 -12
View File
@@ -41,13 +41,8 @@ Texture::~Texture()
void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type) void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type)
{ {
if (_isSizeSet) assertMsg(!_isSizeSet, "Can't set size, because was already set!");
{ assertMsg(t_width <= 256 && t_height <= 256, "Given texture can be too big for PS2. Please strict to 256x256 max. Prefer 128x128.");
PRINT_ERR("Can't set size, because was already set!");
return;
}
if (t_width > 256 || t_height > 256)
PRINT_ERR("Given texture can be too big for PS2. Please strict to 256x256 max. Prefer 128x128.");
width = t_width; width = t_width;
height = t_height; height = t_height;
_type = t_type; _type = t_type;
@@ -57,11 +52,7 @@ void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &
void Texture::setName(char *t_val) void Texture::setName(char *t_val)
{ {
if (_isNameSet) assertMsg(!_isNameSet, "Can't set name, because was already set!");
{
PRINT_ERR("Can't set name, because was already set!");
return;
}
name = String::createCopy(t_val); name = String::createCopy(t_val);
_isNameSet = true; _isNameSet = true;
} }
+25 -33
View File
@@ -52,20 +52,15 @@ void Audio::loadSong(char *t_path)
char *fullFilename = String::createConcatenated("host:", t_path); char *fullFilename = String::createConcatenated("host:", t_path);
wav = fopen(fullFilename, "rb"); wav = fopen(fullFilename, "rb");
delete[] fullFilename; delete[] fullFilename;
if (wav == NULL) assertMsg(wav != NULL, "Failed to open wav file!");
PRINT_ERR("Failed to open wav file!"); rewindSongToStart();
else songLoaded = true;
{ consoleLog("Song loaded!");
rewindSongToStart();
songLoaded = true;
PRINT_LOG("Song loaded!");
}
} }
void Audio::playSong() void Audio::playSong()
{ {
if (!songLoaded) assertMsg(songLoaded, "Cant play song because was not loaded!");
PRINT_ERR("Cant play song because was not loaded!");
if (songFinished) if (songFinished)
rewindSongToStart(); rewindSongToStart();
volume = realVolume; volume = realVolume;
@@ -105,8 +100,7 @@ void Audio::removeSongListener(const u32 &t_id)
index = i; index = i;
break; break;
} }
if (index == -1) assertMsg(index != -1, "Cant remove listener because given id was not found!");
PRINT_ERR("Cant remove listener because given id was not found!");
delete songListeners[index]; delete songListeners[index];
songListeners.erase(songListeners.begin() + index); songListeners.erase(songListeners.begin() + index);
} }
@@ -132,7 +126,7 @@ audsrv_adpcm_t *Audio::loadADPCM(char *t_path)
if (audsrv_load_adpcm(result, data, adpcmFileSize)) if (audsrv_load_adpcm(result, data, adpcmFileSize))
{ {
printf("AUDSRV returned error string: %s", audsrv_get_error_string()); printf("AUDSRV returned error string: %s", audsrv_get_error_string());
PRINT_ERR("audsrv_load_adpcm() failed!"); assertMsg(true == false, "audsrv_load_adpcm() failed!");
} }
fclose(file); fclose(file);
return result; return result;
@@ -143,7 +137,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm)
if (audsrv_play_adpcm(t_adpcm)) if (audsrv_play_adpcm(t_adpcm))
{ {
printf("AUDSRV returned error string: %s", audsrv_get_error_string()); printf("AUDSRV returned error string: %s", audsrv_get_error_string());
PRINT_ERR("audsrv_play_adpcm() failed!"); assertMsg(true == false, "audsrv_play_adpcm() failed!");
} }
} }
@@ -152,7 +146,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm, const s8 &t_ch)
if (audsrv_ch_play_adpcm(t_ch, t_adpcm)) if (audsrv_ch_play_adpcm(t_ch, t_adpcm))
{ {
printf("AUDSRV returned error string: %s", audsrv_get_error_string()); printf("AUDSRV returned error string: %s", audsrv_get_error_string());
PRINT_ERR("audsrv_play_adpcm() failed!"); assertMsg(true == false, "audsrv_ch_play_adpcm() failed!");
} }
} }
@@ -160,7 +154,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm, const s8 &t_ch)
void Audio::startThread(FileService *t_fileService) void Audio::startThread(FileService *t_fileService)
{ {
PRINT_LOG("Creating audio thread"); consoleLog("Creating audio thread");
// fileService = t_fileService; // fileService = t_fileService;
extern void *_gp; extern void *_gp;
thread.func = (void *)Audio::mainThread; thread.func = (void *)Audio::mainThread;
@@ -168,11 +162,11 @@ void Audio::startThread(FileService *t_fileService)
thread.stack_size = getThreadStackSize(); thread.stack_size = getThreadStackSize();
thread.gp_reg = (void *)&_gp; thread.gp_reg = (void *)&_gp;
thread.initial_priority = 0x17; thread.initial_priority = 0x17;
if ((threadId = CreateThread(&thread)) < 0) threadId = CreateThread(&thread);
PRINT_ERR("Create audio thread failed!"); assertMsg(threadId >= 0, "Create audio thread failed!");
PRINT_LOG("Audio thread created"); consoleLog("Audio thread created");
StartThread(threadId, NULL); StartThread(threadId, NULL);
PRINT_LOG("Audio thread started"); consoleLog("Audio thread started");
} }
/** Main thread loop */ /** Main thread loop */
@@ -256,25 +250,23 @@ void Audio::rewindSongToStart()
/** Initialize semaphore which will wait until chunk of the song is not finished. */ /** Initialize semaphore which will wait until chunk of the song is not finished. */
void Audio::initSema() void Audio::initSema()
{ {
PRINT_LOG("Creating audio semaphore"); consoleLog("Creating audio semaphore");
sema.init_count = 0; sema.init_count = 0;
sema.max_count = 1; sema.max_count = 1;
sema.option = 0; sema.option = 0;
fillbufferSema = CreateSema(&sema); fillbufferSema = CreateSema(&sema);
PRINT_LOG("Audio semaphore created"); consoleLog("Audio semaphore created");
} }
/** Load LIBSD and AUDSRV modules */ /** Load LIBSD and AUDSRV modules */
void Audio::loadModules() void Audio::loadModules()
{ {
PRINT_LOG("Modules loading started (LIBSD, AUDSRV)"); consoleLog("Modules loading started (LIBSD, AUDSRV)");
int ret = SifLoadModule("rom0:LIBSD", 0, NULL); int ret = SifLoadModule("rom0:LIBSD", 0, NULL);
if (ret == -203) assertMsg(ret != -203, "LIBSD loading failed!");
PRINT_ERR("LIBSD loading failed!");
ret = SifLoadModule("host:AUDSRV.IRX", 0, NULL); ret = SifLoadModule("host:AUDSRV.IRX", 0, NULL);
if (ret == -203) assertMsg(ret != -203, "AUDSRV.IRX loading failed!");
PRINT_ERR("AUDSRV.IRX loading failed!"); consoleLog("Audio modules loaded");
PRINT_LOG("Audio modules loaded");
} }
/** /**
@@ -283,26 +275,26 @@ void Audio::loadModules()
*/ */
void Audio::initAUDSRV() void Audio::initAUDSRV()
{ {
PRINT_LOG("Initializing AUDSRV"); consoleLog("Initializing AUDSRV");
int ret = audsrv_init(); int ret = audsrv_init();
if (ret != 0) if (ret != 0)
{ {
printf("AUDSRV returned error string: %s", audsrv_get_error_string()); printf("AUDSRV returned error string: %s", audsrv_get_error_string());
PRINT_ERR("Failed to initialize AUDSRV!"); assertMsg(true == false, "Failed to initialize AUDSRV!");
} }
ret = audsrv_adpcm_init(); ret = audsrv_adpcm_init();
if (ret != 0) if (ret != 0)
{ {
printf("AUDSRV returned error string: %s", audsrv_get_error_string()); printf("AUDSRV returned error string: %s", audsrv_get_error_string());
PRINT_ERR("Failed to initialize AUDSRV ADPCM!"); assertMsg(true == false, "Failed to initialize AUDSRV ADPCM!");
} }
ret = audsrv_on_fillbuf(getSongBufferSize(), (audsrv_callback_t)iSignalSema, (void *)fillbufferSema); ret = audsrv_on_fillbuf(getSongBufferSize(), (audsrv_callback_t)iSignalSema, (void *)fillbufferSema);
if (ret != 0) if (ret != 0)
{ {
printf("AUDSRV returned error string: %s", audsrv_get_error_string()); printf("AUDSRV returned error string: %s", audsrv_get_error_string());
PRINT_ERR("Failed to initialize AUDSRV fillbuffer!"); assertMsg(true == false, "Failed to initialize AUDSRV fillbuffer!");
} }
PRINT_LOG("AUDSRV initialized!"); consoleLog("AUDSRV initialized!");
} }
/** /**
+2 -2
View File
@@ -21,7 +21,7 @@
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position) CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
: screen(t_screen) : screen(t_screen)
{ {
PRINT_LOG("Initializing frustum"); consoleLog("Initializing frustum");
farPlaneDist = screen->farPlaneDist; farPlaneDist = screen->farPlaneDist;
nearPlaneDist = screen->nearPlaneDist; nearPlaneDist = screen->nearPlaneDist;
float tang = tanf(screen->fov * Math::HALF_ANG2RAD); float tang = tanf(screen->fov * Math::HALF_ANG2RAD);
@@ -31,7 +31,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
farWidth = farHeight * screen->aspectRatio; farWidth = farHeight * screen->aspectRatio;
p_position = t_position; p_position = t_position;
up.set(0.0F, 1.0F, 0.0F); up.set(0.0F, 1.0F, 0.0F);
PRINT_LOG("CameraBase initialized!"); consoleLog("CameraBase initialized!");
} }
// ---- // ----
+8 -11
View File
@@ -43,8 +43,7 @@ u32 FileService::addReadChunk(FILE *t_file, void *t_destination, const u32 &t_si
s32 FileService::isTaskDone(const u32 &t_taskId) s32 FileService::isTaskDone(const u32 &t_taskId)
{ {
s32 taskIndex = getIndexOf(t_taskId); s32 taskIndex = getIndexOf(t_taskId);
if (taskIndex == -1) assertMsg(taskIndex != -1, "Task was not found!");
PRINT_ERR("Task was not found!");
s32 result = tasks[taskIndex].readStatus; s32 result = tasks[taskIndex].readStatus;
if (result != -2137) if (result != -2137)
removeByIndex(taskIndex); removeByIndex(taskIndex);
@@ -54,10 +53,8 @@ s32 FileService::isTaskDone(const u32 &t_taskId)
const void FileService::removeById(const u32 &t_taskId) const void FileService::removeById(const u32 &t_taskId)
{ {
s32 index = getIndexOf(t_taskId); s32 index = getIndexOf(t_taskId);
if (index != -1) assertMsg(index != -1, "Cant remove task, because it was not found!");
removeByIndex(index); removeByIndex(index);
else
PRINT_ERR("Cant remove task, because it was not found!");
} }
const s32 FileService::getIndexOf(const u32 &t_taskId) const s32 FileService::getIndexOf(const u32 &t_taskId)
@@ -72,18 +69,18 @@ const s32 FileService::getIndexOf(const u32 &t_taskId)
void FileService::startThread() void FileService::startThread()
{ {
PRINT_LOG("Creating file service thread"); consoleLog("Creating file service thread");
extern void *_gp; extern void *_gp;
thread.func = (void *)FileService::mainThread; thread.func = (void *)FileService::mainThread;
thread.stack = threadStack; thread.stack = threadStack;
thread.stack_size = getThreadStackSize(); thread.stack_size = getThreadStackSize();
thread.gp_reg = (void *)&_gp; thread.gp_reg = (void *)&_gp;
thread.initial_priority = 0x12; thread.initial_priority = 0x12;
if ((threadId = CreateThread(&thread)) < 0) threadId = CreateThread(&thread);
PRINT_ERR("Create audio thread failed!"); assertMsg(threadId >= 0, "Create audio thread failed!");
PRINT_LOG("File service created"); consoleLog("File service created");
StartThread(threadId, NULL); StartThread(threadId, NULL);
PRINT_LOG("File service started"); consoleLog("File service started");
} }
/** Main thread loop */ /** Main thread loop */
+2 -2
View File
@@ -30,12 +30,12 @@
*/ */
GifSender::GifSender(u32 t_packetSize, ScreenSettings *t_screen, Light *t_light) : screen(t_screen) GifSender::GifSender(u32 t_packetSize, ScreenSettings *t_screen, Light *t_light) : screen(t_screen)
{ {
PRINT_LOG("Initializing GifSender"); consoleLog("Initializing GifSender");
light = t_light; light = t_light;
packetSize = t_packetSize; packetSize = t_packetSize;
packets[0] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false); packets[0] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
packets[1] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false); packets[1] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
PRINT_LOG("GifSender initialized!"); consoleLog("GifSender initialized!");
} }
/** Releases packets memory */ /** Releases packets memory */
+15 -33
View File
@@ -30,15 +30,10 @@ Pad::Pad()
this->slot = 0; // Always zero if not using multitap this->slot = 0; // Always zero if not using multitap
if ((this->ret = padPortOpen(this->port, this->slot, padBuf)) == 0) if ((this->ret = padPortOpen(this->port, this->slot, padBuf)) == 0)
{ {
PRINT_ERR("padPortOpen failed!");
printf("padPortOpen returned: %d\n", this->ret); printf("padPortOpen returned: %d\n", this->ret);
SleepThread(); assertMsg(true == false, "padPortOpen failed!");
}
if (!this->initPad())
{
PRINT_ERR("initPad failed!");
SleepThread();
} }
assertMsg(this->initPad(), "initPad failed!");
} }
Pad::~Pad() {} Pad::~Pad() {}
@@ -50,22 +45,20 @@ Pad::~Pad() {}
/** Load SIO2MAN and PADMAN modules */ /** Load SIO2MAN and PADMAN modules */
void Pad::loadModules() void Pad::loadModules()
{ {
PRINT_LOG("Loading pad modules"); consoleLog("Loading pad modules");
this->ret = SifLoadModule("rom0:SIO2MAN", 0, NULL); this->ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
if (this->ret < 0) if (this->ret < 0)
{ {
PRINT_ERR("SifLoadModule (SIO2MAN) failed!");
printf("SifLoadModule returned: %d\n", this->ret); printf("SifLoadModule returned: %d\n", this->ret);
SleepThread(); assertMsg(true == false, "SifLoadModule (SIO2MAN) failed!");
} }
this->ret = SifLoadModule("rom0:PADMAN", 0, NULL); this->ret = SifLoadModule("rom0:PADMAN", 0, NULL);
if (this->ret < 0) if (this->ret < 0)
{ {
PRINT_ERR("SifLoadModule (PADMAN) failed!");
printf("SifLoadModule returned: %d\n", this->ret); printf("SifLoadModule returned: %d\n", this->ret);
SleepThread(); assertMsg(true == false, "SifLoadModule (PADMAN) failed!");
} }
PRINT_LOG("Pad modules loaded!"); consoleLog("Pad modules loaded!");
} }
/** Wait when pad will be ready (stable and ready) */ /** Wait when pad will be ready (stable and ready) */
@@ -81,7 +74,7 @@ int Pad::waitPadReady()
if (state != lastState) if (state != lastState)
{ {
padStateInt2String(state, stateString); padStateInt2String(state, stateString);
PRINT_LOG("Pad state changed"); consoleLog("Pad state changed");
printf("Curent pad(%d,%d) status: %s\n", this->port, this->slot, stateString); printf("Curent pad(%d,%d) status: %s\n", this->port, this->slot, stateString);
} }
lastState = state; lastState = state;
@@ -89,23 +82,20 @@ int Pad::waitPadReady()
} }
// Were the pad ever 'out of sync'? // Were the pad ever 'out of sync'?
if (lastState != -1) if (lastState != -1)
PRINT_LOG("Pad is ready!"); consoleLog("Pad is ready!");
return 0; return 0;
} }
/** Initializes and checks type of pad */ /** Initializes and checks type of pad */
int Pad::initPad() int Pad::initPad()
{ {
PRINT_LOG("Initializing pad"); consoleLog("Initializing pad");
this->waitPadReady(); this->waitPadReady();
// How many different modes can this device operate in? // How many different modes can this device operate in?
// i.e. get # entrys in the modetable // i.e. get # entrys in the modetable
int modes = padInfoMode(this->port, this->slot, PAD_MODETABLE, -1); int modes = padInfoMode(this->port, this->slot, PAD_MODETABLE, -1);
if (modes == 0) assertMsg(modes, "Connected device is not a dual shock controller!"); // (it has no actuator engines)
{
PRINT_ERR("Connected device is not a dual shock controller!"); // (it has no actuator engines)
return 1;
}
// Verify that the controller has a DUAL SHOCK mode // Verify that the controller has a DUAL SHOCK mode
int i = 0; int i = 0;
do do
@@ -115,22 +105,14 @@ int Pad::initPad()
i++; i++;
} while (i < modes); } while (i < modes);
if (i >= modes) assertMsg(i < modes, "Connected device is not a dual shock controller!");
{
PRINT_ERR("Connected device is not a dual shock controller!");
return 1;
}
// If ExId != 0x0 => This controller has actuator engines // If ExId != 0x0 => This controller has actuator engines
// This check should always pass if the Dual Shock test above passed // This check should always pass if the Dual Shock test above passed
this->ret = padInfoMode(this->port, this->slot, PAD_MODECUREXID, 0); this->ret = padInfoMode(this->port, this->slot, PAD_MODECUREXID, 0);
if (this->ret == 0) assertMsg(this->ret, "Connected device is not a dual shock controller!");
{
PRINT_ERR("Connected device is not a dual shock controller!");
return 1;
}
PRINT_LOG("Enabling dual shock functions."); consoleLog("Enabling dual shock functions.");
// When using MMODE_LOCK, user cant change mode with Select button // When using MMODE_LOCK, user cant change mode with Select button
padSetMainMode(this->port, this->slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK); padSetMainMode(this->port, this->slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);
@@ -156,7 +138,7 @@ int Pad::initPad()
else else
printf("Did not find any actuators.\n"); printf("Did not find any actuators.\n");
this->waitPadReady(); this->waitPadReady();
PRINT_LOG("Pad initialized!"); consoleLog("Pad initialized!");
return 1; return 1;
} }
+16 -24
View File
@@ -33,7 +33,7 @@ static const float SCREEN_CENTER = GS_CENTER / 2.0F;
*/ */
Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen) Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
{ {
PRINT_LOG("Initializing renderer"); consoleLog("Initializing renderer");
dma_channel_initialize(DMA_CHANNEL_GIF, NULL, 0); // Initialize DMA to enable data transfer dma_channel_initialize(DMA_CHANNEL_GIF, NULL, 0); // Initialize DMA to enable data transfer
dma_channel_fast_waits(DMA_CHANNEL_GIF); dma_channel_fast_waits(DMA_CHANNEL_GIF);
screen = t_screen; screen = t_screen;
@@ -53,7 +53,7 @@ Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
vifSender = new VifSender(&light); vifSender = new VifSender(&light);
perspective.setPerspective(*t_screen); perspective.setPerspective(*t_screen);
renderData.projection = &perspective; renderData.projection = &perspective;
PRINT_LOG("Renderer initialized!"); consoleLog("Renderer initialized!");
} }
Renderer::~Renderer() {} Renderer::~Renderer() {}
@@ -69,8 +69,7 @@ void Renderer::allocateTextureBuffer(Texture *t_texture)
textureBuffer.psm = t_texture->getType(); textureBuffer.psm = t_texture->getType();
textureBuffer.info.components = textureBuffer.psm == TEX_TYPE_RGBA ? TEXTURE_COMPONENTS_RGBA : TEXTURE_COMPONENTS_RGB; textureBuffer.info.components = textureBuffer.psm == TEX_TYPE_RGBA ? TEXTURE_COMPONENTS_RGBA : TEXTURE_COMPONENTS_RGB;
textureBuffer.address = graph_vram_allocate(t_texture->getWidth(), t_texture->getHeight(), textureBuffer.psm, GRAPH_ALIGN_BLOCK); textureBuffer.address = graph_vram_allocate(t_texture->getWidth(), t_texture->getHeight(), textureBuffer.psm, GRAPH_ALIGN_BLOCK);
if (textureBuffer.address <= 1) assertMsg(textureBuffer.address > 1, "Texture buffer allocation error. No memory!");
PRINT_ERR("Texture buffer allocation error. No memory!");
textureBuffer.info.width = draw_log2(t_texture->getWidth()); textureBuffer.info.width = draw_log2(t_texture->getWidth());
textureBuffer.info.height = draw_log2(t_texture->getHeight()); textureBuffer.info.height = draw_log2(t_texture->getHeight());
textureBuffer.info.function = TEXTURE_FUNCTION_MODULATE; textureBuffer.info.function = TEXTURE_FUNCTION_MODULATE;
@@ -89,18 +88,14 @@ void Renderer::deallocateTextureBuffer()
void Renderer::changeTexture(Texture *t_tex) void Renderer::changeTexture(Texture *t_tex)
{ {
if (t_tex != NULL) assertMsg(t_tex != NULL, "Texture was not found in texture repository!");
if (t_tex->getId() != lastTextureId)
{ {
if (t_tex->getId() != lastTextureId) lastTextureId = t_tex->getId();
{ deallocateTextureBuffer();
lastTextureId = t_tex->getId(); allocateTextureBuffer(t_tex);
deallocateTextureBuffer(); GifSender::sendTexture(*t_tex, &textureBuffer);
allocateTextureBuffer(t_tex);
GifSender::sendTexture(*t_tex, &textureBuffer);
}
} }
else
PRINT_ERR("Texture was not found in texture repository!");
} }
void Renderer::draw(Sprite &t_sprite) void Renderer::draw(Sprite &t_sprite)
@@ -164,7 +159,7 @@ void Renderer::draw(Sprite &t_sprite)
/** Initializes drawing environment (1st app packet) */ /** Initializes drawing environment (1st app packet) */
void Renderer::initDrawingEnv() void Renderer::initDrawingEnv()
{ {
PRINT_LOG("Initializing drawing environment"); consoleLog("Initializing drawing environment");
packet2_t *packet2 = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0); packet2_t *packet2 = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0);
packet2_update(packet2, draw_setup_environment(packet2->base, 0, frameBuffers, &(zBuffer))); packet2_update(packet2, draw_setup_environment(packet2->base, 0, frameBuffers, &(zBuffer)));
packet2_update(packet2, draw_primitive_xyoffset(packet2->next, 0, packet2_update(packet2, draw_primitive_xyoffset(packet2->next, 0,
@@ -174,7 +169,7 @@ void Renderer::initDrawingEnv()
dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true); dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true);
dma_channel_wait(DMA_CHANNEL_GIF, 0); dma_channel_wait(DMA_CHANNEL_GIF, 0);
packet2_free(packet2); packet2_free(packet2);
PRINT_LOG("Drawing environment initialized!"); consoleLog("Drawing environment initialized!");
} }
/** Sets drawing prim for all 3D objects */ /** Sets drawing prim for all 3D objects */
@@ -189,7 +184,7 @@ void Renderer::setPrim()
prim.mapping_type = PRIM_MAP_ST; prim.mapping_type = PRIM_MAP_ST;
prim.colorfix = PRIM_UNFIXED; prim.colorfix = PRIM_UNFIXED;
renderData.prim = &prim; renderData.prim = &prim;
PRINT_LOG("Prim set!"); consoleLog("Prim set!");
} }
void Renderer::setWorldColor(const color_t &t_rgb) void Renderer::setWorldColor(const color_t &t_rgb)
@@ -219,7 +214,7 @@ void Renderer::allocateBuffers(int t_screenW, int t_screenH)
zBuffer.method = ZTEST_METHOD_GREATER_EQUAL; zBuffer.method = ZTEST_METHOD_GREATER_EQUAL;
zBuffer.zsm = GS_ZBUF_24; zBuffer.zsm = GS_ZBUF_24;
zBuffer.address = graph_vram_allocate(t_screenW, t_screenH, zBuffer.zsm, GRAPH_ALIGN_PAGE); zBuffer.address = graph_vram_allocate(t_screenW, t_screenH, zBuffer.zsm, GRAPH_ALIGN_PAGE);
PRINT_LOG("Framebuffers, zBuffer set and allocated!"); consoleLog("Framebuffers, zBuffer set and allocated!");
// Initialize the screen and tie the first framebuffer to the read circuits. // Initialize the screen and tie the first framebuffer to the read circuits.
graph_initialize(frameBuffers[0].address, frameBuffers[0].width, frameBuffers[0].height, frameBuffers[0].psm, 0, 0); graph_initialize(frameBuffers[0].address, frameBuffers[0].width, frameBuffers[0].height, frameBuffers[0].psm, 0, 0);
@@ -274,9 +269,8 @@ void Renderer::allocateBuffers(int t_screenW, int t_screenH)
void Renderer::draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount) void Renderer::draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
{ {
beginFrameIfNeeded(); beginFrameIfNeeded();
if (!t_meshes[0]->isDataLoaded()) assertMsg(t_meshes[0]->isDataLoaded(), "Can't draw, because no mesh data was loaded!");
PRINT_ERR("Can't draw, because no mesh data was loaded!"); if (
else if (
t_amount >= 3 && t_amount >= 3 &&
!t_meshes[0]->shouldBeBackfaceCulled && !t_meshes[0]->shouldBeBackfaceCulled &&
t_meshes[0]->getFramesCount() == 1 && t_meshes[0]->getFramesCount() == 1 &&
@@ -309,9 +303,7 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
{ {
beginFrameIfNeeded(); beginFrameIfNeeded();
vifSender->calcMatrix(renderData, t_mesh.position, t_mesh.rotation); vifSender->calcMatrix(renderData, t_mesh.position, t_mesh.rotation);
if (!t_mesh.isDataLoaded()) assertMsg(t_mesh.isDataLoaded(), "Can't draw, because no mesh data was loaded!");
PRINT_ERR("Can't draw, because no mesh data was loaded!");
camRotation.identity(); camRotation.identity();
camRotation.rotate(-t_mesh.rotation); camRotation.rotate(-t_mesh.rotation);
Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition); Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition);
+2 -2
View File
@@ -17,8 +17,8 @@
TextureRepository::TextureRepository() TextureRepository::TextureRepository()
{ {
PRINT_LOG("Initializing texture repository"); consoleLog("Initializing texture repository");
PRINT_LOG("Texture repository initialized!"); consoleLog("Texture repository initialized!");
} }
TextureRepository::~TextureRepository() TextureRepository::~TextureRepository()
+2 -2
View File
@@ -33,7 +33,7 @@ extern u32 VU1Draw3D_CodeEnd __attribute__((section(".vudata")));
VifSender::VifSender(Light *t_light) VifSender::VifSender(Light *t_light)
{ {
PRINT_LOG("Initializing VifSender"); consoleLog("Initializing VifSender");
light = t_light; light = t_light;
lastVertCount = 0; lastVertCount = 0;
isDrawWaitEnabled = true; isDrawWaitEnabled = true;
@@ -44,7 +44,7 @@ VifSender::VifSender(Light *t_light)
packets[1] = packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true); packets[1] = packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
context = 0; context = 0;
setDoubleBufferAddStaticData(); setDoubleBufferAddStaticData();
PRINT_LOG("VifSender initialized!"); consoleLog("VifSender initialized!");
} }
VifSender::~VifSender() VifSender::~VifSender()
+9
View File
@@ -1,6 +1,8 @@
EE_BIN = cube.elf EE_BIN = cube.elf
TYRA_DIR = ./../../engine TYRA_DIR = ./../../engine
PCSX2_PATH = /mnt/c/Program\ Files\ \(x86\)/PCSX2/pcsx2.exe
WSL_TYRA_PATH = \\\\wsl$$\\PS2-DEV\\repos\\tyra
EE_OBJS = \ EE_OBJS = \
objects/cube.o \ objects/cube.o \
@@ -18,6 +20,9 @@ all: $(EE_BIN)
rebuild-engine: rebuild-engine:
cd $(TYRA_DIR) && make clean && make cd $(TYRA_DIR) && make clean && make
rebuild-dbg-engine:
cd $(TYRA_DIR) && make clean && make debug
clean: clean:
rm -f $(EE_OBJS) rm -f $(EE_OBJS)
@@ -30,4 +35,8 @@ run: $(EE_BIN)
rm $(EE_OBJS) rm $(EE_OBJS)
cd bin/ && ps2client execee host:$(EE_BIN) cd bin/ && ps2client execee host:$(EE_BIN)
run-pcsx2:
taskkill.exe /f /t /im pcsx2.exe || true
$(PCSX2_PATH) --elf=$(WSL_TYRA_PATH)\\src\\samples\\cube\\bin\\cube.elf
include $(TYRA_DIR)/Makefile.pref include $(TYRA_DIR)/Makefile.pref
+9
View File
@@ -1,6 +1,8 @@
EE_BIN = dolphin.elf EE_BIN = dolphin.elf
TYRA_DIR = ./../../engine TYRA_DIR = ./../../engine
PCSX2_PATH = /mnt/c/Program\ Files\ \(x86\)/PCSX2/pcsx2.exe
WSL_TYRA_PATH = \\\\wsl$$\\PS2-DEV\\repos\\tyra
EE_OBJS = \ EE_OBJS = \
camera.o \ camera.o \
@@ -18,6 +20,9 @@ all: $(EE_BIN)
rm $(EE_OBJS) rm $(EE_OBJS)
rebuild-engine: rebuild-engine:
cd $(TYRA_DIR) && make clean && make EE_CXXFLAGS="-DNDEBUG $(EE_CXXFLAGS)"
rebuild-dbg-engine:
cd $(TYRA_DIR) && make clean && make cd $(TYRA_DIR) && make clean && make
clean: clean:
@@ -32,4 +37,8 @@ run: $(EE_BIN)
rm $(EE_OBJS) rm $(EE_OBJS)
cd bin/ && ps2client execee host:$(EE_BIN) cd bin/ && ps2client execee host:$(EE_BIN)
run-pcsx2:
taskkill.exe /f /t /im pcsx2.exe || true
$(PCSX2_PATH) --elf=$(WSL_TYRA_PATH)\\src\\samples\\dolphin\\bin\\dolphin.elf
include $(TYRA_DIR)/Makefile.pref include $(TYRA_DIR)/Makefile.pref
+7
View File
@@ -24,6 +24,9 @@ all: $(EE_BIN)
rebuild-engine: rebuild-engine:
cd $(TYRA_DIR) && make clean && make cd $(TYRA_DIR) && make clean && make
rebuild-dbg-engine:
cd $(TYRA_DIR) && make clean && make debug
clean: clean:
rm -f $(EE_OBJS) rm -f $(EE_OBJS)
@@ -36,4 +39,8 @@ run: $(EE_BIN)
rm $(EE_OBJS) rm $(EE_OBJS)
cd bin/ && ps2client execee host:$(EE_BIN) cd bin/ && ps2client execee host:$(EE_BIN)
run-pcsx2:
taskkill.exe /f /t /im pcsx2.exe || true
$(PCSX2_PATH) --elf=$(WSL_TYRA_PATH)\\src\\samples\\floors\\bin\\floors.elf
include $(TYRA_DIR)/Makefile.pref include $(TYRA_DIR)/Makefile.pref
-1
View File
@@ -34,7 +34,6 @@ run-pcsx2:
taskkill.exe /f /t /im pcsx2.exe || true taskkill.exe /f /t /im pcsx2.exe || true
$(PCSX2_PATH) --elf=$(WSL_TYRA_PATH)\\src\\unit_tests\\bin\\unit_tests.elf $(PCSX2_PATH) --elf=$(WSL_TYRA_PATH)\\src\\unit_tests\\bin\\unit_tests.elf
show: show:
cat bin/test-result.txt cat bin/test-result.txt