mirror of https://github.com/ClassiCube/ClassiCube
GBA: now reaches 2 FPS
This commit is contained in:
parent
74e58b34e1
commit
01ff9ecdc3
|
|
@ -12,7 +12,8 @@
|
|||
#include "Options.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#ifndef CC_DISABLE_ANIMATIONS
|
||||
/* Disables when no hardware FPU, as lava/water animations are FPU heavy and thus costly */
|
||||
#if CC_BUILD_FPU_MODE >= CC_FPU_MODE_NORMAL
|
||||
static void Animations_Update(int loc, struct Bitmap* bmp, int stride);
|
||||
|
||||
#ifdef CC_BUILD_LOWMEM
|
||||
|
|
|
|||
40
src/Core.h
40
src/Core.h
|
|
@ -148,6 +148,7 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_GFX_BACKEND_GL11 7
|
||||
#define CC_GFX_BACKEND_SOFTMIN 8
|
||||
#define CC_GFX_BACKEND_SOFTFP 9
|
||||
#define CC_GFX_BACKEND_IS_GL() (CC_GFX_BACKEND == CC_GFX_BACKEND_GL1 || CC_GFX_BACKEND == CC_GFX_BACKEND_GL2 || CC_GFX_BACKEND == CC_GFX_BACKEND_GL11)
|
||||
|
||||
#define CC_SSL_BACKEND_NONE 1
|
||||
#define CC_SSL_BACKEND_BEARSSL 2
|
||||
|
|
@ -164,7 +165,10 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_AUD_BACKEND_OPENSLES 3
|
||||
#define CC_AUD_BACKEND_NULL 4
|
||||
|
||||
#define CC_GFX_BACKEND_IS_GL() (CC_GFX_BACKEND == CC_GFX_BACKEND_GL1 || CC_GFX_BACKEND == CC_GFX_BACKEND_GL2 || CC_GFX_BACKEND == CC_GFX_BACKEND_GL11)
|
||||
#define CC_FPU_MODE_MINIMAL 1 /* Integer math funcs, no animations, no held block, flat inventory */
|
||||
#define CC_FPU_MODE_LIMITED 2 /* Integer math funcs, no animations, no held block */
|
||||
#define CC_FPU_MODE_REDUCED 3 /* Integer math funcs, no animations */
|
||||
#define CC_FPU_MODE_NORMAL 4
|
||||
|
||||
#define CC_BUILD_NETWORKING
|
||||
#define CC_BUILD_FREETYPE
|
||||
|
|
@ -269,15 +273,13 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_LOWMEM
|
||||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU CC_FPU_MODE_MINIMAL
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#undef CC_BUILD_FILESYSTEM
|
||||
#undef CC_BUILD_COMPRESSION
|
||||
#define CC_BUILD_MAXSTACK (32 * 1024)
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL
|
||||
#define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_SOFTGPU
|
||||
|
|
@ -289,15 +291,13 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_LOWMEM
|
||||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU CC_FPU_MODE_MINIMAL
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#undef CC_BUILD_FILESYSTEM
|
||||
#undef CC_BUILD_COMPRESSION
|
||||
#define CC_BUILD_MAXSTACK (32 * 1024)
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL
|
||||
#define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_SOFTMIN
|
||||
|
|
@ -526,14 +526,12 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_MAXSTACK (8 * 1024) /* TODO verify */
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_MINIMAL
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_FILESYSTEM
|
||||
#undef CC_BUILD_COMPRESSION
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_UI
|
||||
#define CC_DISABLE_EXTRA_MODELS
|
||||
#undef CC_VAR
|
||||
|
|
@ -552,8 +550,7 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_MAXSTACK (16 * 1024) /* Only < 16 kb stack as it's in DTCM region */
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_REDUCED
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL
|
||||
#ifndef NDS_NONET
|
||||
|
|
@ -586,11 +583,9 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_COOPTHREADED
|
||||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_LIMITED
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_FILESYSTEM
|
||||
#define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL
|
||||
|
|
@ -612,11 +607,9 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_MAXSTACK (64 * 1024)
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_LIMITED
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_FILESYSTEM
|
||||
#define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL
|
||||
|
|
@ -629,14 +622,12 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_MAXSTACK (64 * 1024)
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_MINIMAL
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_FILESYSTEM
|
||||
#undef CC_BUILD_COMPRESSION
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_UI
|
||||
#define CC_DISABLE_EXTRA_MODELS
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_SOFTMIN
|
||||
|
|
@ -657,11 +648,9 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_WINCE
|
||||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_NOFPU
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_LIMITED
|
||||
#undef CC_BUILD_ADVLIGHTING
|
||||
#undef CC_BUILD_FREETYPE
|
||||
#define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
|
||||
#define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
|
||||
#define CC_BUILD_TOUCH
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_WIN32CE
|
||||
#define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN
|
||||
|
|
@ -709,6 +698,9 @@ typedef cc_uint8 cc_bool;
|
|||
#ifndef CC_BUILD_MAXSTACK
|
||||
#define CC_BUILD_MAXSTACK (256 * 1024)
|
||||
#endif
|
||||
#ifndef CC_BUILD_FPU_MODE
|
||||
#define CC_BUILD_FPU_MODE CC_FPU_MODE_NORMAL
|
||||
#endif
|
||||
|
||||
#ifdef EXTENDED_BLOCKS
|
||||
typedef cc_uint16 BlockID;
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ float Random_Float(RNGState* seed) {
|
|||
|
||||
float Math_SinF(float x) { return sinf(x); }
|
||||
float Math_CosF(float x) { return cosf(x); }
|
||||
#elif defined CC_BUILD_NOFPU
|
||||
#elif CC_BUILD_FPU_MODE < CC_FPU_MODE_NORMAL
|
||||
|
||||
// Source https://www.coranac.com/2009/07/sines
|
||||
#define ISIN_QN 10
|
||||
|
|
|
|||
|
|
@ -426,73 +426,6 @@ static void DrawSprite2D(Vertex* V0, Vertex* V1, Vertex* V2) {
|
|||
b2 = BitmapCol_B(tColor); \
|
||||
B = ( b1 * b2 ) >> 8; \
|
||||
|
||||
static void DrawTriangle2D(Vertex* V0, Vertex* V1, Vertex* V2) {
|
||||
int x0 = (int)V0->x, y0 = (int)V0->y;
|
||||
int x1 = (int)V1->x, y1 = (int)V1->y;
|
||||
int x2 = (int)V2->x, y2 = (int)V2->y;
|
||||
int minX = min(x0, min(x1, x2));
|
||||
int minY = min(y0, min(y1, y2));
|
||||
int maxX = max(x0, max(x1, x2));
|
||||
int maxY = max(y0, max(y1, y2));
|
||||
|
||||
// Reject triangles completely outside
|
||||
if (maxX < 0 || minX > fb_maxX) return;
|
||||
if (maxY < 0 || minY > fb_maxY) return;
|
||||
|
||||
// Perform scissoring
|
||||
minX = max(minX, 0); maxX = min(maxX, fb_maxX);
|
||||
minY = max(minY, 0); maxY = min(maxY, fb_maxY);
|
||||
|
||||
// https://fgiesen.wordpress.com/2013/02/10/optimizing-the-basic-rasterizer/
|
||||
// Essentially these are the deltas of edge functions between X/Y and X/Y + 1 (i.e. one X/Y step)
|
||||
int dx01 = y0 - y1, dy01 = x1 - x0;
|
||||
int dx12 = y1 - y2, dy12 = x2 - x1;
|
||||
int dx20 = y2 - y0, dy20 = x0 - x2;
|
||||
|
||||
// TODO still too slow, costs 300 ms/frame
|
||||
float bc0_start = edgeFunction(x1,y1, x2,y2, minX+0.5f,minY+0.5f);
|
||||
float bc1_start = edgeFunction(x2,y2, x0,y0, minX+0.5f,minY+0.5f);
|
||||
float bc2_start = edgeFunction(x0,y0, x1,y1, minX+0.5f,minY+0.5f);
|
||||
|
||||
PackedCol color = V0->c;
|
||||
int R, G, B, A, x, y;
|
||||
int a1, r1, g1, b1;
|
||||
int a2, r2, g2, b2;
|
||||
|
||||
if (gfx_format != VERTEX_FORMAT_TEXTURED) {
|
||||
R = PackedCol_R(color);
|
||||
G = PackedCol_G(color);
|
||||
B = PackedCol_B(color);
|
||||
A = PackedCol_A(color);
|
||||
} else {
|
||||
/* Always use a single pixel */
|
||||
float rawY0 = V0->v * curTexHeight;
|
||||
float rawY1 = V1->v * curTexHeight;
|
||||
|
||||
float rawY = min(rawY0, rawY1);
|
||||
int texY = (int)(rawY + 0.01f) & texHeightMask;
|
||||
MultiplyColors(color, curTexPixels[texY * curTexWidth]);
|
||||
}
|
||||
|
||||
if (A == 0) return;
|
||||
color = BitmapCol_Make(R, G, B, 0xFF);
|
||||
|
||||
for (y = minY; y <= maxY; y++, bc0_start += dy12, bc1_start += dy20, bc2_start += dy01)
|
||||
{
|
||||
float bc0 = bc0_start;
|
||||
float bc1 = bc1_start;
|
||||
float bc2 = bc2_start;
|
||||
|
||||
for (x = minX; x <= maxX; x++, bc0 += dx12, bc1 += dx20, bc2 += dx01)
|
||||
{
|
||||
if (bc0 < 0 || bc1 < 0 || bc2 < 0) continue;
|
||||
int cb_index = y * cb_stride + x;
|
||||
|
||||
colorBuffer[cb_index] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawTriangle3D(Vertex* V0, Vertex* V1, Vertex* V2) {
|
||||
int x0 = (int)V0->x, y0 = (int)V0->y;
|
||||
int x1 = (int)V1->x, y1 = (int)V1->y;
|
||||
|
|
@ -854,17 +787,7 @@ void DrawQuads(int startVertex, int verticesCount, DrawHints hints) {
|
|||
DrawSprite2D(&vertices[0], &vertices[1], &vertices[2]);
|
||||
}
|
||||
} else if (gfx_rendering2D) {
|
||||
// 4 vertices = 1 quad = 2 triangles
|
||||
for (i = 0; i < verticesCount / 4; i++, j += 4)
|
||||
{
|
||||
TransformVertex2D(j + 0, &vertices[0]);
|
||||
TransformVertex2D(j + 1, &vertices[1]);
|
||||
TransformVertex2D(j + 2, &vertices[2]);
|
||||
TransformVertex2D(j + 3, &vertices[3]);
|
||||
|
||||
DrawTriangle2D(&vertices[0], &vertices[2], &vertices[1]);
|
||||
DrawTriangle2D(&vertices[2], &vertices[0], &vertices[3]);
|
||||
}
|
||||
Platform_LogConst("2D triangle unsupported..");
|
||||
} else if (colWrite) {
|
||||
// 4 vertices = 1 quad = 2 triangles
|
||||
for (i = 0; i < verticesCount / 4; i++, j += 4)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "Options.h"
|
||||
|
||||
cc_bool HeldBlockRenderer_Show;
|
||||
#ifndef CC_DISABLE_HELDBLOCK
|
||||
#if CC_BUILD_FPU_MODE >= CC_FPU_MODE_REDUCED
|
||||
static BlockID held_block;
|
||||
static struct Entity held_entity;
|
||||
static struct Matrix held_blockProj;
|
||||
|
|
|
|||
|
|
@ -130,17 +130,26 @@ void IsometricDrawer_AddBatch(BlockID block, float size, float x, float y) {
|
|||
|
||||
iso_posX = x; iso_posY = y;
|
||||
|
||||
#if CC_BUILD_FPU_MODE <= CC_FPU_MODE_MINIMAL
|
||||
IsometricDrawer_Flat(block, size);
|
||||
#else
|
||||
if (Blocks.Draw[block] == DRAW_SPRITE) {
|
||||
IsometricDrawer_Flat(block, size);
|
||||
} else {
|
||||
IsometricDrawer_Angled(block, size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int IsometricDrawer_EndBatch(void) {
|
||||
return (int)(iso_vertices - iso_vertices_base);
|
||||
}
|
||||
|
||||
#if CC_BUILD_FPU_MODE <= CC_FPU_MODE_MINIMAL
|
||||
#define ISO_DRAW_HINT DRAW_HINT_SPRITE
|
||||
#else
|
||||
#define ISO_DRAW_HINT DRAW_HINT_NONE
|
||||
#endif
|
||||
void IsometricDrawer_Render(int count, int offset, int* state) {
|
||||
int i, curIdx, batchBeg, batchLen;
|
||||
|
||||
|
|
@ -154,7 +163,7 @@ void IsometricDrawer_Render(int count, int offset, int* state) {
|
|||
|
||||
/* Flush previous batch */
|
||||
Atlas1D_Bind(curIdx);
|
||||
Gfx_DrawVb_IndexedTris_Range(batchLen, batchBeg, DRAW_HINT_NONE);
|
||||
Gfx_DrawVb_IndexedTris_Range(batchLen, batchBeg, ISO_DRAW_HINT);
|
||||
|
||||
/* Reset for next batch */
|
||||
curIdx = state[i];
|
||||
|
|
@ -163,5 +172,5 @@ void IsometricDrawer_Render(int count, int offset, int* state) {
|
|||
}
|
||||
|
||||
Atlas1D_Bind(curIdx);
|
||||
Gfx_DrawVb_IndexedTris_Range(batchLen, batchBeg, DRAW_HINT_NONE);
|
||||
Gfx_DrawVb_IndexedTris_Range(batchLen, batchBeg, ISO_DRAW_HINT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ static void HUDScreen_Render(void* screen, float delta) {
|
|||
if (!Gui.HideCrosshair && Gui.IconsTex && !tablist_active) {
|
||||
Gfx_BindTexture(Gui.IconsTex);
|
||||
Gfx_BindDynamicVb(s->vb); /* Have to rebind for mobile right now... */
|
||||
Gfx_DrawVb_IndexedTris(4);
|
||||
Gfx_DrawVb_IndexedTris_Range(4, 0, DRAW_HINT_SPRITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2818,7 +2818,7 @@ static int ThumbstickWidget_Render2(void* widget, int offset) {
|
|||
Gfx_BindTexture(Gui.TouchTex);
|
||||
for (i = 0; i < 4; i++) {
|
||||
base = (flags & (1 << i)) ? 0 : THUMBSTICKWIDGET_PER;
|
||||
Gfx_DrawVb_IndexedTris_Range(4, offset + base + (i * 4), DRAW_HINT_NONE);
|
||||
Gfx_DrawVb_IndexedTris_Range(4, offset + base + (i * 4), DRAW_HINT_SPRITE);
|
||||
}
|
||||
}
|
||||
return offset + THUMBSTICKWIDGET_MAX;
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol color) {
|
|||
v = Gfx_Build2DFlat(x, y, width, height, color, v);
|
||||
|
||||
Gfx_UnlockDynamicVb(Gfx_quadVb);
|
||||
Gfx_DrawVb_IndexedTris(4);
|
||||
Gfx_DrawVb_IndexedTris_Range(4, 0, DRAW_HINT_RECT);
|
||||
}
|
||||
|
||||
void Gfx_Draw2DGradient(int x, int y, int width, int height, PackedCol top, PackedCol bottom) {
|
||||
|
|
@ -194,7 +194,7 @@ void Gfx_Draw2DGradient(int x, int y, int width, int height, PackedCol top, Pack
|
|||
v = Gfx_Build2DGradient(x, y, width, height, top, bottom, v);
|
||||
|
||||
Gfx_UnlockDynamicVb(Gfx_quadVb);
|
||||
Gfx_DrawVb_IndexedTris(4);
|
||||
Gfx_DrawVb_IndexedTris_Range(4, 0, DRAW_HINT_RECT);
|
||||
}
|
||||
|
||||
void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol color) {
|
||||
|
|
@ -206,7 +206,7 @@ void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol color) {
|
|||
Gfx_Make2DQuad(tex, color, &ptr);
|
||||
|
||||
Gfx_UnlockDynamicVb(Gfx_texVb);
|
||||
Gfx_DrawVb_IndexedTris(4);
|
||||
Gfx_DrawVb_IndexedTris_Range(4, 0, DRAW_HINT_SPRITE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue