Commit 13953072 authored by Scott Duensing's avatar Scott Duensing

Bug fixes, start of fixed point experiments.

parent 9d1a7b90
......@@ -41,28 +41,30 @@ int main(void) {
}
fprintf(out, \
"/*\n" \
" * JoeyLib 3D\n" \
" * Copyright (C) 2019 Scott Duensing <scott@kangaroopunch.com>\n" \
" *\n" \
" * This software is provided 'as-is', without any express or implied\n" \
" * warranty. In no event will the authors be held liable for any damages\n" \
" * arising from the use of this software.\n" \
" *\n" \
" * Permission is granted to anyone to use this software for any purpose,\n" \
" * including commercial applications, and to alter it and redistribute it\n" \
" * freely, subject to the following restrictions:\n" \
" *\n" \
" * 1. The origin of this software must not be misrepresented; you must not\n" \
" * claim that you wrote the original software. If you use this software\n" \
" * in a product, an acknowledgment in the product documentation would be\n" \
" * appreciated but is not required.\n" \
" * 2. Altered source versions must be plainly marked as such, and must not be\n" \
" * misrepresented as being the original software.\n" \
" * 3. This notice may not be removed or altered from any source distribution.\n" \
"*/\n\n\n" \
"#ifndef H_J3DTBLS_\n" \
"#define H_J3DTBLS_\n\n\nstatic float sinTable[] = {\n\t" \
"/*\n"
" * JoeyLib 3D\n"
" * Copyright (C) 2019 Scott Duensing <scott@kangaroopunch.com>\n"
" *\n"
" * This software is provided 'as-is', without any express or implied\n"
" * warranty. In no event will the authors be held liable for any damages\n"
" * arising from the use of this software.\n"
" *\n"
" * Permission is granted to anyone to use this software for any purpose,\n"
" * including commercial applications, and to alter it and redistribute it\n"
" * freely, subject to the following restrictions:\n"
" *\n"
" * 1. The origin of this software must not be misrepresented; you must not\n"
" * claim that you wrote the original software. If you use this software\n"
" * in a product, an acknowledgment in the product documentation would be\n"
" * appreciated but is not required.\n"
" * 2. Altered source versions must be plainly marked as such, and must not be\n"
" * misrepresented as being the original software.\n"
" * 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n\n\n"
"#ifndef H_J3DTBLS_\n"
"#define H_J3DTBLS_\n\n"
"#include \"j3d.h\"\n\n"
"nstatic jreal sinTable[] = {\n\t"
);
// Build look-up tables for speed later
......@@ -82,7 +84,7 @@ int main(void) {
}
fprintf(out, "\n};\n\n");
if (pass == 0) {
fprintf(out, "static float cosTable[] = {\n\t");
fprintf(out, "static jreal cosTable[] = {\n\t");
}
}
......
This diff is collapsed.
......@@ -27,6 +27,14 @@
#include "joey.h"
// Sad start to fixed point math
#ifdef JOEY_IIGS
//typedef extended jreal;
typedef float jreal;
#else
typedef float jreal;
#endif
typedef enum {
DIRTYNESS_CLEAN = 0x00,
DIRTYNESS_SCALE = 0x01,
......@@ -35,7 +43,7 @@ typedef enum {
DIRTYNESS_ALL = 0xFF
} j3DirtynessT;
typedef float j3Matrix4x4T[4][4];
typedef jreal j3Matrix4x4T[4][4];
typedef struct {
jint16 x;
......@@ -44,9 +52,9 @@ typedef struct {
} j3FacingT;
typedef struct {
float x;
float y;
float z;
jreal x;
jreal y;
jreal z;
} j3VertexT, j3Vector3DT;
typedef struct {
......@@ -64,8 +72,8 @@ typedef struct {
bool lit; // Do we care about lighting?
bool visible; // Can we see this triangle?
bool twoSided; // Are both sides visible?
float normalLength; // Magnatude of surface normal
float averageDepth; // Average Z depth of this triangle
jreal normalLength; // Magnatude of surface normal
jreal averageDepth; // Average Z depth of this triangle
juint16 index[3]; // We do this instead of just a typedef so it works with stretch_buffer
} j3TriangleT;
......@@ -73,7 +81,7 @@ typedef struct {
jint16 color; // Assigned color of this face
bool lit; // Do we care about lighting?
bool twoSided; // Are both sides visible?
float normalLength; // Magnatude of surface normal
jreal normalLength; // Magnatude of surface normal
juint16 index[3]; // We do this instead of just a typedef so it works with stretch_buffer
} j3TriangleThinT;
......@@ -138,31 +146,31 @@ typedef struct {
// Prototypes
void j3CameraMove(float x, float y, float z);
void j3CameraMoveTo(float x, float y, float z);
void j3CameraRotate(float x, float y, float z);
void j3CameraRotateTo(float x, float y, float z);
void j3CameraMove(jreal x, jreal y, jreal z);
void j3CameraMoveTo(jreal x, jreal y, jreal z);
void j3CameraRotate(jreal x, jreal y, jreal z);
void j3CameraRotateTo(jreal x, jreal y, jreal z);
void j3CameraSetClippingBounds(jint16 x1, jint16 y1, jint16 x2, jint16 y2);
void j3DrawTriangle2D(jint16 x1, jint16 y1, jint16 x2, jint16 y2, jint16 x3, jint16 y3, jint16 color);
void j3DrawWorld(j3WorldT *w);
void j3MathCrossProduct3D(j3Vector3DT *u, j3Vector3DT *v, j3Vector3DT *normal);
float j3MathDotProduct3D(j3Vector3DT *u, j3Vector3DT *v);
jreal j3MathDotProduct3D(j3Vector3DT *u, j3Vector3DT *v);
void j3MathMatrix4x4Identity(j3Matrix4x4T result);
void j3MathMatrix4x4Mult(j3Matrix4x4T a, j3Matrix4x4T b, j3Matrix4x4T result);
void j3MathMakeVector3D(j3VertexT *init, j3VertexT *term, j3Vector3DT *result);
float j3MathVectorMagnatude3D(j3Vector3DT *v);
jreal j3MathVectorMagnatude3D(j3Vector3DT *v);
void j3UtilShutdown(void);
void j3UtilStartup(void);
// Private Prototypes
void _j3ObjectMove(j3ObjectT *o, float x, float y, float z);
void _j3ObjectMoveTo(j3ObjectT *o, float x, float y, float z);
void _j3ObjectMove(j3ObjectT *o, jreal x, jreal y, jreal z);
void _j3ObjectMoveTo(j3ObjectT *o, jreal x, jreal y, jreal z);
void _j3ObjectReset(j3ObjectT *o);
void _j3ObjectRotate(j3ObjectT *o, float x, float y, float z);
void _j3ObjectRotateTo(j3ObjectT *o, float x, float y, float z);
void _j3ObjectScale(j3ObjectT *o, float x, float y, float z);
void _j3ObjectScaleTo(j3ObjectT *o, float x, float y, float z);
void _j3ObjectRotate(j3ObjectT *o, jreal x, jreal y, jreal z);
void _j3ObjectRotateTo(j3ObjectT *o, jreal x, jreal y, jreal z);
void _j3ObjectScale(j3ObjectT *o, jreal x, jreal y, jreal z);
void _j3ObjectScaleTo(j3ObjectT *o, jreal x, jreal y, jreal z);
void _j3PropFree(j3PropT **prop);
jint16 _j3PropLoad(j3PropT **prop, char *file);
jint16 _j3WorldAddProp(j3WorldT **world, j3PropT *prop);
......
......@@ -23,8 +23,9 @@
#ifndef H_J3DTBLS_
#define H_J3DTBLS_
#include "j3d.h"
static float sinTable[] = {
nstatic jreal sinTable[] = {
0.0000000, 0.0174524, 0.0348995, 0.0523360, 0.0697565, 0.0871557,
0.1045285, 0.1218693, 0.1391731, 0.1564345, 0.1736482, 0.1908090,
0.2079117, 0.2249510, 0.2419219, 0.2588190, 0.2756374, 0.2923717,
......@@ -88,7 +89,7 @@ static float sinTable[] = {
-0.0000003
};
static float cosTable[] = {
static jreal cosTable[] = {
1.0000000, 0.9998477, 0.9993908, 0.9986295, 0.9975641, 0.9961947,
0.9945219, 0.9925462, 0.9902681, 0.9876883, 0.9848078, 0.9816272,
0.9781476, 0.9743701, 0.9702957, 0.9659258, 0.9612617, 0.9563048,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment