Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,28 @@ jobs:
with:
name: butterscotch-ps3
path: build/butterscotch.elf

build-old-gcc:
strategy:
fail-fast: false
matrix:
include:
- name: GCC 3.0
compiler: gcc-3.0
flags: '-std=gnu99 -w'
- name: GCC 2.95
compiler: g++-2.95
flags: '-fpermissive -w'
name: Build (${{ matrix.name }})
runs-on: ubuntu-latest
steps:
- name: Create Debian Woody chroot
run: |
sudo apt-get install --no-install-recommends -y debootstrap
sudo debootstrap --arch=i386 --include='${{ matrix.compiler }},make,libsdl1.2-dev' woody ~/woody http://archive.debian.org/debian

- name: Checkout repo into chroot
run: sudo git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ~/woody/butterscotch

- name: Build
run: sudo chroot ~/woody /bin/sh --login -c 'make -C /butterscotch CC="${{ matrix.compiler }} ${{ matrix.flags }}" DESKTOP_BACKEND=sdl1 AUDIO_BACKEND=none SDL1_LIBS='-lSDL' DISABLE_MMD=1'
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ endif
SRCS += $(wildcard src/desktop/*.c) $(wildcard src/desktop/backends/$(DESKTOP_BACKEND).c)
ifeq ($(OS),Windows)
PKG_CONFIG_FLAGS := --static
else
PKG_CONFIG_FLAGS :=
endif
INCLUDES += -Isrc/desktop
ifeq ($(DESKTOP_BACKEND),glfw3)
Expand All @@ -75,7 +73,7 @@ LIBS += $(SDL1_LIBS)
DEFINES += -DUSE_SDL1
endif
ifeq ($(DESKTOP_BACKEND),sdl2)
SDL2_LIBS += $(shell pkg-config --libs sdl2)
SDL2_LIBS += $(shell pkg-config $(PKG_CONFIG_FLAGS) --libs sdl2)
LIBS += $(SDL2_LIBS)
DEFINES += -DUSE_SDL2
endif
Expand Down
1 change: 0 additions & 1 deletion src/audio/ps2/ps2_audio_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "audio_system.h"

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

#define MAX_PS2_SOUND_INSTANCES 64
Expand Down
1 change: 0 additions & 1 deletion src/audio_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "common.h"
#include <stdint.h>
#include <stdbool.h>

#include "data_win.h"
#include "file_system.h"
Expand Down
1 change: 0 additions & 1 deletion src/binary_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct {
FILE* file;
Expand Down
2 changes: 1 addition & 1 deletion src/clock_gettime_macos.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <mach/mach_port.h>
#include <mach/mach_time.h>
#include <mach/thread_act.h>
#include <stdbool.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "common.h"

#ifndef CLOCK_REALTIME
typedef int clockid_t;
Expand Down
9 changes: 9 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#pragma once

/*
* GCC 2.95 requires building in C++ mode.
* GCC 2.95's stdbool.h doesn't work in C++ mode.
* C++ defines bool as a built-in type anyway.
*/
#ifndef __cplusplus
#include <stdbool.h>
#endif
#ifndef nullptr
#define nullptr NULL
#endif

#include <stdint.h>

#ifndef UINT32_MAX
#define UINT32_MAX 0xFFFFFFFFU
#endif
Expand Down
1 change: 0 additions & 1 deletion src/data_win.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "data_win.h"
#include "binary_reader.h"

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion src/data_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common.h"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

Expand Down
7 changes: 7 additions & 0 deletions src/desktop/backends/sdl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#include "input_recording.h"
#include "desktop/platformdefs.h"

#ifndef SDL_BUTTON_WHEELUP
#define SDL_BUTTON_WHEELUP 4
#endif
#ifndef SDL_BUTTON_WHEELDOWN
#define SDL_BUTTON_WHEELDOWN 5
#endif

static Runner *g_runner;
static int32_t fbWidth, fbHeight;
static SDL_Surface* scr;
Expand Down
2 changes: 0 additions & 2 deletions src/desktop/platformdefs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <stdbool.h>

#include "runner.h"
#include "input_recording.h"

Expand Down
1 change: 0 additions & 1 deletion src/int_int_hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common.h"
#include "utils.h"
#include <stdint.h>
#include <stdbool.h>

// Open-addressing, linear-probing hashmap from int32_t to RValue.
//
Expand Down
1 change: 0 additions & 1 deletion src/int_rvalue_hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "utils.h"
#include "rvalue.h"
#include <stdint.h>
#include <stdbool.h>

// Open-addressing, linear-probing hashmap from int32_t to RValue.
//
Expand Down
2 changes: 1 addition & 1 deletion src/json_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ JsonValue* JsonReader_parse(const char* json) {
pos = 3;
}

JsonParser parser = {0};
JsonParser parser;
parser.input = json;
parser.position = pos;
parser.length = len;
Expand Down
122 changes: 70 additions & 52 deletions src/ps2/gs_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <malloc.h>
#include <kernel.h>
#include <gsInline.h>
Expand All @@ -15,9 +16,17 @@
#include "matrix_math.h"

#ifdef ENABLE_PS2_RENDERER_LOGS
#define rendererPrintf(...) fprintf(stderr, __VA_ARGS__)
static void rendererPrintf(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
#else
#define rendererPrintf(...) ((void) 0)
static void _rendererPrintf(const char* fmt, ...) {
(void)fmt;
}
#define rendererPrintf if (0) _rendererPrintf
#endif

// ===[ Constants ]===
Expand Down Expand Up @@ -149,7 +158,12 @@ static void loadAtlas(GsRenderer* gs) {
gs->tileEntryMap = nullptr;
repeat(gs->atlasTileCount, i) {
AtlasTileEntry* entry = &gs->atlasTileEntries[i];
TileLookupKey key = { .bgDef = entry->bgDef, .srcX = entry->srcX, .srcY = entry->srcY, .srcW = entry->srcW, .srcH = entry->srcH };
TileLookupKey key = {0};
key.bgDef = entry->bgDef;
key.srcX = entry->srcX;
key.srcY = entry->srcY;
key.srcW = entry->srcW;
key.srcH = entry->srcH;
hmput(gs->tileEntryMap, key, entry);
}

Expand Down Expand Up @@ -910,7 +924,12 @@ static bool setupTextureForTPAG(GsRenderer* gs, GSTEXTURE* tex, int32_t tpagInde

// Finds a tile entry by (bgDef, srcX, srcY, srcW, srcH). Returns nullptr if not found.
static AtlasTileEntry* findTileEntry(GsRenderer* gs, int16_t bgDef, uint16_t srcX, uint16_t srcY, uint16_t srcW, uint16_t srcH) {
TileLookupKey key = { .bgDef = bgDef, .srcX = srcX, .srcY = srcY, .srcW = srcW, .srcH = srcH };
TileLookupKey key = {0};
key.bgDef = bgDef;
key.srcX = srcX;
key.srcY = srcY;
key.srcW = srcW;
key.srcH = srcH;
ptrdiff_t idx = hmgeti(gs->tileEntryMap, key);
if (idx == -1) return nullptr;
return gs->tileEntryMap[idx].value;
Expand Down Expand Up @@ -2947,61 +2966,60 @@ static bool gsSurfaceGetPixels(MAYBE_UNUSED Renderer* renderer, MAYBE_UNUSED int

// ===[ Vtable ]===

static RendererVtable gsVtable = {
.init = gsInit,
.destroy = gsDestroy,
.beginFrame = gsBeginFrame,
.endFrameInit = gsEndFrameInit,
.endFrameEnd = gsEndFrameEnd,
.beginView = gsBeginView,
.endView = gsEndView,
.applyProjection = gsApplyProjection,
.beginGUI = gsBeginGUI,
.endGUI = gsEndGUI,
.drawSprite = gsDrawSprite,
.drawSpritePos = gsDrawSpritePos,
.drawSpritePart = gsDrawSpritePart,
.drawRectangle = gsDrawRectangle,
.drawRectangleColor = gsDrawRectangleColor,
.drawLine = gsDrawLine,
.drawLineColor = gsDrawLineColor,
.drawText = gsDrawText,
.drawTextColor = gsDrawTextColor,
.drawTriangle = gsDrawTriangle,
.flush = gsFlush,
.clearScreen = gsClearScreen,
.createSpriteFromSurface = gsCreateSpriteFromSurface,
.deleteSprite = gsDeleteSprite,
.gpuSetBlendMode = gsGpuSetBlendMode,
.gpuSetBlendModeExt = gsGpuSetBlendModeExt,
.gpuSetBlendEnable = gsGpuSetBlendEnable,
.gpuGetBlendEnable = gsGpuGetBlendEnable,
.gpuSetAlphaTestEnable = gsGpuSetAlphaTestEnable,
.gpuSetAlphaTestRef = gsGpuSetAlphaTestRef,
.gpuSetColorWriteEnable = gsGpuSetColorWriteEnable,
.gpuGetColorWriteEnable = gsGpuGetColorWriteEnable,
.drawTile = gsDrawTile,
.drawTiled = gsDrawTiled,
.drawTiledPart = gsDrawTiledPart,
.createSurface = gsCreateSurface,
.surfaceExists = gsSurfaceExists,
.setRenderTarget = gsSetRenderTarget,
.ensureApplicationSurface = gsEnsureApplicationSurface,
.getSurfaceWidth = gsGetSurfaceWidth,
.getSurfaceHeight = gsGetSurfaceHeight,
.drawSurface = gsDrawSurface,
.surfaceResize = gsSurfaceResize,
.surfaceFree = gsSurfaceFree,
.surfaceCopy = gsSurfaceCopy,
.surfaceGetPixels = gsSurfaceGetPixels,
};
static RendererVtable gsVtable;

// ===[ Public API ]===

Renderer* GsRenderer_create(GSGLOBAL* gsGlobal, int64_t eeAtlasCacheMiB) {
GsRenderer* gs = safeCalloc(1, sizeof(GsRenderer));
gs->eeAtlasCacheBytes = eeAtlasCacheMiB;
gs->base.vtable = &gsVtable;
gsVtable.init = gsInit;
gsVtable.destroy = gsDestroy;
gsVtable.beginFrame = gsBeginFrame;
gsVtable.endFrameInit = gsEndFrameInit;
gsVtable.endFrameEnd = gsEndFrameEnd;
gsVtable.beginView = gsBeginView;
gsVtable.endView = gsEndView;
gsVtable.applyProjection = gsApplyProjection;
gsVtable.beginGUI = gsBeginGUI;
gsVtable.endGUI = gsEndGUI;
gsVtable.drawSprite = gsDrawSprite;
gsVtable.drawSpritePart = gsDrawSpritePart;
gsVtable.drawSpritePos = gsDrawSpritePos;
gsVtable.drawRectangle = gsDrawRectangle;
gsVtable.drawRectangleColor = gsDrawRectangleColor;
gsVtable.drawLine = gsDrawLine;
gsVtable.drawTriangle = gsDrawTriangle;
gsVtable.drawLineColor = gsDrawLineColor;
gsVtable.drawText = gsDrawText;
gsVtable.drawTextColor = gsDrawTextColor;
gsVtable.flush = gsFlush;
gsVtable.clearScreen = gsClearScreen;
gsVtable.createSpriteFromSurface = gsCreateSpriteFromSurface;
gsVtable.deleteSprite = gsDeleteSprite;
gsVtable.gpuSetBlendMode = gsGpuSetBlendMode;
gsVtable.gpuSetBlendModeExt = gsGpuSetBlendModeExt;
gsVtable.gpuSetBlendEnable = gsGpuSetBlendEnable;
gsVtable.gpuSetAlphaTestEnable = gsGpuSetAlphaTestEnable;
gsVtable.gpuSetAlphaTestRef = gsGpuSetAlphaTestRef;
gsVtable.gpuSetColorWriteEnable = gsGpuSetColorWriteEnable;
gsVtable.gpuGetColorWriteEnable = gsGpuGetColorWriteEnable;
gsVtable.gpuGetBlendEnable = gsGpuGetBlendEnable;
gsVtable.drawTile = gsDrawTile;
gsVtable.drawTiled = gsDrawTiled;
gsVtable.drawTiledPart = gsDrawTiledPart;
gsVtable.createSurface = gsCreateSurface;
gsVtable.surfaceExists = gsSurfaceExists;
gsVtable.setRenderTarget = gsSetRenderTarget;
gsVtable.ensureApplicationSurface = gsEnsureApplicationSurface;
gsVtable.getSurfaceWidth = gsGetSurfaceWidth;
gsVtable.getSurfaceHeight = gsGetSurfaceHeight;
gsVtable.drawSurface = gsDrawSurface;
gsVtable.surfaceResize = gsSurfaceResize;
gsVtable.surfaceFree = gsSurfaceFree;
gsVtable.surfaceCopy = gsSurfaceCopy;
gsVtable.surfaceGetPixels = gsSurfaceGetPixels;
gs->gsGlobal = gsGlobal;
gs->scaleX = 2.0f;
gs->scaleY = 2.0f;
Expand Down
41 changes: 20 additions & 21 deletions src/ps2/ps2_file_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,27 +503,7 @@ static FileSystemDirEntry* ps2ListDirectory(MAYBE_UNUSED FileSystem* fs, MAYBE_U

// ===[ Vtable ]===

static FileSystemVtable ps2FileSystemVtable = {
.resolvePath = resolvePath,
.fileExists = fileExists,
.readFileText = readFileText,
.writeFileText = writeFileText,
.deleteFile = deleteFile,
.readFileBinary = ps2ReadFileBinary,
.writeFileBinary = ps2WriteFileBinary,
.binaryOpen = ps2BinaryOpen,
.binaryClose = ps2BinaryClose,
.binaryRead = ps2BinaryRead,
.binaryWrite = ps2BinaryWrite,
.binaryTell = ps2BinaryTell,
.binarySeek = ps2BinarySeek,
.binarySize = ps2BinarySize,
.binaryRewrite = ps2BinaryRewrite,
.directoryExists = ps2DirectoryExists,
.createDirectory = ps2CreateDirectory,
.deleteDirectory = ps2DeleteDirectory,
.listDirectory = ps2ListDirectory,
};
static FileSystemVtable ps2FileSystemVtable;

// ===[ Lifecycle ]===

Expand Down Expand Up @@ -584,6 +564,25 @@ FileSystem* Ps2FileSystem_create(JsonValue* configRoot, const char* gameTitle) {

Ps2FileSystem* pfs = safeCalloc(1, sizeof(Ps2FileSystem));
pfs->base.vtable = &ps2FileSystemVtable;
ps2FileSystemVtable.resolvePath = resolvePath;
ps2FileSystemVtable.fileExists = fileExists;
ps2FileSystemVtable.readFileText = readFileText;
ps2FileSystemVtable.writeFileText = writeFileText;
ps2FileSystemVtable.deleteFile = deleteFile;
ps2FileSystemVtable.readFileBinary = ps2ReadFileBinary;
ps2FileSystemVtable.writeFileBinary = ps2WriteFileBinary;
ps2FileSystemVtable.binaryOpen = ps2BinaryOpen;
ps2FileSystemVtable.binaryClose = ps2BinaryClose;
ps2FileSystemVtable.binaryRead = ps2BinaryRead;
ps2FileSystemVtable.binaryWrite = ps2BinaryWrite;
ps2FileSystemVtable.binaryTell = ps2BinaryTell;
ps2FileSystemVtable.binarySeek = ps2BinarySeek;
ps2FileSystemVtable.binarySize = ps2BinarySize;
ps2FileSystemVtable.binaryRewrite = ps2BinaryRewrite;
ps2FileSystemVtable.directoryExists = ps2DirectoryExists;
ps2FileSystemVtable.createDirectory = ps2CreateDirectory;
ps2FileSystemVtable.deleteDirectory = ps2DeleteDirectory;
ps2FileSystemVtable.listDirectory = ps2ListDirectory;
pfs->gameTitle = safeStrdup(gameTitle);
pfs->saveIconConfig = parseSaveIconConfig(configRoot);
pfs->mappings = nullptr;
Expand Down
6 changes: 2 additions & 4 deletions src/ps2/ps2_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ void PS2Utils_extractDeviceKey(const char* path) {
result[length] = '\0';

// The "result" is the device key as a string (example: "mass" or "host")
deviceKey = (PS2DeviceKey) {
.key = result,
.usesISO9660 = strncmp(result, "cdrom", strlen("cdrom")) == 0,
};
deviceKey.key = result;
deviceKey.usesISO9660 = strncmp(result, "cdrom", strlen("cdrom")) == 0;

deviceKeyLoaded = true;
}
Expand Down
Loading
Loading