From: ljsebald <ljs...@us...> - 2023-12-15 18:14:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a7789e6439b2b1028b5daea78ed33ef93f848752 (commit) via fa318b8bf587f4dfbf4944a7808bc390a6838f2d (commit) via 2e346c244254f9601fe28ad925c1bec4e6982c82 (commit) via 2cfe5e5f94edf103820183be0cd11c5cd18fe9ac (commit) via f975b3a3d6bdf47088123edd03112353474ac338 (commit) via 795ea8bc79d4da2dcbe3e733ae780b4d8130230a (commit) from 1cf3ac01456a7c8625dcd630ab03e910cd6a3746 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a7789e6439b2b1028b5daea78ed33ef93f848752 Author: Paul Cercueil <pa...@cr...> Date: Fri Dec 15 19:14:13 2023 +0100 Faster IRQ context saving / restore (#406) * irq: Optimize save/restore of IRQ contexts Reorder the fields of the irq_context structure, so that they can be saved and restored sequentially and in the fastest way possible. Signed-off-by: Paul Cercueil <pa...@cr...> * irq: Make sure IRQ context is always aligned to 32 bytes - To make sure that the irq_context structure within a kthread_t is properly aligned, move it to the beginning of the structure, and change the memory allocation for kthreads to memalign(). - Add alignment specifier to kthread and irq_context structures. Signed-off-by: Paul Cercueil <pa...@cr...> * irq: Use 64-bit I/O to save/restore FPU registers Now that the irq_context_t is guaranteed to be aligned to 8 bytes, and our FPU register fields within the structure are themselves aligned to 8 bytes, we can load / restore all FPU registers using 64-bit I/O in much fewer instructions. Signed-off-by: Paul Cercueil <pa...@cr...> * irq: Speed up saving IRQ context by pre-allocating cache lines Use a tiny loop before the IRQ context is saved that will pre-allocate cache lines covering the IRQ context structure. This speeds up saving the IRQ context, as each subsequent memory store will execute without any additional latency. Signed-off-by: Paul Cercueil <pa...@cr...> * doc: Update CHANGELOG Add an entry for my change which improved performance of IRQ context save / restore. Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> commit fa318b8bf587f4dfbf4944a7808bc390a6838f2d Author: Andy Barajas <and...@gm...> Date: Fri Dec 15 10:13:23 2023 -0800 Handle double promotion (#407) * Replace M_PI which is a double value with F_PI. Remove unwanted double promotion * Remove unwanted double promotion inside KOS * Addressed discord input * More explicit float types * Fixed mistake removal of f * Avoid it being inlined into potentially another FPU context * Hande printf related double premotions * Clarify floating values in fmath_base commit 2e346c244254f9601fe28ad925c1bec4e6982c82 Author: OniEnzeru <152...@us...> Date: Fri Dec 15 11:11:00 2023 -0700 Fix face culling bug in CPP GL example and GL_INVALID_ENUM (#399) * Fix face culling bug in CPP GL example. fix GL_INAVLID_ENUM and double PVR_INIT commit 2cfe5e5f94edf103820183be0cd11c5cd18fe9ac Merge: f975b3a 795ea8b Author: Lawrence Sebald <ljs...@us...> Date: Fri Dec 15 13:08:11 2023 -0500 Merge pull request #409 from kilgariff/master Fix bubbles and serpent examples and remove HBlank settings from PVR init. commit f975b3a3d6bdf47088123edd03112353474ac338 Author: Andy Barajas <and...@gm...> Date: Fri Dec 15 10:07:12 2023 -0800 Fix rotocube example (#410) * Fix rotocube example * Removed unneeded -lm from Makefile commit 795ea8bc79d4da2dcbe3e733ae780b4d8130230a Author: Ross Kilgariff <ros...@gm...> Date: Thu Dec 7 21:59:44 2023 +0000 Remove all VPOS_IRQ and HPOS_IRQ settings from pvr_init as all video settings are done in video.c instead ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + examples/dreamcast/2ndmix/2ndmix.c | 4 +- examples/dreamcast/cpp/gltest/gltest.cpp | 15 +- examples/dreamcast/kgl/basic/gl/gltest.c | 2 +- .../dreamcast/kgl/benchmarks/quadmark/quadmark.c | 4 +- .../dreamcast/kgl/benchmarks/trimark/trimark.c | 4 +- .../kgl/benchmarks/tristripmark/tristripmark.c | 4 +- examples/dreamcast/kgl/demos/mipmap/gl-mipmap.c | 4 +- examples/dreamcast/kgl/demos/specular/input.c | 2 +- examples/dreamcast/kgl/demos/specular/specular.c | 34 +-- examples/dreamcast/kgl/demos/specular/vector.h | 4 +- examples/dreamcast/parallax/bubbles/Makefile | 2 +- examples/dreamcast/parallax/bubbles/bubbles.c | 30 ++- examples/dreamcast/parallax/rotocube/Makefile | 2 +- examples/dreamcast/parallax/rotocube/rotocube.c | 32 +-- examples/dreamcast/parallax/serpent_dma/Makefile | 2 +- .../dreamcast/parallax/serpent_dma/perfmeter.c | 6 +- examples/dreamcast/parallax/serpent_dma/serpent.c | 23 ++- examples/dreamcast/parallax/sinus/sinus.c | 6 +- examples/dreamcast/png/example.c | 40 ++-- examples/dreamcast/pvr/plasma/plasma.c | 4 +- examples/dreamcast/pvr/pvrmark/pvrmark.c | 4 +- .../dreamcast/pvr/pvrmark_strips/pvrmark_strips.c | 4 +- .../pvrmark_strips_direct/pvrmark_strips_direct.c | 4 +- .../dreamcast/pvr/texture_render/texture_render.c | 2 +- .../dreamcast/pvr/yuv_converter/YUV420/yuv420.c | 24 +-- .../dreamcast/pvr/yuv_converter/YUV422/yuv422.c | 24 +-- examples/dreamcast/sound/ghettoplay-vorbis/gp.h | 4 +- examples/dreamcast/tsunami/banner/banner.cpp | 4 +- examples/dreamcast/vmu/vmu_lcd/lcd.c | 3 +- include/kos/thread.h | 8 +- kernel/arch/dreamcast/hardware/pvr/pvr_fog.c | 6 +- .../dreamcast/hardware/pvr/pvr_init_shutdown.c | 2 - kernel/arch/dreamcast/hardware/sq.c | 2 +- kernel/arch/dreamcast/include/arch/irq.h | 8 +- kernel/arch/dreamcast/include/dc/fmath_base.h | 10 +- kernel/arch/dreamcast/kernel/entry.s | 229 ++++++++++----------- kernel/arch/dreamcast/kernel/thdswitch.s | 125 +++++------ kernel/thread/thread.c | 2 +- 39 files changed, 338 insertions(+), 352 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index d3961eb..fbbaa7b 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -210,6 +210,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added __weak, __used, likely() and unlikely() [FG] - DC Added Maple-specific KOS_INIT_FLAGS() which allow for GC-ing unused drivers [FG] - DC Added basic example for micropython KOS port [Aaron Glazer == AG] +- DC Improved performance of IRQ context save / restore [PC] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/2ndmix/2ndmix.c b/examples/dreamcast/2ndmix/2ndmix.c index d59e8de..d94aa4c 100644 --- a/examples/dreamcast/2ndmix/2ndmix.c +++ b/examples/dreamcast/2ndmix/2ndmix.c @@ -237,7 +237,7 @@ void draw_cube(int which) { then try setting *32 on ytrans to something higher =) */ xtrans = mcos(ra) * 220; ytrans = msin((ra * 3) % 256) * 32; - ztrans = msin(ra) * 256 + 256.0; + ztrans = msin(ra) * 256 + 256.0f; for(cp = 0; cp < (NUM_FACES * 4 * 3); cp += 3) { x = cube_points[cp + 0] * mult * cubesizes[which]; @@ -274,7 +274,7 @@ void draw_cube(int which) { vert.x = xt + 320.0f; vert.y = yt + 240.0f; - vert.z = 128.0 - (z / 64.0); + vert.z = 128.0f - (z / 64.0f); a = 0.8f; if(ztrans == 0) ztrans++; diff --git a/examples/dreamcast/cpp/gltest/gltest.cpp b/examples/dreamcast/cpp/gltest/gltest.cpp index a2a9b7d..01dd49d 100644 --- a/examples/dreamcast/cpp/gltest/gltest.cpp +++ b/examples/dreamcast/cpp/gltest/gltest.cpp @@ -281,7 +281,6 @@ int main(int argc, char **argv) { /* Initialize KOS */ dbglog_set_level(DBG_WARNING); - pvr_init_defaults(); printf("gltest beginning\n"); @@ -302,7 +301,7 @@ int main(int argc, char **argv) { /* Load a texture and make it look nice */ loadtxr("/rd/glass.pvr", &texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); - glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA); printf("texture is %08x\n", texture); @@ -378,9 +377,12 @@ int main(int argc, char **argv) { glTranslatef(0.0f, 0.0f, z); glRotatef(r, 0.0f, 1.0f, 0.5f); - cubes[0]->draw(); + /* Always draw 2 cubes as solids */ + glEnable(GL_CULL_FACE); + glDisable(GL_BLEND); + + cubes[0]->draw(); cubes[1]->draw(); - /* Potentially do two as translucent */ if(trans & 1) { glEnable(GL_BLEND); @@ -391,11 +393,6 @@ int main(int argc, char **argv) { cubes[2]->draw(); cubes[3]->draw(); - if(trans & 1) { - glEnable(GL_CULL_FACE); - glDisable(GL_BLEND); - } - /* Finish the frame */ glutSwapBuffers(); } diff --git a/examples/dreamcast/kgl/basic/gl/gltest.c b/examples/dreamcast/kgl/basic/gl/gltest.c index 3224226..4d4e181 100644 --- a/examples/dreamcast/kgl/basic/gl/gltest.c +++ b/examples/dreamcast/kgl/basic/gl/gltest.c @@ -236,7 +236,7 @@ int main(int argc, char **argv) { pvr_get_stats(&stats); printf("VBL Count: %ld, last_time: %d, frame rate: %f fps\n", - stats.vbl_count, stats.frame_last_time, stats.frame_rate); + stats.vbl_count, stats.frame_last_time, (double)stats.frame_rate); return 0; } diff --git a/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c b/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c index ea0a240..0a6e380 100644 --- a/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c +++ b/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c @@ -40,7 +40,7 @@ void stats(void) { pvr_get_stats(&stats); dbglog(DBG_DEBUG, "3D Stats: %ld VBLs, frame rate ~%f fps\n", - stats.vbl_count, stats.frame_rate); + stats.vbl_count, (double)stats.frame_rate); } @@ -113,7 +113,7 @@ void check_switch(void) { if(now >= (begin + 5)) { begin = time(NULL); - printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps * 2)); + printf(" Average Frame Rate: ~%f fps (%d pps)\n", (double)avgfps, (int)(polycnt * avgfps * 2)); switch(phase) { case PHASE_HALVE: diff --git a/examples/dreamcast/kgl/benchmarks/trimark/trimark.c b/examples/dreamcast/kgl/benchmarks/trimark/trimark.c index 1973bd2..38866c4 100644 --- a/examples/dreamcast/kgl/benchmarks/trimark/trimark.c +++ b/examples/dreamcast/kgl/benchmarks/trimark/trimark.c @@ -40,7 +40,7 @@ void stats(void) { pvr_get_stats(&stats); dbglog(DBG_DEBUG, "3D Stats: %ld VBLs, frame rate ~%f fps\n", - stats.vbl_count, stats.frame_rate); + stats.vbl_count, (double)stats.frame_rate); } @@ -112,7 +112,7 @@ void check_switch(void) { if(now >= (begin + 5)) { begin = time(NULL); - printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps * 2)); + printf(" Average Frame Rate: ~%f fps (%d pps)\n", (double)avgfps, (int)(polycnt * avgfps * 2)); switch(phase) { case PHASE_HALVE: diff --git a/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c b/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c index 9ee44da..8cb6735 100644 --- a/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c +++ b/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c @@ -40,7 +40,7 @@ void stats(void) { pvr_get_stats(&stats); dbglog(DBG_DEBUG, "3D Stats: %ld VBLs, frame rate ~%f fps\n", - stats.vbl_count, stats.frame_rate); + stats.vbl_count, (double)stats.frame_rate); } @@ -115,7 +115,7 @@ void check_switch(void) { if(now >= (begin + 5)) { begin = time(NULL); - printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps * 2)); + printf(" Average Frame Rate: ~%f fps (%d pps)\n", (double)avgfps, (int)(polycnt * avgfps * 2)); switch(phase) { case PHASE_HALVE: diff --git a/examples/dreamcast/kgl/demos/mipmap/gl-mipmap.c b/examples/dreamcast/kgl/demos/mipmap/gl-mipmap.c index 53b75b1..ffcf93b 100644 --- a/examples/dreamcast/kgl/demos/mipmap/gl-mipmap.c +++ b/examples/dreamcast/kgl/demos/mipmap/gl-mipmap.c @@ -69,9 +69,9 @@ void RenderInit(void) { /* Render a Textured Quad of given texture ID, width, and height */ void RenderTexturedQuadCentered(GLuint texID, GLfloat width, GLfloat height) { - GLfloat x1 = (vid_mode->width - width) / 2.0; + GLfloat x1 = (vid_mode->width - width) / 2.0f; GLfloat x2 = x1 + width; - GLfloat y1 = (vid_mode->height - height) / 2.0; + GLfloat y1 = (vid_mode->height - height) / 2.0f; GLfloat y2 = y1 + height; glBindTexture(GL_TEXTURE_2D, texID); diff --git a/examples/dreamcast/kgl/demos/specular/input.c b/examples/dreamcast/kgl/demos/specular/input.c index 939a53a..f522e03 100644 --- a/examples/dreamcast/kgl/demos/specular/input.c +++ b/examples/dreamcast/kgl/demos/specular/input.c @@ -16,7 +16,7 @@ #define SHIFT_X 0.01f #define SHIFT_Z 0.01f #define SHIFT_Y 0.2f -#define ROT_XZ ROTATION/5.0 +#define ROT_XZ ROTATION/5.0f void InputCallback(vector3f campos, vector3f camdst) { diff --git a/examples/dreamcast/kgl/demos/specular/specular.c b/examples/dreamcast/kgl/demos/specular/specular.c index 5b65b0f..bbecc47 100644 --- a/examples/dreamcast/kgl/demos/specular/specular.c +++ b/examples/dreamcast/kgl/demos/specular/specular.c @@ -39,9 +39,9 @@ static GLfloat z = -5.0f; /* Depth Into The Screen */ static GLuint texture[2]; /* Storage For Two Textures */ -static vector3f up = { 0, 1, 0 }, - camFrom = { -74, 10, 0.0 }, - camTo = { -74, 10, 10.0 }; +static vector3f up = { 0.0f, 1.0f, 0.0f }, + camFrom = { -74.0f, 10.0f, 0.0f }, + camTo = { -74.0f, 10.0f, 10.0f }; typedef struct { float min, @@ -946,7 +946,7 @@ void GPU_Stats(void) { if(fps.frame % 60 == 0) { printf("PVR FPS MIN: %.2f | MAX: %.2f | LAST: %.2f | AVG: %.2f\n", - (double)fps.min, (double)fps.max, (double)fps.last, (double)fps.avg / fps.frame); + (double)fps.min, (double)fps.max, (double)fps.last, (double)(fps.avg / fps.frame)); } } else @@ -1021,9 +1021,9 @@ int main() { glEnable(GL_LIGHT0); /* Set Light and Material Parameters */ - float lp[4] = { 0.0, 10.0, 0.0, 0.0 }; - float lp2[4] = { 0.0, 10.0, 0.0, 0.0 }; - float lc[4] = { -50.0, 10.0, 0.0, 0.0 }; + float lp[4] = { 0.0f, 10.0f, 0.0f, 0.0f }; + float lp2[4] = { 0.0f, 10.0f, 0.0f, 0.0f }; + float lc[4] = { -50, 10.0f, 0.0f, 0.0f }; float lcolor[3] = { 0.8f, 0.0f, 0.0f }; float lcolor2[3] = { 0.0f, 0.0f, 0.8f }; float lcolors[3] = { 0.6f, 0.6f, 0.6f }; @@ -1034,30 +1034,30 @@ int main() { glLightfv(GL_LIGHT1, GL_DIFFUSE, lcolor2); glLightfv(GL_LIGHT1, GL_SPECULAR, lcolors); - float l3c[3] = { 0.5, 0.5, 0.0 }; - float l3p[4] = { 0, -10, 0, 0 }; - float l3d[3] = { 0, 1, 0 }; + float l3c[3] = { 0.5f, 0.5f, 0.0f }; + float l3p[4] = { 0.0f, -10.0f, 0.0f, 0.0f }; + float l3d[3] = { 0.0f, 1.0f, 0.0f }; glLightfv(GL_LIGHT2, GL_POSITION, l3p); glLightfv(GL_LIGHT2, GL_DIFFUSE, l3c); glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, l3d); - float l4c[3] = { 0.0, 0.5, 0.5 }; - float l4p[4] = { -50, -10, 0, 0 }; - float l4d[3] = { 0, 1, 0 }; + float l4c[3] = { 0.0f, 0.5f, 0.5f }; + float l4p[4] = { -50, -10.0f, 0.0f, 0.0f }; + float l4d[3] = { 0.0f, 1.0f, 0.0f }; glLightfv(GL_LIGHT3, GL_POSITION, l4p); glLightfv(GL_LIGHT3, GL_DIFFUSE, l4c); glLightfv(GL_LIGHT3, GL_SPOT_DIRECTION, l4d); - float l5c[3] = { 0.0, 0.8, 0.0 }; - float l5p[4] = { -50, -10, 50, 0 }; - float l5d[3] = { 0, 1, 0 }; + float l5c[3] = { 0.0f, 0.8f, 0.0f }; + float l5p[4] = { -50.0f, -10.0f, 50.0f, 0.0f}; + float l5d[3] = { 0.0f, 1.0f, 0.0f }; glLightfv(GL_LIGHT4, GL_POSITION, l5p); glLightfv(GL_LIGHT4, GL_DIFFUSE, l5c); glLightfv(GL_LIGHT4, GL_SPOT_DIRECTION, l5d); /* Set Material Parameters */ - float Mat_Specular[3] = { 0.6, 0.6, 0.6 }; + float Mat_Specular[3] = { 0.6f, 0.6f, 0.6f }; glLightfv(GL_LIGHT0, GL_SPECULAR, Mat_Specular); glMaterialfv(GL_FRONT, GL_SPECULAR, Mat_Specular); glMaterialf(GL_FRONT, GL_SHININESS, 10.0f); diff --git a/examples/dreamcast/kgl/demos/specular/vector.h b/examples/dreamcast/kgl/demos/specular/vector.h index f4d79af..f7ee18e 100644 --- a/examples/dreamcast/kgl/demos/specular/vector.h +++ b/examples/dreamcast/kgl/demos/specular/vector.h @@ -15,8 +15,8 @@ typedef float vector4f[4]; #define DEG2RAD (F_PI / 180.0f) #define RAD2DEG (180.0f / F_PI) -#define RADIAN 0.0174532925 // Convert Degrees to Radians -#define CIRCLE 6.2831853 // RADIAN * 360.0f +#define RADIAN 0.0174532925f // Convert Degrees to Radians +#define CIRCLE 6.2831853f // RADIAN * 360.0f void VectorShift(vector3f p, vector3f c, float mag); diff --git a/examples/dreamcast/parallax/bubbles/Makefile b/examples/dreamcast/parallax/bubbles/Makefile index fe8c888..8c71e29 100644 --- a/examples/dreamcast/parallax/bubbles/Makefile +++ b/examples/dreamcast/parallax/bubbles/Makefile @@ -17,7 +17,7 @@ rm-elf: -rm -f $(TARGET) $(TARGET): $(OBJS) - kos-cc -o $(TARGET) $(OBJS) -lparallax -lGL + kos-cc -o $(TARGET) $(OBJS) -lparallax run: $(TARGET) $(KOS_LOADER) $(TARGET) diff --git a/examples/dreamcast/parallax/bubbles/bubbles.c b/examples/dreamcast/parallax/bubbles/bubbles.c index 0accb63..3575ddd 100644 --- a/examples/dreamcast/parallax/bubbles/bubbles.c +++ b/examples/dreamcast/parallax/bubbles/bubbles.c @@ -45,13 +45,13 @@ static void sphere(float radius, int slices, int stacks) { /* Iterate over stacks */ for(i = 0; i < stacks; i++) { - pitch = 2 * M_PI * ((float)i / (float)stacks); - pitch2 = 2 * M_PI * ((float)(i + 1) / (float)stacks); + pitch = 2 * F_PI * ((float)i / (float)stacks); + pitch2 = 2 * F_PI * ((float)(i + 1) / (float)stacks); /* Iterate over slices: each entire stack will be one long triangle strip. */ for(j = 0; j <= slices / 2; j++) { - yaw = 2 * M_PI * ((float)j / (float)slices); + yaw = 2 * F_PI * ((float)j / (float)slices); /* x, y+1 */ x = radius * fcos(yaw) * fcos(pitch2); @@ -107,7 +107,7 @@ static void sphere_frame_opaque(void) { plx_mat3d_push(); for(i = 0; i < SPHERE_CNT; i++) { - plx_mat3d_translate(6.0f * fcos(i * 2 * M_PI / SPHERE_CNT), 0.0f, 6.0f * fsin(i * 2 * M_PI / SPHERE_CNT)); + plx_mat3d_translate(6.0f * fcos(i * 2 * F_PI / SPHERE_CNT), 0.0f, 6.0f * fsin(i * 2 * F_PI / SPHERE_CNT)); plx_mat3d_rotate(r, 1.0f, 1.0f, 1.0f); sphere(1.2f, 20, 20); @@ -123,7 +123,7 @@ static void sphere_frame_opaque(void) { plx_mat3d_push(); for(i = 0; i < SPHERE_CNT; i++) { - plx_mat3d_translate(3.0f * fcos(i * 2 * M_PI / SPHERE_CNT), 0.0f, 3.0f * fsin(i * 2 * M_PI / SPHERE_CNT)); + plx_mat3d_translate(3.0f * fcos(i * 2 * F_PI / SPHERE_CNT), 0.0f, 3.0f * fsin(i * 2 * F_PI / SPHERE_CNT)); plx_mat3d_rotate(r, 1.0f, 1.0f, 1.0f); sphere(0.8f, 20, 20); @@ -137,7 +137,7 @@ static void sphere_frame_opaque(void) { pvr_scene_finish(); r++; - phase += 2 * M_PI / 240.0f; + phase += 2 * F_PI / 240.0f; } static void sphere_frame_trans(void) { @@ -156,7 +156,7 @@ static void sphere_frame_trans(void) { plx_mat3d_push(); for(i = 0; i < SPHERE_CNT; i++) { - plx_mat3d_translate(4.0f * fcos(i * 2 * M_PI / SPHERE_CNT), 0.0f, 4.0f * fsin(i * 2 * M_PI / SPHERE_CNT)); + plx_mat3d_translate(4.0f * fcos(i * 2 * F_PI / SPHERE_CNT), 0.0f, 4.0f * fsin(i * 2 * F_PI / SPHERE_CNT)); plx_mat3d_rotate(r, 1.0f, 1.0f, 1.0f); sphere(1.0f, 20, 20); @@ -170,7 +170,7 @@ static void sphere_frame_trans(void) { pvr_scene_finish(); r++; - phase += 2 * M_PI / 240.0f; + phase += 2 * F_PI / 240.0f; } void do_sphere_test(void) { @@ -235,7 +235,19 @@ pvr_init_params_t params = { { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0 }, /* Vertex buffer size 512K */ - 512 * 1024 + 512 * 1024, + + /* No DMA */ + 0, + + /* No FSAA */ + 0, + + /* Translucent Autosort enabled. */ + 0, + + /* Extra OPBs */ + 3 }; int main(int argc, char **argv) { diff --git a/examples/dreamcast/parallax/rotocube/Makefile b/examples/dreamcast/parallax/rotocube/Makefile index c8bd970..736e080 100644 --- a/examples/dreamcast/parallax/rotocube/Makefile +++ b/examples/dreamcast/parallax/rotocube/Makefile @@ -12,7 +12,7 @@ rm-elf: -rm -f $(TARGET) $(TARGET): $(OBJS) - kos-cc -o $(TARGET) $(OBJS) -lparallax -lm + kos-cc -o $(TARGET) $(OBJS) -lparallax run: $(TARGET) $(KOS_LOADER) $(TARGET) diff --git a/examples/dreamcast/parallax/rotocube/rotocube.c b/examples/dreamcast/parallax/rotocube/rotocube.c index 319c7cc..35427f4 100644 --- a/examples/dreamcast/parallax/rotocube/rotocube.c +++ b/examples/dreamcast/parallax/rotocube/rotocube.c @@ -35,26 +35,11 @@ to a translucent poly to interfere with the cube. */ -// Draw a single point in 3D space. Uses the currently loaded matrix. -void drawpnt(float x, float y, float z, float a, float r, float g, float b) { - uint32 col = plx_pack_color(a, r, g, b); - - // Transform the point, clip the Z plane to avoid artifacts. - plx_mat_tfip_3d(x, y, z); - - if(z <= 0.00001f) z = 0.00001f; - - // Draw it. - plx_vert_inp(PLX_VERT, x, y + 1.0f, z, col); - plx_vert_inp(PLX_VERT, x, y, z, col); - plx_vert_inp(PLX_VERT, x + 1.0f, y + 1.0f, z, col); - plx_vert_inp(PLX_VERT_EOS, x + 1.0f, y, z, col); -} +static plx_dr_state_t dr; // Draws the full cube at the current position. void drawcube(void) { uint32 color = 0xff808080; - plx_dr_state_t dr; plx_dr_init(&dr); @@ -100,24 +85,21 @@ void drawwave(int theta) { uint32 color = 0xffa0a0a0; int i, divs = 320; float x, y, t; - plx_dr_state_t dr; - - plx_dr_init(&dr); // Convert to radians for sin/cos - t = theta * 2 * M_PI / 360.0f; + t = theta * 2 * F_PI / 360.0f; for(i = 0; i <= divs; i++) { x = i * 640.0f / divs; // These are more or less magic numbers I played with until // it looked neat. - y = 240.0f + fsin(t + i * M_PI / 64.0f) * 30.0f * fsin(t * 4); - y += fcos(t + i * M_PI / 36.0f) * 40.0f * fcos(t * 6); - y += fcos(t + i * M_PI / 30.0f) * 24.0f * fcos(t * 8); + y = 240.0f + fsin(t + i * F_PI / 64.0f) * 30.0f * fsin(t * 4); + y += fcos(t + i * F_PI / 36.0f) * 40.0f * fcos(t * 6); + y += fcos(t + i * F_PI / 30.0f) * 24.0f * fcos(t * 8); - plx_vert_ind(&dr, PLX_VERT, x, y, 0.0001f, color); - plx_vert_ind(&dr, i == divs ? PLX_VERT_EOS : PLX_VERT, x, 480.0f, 0.0001f, color); + plx_vert_inp(PLX_VERT, x, y, 0.0001f, color); + plx_vert_inp(i == divs ? PLX_VERT_EOS : PLX_VERT, x, 480.0f, 0.0001f, color); } } diff --git a/examples/dreamcast/parallax/serpent_dma/Makefile b/examples/dreamcast/parallax/serpent_dma/Makefile index c77576f..ac60e1c 100644 --- a/examples/dreamcast/parallax/serpent_dma/Makefile +++ b/examples/dreamcast/parallax/serpent_dma/Makefile @@ -17,7 +17,7 @@ rm-elf: -rm -f $(TARGET) $(TARGET): $(OBJS) - kos-cc -o $(TARGET) $(OBJS) -lparallax -lkosutils -lpng -ljpeg -lkmg -lz -lm + kos-cc -o $(TARGET) $(OBJS) -lparallax -lkosutils -lm ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |