Dreamcast: Hopefully get github actions build to work

This commit is contained in:
UnknownShadow200 2023-09-30 13:44:27 +10:00
parent 08e2238a49
commit 2b34308d8d
6 changed files with 35 additions and 35 deletions

View File

@ -17,6 +17,7 @@ jobs:
id: compile
run: |
source /opt/toolchains/dc/kos/environ.sh
export PATH=/opt/toolchains/dc/kos/utils/img4dc/build/cdi4dc/:$PATH
make dreamcast
- uses: ./.github/actions/notify_failure
@ -24,7 +25,13 @@ jobs:
with:
NOTIFY_MESSAGE: 'Failed to compile Dreamcast build'
WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}'
- uses: ./.github/actions/upload_build
if: ${{ always() && steps.compile.outcome == 'success' }}
with:
SOURCE_FILE: 'ClassiCube-dc.elf'
DEST_NAME: 'ClassiCube-dc.elf'
- uses: ./.github/actions/upload_build
if: ${{ always() && steps.compile.outcome == 'success' }}
with:

View File

@ -124,7 +124,6 @@ void IsometricDrawer_BeginBatch(struct VertexTextured* vertices, int* state) {
}
void IsometricDrawer_AddBatch(BlockID block, float size, float x, float y) {
struct VertexTextured* beg = iso_vertices;
if (Blocks.Draw[block] == DRAW_GAS) return;
iso_posX = x; iso_posY = y;

View File

@ -36,10 +36,31 @@ cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
if (end < beg) return 0;
return (end - beg) / 1000;
}
// Borrowed from kos/kernel/arch/dreamcast/kernel/timer.c so it compiles
// with older toolchain versions
#define _PMCR_CTRL_0 ( *((volatile uint16*)(0xff000084)) )
#define _PMCTR_HIGH_0 ( *((volatile uint32*)(0xff100004)) )
#define _PMCTR_LOW_0 ( *((volatile uint32*)(0xff100008)) )
#define _PMCR_CLR 0x2000
#define _PMCR_PMENABLE 0x8000
#define _PMCR_RUN 0xc000
#define _PMCR_PMM_MASK 0x003f
#define _PMCR_CLOCK_TYPE_SHIFT 8
#define _NS_PER_CYCLE 5
#define _PMCR_COUNT_CPU_CYCLES 0
#define _PMCR_ELAPSED_TIME_MODE 0x23
cc_uint64 Stopwatch_Measure(void) {
return timer_ns_gettime64();
uint64 cycles = (uint64)(_PMCTR_HIGH_0 & 0xFFFF) << 32 | _PMCTR_LOW_0;
return cycles * _NS_PER_CYCLE;
}
static void Stopwatch_Init(void) {
_PMCR_CTRL_0 &= ~(_PMCR_PMM_MASK | _PMCR_PMENABLE);
_PMCR_CTRL_0 |= _PMCR_CLR;
_PMCR_CTRL_0 = _PMCR_RUN | _PMCR_ELAPSED_TIME_MODE | (_PMCR_COUNT_CPU_CYCLES << _PMCR_CLOCK_TYPE_SHIFT);
}
// NOTE: If using newer toolchain versions, only need this:
// cc_uint64 Stopwatch_Measure(void) { return timer_ns_gettime64(); }
void Platform_Log(const char* msg, int len) {
fs_write(STDOUT_FILENO, msg, len);
@ -420,7 +441,7 @@ cc_result Process_StartOpen(const cc_string* args) {
}
void Platform_Init(void) {
/*pspDebugSioInit();*/
Stopwatch_Init();
char cwd[600] = { 0 };
char* ptr = getcwd(cwd, 600);

View File

@ -3,7 +3,7 @@ SOURCE_DIRS := src src/yalloc
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(notdir $(C_FILES:%.c=%.o))
C_FLAGS = -O3 -DNDEBUG -mfsrra -mfsca -ffp-contract=fast -ffast-math -O3 -mpretend-cmove -fexpensive-optimizations -fomit-frame-pointer -finline-functions -ml -m4-single-only -ffunction-sections -fdata-sections -std=gnu99
C_FLAGS = -O3 -DNDEBUG -mfsrra -mfsca -fno-math-errno -ffp-contract=fast -ffast-math -O3 -mpretend-cmove -fexpensive-optimizations -fomit-frame-pointer -finline-functions -ml -m4-single-only -ffunction-sections -fdata-sections -std=gnu99
C_DEFINES = -DDREAMCAST -DNDEBUG -D__DREAMCAST__ -D__arch_dreamcast -D_arch_dreamcast -D_arch_sub_pristine

View File

@ -1,27 +0,0 @@
#include <string.h>
#include <math.h>
#include <stdio.h>
#include "private.h"
Viewport VIEWPORT = {
0, 0, 640, 480, 320.0f, 240.0f, 320.0f, 240.0f
};
void _glInitMatrices() {
const VideoMode* vid_mode = GetVideoMode();
glViewport(0, 0, vid_mode->width, vid_mode->height);
}
/* Set the GL viewport */
void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
VIEWPORT.x = x;
VIEWPORT.y = y;
VIEWPORT.width = width;
VIEWPORT.height = height;
VIEWPORT.hwidth = ((GLfloat) VIEWPORT.width) * 0.5f;
VIEWPORT.hheight = ((GLfloat) VIEWPORT.height) * 0.5f;
VIEWPORT.x_plus_hwidth = VIEWPORT.x + VIEWPORT.hwidth;
VIEWPORT.y_plus_hheight = VIEWPORT.y + VIEWPORT.hheight;
}

View File

@ -37,7 +37,7 @@ void InitGPU(_Bool autosort, _Bool fsaa) {
}
GL_FORCE_INLINE float _glFastInvert(float x) {
return (1.f / __builtin_sqrtf(x * x));
return MATH_fsrra(x * x);
}
GL_FORCE_INLINE void _glPerspectiveDivideVertex(Vertex* vertex, const float h) {
@ -92,7 +92,7 @@ static inline void _glClipEdge(const Vertex* const v1, const Vertex* const v2, V
const static float o = 0.003921569f; // 1 / 255
const float d0 = v1->w + v1->xyz[2];
const float d1 = v2->w + v2->xyz[2];
const float t = (fabs(d0) * (1.0f / sqrtf((d1 - d0) * (d1 - d0)))) + 0.000001f;
const float t = (fabs(d0) * MATH_fsrra((d1 - d0) * (d1 - d0))) + 0.000001f;
const float invt = 1.0f - t;
vout->xyz[0] = invt * v1->xyz[0] + t * v2->xyz[0];
@ -434,4 +434,4 @@ void SceneListSubmit(Vertex* v2, int n) {
}
_glFlushBuffer();
}
}