summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore12
-rw-r--r--BUILD.md9
-rw-r--r--CMakeLists.txt32
-rw-r--r--FETCH_DEPS.md32
-rw-r--r--PHASE2_COMPRESSION.md4
-rw-r--r--PROJECT_CONTEXT.md24
-rw-r--r--archive/demo64k.zipbin0 -> 7166 bytes
-rw-r--r--scripts/gemini_commit.bat7
-rwxr-xr-xscripts/gemini_commit.sh6
-rw-r--r--scripts/gemini_end.bat5
-rwxr-xr-xscripts/gemini_end.sh5
-rw-r--r--scripts/gemini_start.bat8
-rwxr-xr-xscripts/gemini_start.sh6
-rw-r--r--scripts/project_init.bat15
-rwxr-xr-xscripts/project_init.sh17
-rw-r--r--src/audio/audio.cpp33
-rw-r--r--src/audio/audio.h4
-rw-r--r--src/gpu/gpu.cpp5
-rw-r--r--src/gpu/gpu.h6
-rw-r--r--src/gpu/shader.wgsl14
-rw-r--r--src/main.cpp20
-rw-r--r--src/platform.cpp26
-rw-r--r--src/platform.h8
-rw-r--r--src/util/math.h2
24 files changed, 300 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..08603d6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+# Build artifacts
+/build/
+build/
+
+# Editor backups
+*~
+*.swp
+*.swo
+
+# OS files
+.DS_Store
+Thumbs.db
diff --git a/BUILD.md b/BUILD.md
new file mode 100644
index 0000000..d8501dc
--- /dev/null
+++ b/BUILD.md
@@ -0,0 +1,9 @@
+# Build Instructions
+
+Debug build:
+cmake -S . -B build
+cmake --build build
+
+Size-optimized build:
+cmake -S . -B build -DDEMO_SIZE_OPT=ON
+cmake --build build
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..b5ac51e
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.16)
+project(demo64k LANGUAGES C CXX)
+
+option(DEMO_SIZE_OPT "Enable size optimization flags" OFF)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+add_executable(demo64k
+ src/main.cpp
+ src/platform.cpp
+ src/gpu/gpu.cpp
+ src/audio/audio.cpp
+)
+
+target_include_directories(demo64k PRIVATE
+ src
+ third_party
+)
+
+find_package(glfw3 REQUIRED)
+target_link_libraries(demo64k PRIVATE glfw)
+
+if (DEMO_SIZE_OPT)
+ if (MSVC)
+ target_compile_options(demo64k PRIVATE /Os /GS-)
+ target_link_options(demo64k PRIVATE /OPT:REF /OPT:ICF /INCREMENTAL:NO)
+ else()
+ target_compile_options(demo64k PRIVATE -Os -ffunction-sections -fdata-sections)
+ target_link_options(demo64k PRIVATE -Wl,--gc-sections -s)
+ endif()
+endif()
diff --git a/FETCH_DEPS.md b/FETCH_DEPS.md
new file mode 100644
index 0000000..d16fb45
--- /dev/null
+++ b/FETCH_DEPS.md
@@ -0,0 +1,32 @@
+# Fetching Third-Party Dependencies
+
+This project intentionally does NOT vendor large third-party libraries.
+
+Currently required:
+
+## miniaudio
+
+Single-header audio library.
+
+Source:
+https://github.com/mackron/miniaudio
+
+Required file:
+- miniaudio.h
+
+Expected location:
+third_party/miniaudio.h
+
+### Automatic fetch
+
+Use one of the provided scripts:
+- scripts/project_init.sh
+- scripts/project_init.bat
+
+### Manual fetch
+
+Download miniaudio.h from:
+https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
+
+and place it into:
+third_party/miniaudio.h
diff --git a/PHASE2_COMPRESSION.md b/PHASE2_COMPRESSION.md
new file mode 100644
index 0000000..a2d19d3
--- /dev/null
+++ b/PHASE2_COMPRESSION.md
@@ -0,0 +1,4 @@
+# Phase 2 – Compression & Size Reduction
+
+See conversation description for full intent.
+Executable and shader compression deferred until visuals/audio stabilize.
diff --git a/PROJECT_CONTEXT.md b/PROJECT_CONTEXT.md
new file mode 100644
index 0000000..0bddb50
--- /dev/null
+++ b/PROJECT_CONTEXT.md
@@ -0,0 +1,24 @@
+# 64k Demo Project
+
+Goal:
+- Produce a <=64k native demo binary
+- Same C++ codebase for Windows, macOS, Linux
+
+Graphics:
+- WebGPU via wgpu-native
+- WGSL shaders
+- Single fullscreen pass initially
+
+Audio:
+- 32 kHz, 16-bit mono
+- Procedurally generated samples
+- No decoding, no assets
+
+Constraints:
+- Size-sensitive
+- Minimal dependencies
+- Explicit control over all allocations
+
+Style:
+- Demoscene
+- No engine abstractions
diff --git a/archive/demo64k.zip b/archive/demo64k.zip
new file mode 100644
index 0000000..de88b13
--- /dev/null
+++ b/archive/demo64k.zip
Binary files differ
diff --git a/scripts/gemini_commit.bat b/scripts/gemini_commit.bat
new file mode 100644
index 0000000..f9d922c
--- /dev/null
+++ b/scripts/gemini_commit.bat
@@ -0,0 +1,7 @@
+@echo off
+REM Ask Gemini to summarize work and update docs
+
+gemini --files ^
+ TASKS.md ^
+ NOTES.md ^
+ "Summarize what was accomplished. Update TASKS.md with next steps."
diff --git a/scripts/gemini_commit.sh b/scripts/gemini_commit.sh
new file mode 100755
index 0000000..ae327e4
--- /dev/null
+++ b/scripts/gemini_commit.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Ask Gemini to summarize work and update docs
+
+gemini --files TASKS.md NOTES.md "Summarize what was accomplished.
+ Update TASKS.md with next steps.
+ Add warnings or decisions to NOTES.md."
diff --git a/scripts/gemini_end.bat b/scripts/gemini_end.bat
new file mode 100644
index 0000000..ab4beba
--- /dev/null
+++ b/scripts/gemini_end.bat
@@ -0,0 +1,5 @@
+@echo off
+REM End-of-session summary
+
+gemini --files PROJECT_CONTEXT.md ^
+ "Confirm no constraints were violated. Provide a short summary."
diff --git a/scripts/gemini_end.sh b/scripts/gemini_end.sh
new file mode 100755
index 0000000..5689acf
--- /dev/null
+++ b/scripts/gemini_end.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# End-of-session summary
+
+gemini --files PROJECT_CONTEXT.md "Confirm no project constraints were violated.
+ Provide a short end-of-session summary."
diff --git a/scripts/gemini_start.bat b/scripts/gemini_start.bat
new file mode 100644
index 0000000..22bca70
--- /dev/null
+++ b/scripts/gemini_start.bat
@@ -0,0 +1,8 @@
+@echo off
+REM Start a Gemini session with core context
+
+gemini --files ^
+ PROJECT_CONTEXT.md ^
+ BUILD.md ^
+ PHASE2_COMPRESSION.md ^
+ "Read the project context carefully. Summarize the project goals and current phase. Wait."
diff --git a/scripts/gemini_start.sh b/scripts/gemini_start.sh
new file mode 100755
index 0000000..ea11bea
--- /dev/null
+++ b/scripts/gemini_start.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Start a Gemini session with core context
+
+gemini --files PROJECT_CONTEXT.md BUILD.md PHASE2_COMPRESSION.md "Read the project context carefully.
+ Summarize the project goals and current phase.
+ Wait for further instructions."
diff --git a/scripts/project_init.bat b/scripts/project_init.bat
new file mode 100644
index 0000000..01d9ba2
--- /dev/null
+++ b/scripts/project_init.bat
@@ -0,0 +1,15 @@
+@echo off
+echo Initializing demo64k dependencies...
+
+if not exist third_party (
+ mkdir third_party
+)
+
+if not exist third_party\miniaudio.h (
+ echo Fetching miniaudio.h...
+ powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h -OutFile third_party\miniaudio.h"
+) else (
+ echo miniaudio.h already present.
+)
+
+echo Done.
diff --git a/scripts/project_init.sh b/scripts/project_init.sh
new file mode 100755
index 0000000..40f9457
--- /dev/null
+++ b/scripts/project_init.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Fetch minimal third-party dependencies
+
+set -e
+
+echo "Initializing demo64k dependencies..."
+
+mkdir -p third_party
+
+if [ ! -f third_party/miniaudio.h ]; then
+ echo "Fetching miniaudio.h..."
+ curl -L https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h -o third_party/miniaudio.h
+else
+ echo "miniaudio.h already present."
+fi
+
+echo "Done."
diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp
new file mode 100644
index 0000000..9e778f1
--- /dev/null
+++ b/src/audio/audio.cpp
@@ -0,0 +1,33 @@
+#define MINIAUDIO_IMPLEMENTATION
+#include "miniaudio.h"
+#include <math.h>
+
+static ma_device device;
+static float phase = 0.0f;
+
+static void audio_callback(ma_device*, void* output, const void*, ma_uint32 frames) {
+ int16_t* out = (int16_t*)output;
+ const float freq = 440.0f;
+ const float sr = 32000.0f;
+
+ for (ma_uint32 i = 0; i < frames; i++) {
+ float s = sinf(phase) * 0.2f;
+ phase += 2.0f * 3.14159265f * freq / sr;
+ if (phase > 2.0f * 3.14159265f) phase -= 2.0f * 3.14159265f;
+ out[i] = (int16_t)(s * 32767.0f);
+ }
+}
+
+void audio_init() {
+ ma_device_config cfg = ma_device_config_init(ma_device_type_playback);
+ cfg.playback.format = ma_format_s16;
+ cfg.playback.channels = 1;
+ cfg.sampleRate = 32000;
+ cfg.dataCallback = audio_callback;
+
+ ma_device_init(nullptr, &cfg, &device);
+ ma_device_start(&device);
+}
+
+void audio_update() {}
+void audio_shutdown() { ma_device_uninit(&device); }
diff --git a/src/audio/audio.h b/src/audio/audio.h
new file mode 100644
index 0000000..b3dde7f
--- /dev/null
+++ b/src/audio/audio.h
@@ -0,0 +1,4 @@
+#pragma once
+void audio_init();
+void audio_update();
+void audio_shutdown();
diff --git a/src/gpu/gpu.cpp b/src/gpu/gpu.cpp
new file mode 100644
index 0000000..4e48887
--- /dev/null
+++ b/src/gpu/gpu.cpp
@@ -0,0 +1,5 @@
+#include "gpu.h"
+
+void gpu_init(GLFWwindow*) {}
+void gpu_draw() {}
+void gpu_shutdown() {}
diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h
new file mode 100644
index 0000000..02204af
--- /dev/null
+++ b/src/gpu/gpu.h
@@ -0,0 +1,6 @@
+#pragma once
+struct GLFWwindow;
+
+void gpu_init(GLFWwindow* window);
+void gpu_draw();
+void gpu_shutdown();
diff --git a/src/gpu/shader.wgsl b/src/gpu/shader.wgsl
new file mode 100644
index 0000000..4e0ec11
--- /dev/null
+++ b/src/gpu/shader.wgsl
@@ -0,0 +1,14 @@
+@vertex
+fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> {
+ var pos = array<vec2<f32>, 3>(
+ vec2<f32>(-1.0, -1.0),
+ vec2<f32>( 3.0, -1.0),
+ vec2<f32>(-1.0, 3.0)
+ );
+ return vec4<f32>(pos[i], 0.0, 1.0);
+}
+
+@fragment
+fn fs_main() -> @location(0) vec4<f32> {
+ return vec4<f32>(0.0, 0.0, 0.0, 1.0);
+}
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..3b61e1e
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,20 @@
+#include "platform.h"
+#include "gpu/gpu.h"
+#include "audio/audio.h"
+
+int main() {
+ platform_init();
+ gpu_init(platform_get_window());
+ audio_init();
+
+ while (!platform_should_close()) {
+ platform_poll();
+ gpu_draw();
+ audio_update();
+ }
+
+ audio_shutdown();
+ gpu_shutdown();
+ platform_shutdown();
+ return 0;
+}
diff --git a/src/platform.cpp b/src/platform.cpp
new file mode 100644
index 0000000..adb41d2
--- /dev/null
+++ b/src/platform.cpp
@@ -0,0 +1,26 @@
+#include "platform.h"
+#include <GLFW/glfw3.h>
+
+static GLFWwindow* window = nullptr;
+
+void platform_init() {
+ glfwInit();
+ window = glfwCreateWindow(1280, 720, "demo64k", nullptr, nullptr);
+}
+
+void platform_shutdown() {
+ glfwDestroyWindow(window);
+ glfwTerminate();
+}
+
+void platform_poll() {
+ glfwPollEvents();
+}
+
+bool platform_should_close() {
+ return glfwWindowShouldClose(window);
+}
+
+GLFWwindow* platform_get_window() {
+ return window;
+}
diff --git a/src/platform.h b/src/platform.h
new file mode 100644
index 0000000..0ebeb59
--- /dev/null
+++ b/src/platform.h
@@ -0,0 +1,8 @@
+#pragma once
+struct GLFWwindow;
+
+void platform_init();
+void platform_shutdown();
+void platform_poll();
+bool platform_should_close();
+GLFWwindow* platform_get_window();
diff --git a/src/util/math.h b/src/util/math.h
new file mode 100644
index 0000000..084dfd1
--- /dev/null
+++ b/src/util/math.h
@@ -0,0 +1,2 @@
+#pragma once
+#define PI 3.14159265f