├── .github └── workflows │ └── build.yml ├── LICENSE ├── README.md ├── build.zig ├── build.zig.zon ├── httpserver ├── root.zig └── serve.zig └── src ├── agnes ├── agnes.c ├── agnes.h ├── agnes.html ├── agnes.zig ├── console.zig └── croom.nes ├── bat ├── TimGM6mb.sf2 ├── bat.html ├── bat.zig ├── console.zig ├── escape.mod ├── pocketmod.c ├── pocketmod.h └── ziggysynth.zig ├── coi-serviceworker.js ├── doom ├── console.zig ├── doom.html ├── doom.zig ├── doom1.wad ├── gzdoom.sf2 ├── puredoom │ ├── DOOM.c │ ├── DOOM.h │ ├── PureDOOM.c │ ├── PureDOOM.h │ ├── am_map.c │ ├── am_map.h │ ├── d_englsh.h │ ├── d_event.h │ ├── d_french.h │ ├── d_items.c │ ├── d_items.h │ ├── d_main.c │ ├── d_main.h │ ├── d_net.c │ ├── d_net.h │ ├── d_player.h │ ├── d_textur.h │ ├── d_think.h │ ├── d_ticcmd.h │ ├── doom_config.h │ ├── doomdata.h │ ├── doomdef.c │ ├── doomdef.h │ ├── doomstat.c │ ├── doomstat.h │ ├── doomtype.h │ ├── dstrings.c │ ├── dstrings.h │ ├── f_finale.c │ ├── f_finale.h │ ├── f_wipe.c │ ├── f_wipe.h │ ├── g_game.c │ ├── g_game.h │ ├── hu_lib.c │ ├── hu_lib.h │ ├── hu_stuff.c │ ├── hu_stuff.h │ ├── i_net.c │ ├── i_net.h │ ├── i_sound.c │ ├── i_sound.h │ ├── i_system.c │ ├── i_system.h │ ├── i_video.c │ ├── i_video.h │ ├── info.c │ ├── info.h │ ├── m_argv.c │ ├── m_argv.h │ ├── m_bbox.c │ ├── m_bbox.h │ ├── m_cheat.c │ ├── m_cheat.h │ ├── m_fixed.c │ ├── m_fixed.h │ ├── m_menu.c │ ├── m_menu.h │ ├── m_misc.c │ ├── m_misc.h │ ├── m_random.c │ ├── m_random.h │ ├── m_swap.c │ ├── m_swap.h │ ├── p_ceilng.c │ ├── p_doors.c │ ├── p_enemy.c │ ├── p_floor.c │ ├── p_inter.c │ ├── p_inter.h │ ├── p_lights.c │ ├── p_local.h │ ├── p_map.c │ ├── p_maputl.c │ ├── p_mobj.c │ ├── p_mobj.h │ ├── p_plats.c │ ├── p_pspr.c │ ├── p_pspr.h │ ├── p_saveg.c │ ├── p_saveg.h │ ├── p_setup.c │ ├── p_setup.h │ ├── p_sight.c │ ├── p_spec.c │ ├── p_spec.h │ ├── p_switch.c │ ├── p_telept.c │ ├── p_tick.c │ ├── p_tick.h │ ├── p_user.c │ ├── pocketmod.c │ ├── pocketmod.h │ ├── r_bsp.c │ ├── r_bsp.h │ ├── r_data.c │ ├── r_data.h │ ├── r_defs.h │ ├── r_draw.c │ ├── r_draw.h │ ├── r_local.h │ ├── r_main.c │ ├── r_main.h │ ├── r_plane.c │ ├── r_plane.h │ ├── r_segs.c │ ├── r_segs.h │ ├── r_sky.c │ ├── r_sky.h │ ├── r_state.h │ ├── r_things.c │ ├── r_things.h │ ├── s_sound.c │ ├── s_sound.h │ ├── sounds.c │ ├── sounds.h │ ├── st_lib.c │ ├── st_lib.h │ ├── st_stuff.c │ ├── st_stuff.h │ ├── tables.c │ ├── tables.h │ ├── v_video.c │ ├── v_video.h │ ├── w_wad.c │ ├── w_wad.h │ ├── wi_stuff.c │ ├── wi_stuff.h │ ├── z_zone.c │ └── z_zone.h └── ziggysynth.zig ├── index.html ├── mandelbrot ├── console.zig ├── mandelbrot.html └── mandelbrot.zig ├── mod ├── bananasplit.mod ├── mod.html ├── mod.zig ├── pocketmod.c └── pocketmod.h ├── olive ├── console.zig ├── olive.c │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── assets │ │ ├── CREDITS.txt │ │ ├── Lena_112.png │ │ ├── lavastone-origin.png │ │ ├── lavastone.png │ │ ├── oldstone-origin.png │ │ ├── oldstone.png │ │ ├── olivec-200.png │ │ ├── olivec.svg │ │ ├── tsodinCup.png │ │ ├── tsodinCupLowPoly.obj │ │ ├── tsodinPog.png │ │ └── utahTeapot.obj │ ├── css │ │ ├── index.css │ │ └── reset.css │ ├── demos │ │ ├── cup3d.c │ │ ├── dots3d.c │ │ ├── model3d.c │ │ ├── squish.c │ │ ├── teapot3d.c │ │ ├── triangle.c │ │ ├── triangle3d.c │ │ ├── triangle3dTex.c │ │ ├── triangleTex.c │ │ └── vc.c │ ├── dev-deps │ │ ├── arena.h │ │ ├── stb_image.h │ │ ├── stb_image_write.h │ │ └── sv.h │ ├── docs │ │ ├── .gitignore │ │ ├── 3d-projection.pdf │ │ ├── 3d-projection.tex │ │ ├── barycentric.pdf │ │ └── barycentric.tex │ ├── fonts │ │ ├── LibreBaskerville-Regular.ttf │ │ └── OFL.txt │ ├── index.html │ ├── js │ │ └── vc.js │ ├── nobuild.c │ ├── nobuild.h │ ├── olive.c │ ├── olive.h │ ├── test.c │ ├── test │ │ ├── .gitignore │ │ ├── alpha_blending_expected.png │ │ ├── barycentric_overflow_expected.png │ │ ├── bilinear_interpolation_expected.png │ │ ├── checker_example_expected.png │ │ ├── circle_example_expected.png │ │ ├── draw_line_expected.png │ │ ├── empty_rect_expected.png │ │ ├── fill_circle_expected.png │ │ ├── fill_ellipse_expected.png │ │ ├── fill_rect_expected.png │ │ ├── fill_triangle_expected.png │ │ ├── frame_expected.png │ │ ├── hello_world_text_rendering_expected.png │ │ ├── line_edge_cases_expected.png │ │ ├── lines_circle_expected.png │ │ ├── lines_example_expected.png │ │ ├── sprite_blend_empty_rect_expected.png │ │ ├── sprite_blend_expected.png │ │ ├── sprite_blend_flip_cut_expected.png │ │ ├── sprite_blend_flip_expected.png │ │ ├── sprite_blend_null_expected.png │ │ ├── sprite_blend_out_of_bounds_cut_expected.png │ │ ├── sprite_blend_vs_copy_expected.png │ │ ├── triangle_order_flip_expected.png │ │ └── weird_triangle_bug_expected.png │ ├── tools │ │ ├── obj2c.c │ │ └── png2c.c │ └── wasm │ │ ├── cup3d.wasm │ │ ├── dots3d.wasm │ │ ├── squish.wasm │ │ ├── teapot3d.wasm │ │ ├── triangle.wasm │ │ ├── triangle3d.wasm │ │ ├── triangle3dTex.wasm │ │ └── triangleTex.wasm ├── olive.html ├── olive.zig ├── renderer.zig ├── zero64.raw ├── zlm-generic.zig └── zlm.zig ├── pcm-processor.js ├── ringbuf.js ├── sinetone ├── sinetone.html └── sinetone.zig ├── synth ├── TimGM6mb.sf2 ├── synth.html ├── synth.zig └── ziggysynth.zig ├── terminal ├── assets.zig ├── assets │ ├── pc-bold.ttf │ └── pc.ttf ├── console.zig ├── game.zig ├── inttypes.h ├── olive.c │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── assets │ │ ├── CREDITS.txt │ │ ├── Lena_112.png │ │ ├── lavastone-origin.png │ │ ├── lavastone.png │ │ ├── oldstone-origin.png │ │ ├── oldstone.png │ │ ├── olivec-200.png │ │ ├── olivec.svg │ │ ├── tsodinCup.png │ │ ├── tsodinCupLowPoly.obj │ │ ├── tsodinPog.png │ │ └── utahTeapot.obj │ ├── css │ │ ├── index.css │ │ └── reset.css │ ├── demos │ │ ├── cup3d.c │ │ ├── dots3d.c │ │ ├── model3d.c │ │ ├── squish.c │ │ ├── teapot3d.c │ │ ├── triangle.c │ │ ├── triangle3d.c │ │ ├── triangle3dTex.c │ │ ├── triangleTex.c │ │ └── vc.c │ ├── dev-deps │ │ ├── arena.h │ │ ├── stb_image.h │ │ ├── stb_image_write.h │ │ └── sv.h │ ├── docs │ │ ├── .gitignore │ │ ├── 3d-projection.pdf │ │ ├── 3d-projection.tex │ │ ├── barycentric.pdf │ │ └── barycentric.tex │ ├── fonts │ │ ├── LibreBaskerville-Regular.ttf │ │ └── OFL.txt │ ├── index.html │ ├── js │ │ └── vc.js │ ├── nobuild.c │ ├── nobuild.h │ ├── olive.c │ ├── olive.h │ ├── test.c │ ├── test │ │ ├── .gitignore │ │ ├── alpha_blending_expected.png │ │ ├── barycentric_overflow_expected.png │ │ ├── bilinear_interpolation_expected.png │ │ ├── checker_example_expected.png │ │ ├── circle_example_expected.png │ │ ├── draw_line_expected.png │ │ ├── empty_rect_expected.png │ │ ├── fill_circle_expected.png │ │ ├── fill_ellipse_expected.png │ │ ├── fill_rect_expected.png │ │ ├── fill_triangle_expected.png │ │ ├── frame_expected.png │ │ ├── hello_world_text_rendering_expected.png │ │ ├── line_edge_cases_expected.png │ │ ├── lines_circle_expected.png │ │ ├── lines_example_expected.png │ │ ├── sprite_blend_empty_rect_expected.png │ │ ├── sprite_blend_expected.png │ │ ├── sprite_blend_flip_cut_expected.png │ │ ├── sprite_blend_flip_expected.png │ │ ├── sprite_blend_null_expected.png │ │ ├── sprite_blend_out_of_bounds_cut_expected.png │ │ ├── sprite_blend_vs_copy_expected.png │ │ ├── triangle_order_flip_expected.png │ │ └── weird_triangle_bug_expected.png │ ├── tools │ │ ├── obj2c.c │ │ └── png2c.c │ └── wasm │ │ ├── cup3d.wasm │ │ ├── dots3d.wasm │ │ ├── squish.wasm │ │ ├── teapot3d.wasm │ │ ├── triangle.wasm │ │ ├── triangle3d.wasm │ │ ├── triangle3dTex.wasm │ │ └── triangleTex.wasm ├── rect.zig ├── renderer.zig ├── stb_truetype.c ├── stb_truetype.h ├── terminal.html ├── terminal.zig └── zlm │ ├── zlm-generic.zig │ └── zlm.zig ├── tinygl ├── TinyGL │ ├── BeOS │ │ ├── GLView.cpp │ │ ├── GLView.h │ │ └── Makefile │ ├── Changelog │ ├── INSTALL │ ├── LICENSE │ ├── LIMITATIONS │ ├── Makefile │ ├── README │ ├── README.BEOS │ ├── config.mk │ ├── examples │ │ ├── Makefile │ │ ├── gears.c │ │ ├── glu.c │ │ ├── glu.h │ │ ├── mech.c │ │ ├── nanox.c │ │ ├── spin.c │ │ ├── texobj.c │ │ ├── ui.h │ │ └── x11.c │ ├── include │ │ ├── GL │ │ │ ├── gl.h │ │ │ ├── glx.h │ │ │ ├── nglx.h │ │ │ └── oscontext.h │ │ └── GLView.h │ └── src │ │ ├── Makefile │ │ ├── api.c │ │ ├── arrays.c │ │ ├── clear.c │ │ ├── clip.c │ │ ├── error.c │ │ ├── get.c │ │ ├── glx.c │ │ ├── image_util.c │ │ ├── init.c │ │ ├── light.c │ │ ├── list.c │ │ ├── matrix.c │ │ ├── memory.c │ │ ├── misc.c │ │ ├── msghandling.c │ │ ├── msghandling.h │ │ ├── nglx.c │ │ ├── opinfo.h │ │ ├── oscontext.c │ │ ├── select.c │ │ ├── specbuf.c │ │ ├── specbuf.h │ │ ├── texture.c │ │ ├── vertex.c │ │ ├── zbuffer.c │ │ ├── zbuffer.h │ │ ├── zdither.c │ │ ├── zfeatures.h │ │ ├── zgl.h │ │ ├── zline.c │ │ ├── zline.h │ │ ├── zmath.c │ │ ├── zmath.h │ │ ├── ztriangle.c │ │ └── ztriangle.h ├── console.zig ├── tinygl.html └── tinygl.zig ├── unmute.js └── wasmpcm.js /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 6 | permissions: 7 | contents: read 8 | pages: write 9 | id-token: write 10 | 11 | jobs: 12 | test: 13 | strategy: 14 | matrix: 15 | os: [ubuntu-latest] 16 | runs-on: ${{matrix.os}} 17 | steps: 18 | - name: Checkout zig-wasm-audio-framebuffer 19 | uses: actions/checkout@v2 20 | with: 21 | path: zig-wasm-audio-framebuffer 22 | - name: Setup Zig 23 | uses: mlugg/setup-zig@v1 24 | with: 25 | version: master 26 | - name: Build 27 | run: zig build -Doptimize=ReleaseFast 28 | working-directory: zig-wasm-audio-framebuffer 29 | - name: Setup Pages 30 | if: github.ref == 'refs/heads/main' 31 | uses: actions/configure-pages@v3 32 | - name: Upload Artifact 33 | if: github.ref == 'refs/heads/main' 34 | uses: actions/upload-pages-artifact@v1 35 | with: 36 | path: "zig-wasm-audio-framebuffer/zig-out" 37 | - name: Deploy to GitHub Pages 38 | id: deployment 39 | uses: actions/deploy-pages@v2 40 | 41 | 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Toby Jaffey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | 24 | Other components under their respective licenses 25 | 26 | -------------------------------------------------------------------------------- /build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | // This is the default name used by packages depending on this one. For 3 | // example, when a user runs `zig fetch --save `, this field is used 4 | // as the key in the `dependencies` table. Although the user can choose a 5 | // different name, most users will stick with this provided value. 6 | // 7 | // It is redundant to include "zig" in this name because it is already 8 | // within the Zig package namespace. 9 | .name = "zig-wasm-audio-framebuffer", 10 | 11 | // This is a [Semantic Version](https://semver.org/). 12 | // In a future version of Zig it will be used for package deduplication. 13 | .version = "0.0.0", 14 | 15 | // This field is optional. 16 | // This is currently advisory only; Zig does not yet do anything 17 | // with this value. 18 | //.minimum_zig_version = "0.11.0", 19 | 20 | // This field is optional. 21 | // Each dependency must either provide a `url` and `hash`, or a `path`. 22 | // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. 23 | // Once all dependencies are fetched, `zig build` no longer requires 24 | // internet connectivity. 25 | .dependencies = .{ 26 | .mime = .{ 27 | .url = "https://github.com/andrewrk/mime/archive/refs/tags/2.0.1.tar.gz", 28 | .hash = "12209083b0c43d0f68a26a48a7b26ad9f93b22c9cff710c78ddfebb47b89cfb9c7a4", 29 | }, 30 | .zvterm = .{ 31 | .url = "git+https://github.com/ringtailsoftware/zvterm.git#7617c3610f0dd491c197ba03f3149c4040ff6845", 32 | .hash = "12207e677beeb14481d932fe7d2c97d0ae9b968053753f0639690e00d5ceaabb8800", 33 | }, 34 | .zeptolibc = .{ 35 | .url = "git+https://github.com/ringtailsoftware/zeptolibc.git#03717dc35bd1eb7b0d5afe0438bee73793ca8334", 36 | .hash = "12202a7c100a234ad042d4e1eda738e04652a1b20ddc50aed529954702198fa09f42", 37 | }, 38 | .mibu = .{ 39 | .url = "git+https://github.com/xyaman/mibu.git#b001662c929e2719ee24be585a3120640f946337", 40 | .hash = "1220d78664322b50e31a99cfb004b6fa60c43098d95abf7ec60a21ebeaf1c914edaf", 41 | }, 42 | .zigtris = .{ 43 | .url = "git+https://github.com/ringtailsoftware/zigtris.git#7563ff5421974857ee8e745f7ae020874f2954af", 44 | .hash = "122062266e1f9482cd9601be6ecb8cacc91cc8c9a912e3a8c4e48a69827869dc17ec", 45 | }, 46 | }, 47 | .paths = .{ 48 | "build.zig", 49 | "build.zig.zon", 50 | "src", 51 | // For example... 52 | //"LICENSE", 53 | //"README.md", 54 | }, 55 | } 56 | -------------------------------------------------------------------------------- /src/agnes/agnes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | agnes 6 | 15 | 16 | 17 | 18 | 19 | 37 | 38 | 39 |

40 | 41 |

43 |

44 | Graphics only, agnes does not support sound.
45 | Replace ROM file in build to play any NES game
46 | 47 | Z = A, X = B, Shift = SELECT, Enter = START 48 |

49 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/agnes/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | 6 | // Implement a std.io.Writer backed by console_write() 7 | const ConsoleWriter = struct { 8 | const Writer = std.io.Writer( 9 | *ConsoleWriter, 10 | error{}, 11 | write, 12 | ); 13 | 14 | fn write( 15 | self: *ConsoleWriter, 16 | data: []const u8, 17 | ) error{}!usize { 18 | _ = self; 19 | console_write(data.ptr, data.len); 20 | return data.len; 21 | } 22 | 23 | pub fn writer(self: *ConsoleWriter) Writer { 24 | return .{ .context = self }; 25 | } 26 | }; 27 | 28 | pub fn getWriter() *ConsoleWriter { 29 | return &cw; 30 | } 31 | -------------------------------------------------------------------------------- /src/agnes/croom.nes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/agnes/croom.nes -------------------------------------------------------------------------------- /src/bat/TimGM6mb.sf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/bat/TimGM6mb.sf2 -------------------------------------------------------------------------------- /src/bat/bat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bat 6 | 15 | 16 | 17 | 18 | 19 | 37 | 38 | 39 |

40 | 41 |

43 |

44 | 320x240x32bpp graphics buffer, sound fx (midi) and music (mod)
45 | Use left and right arrow keys to move 46 |

47 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/bat/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | 6 | // Implement a std.io.Writer backed by console_write() 7 | const ConsoleWriter = struct { 8 | const Writer = std.io.Writer( 9 | *ConsoleWriter, 10 | error{}, 11 | write, 12 | ); 13 | 14 | fn write( 15 | self: *ConsoleWriter, 16 | data: []const u8, 17 | ) error{}!usize { 18 | _ = self; 19 | console_write(data.ptr, data.len); 20 | return data.len; 21 | } 22 | 23 | pub fn writer(self: *ConsoleWriter) Writer { 24 | return .{ .context = self }; 25 | } 26 | }; 27 | 28 | pub fn getWriter() *ConsoleWriter { 29 | return &cw; 30 | } 31 | -------------------------------------------------------------------------------- /src/bat/escape.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/bat/escape.mod -------------------------------------------------------------------------------- /src/bat/pocketmod.c: -------------------------------------------------------------------------------- 1 | #define POCKETMOD_IMPLEMENTATION 2 | #include "pocketmod.h" 3 | -------------------------------------------------------------------------------- /src/doom/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | //fn console_write(data:[*]const u8, len:usize) void { 6 | // std.log.info("{s}", .{data[0..len]}); 7 | //} 8 | 9 | // Implement a std.io.Writer backed by console_write() 10 | const ConsoleWriter = struct { 11 | const Writer = std.io.Writer( 12 | *ConsoleWriter, 13 | error{}, 14 | write, 15 | ); 16 | 17 | fn write( 18 | self: *ConsoleWriter, 19 | data: []const u8, 20 | ) error{}!usize { 21 | _ = self; 22 | console_write(data.ptr, data.len); 23 | return data.len; 24 | } 25 | 26 | pub fn writer(self: *ConsoleWriter) Writer { 27 | return .{ .context = self }; 28 | } 29 | }; 30 | 31 | pub fn getWriter() *ConsoleWriter { 32 | return &cw; 33 | } 34 | -------------------------------------------------------------------------------- /src/doom/doom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | doom 6 | 15 | 16 | 17 | 18 | 19 | 48 | 49 | 50 |

51 | 52 |

54 |

55 | 56 |

57 |

58 | Shareware doom1.wad
59 | gzdoom.sf2 MIDI SoundFont from gzdoom
60 |

61 |

62 | Cheats: "idkfa" to get all weapons, "iddqd" for god mode, "idclip" to walk through walls)
63 | More cheat codes 64 |

65 |

66 | Controls: cursor keys, ctrl or '\' to fire (use \ on mac to avoid ctrl+cursor shortcuts), alt+cursor to strafe, space to open doors 67 |

68 | 69 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/doom/doom1.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/doom/doom1.wad -------------------------------------------------------------------------------- /src/doom/gzdoom.sf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/doom/gzdoom.sf2 -------------------------------------------------------------------------------- /src/doom/puredoom/PureDOOM.c: -------------------------------------------------------------------------------- 1 | #define DOOM_IMPLEMENTATION 2 | extern void doom_print_impl(const char* str); 3 | #include "PureDOOM.h" 4 | 5 | static char *argv[] = {"pd"}; 6 | void pd_init(void) { 7 | doom_init(1, argv, 0); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/doom/puredoom/am_map.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // AutoMap module. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __AMMAP_H__ 23 | #define __AMMAP_H__ 24 | 25 | 26 | #include "d_event.h" 27 | 28 | 29 | // Used by ST StatusBar stuff. 30 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 31 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 32 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 33 | 34 | 35 | // Called by main loop. 36 | doom_boolean AM_Responder(event_t* ev); 37 | 38 | // Called by main loop. 39 | void AM_Ticker(void); 40 | 41 | // Called by main loop, 42 | // called instead of view drawer if automap active. 43 | void AM_Drawer(void); 44 | 45 | // Called to force the automap to quit 46 | // if the level is completed while it is up. 47 | void AM_Stop(void); 48 | 49 | 50 | #endif 51 | 52 | //----------------------------------------------------------------------------- 53 | // 54 | // $Log:$ 55 | // 56 | //----------------------------------------------------------------------------- 57 | -------------------------------------------------------------------------------- /src/doom/puredoom/d_items.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Items: key cards, artifacts, weapon, ammunition. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __D_ITEMS__ 23 | #define __D_ITEMS__ 24 | 25 | 26 | #include "doomdef.h" 27 | 28 | 29 | // Weapon info: sprite frames, ammunition use. 30 | typedef struct 31 | { 32 | ammotype_t ammo; 33 | int upstate; 34 | int downstate; 35 | int readystate; 36 | int atkstate; 37 | int flashstate; 38 | } weaponinfo_t; 39 | 40 | 41 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 42 | 43 | 44 | #endif 45 | 46 | //----------------------------------------------------------------------------- 47 | // 48 | // $Log:$ 49 | // 50 | //----------------------------------------------------------------------------- 51 | -------------------------------------------------------------------------------- /src/doom/puredoom/d_main.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // System specific interface stuff. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __D_MAIN__ 25 | #define __D_MAIN__ 26 | 27 | 28 | #include "d_event.h" 29 | 30 | 31 | #define MAXWADFILES 20 32 | 33 | 34 | extern char* wadfiles[MAXWADFILES]; 35 | 36 | 37 | void D_AddFile(char* file); 38 | 39 | // 40 | // D_DoomMain() 41 | // Not a globally visible function, just included for source reference, 42 | // calls all startup code, parses command line options. 43 | // If not overrided by user input, calls N_AdvanceDemo. 44 | // 45 | void D_DoomMain(void); 46 | 47 | // Called by IO functions when input is detected. 48 | void D_PostEvent(event_t* ev); 49 | 50 | // 51 | // BASE LEVEL 52 | // 53 | void D_PageTicker(void); 54 | void D_PageDrawer(void); 55 | void D_AdvanceDemo(void); 56 | void D_StartTitle(void); 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/doom/puredoom/d_textur.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Typedefs related to to textures etc., 19 | // isolated here to make it easier separating modules. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __D_TEXTUR__ 24 | #define __D_TEXTUR__ 25 | 26 | 27 | #include "doomtype.h" 28 | 29 | 30 | // 31 | // Flats? 32 | // 33 | // a pic is an unmasked block of pixels 34 | typedef struct 35 | { 36 | byte width; 37 | byte height; 38 | byte data; 39 | } pic_t; 40 | 41 | 42 | #endif 43 | 44 | //----------------------------------------------------------------------------- 45 | // 46 | // $Log:$ 47 | // 48 | //----------------------------------------------------------------------------- 49 | -------------------------------------------------------------------------------- /src/doom/puredoom/d_think.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // MapObj data. Map Objects or mobjs are actors, entities, 19 | // thinker, take-your-pick... anything that moves, acts, or 20 | // suffers state changes of more or less violent nature. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __D_THINK__ 25 | #define __D_THINK__ 26 | 27 | 28 | // 29 | // Experimental stuff. 30 | // To compile this as "ANSI C with classes" 31 | // we will need to handle the various 32 | // action functions cleanly. 33 | // 34 | typedef void (*actionf_v)(); 35 | typedef void (*actionf_p1)(void*); 36 | typedef void (*actionf_p2)(void*, void*); 37 | 38 | typedef union 39 | { 40 | actionf_p1 acp1; 41 | actionf_v acv; 42 | actionf_p2 acp2; 43 | } actionf_t; 44 | 45 | 46 | // Historically, "think_t" is yet another 47 | // function pointer to a routine to handle 48 | // an actor. 49 | typedef actionf_t think_t; 50 | 51 | 52 | // Doubly linked list of actors. 53 | typedef struct thinker_s 54 | { 55 | struct thinker_s* prev; 56 | struct thinker_s* next; 57 | think_t function; 58 | } thinker_t; 59 | 60 | 61 | #endif 62 | 63 | //----------------------------------------------------------------------------- 64 | // 65 | // $Log:$ 66 | // 67 | //----------------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /src/doom/puredoom/d_ticcmd.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __D_TICCMD__ 23 | #define __D_TICCMD__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // The data sampled per tick (single player) 30 | // and transmitted to other peers (multiplayer). 31 | // Mainly movements/button commands per game tick, 32 | // plus a checksum for internal state consistency. 33 | typedef struct 34 | { 35 | char forwardmove; // *2048 for move 36 | char sidemove; // *2048 for move 37 | short angleturn; // <<16 for angle delta 38 | short consistancy; // checks for net game 39 | byte chatchar; 40 | byte buttons; 41 | } ticcmd_t; 42 | 43 | 44 | #endif 45 | 46 | //----------------------------------------------------------------------------- 47 | // 48 | // $Log:$ 49 | // 50 | //----------------------------------------------------------------------------- 51 | -------------------------------------------------------------------------------- /src/doom/puredoom/doom_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOOM_CONFIG_H__ 2 | #define __DOOM_CONFIG_H__ 3 | 4 | 5 | #if defined(WIN32) 6 | #define DOOM_WIN32 7 | #elif defined(__APPLE__) 8 | #define DOOM_APPLE 9 | #else 10 | #define DOOM_LINUX 11 | #endif 12 | 13 | 14 | #include "DOOM.h" 15 | 16 | 17 | #define doom_abs(x) ((x) < 0 ? -(x) : (x)) 18 | 19 | 20 | extern char error_buf[260]; 21 | extern int doom_flags; 22 | extern doom_print_fn doom_print; 23 | extern doom_malloc_fn doom_malloc; 24 | extern doom_free_fn doom_free; 25 | extern doom_open_fn doom_open; 26 | extern doom_close_fn doom_close; 27 | extern doom_read_fn doom_read; 28 | extern doom_write_fn doom_write; 29 | extern doom_seek_fn doom_seek; 30 | extern doom_tell_fn doom_tell; 31 | extern doom_eof_fn doom_eof; 32 | extern doom_gettime_fn doom_gettime; 33 | extern doom_exit_fn doom_exit; 34 | extern doom_getenv_fn doom_getenv; 35 | 36 | 37 | const char* doom_itoa(int i, int radix); 38 | const char* doom_ctoa(char c); 39 | const char* doom_ptoa(void* p); 40 | void doom_memset(void* ptr, int value, int num); 41 | void* doom_memcpy(void* destination, const void* source, int num); 42 | int doom_fprint(void* handle, const char* str); 43 | int doom_strlen(const char* str); 44 | char* doom_concat(char* dst, const char* src); 45 | char* doom_strcpy(char* destination, const char* source); 46 | char* doom_strncpy(char* destination, const char* source, int num); 47 | int doom_strcmp(const char* str1, const char* str2); 48 | int doom_strncmp(const char* str1, const char* str2, int n); 49 | int doom_strcasecmp(const char* str1, const char* str2); 50 | int doom_strncasecmp(const char* str1, const char* str2, int n); 51 | int doom_atoi(const char* str); 52 | int doom_atox(const char* str); 53 | int doom_toupper(int c); 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/doom/puredoom/doomdef.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // DoomDef - basic defines for DOOM, e.g. Version, game mode 21 | // and skill level, and display parameters. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #include "doom_config.h" 26 | 27 | #include "doomdef.h" 28 | -------------------------------------------------------------------------------- /src/doom/puredoom/doomstat.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Put all global tate variables here. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | #include "doomstat.h" 27 | 28 | 29 | // Game Mode - identify IWAD as shareware, retail etc. 30 | GameMode_t gamemode = indetermined; 31 | GameMission_t gamemission = doom; 32 | 33 | // Language. 34 | Language_t language = english; 35 | 36 | // Set if homebrew PWAD stuff has been added. 37 | doom_boolean modifiedgame; 38 | -------------------------------------------------------------------------------- /src/doom/puredoom/doomtype.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Simple basic typedefs, isolated here to make it easier 19 | // separating modules. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __DOOMTYPE__ 24 | #define __DOOMTYPE__ 25 | 26 | 27 | // Fixed to use builtin bool type with C++. 28 | #ifdef __cplusplus 29 | typedef bool doom_boolean; 30 | #else 31 | #if !defined(false) && !defined(true) 32 | typedef enum 33 | { 34 | false, true 35 | } doom_boolean; 36 | #else 37 | typedef int doom_boolean; 38 | #endif 39 | #endif 40 | 41 | 42 | typedef unsigned char byte; 43 | 44 | 45 | #define DOOM_MAXCHAR ((char)0x7f) 46 | #define DOOM_MAXSHORT ((short)0x7fff) 47 | 48 | // Max pos 32-bit int. 49 | #define DOOM_MAXINT ((int)0x7fffffff) 50 | #define DOOM_MAXLONG ((long)0x7fffffff) 51 | #define DOOM_MINCHAR ((char)0x80) 52 | #define DOOM_MINSHORT ((short)0x8000) 53 | 54 | // Max negative 32-bit integer. 55 | #define DOOM_MININT ((int)0x80000000) 56 | #define DOOM_MINLONG ((long)0x80000000) 57 | 58 | 59 | #endif 60 | 61 | //----------------------------------------------------------------------------- 62 | // 63 | // $Log:$ 64 | // 65 | //----------------------------------------------------------------------------- 66 | -------------------------------------------------------------------------------- /src/doom/puredoom/dstrings.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Globally defined strings. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | #include "dstrings.h" 27 | 28 | 29 | char* endmsg[NUM_QUITMESSAGES + 1] = 30 | { 31 | // DOOM1 32 | QUITMSG, 33 | "please don't leave, there's more\ndemons to toast!", 34 | "let's beat it -- this is turning\ninto a bloodbath!", 35 | "i wouldn't leave if i were you.\ndos is much worse.", 36 | "you're trying to say you like dos\nbetter than me, right?", 37 | "don't leave yet -- there's a\ndemon around that corner!", 38 | "ya know, next time you come in here\ni'm gonna toast ya.", 39 | "go ahead and leave. see if i care.", 40 | 41 | // QuitDOOM II messages 42 | "you want to quit?\nthen, thou hast lost an eighth!", 43 | "don't go now, there's a \ndimensional shambler waiting\nat the dos prompt!", 44 | "get outta here and go back\nto your boring programs.", 45 | "if i were your boss, i'd \n deathmatch ya in a minute!", 46 | "look, bud. you leave now\nand you forfeit your body count!", 47 | "just leave. when you come\nback, i'll be waiting with a bat.", 48 | "you're lucky i don't smack\nyou for thinking about leaving.", 49 | 50 | // FinalDOOM? 51 | "fuck you, pussy!\nget the fuck out!", 52 | "you quit and i'll jizz\nin your cystholes!", 53 | "if you leave, i'll make\nthe lord drink my jizz.", 54 | "hey, ron! can we say\n'fuck' in the game?", 55 | "i'd leave: this is just\nmore monsters and levels.\nwhat a load.", 56 | "suck it down, asshole!\nyou're a fucking wimp!", 57 | "don't quit now! we're \nstill spending your money!", 58 | 59 | // Internal debug. Different style, too. 60 | "THIS IS NO MESSAGE!\nPage intentionally left blank." 61 | }; 62 | -------------------------------------------------------------------------------- /src/doom/puredoom/dstrings.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // DOOM strings, by language. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #ifndef __DSTRINGS__ 26 | #define __DSTRINGS__ 27 | 28 | 29 | // All important printed strings. 30 | // Language selection (message strings). 31 | // Use -DFRENCH etc. 32 | 33 | #ifdef FRENCH 34 | #include "d_french.h" // Leave the extra space there, to throw off regex in PureDOOM.h creation 35 | #else 36 | #include "d_englsh.h" 37 | #endif 38 | 39 | 40 | // Misc. other strings. 41 | #define SAVEGAMENAME "doomsav" 42 | 43 | // 44 | // File locations, 45 | // relative to current position. 46 | // Path names are OS-sensitive. 47 | // 48 | #define DEVMAPS "devmaps" 49 | #define DEVDATA "devdata" 50 | 51 | // Not done in french? 52 | 53 | // QuitDOOM messages 54 | #define NUM_QUITMESSAGES 22 55 | 56 | 57 | extern char* endmsg[]; 58 | 59 | 60 | #endif 61 | 62 | //----------------------------------------------------------------------------- 63 | // 64 | // $Log:$ 65 | // 66 | //----------------------------------------------------------------------------- 67 | -------------------------------------------------------------------------------- /src/doom/puredoom/f_finale.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __F_FINALE__ 23 | #define __F_FINALE__ 24 | 25 | 26 | #include "doomtype.h" 27 | #include "d_event.h" 28 | 29 | 30 | // 31 | // FINALE 32 | // 33 | 34 | // Called by main loop. 35 | doom_boolean F_Responder(event_t* ev); 36 | 37 | // Called by main loop. 38 | void F_Ticker(void); 39 | 40 | // Called by main loop. 41 | void F_Drawer(void); 42 | 43 | void F_StartFinale(void); 44 | 45 | 46 | #endif 47 | 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /src/doom/puredoom/f_wipe.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Mission start screen wipe/melt, special effects. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __F_WIPE_H__ 23 | #define __F_WIPE_H__ 24 | 25 | 26 | // 27 | // SCREEN WIPE PACKAGE 28 | // 29 | 30 | enum 31 | { 32 | // simple gradual pixel change for 8-bit only 33 | wipe_ColorXForm, 34 | 35 | // weird screen melt 36 | wipe_Melt, 37 | 38 | wipe_NUMWIPES 39 | }; 40 | 41 | 42 | int wipe_StartScreen(int x, int y, int width, int height); 43 | int wipe_EndScreen(int x, int y, int width, int height); 44 | int wipe_ScreenWipe(int wipeno, int x, int y, int width, int height, int ticks); 45 | 46 | 47 | #endif 48 | 49 | //----------------------------------------------------------------------------- 50 | // 51 | // $Log:$ 52 | // 53 | //----------------------------------------------------------------------------- 54 | -------------------------------------------------------------------------------- /src/doom/puredoom/g_game.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Duh. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __G_GAME__ 23 | #define __G_GAME__ 24 | 25 | 26 | #include "doomdef.h" 27 | #include "d_event.h" 28 | 29 | 30 | // 31 | // GAME 32 | // 33 | void G_DeathMatchSpawnPlayer(int playernum); 34 | 35 | void G_InitNew(skill_t skill, int episode, int map); 36 | 37 | // Can be called by the startup code or M_Responder. 38 | // A normal game starts at map 1, 39 | // but a warp test can start elsewhere 40 | void G_DeferedInitNew(skill_t skill, int episode, int map); 41 | 42 | void G_DeferedPlayDemo(char* demo); 43 | 44 | // Can be called by the startup code or M_Responder, 45 | // calls P_SetupLevel or W_EnterWorld. 46 | void G_LoadGame(char* name); 47 | 48 | void G_DoLoadGame(void); 49 | 50 | // Called by M_Responder. 51 | void G_SaveGame(int slot, char* description); 52 | 53 | // Only called by startup code. 54 | void G_RecordDemo(char* name); 55 | 56 | void G_BeginRecording(void); 57 | 58 | void G_TimeDemo(char* name); 59 | doom_boolean G_CheckDemoStatus(void); 60 | 61 | void G_ExitLevel(void); 62 | void G_SecretExitLevel(void); 63 | 64 | void G_WorldDone(void); 65 | 66 | void G_Ticker(void); 67 | doom_boolean G_Responder(event_t* ev); 68 | 69 | void G_ScreenShot(void); 70 | 71 | 72 | #endif 73 | 74 | //----------------------------------------------------------------------------- 75 | // 76 | // $Log:$ 77 | // 78 | //----------------------------------------------------------------------------- 79 | -------------------------------------------------------------------------------- /src/doom/puredoom/hu_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: Head up display 18 | // 19 | //----------------------------------------------------------------------------- 20 | 21 | #ifndef __HU_STUFF_H__ 22 | #define __HU_STUFF_H__ 23 | 24 | 25 | #include "d_event.h" 26 | 27 | 28 | // 29 | // Globally visible constants. 30 | // 31 | #define HU_FONTSTART '!' // the first font characters 32 | #define HU_FONTEND '_' // the last font characters 33 | 34 | // Calculate # of glyphs in font. 35 | #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) 36 | 37 | #define HU_BROADCAST 5 38 | 39 | #define HU_MSGREFRESH KEY_ENTER 40 | #define HU_MSGX 0 41 | #define HU_MSGY 0 42 | #define HU_MSGWIDTH 64 // in characters 43 | #define HU_MSGHEIGHT 1 // in lines 44 | 45 | #define HU_MSGTIMEOUT (4*TICRATE) 46 | 47 | 48 | // 49 | // HEADS UP TEXT 50 | // 51 | 52 | void HU_Init(void); 53 | void HU_Start(void); 54 | doom_boolean HU_Responder(event_t* ev); 55 | void HU_Ticker(void); 56 | void HU_Drawer(void); 57 | char HU_dequeueChatChar(void); 58 | void HU_Erase(void); 59 | 60 | 61 | #endif 62 | 63 | //----------------------------------------------------------------------------- 64 | // 65 | // $Log:$ 66 | // 67 | //----------------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /src/doom/puredoom/i_net.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific network interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __I_NET__ 23 | #define __I_NET__ 24 | 25 | 26 | // Called by D_DoomMain. 27 | 28 | void I_InitNetwork (void); 29 | void I_NetCmd (void); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /src/doom/puredoom/i_system.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __I_SYSTEM__ 23 | #define __I_SYSTEM__ 24 | 25 | 26 | #include "d_ticcmd.h" 27 | #include "d_event.h" 28 | 29 | 30 | // Called by DoomMain. 31 | void I_Init(void); 32 | 33 | // Called by startup code 34 | // to get the ammount of memory to malloc 35 | // for the zone management. 36 | byte* I_ZoneBase(int* size); 37 | 38 | // Called by D_DoomLoop, 39 | // returns current time in tics. 40 | int I_GetTime(void); 41 | 42 | // Called by D_DoomLoop, 43 | // called before processing any tics in a frame 44 | // (just after displaying a frame). 45 | // Time consuming syncronous operations 46 | // are performed here (joystick reading). 47 | // Can call D_PostEvent. 48 | void I_StartFrame(void); 49 | 50 | // Called by D_DoomLoop, 51 | // called before processing each tic in a frame. 52 | // Quick syncronous operations are performed here. 53 | // Can call D_PostEvent. 54 | void I_StartTic(void); 55 | 56 | // Asynchronous interrupt functions should maintain private queues 57 | // that are read by the synchronous functions 58 | // to be converted into events. 59 | 60 | // Either returns a null ticcmd, 61 | // or calls a loadable driver to build it. 62 | // This ticcmd will then be modified by the gameloop 63 | // for normal input. 64 | ticcmd_t* I_BaseTiccmd(void); 65 | 66 | // Called by M_Responder when quit is selected. 67 | // Clean exit, displays sell blurb. 68 | void I_Quit(void); 69 | 70 | // Allocates from low memory under dos, 71 | // just mallocs under unix 72 | byte* I_AllocLow(int length); 73 | 74 | void I_Tactile(int on, int off, int total); 75 | 76 | void I_Error(char* error); 77 | 78 | 79 | #endif 80 | 81 | //----------------------------------------------------------------------------- 82 | // 83 | // $Log:$ 84 | // 85 | //----------------------------------------------------------------------------- 86 | -------------------------------------------------------------------------------- /src/doom/puredoom/i_video.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // System specific interface stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __I_VIDEO__ 23 | #define __I_VIDEO__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // Called by D_DoomMain, 30 | // determines the hardware configuration 31 | // and sets up the video mode 32 | void I_InitGraphics(void); 33 | 34 | void I_ShutdownGraphics(void); 35 | 36 | // Takes full 8 bit values. 37 | void I_SetPalette(byte* palette); 38 | 39 | void I_UpdateNoBlit(void); 40 | void I_FinishUpdate(void); 41 | 42 | // Wait for vertical retrace or pause a bit. 43 | void I_WaitVBL(int count); 44 | 45 | void I_ReadScreen(byte* scr); 46 | 47 | void I_BeginRead(void); 48 | void I_EndRead(void); 49 | 50 | 51 | #endif 52 | 53 | //----------------------------------------------------------------------------- 54 | // 55 | // $Log:$ 56 | // 57 | //----------------------------------------------------------------------------- 58 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_argv.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #include "doom_config.h" 25 | 26 | 27 | // #if defined(DOOM_WIN32) 28 | // #define strcasecmp stricmp 29 | // #endif 30 | 31 | 32 | int myargc; 33 | char** myargv; 34 | 35 | 36 | // 37 | // M_CheckParm 38 | // Checks for the given parameter 39 | // in the program's command line arguments. 40 | // Returns the argument number (1 to argc-1) 41 | // or 0 if not present 42 | int M_CheckParm(char* check) 43 | { 44 | int i; 45 | 46 | for (i = 1; i < myargc; i++) 47 | { 48 | if (!doom_strcasecmp(check, myargv[i])) 49 | return i; 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_argv.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Nil. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_ARGV__ 23 | #define __M_ARGV__ 24 | 25 | 26 | // 27 | // MISC 28 | // 29 | extern int myargc; 30 | extern char** myargv; 31 | 32 | // Returns the position of the given parameter 33 | // in the arg list (0 if not found). 34 | int M_CheckParm(char* check); 35 | 36 | 37 | #endif 38 | 39 | //----------------------------------------------------------------------------- 40 | // 41 | // $Log:$ 42 | // 43 | //----------------------------------------------------------------------------- 44 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_bbox.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Main loop menu stuff. 21 | // Random number LUT. 22 | // Default Config File. 23 | // PCX Screenshots. 24 | // 25 | //----------------------------------------------------------------------------- 26 | 27 | 28 | #include "doom_config.h" 29 | 30 | #include "m_bbox.h" 31 | 32 | 33 | void M_ClearBox(fixed_t* box) 34 | { 35 | box[BOXTOP] = box[BOXRIGHT] = DOOM_MININT; 36 | box[BOXBOTTOM] = box[BOXLEFT] = DOOM_MAXINT; 37 | } 38 | 39 | 40 | void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y) 41 | { 42 | if (x < box[BOXLEFT]) 43 | box[BOXLEFT] = x; 44 | else if (x > box[BOXRIGHT]) 45 | box[BOXRIGHT] = x; 46 | if (y < box[BOXBOTTOM]) 47 | box[BOXBOTTOM] = y; 48 | else if (y > box[BOXTOP]) 49 | box[BOXTOP] = y; 50 | } 51 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_bbox.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Nil. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_BBOX__ 23 | #define __M_BBOX__ 24 | 25 | 26 | #include "doomtype.h" 27 | #include "m_fixed.h" 28 | 29 | 30 | // Bounding box coordinate storage. 31 | enum 32 | { 33 | BOXTOP, 34 | BOXBOTTOM, 35 | BOXLEFT, 36 | BOXRIGHT 37 | }; // bbox coordinates 38 | 39 | 40 | // Bounding box functions. 41 | void M_ClearBox(fixed_t* box); 42 | void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y); 43 | 44 | 45 | #endif 46 | 47 | //----------------------------------------------------------------------------- 48 | // 49 | // $Log:$ 50 | // 51 | //----------------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_cheat.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Cheat sequence checking. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | 27 | #include "m_cheat.h" 28 | 29 | 30 | // 31 | // CHEAT SEQUENCE PACKAGE 32 | // 33 | 34 | static int firsttime = 1; 35 | static unsigned char cheat_xlate_table[256]; 36 | 37 | 38 | // 39 | // Called in st_stuff module, which handles the input. 40 | // Returns a 1 if the cheat was successful, 0 if failed. 41 | // 42 | int cht_CheckCheat(cheatseq_t* cht, char key) 43 | { 44 | int i; 45 | int rc = 0; 46 | 47 | if (firsttime) 48 | { 49 | firsttime = 0; 50 | for (i = 0; i < 256; i++) cheat_xlate_table[i] = SCRAMBLE(i); 51 | } 52 | 53 | if (!cht->p) 54 | cht->p = cht->sequence; // initialize if first time 55 | 56 | if (*cht->p == 0) 57 | *(cht->p++) = key; 58 | else if 59 | (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; 60 | else 61 | cht->p = cht->sequence; 62 | 63 | if (*cht->p == 1) 64 | cht->p++; 65 | else if (*cht->p == 0xff) // end of sequence character 66 | { 67 | cht->p = cht->sequence; 68 | rc = 1; 69 | } 70 | 71 | return rc; 72 | } 73 | 74 | 75 | void cht_GetParam(cheatseq_t* cht, char* buffer) 76 | { 77 | unsigned char* p, c; 78 | 79 | p = cht->sequence; 80 | while (*(p++) != 1); 81 | 82 | do 83 | { 84 | c = *p; 85 | *(buffer++) = c; 86 | *(p++) = 0; 87 | } while (c && *p != 0xff); 88 | 89 | if (*p == 0xff) 90 | *buffer = 0; 91 | } 92 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_cheat.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Cheat code checking. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_CHEAT__ 23 | #define __M_CHEAT__ 24 | 25 | 26 | // 27 | // CHEAT SEQUENCE PACKAGE 28 | // 29 | 30 | #define SCRAMBLE(a) \ 31 | ((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \ 32 | + (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) 33 | 34 | 35 | typedef struct 36 | { 37 | unsigned char* sequence; 38 | unsigned char* p; 39 | } cheatseq_t; 40 | 41 | 42 | int cht_CheckCheat(cheatseq_t* cht, char key); 43 | void cht_GetParam(cheatseq_t* cht, char* buffer); 44 | 45 | 46 | #endif 47 | 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_fixed.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Fixed point implementation. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #include "doom_config.h" 26 | 27 | //#include "stdlib.h" 28 | #include "doomtype.h" 29 | #include "i_system.h" 30 | #include "m_fixed.h" 31 | 32 | 33 | fixed_t FixedMul(fixed_t a, fixed_t b) 34 | { 35 | return ((long long)a * (long long)b) >> FRACBITS; 36 | } 37 | 38 | 39 | // 40 | // FixedDiv, C version. 41 | // 42 | fixed_t FixedDiv(fixed_t a, fixed_t b) 43 | { 44 | if ((doom_abs(a) >> 14) >= doom_abs(b)) 45 | return (a ^ b) < 0 ? DOOM_MININT : DOOM_MAXINT; 46 | return FixedDiv2(a, b); 47 | } 48 | 49 | 50 | fixed_t FixedDiv2(fixed_t a, fixed_t b) 51 | { 52 | double c; 53 | 54 | c = ((double)a) / ((double)b) * FRACUNIT; 55 | 56 | if (c >= 2147483648.0 || c < -2147483648.0) 57 | I_Error("Error: FixedDiv: divide by zero"); 58 | return (fixed_t)c; 59 | } 60 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_fixed.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Fixed point arithemtics, implementation. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_FIXED__ 23 | #define __M_FIXED__ 24 | 25 | 26 | // 27 | // Fixed point, 32bit as 16.16. 28 | // 29 | #define FRACBITS 16 30 | #define FRACUNIT (1<> 8) | (x << 8); 39 | } 40 | 41 | 42 | // Swapping 32bit. 43 | unsigned long SwapLONG(unsigned long x) 44 | { 45 | return 46 | (x >> 24) 47 | | ((x >> 8) & 0xff00) 48 | | ((x << 8) & 0xff0000) 49 | | (x << 24); 50 | } 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/doom/puredoom/m_swap.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Endianess handling, swapping 16bit and 32bit. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __M_SWAP__ 23 | #define __M_SWAP__ 24 | 25 | 26 | // Endianess handling. 27 | // WAD files are stored little endian. 28 | #ifdef __BIG_ENDIAN__ 29 | unsigned short SwapSHORT(unsigned short); 30 | unsigned long SwapLONG(unsigned long); 31 | #define SHORT(x) ((short)SwapSHORT((unsigned short) (x))) 32 | #define LONG(x) ((long)SwapLONG((unsigned long) (x))) 33 | #else 34 | #define SHORT(x) (x) 35 | #define LONG(x) (x) 36 | #endif 37 | 38 | 39 | #endif 40 | 41 | //----------------------------------------------------------------------------- 42 | // 43 | // $Log:$ 44 | // 45 | //----------------------------------------------------------------------------- 46 | -------------------------------------------------------------------------------- /src/doom/puredoom/p_inter.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_INTER__ 23 | #define __P_INTER__ 24 | 25 | 26 | #include "d_player.h" 27 | 28 | 29 | doom_boolean P_GivePower(player_t*, int); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /src/doom/puredoom/p_pspr.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Sprite animation. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | 23 | #ifndef __P_PSPR__ 24 | #define __P_PSPR__ 25 | 26 | // Basic data types. 27 | // Needs fixed point, and BAM angles. 28 | #include "m_fixed.h" 29 | #include "tables.h" 30 | 31 | // Needs to include the precompiled 32 | // sprite animation tables. 33 | // Header generated by multigen utility. 34 | // This includes all the data for thing animation, 35 | // i.e. the Thing Atrributes table 36 | // and the Frame Sequence table. 37 | #include "info.h" 38 | 39 | // 40 | // Frame flags: 41 | // handles maximum brightness (torches, muzzle flare, light sources) 42 | // 43 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 44 | #define FF_FRAMEMASK 0x7fff 45 | 46 | 47 | // 48 | // Overlay psprites are scaled shapes 49 | // drawn directly on the view screen, 50 | // coordinates are given for a 320*200 view screen. 51 | // 52 | typedef enum 53 | { 54 | ps_weapon, 55 | ps_flash, 56 | NUMPSPRITES 57 | } psprnum_t; 58 | 59 | 60 | typedef struct 61 | { 62 | state_t* state; // a 0 state means not active 63 | int tics; 64 | fixed_t sx; 65 | fixed_t sy; 66 | } pspdef_t; 67 | 68 | 69 | #endif 70 | 71 | //----------------------------------------------------------------------------- 72 | // 73 | // $Log:$ 74 | // 75 | //----------------------------------------------------------------------------- 76 | -------------------------------------------------------------------------------- /src/doom/puredoom/p_saveg.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Savegame I/O, archiving, persistence. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_SAVEG__ 23 | #define __P_SAVEG__ 24 | 25 | 26 | #include "doomtype.h" 27 | 28 | 29 | // Persistent storage/archiving. 30 | // These are the load / save game routines. 31 | void P_ArchivePlayers(void); 32 | void P_UnArchivePlayers(void); 33 | void P_ArchiveWorld(void); 34 | void P_UnArchiveWorld(void); 35 | void P_ArchiveThinkers(void); 36 | void P_UnArchiveThinkers(void); 37 | void P_ArchiveSpecials(void); 38 | void P_UnArchiveSpecials(void); 39 | 40 | extern byte* save_p; 41 | 42 | 43 | #endif 44 | 45 | //----------------------------------------------------------------------------- 46 | // 47 | // $Log:$ 48 | // 49 | //----------------------------------------------------------------------------- 50 | -------------------------------------------------------------------------------- /src/doom/puredoom/p_setup.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Setup a game, startup stuff. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_SETUP__ 23 | #define __P_SETUP__ 24 | 25 | 26 | // NOT called by W_Ticker. Fixme. 27 | void P_SetupLevel(int episode, int map, int playermask, skill_t skill); 28 | 29 | // Called by startup code. 30 | void P_Init(void); 31 | 32 | 33 | #endif 34 | 35 | //----------------------------------------------------------------------------- 36 | // 37 | // $Log:$ 38 | // 39 | //----------------------------------------------------------------------------- 40 | -------------------------------------------------------------------------------- /src/doom/puredoom/p_tick.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // ? 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __P_TICK__ 23 | #define __P_TICK__ 24 | 25 | 26 | // Called by C_Ticker, 27 | // can call G_PlayerExited. 28 | // Carries out all thinking of monsters and players. 29 | void P_Ticker(void); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /src/doom/puredoom/pocketmod.c: -------------------------------------------------------------------------------- 1 | #define POCKETMOD_IMPLEMENTATION 2 | #include "pocketmod.h" 3 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_bsp.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh module, BSP traversal and handling. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_BSP__ 23 | #define __R_BSP__ 24 | 25 | 26 | #include "r_defs.h" 27 | 28 | 29 | extern seg_t* curline; 30 | extern side_t* sidedef; 31 | extern line_t* linedef; 32 | extern sector_t* frontsector; 33 | extern sector_t* backsector; 34 | 35 | extern int rw_x; 36 | extern int rw_stopx; 37 | 38 | extern doom_boolean segtextured; 39 | 40 | // false if the back side is the same plane 41 | extern doom_boolean markfloor; 42 | extern doom_boolean markceiling; 43 | 44 | extern doom_boolean skymap; 45 | 46 | extern drawseg_t drawsegs[MAXDRAWSEGS]; 47 | extern drawseg_t* ds_p; 48 | 49 | extern lighttable_t** hscalelight; 50 | extern lighttable_t** vscalelight; 51 | extern lighttable_t** dscalelight; 52 | 53 | 54 | typedef void (*drawfunc_t) (int start, int stop); 55 | 56 | 57 | // BSP? 58 | void R_ClearClipSegs(void); 59 | void R_ClearDrawSegs(void); 60 | void R_RenderBSPNode(int bspnum); 61 | 62 | 63 | #endif 64 | 65 | //----------------------------------------------------------------------------- 66 | // 67 | // $Log:$ 68 | // 69 | //----------------------------------------------------------------------------- 70 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_data.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh module, data I/O, caching, retrieval of graphics 19 | // by name. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __R_DATA__ 24 | #define __R_DATA__ 25 | 26 | 27 | #include "r_defs.h" 28 | #include "r_state.h" 29 | 30 | 31 | // Retrieve column data for span blitting. 32 | byte* R_GetColumn(int tex, int col); 33 | 34 | // I/O, setting up the stuff. 35 | void R_InitData(void); 36 | void R_PrecacheLevel(void); 37 | 38 | // Retrieval. 39 | // Floor/ceiling opaque texture tiles, 40 | // lookup by name. For animation? 41 | int R_FlatNumForName(char* name); 42 | 43 | // Called by P_Ticker for switches and animations, 44 | // returns the texture number for the texture name. 45 | int R_TextureNumForName(char* name); 46 | int R_CheckTextureNumForName(char* name); 47 | 48 | #endif 49 | 50 | //----------------------------------------------------------------------------- 51 | // 52 | // $Log:$ 53 | // 54 | //----------------------------------------------------------------------------- 55 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_local.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh (R_*) module, global header. 19 | // All the rendering/drawing stuff is here. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __R_LOCAL__ 24 | #define __R_LOCAL__ 25 | 26 | // Binary Angles, sine/cosine/atan lookups. 27 | #include "tables.h" 28 | 29 | // Screen size related parameters. 30 | #include "doomdef.h" 31 | 32 | // Include the refresh/render data structs. 33 | #include "r_data.h" 34 | 35 | // 36 | // Separate header file for each module. 37 | // 38 | #include "r_main.h" 39 | #include "r_bsp.h" 40 | #include "r_segs.h" 41 | #include "r_plane.h" 42 | #include "r_data.h" 43 | #include "r_things.h" 44 | #include "r_draw.h" 45 | 46 | #endif // __R_LOCAL__ 47 | 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_plane.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh, visplane stuff (floor, ceilings). 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_PLANE__ 23 | #define __R_PLANE__ 24 | 25 | 26 | #include "r_data.h" 27 | 28 | 29 | // Visplane related. 30 | extern short* lastopening; 31 | 32 | typedef void (*planefunction_t) (int top, int bottom); 33 | 34 | extern planefunction_t floorfunc; 35 | extern planefunction_t ceilingfunc_t; 36 | 37 | extern short floorclip[SCREENWIDTH]; 38 | extern short ceilingclip[SCREENWIDTH]; 39 | 40 | extern fixed_t yslope[SCREENHEIGHT]; 41 | extern fixed_t distscale[SCREENWIDTH]; 42 | 43 | void R_InitPlanes(void); 44 | void R_ClearPlanes(void); 45 | void R_MapPlane(int y, int x1, int x2); 46 | void R_MakeSpans(int x, int t1, int b1, int t2, int b2); 47 | void R_DrawPlanes(void); 48 | visplane_t* R_FindPlane(fixed_t height, int picnum, int lightlevel); 49 | visplane_t* R_CheckPlane(visplane_t* pl, int start, int stop); 50 | 51 | 52 | #endif 53 | 54 | //----------------------------------------------------------------------------- 55 | // 56 | // $Log:$ 57 | // 58 | //----------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_segs.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Refresh module, drawing LineSegs from BSP. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_SEGS__ 23 | #define __R_SEGS__ 24 | 25 | 26 | #include "r_defs.h" 27 | 28 | 29 | void R_RenderMaskedSegRange(drawseg_t* ds, int x1, int x2); 30 | 31 | 32 | #endif 33 | 34 | //----------------------------------------------------------------------------- 35 | // 36 | // $Log:$ 37 | // 38 | //----------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_sky.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // Sky rendering. The DOOM sky is a texture map like any 21 | // wall, wrapping around. A 1024 columns equal 360 degrees. 22 | // The default sky map is 256 columns and repeats 4 times 23 | // on a 320 screen? 24 | // 25 | // 26 | //----------------------------------------------------------------------------- 27 | 28 | 29 | #include "doom_config.h" 30 | 31 | #include "m_fixed.h" // Needed for FRACUNIT. 32 | #include "r_data.h" // Needed for Flat retrieval. 33 | #include "r_sky.h" 34 | 35 | 36 | // 37 | // sky mapping 38 | // 39 | int skyflatnum; 40 | int skytexture; 41 | int skytexturemid; 42 | 43 | 44 | // 45 | // R_InitSkyMap 46 | // Called whenever the view size changes. 47 | // 48 | void R_InitSkyMap(void) 49 | { 50 | skytexturemid = 100 * FRACUNIT; 51 | } 52 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_sky.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Sky rendering. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_SKY__ 23 | #define __R_SKY__ 24 | 25 | // SKY, store the number for name. 26 | #define SKYFLATNAME "F_SKY1" 27 | 28 | // The sky map is 256*128*4 maps. 29 | #define ANGLETOSKYSHIFT 22 30 | 31 | extern int skytexture; 32 | extern int skytexturemid; 33 | 34 | // Called whenever the view size changes. 35 | void R_InitSkyMap(void); 36 | 37 | #endif 38 | 39 | //----------------------------------------------------------------------------- 40 | // 41 | // $Log:$ 42 | // 43 | //----------------------------------------------------------------------------- 44 | -------------------------------------------------------------------------------- /src/doom/puredoom/r_things.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Rendering of moving objects, sprites. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __R_THINGS__ 23 | #define __R_THINGS__ 24 | 25 | 26 | #include "r_defs.h" 27 | 28 | 29 | #define MAXVISSPRITES 128 30 | 31 | 32 | extern vissprite_t vissprites[MAXVISSPRITES]; 33 | extern vissprite_t* vissprite_p; 34 | extern vissprite_t vsprsortedhead; 35 | 36 | // Constant arrays used for psprite clipping 37 | // and initializing clipping. 38 | extern short negonearray[SCREENWIDTH]; 39 | extern short screenheightarray[SCREENWIDTH]; 40 | 41 | // vars for R_DrawMaskedColumn 42 | extern short* mfloorclip; 43 | extern short* mceilingclip; 44 | extern fixed_t spryscale; 45 | extern fixed_t sprtopscreen; 46 | 47 | extern fixed_t pspritescale; 48 | extern fixed_t pspriteiscale; 49 | 50 | 51 | void R_DrawMaskedColumn(column_t* column); 52 | void R_SortVisSprites(void); 53 | void R_AddSprites(sector_t* sec); 54 | void R_InitSprites(char** namelist); 55 | void R_ClearSprites(void); 56 | void R_DrawMasked(void); 57 | 58 | 59 | #endif 60 | 61 | //----------------------------------------------------------------------------- 62 | // 63 | // $Log:$ 64 | // 65 | //----------------------------------------------------------------------------- 66 | -------------------------------------------------------------------------------- /src/doom/puredoom/s_sound.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // The not so system specific sound interface. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __S_SOUND__ 23 | #define __S_SOUND__ 24 | 25 | 26 | // 27 | // Initializes sound stuff, including volume 28 | // Sets channels, SFX and music volume, 29 | // allocates channel buffer, sets S_sfx lookup. 30 | // 31 | void S_Init(int sfxVolume, int musicVolume); 32 | 33 | // 34 | // Per level startup code. 35 | // Kills playing sounds at start of level, 36 | // determines music if any, changes music. 37 | // 38 | void S_Start(void); 39 | 40 | // 41 | // Start sound for thing at 42 | // using from sounds.h 43 | // 44 | void S_StartSound(void* origin, int sound_id); 45 | 46 | // Will start a sound at a given volume. 47 | void S_StartSoundAtVolume(void* origin, int sound_id, int volume); 48 | 49 | // Stop sound for thing at 50 | void S_StopSound(void* origin); 51 | 52 | // Start music using from sounds.h 53 | void S_StartMusic(int music_id); 54 | 55 | // Start music using from sounds.h, 56 | // and set whether looping 57 | void S_ChangeMusic(int music_id, int looping); 58 | 59 | // Stops the music fer sure. 60 | void S_StopMusic(void); 61 | 62 | // Stop and resume music, during game PAUSE. 63 | void S_PauseSound(void); 64 | void S_ResumeSound(void); 65 | 66 | // 67 | // Updates music & sounds 68 | // 69 | void S_UpdateSounds(void* listener); 70 | 71 | void S_SetMusicVolume(int volume); 72 | void S_SetSfxVolume(int volume); 73 | 74 | 75 | #endif 76 | 77 | //----------------------------------------------------------------------------- 78 | // 79 | // $Log:$ 80 | // 81 | //----------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /src/doom/puredoom/st_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Status bar code. 19 | // Does the face/direction indicator animatin. 20 | // Does palette indicators as well (red pain/berserk, bright pickup) 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __STSTUFF_H__ 25 | #define __STSTUFF_H__ 26 | 27 | #include "doomtype.h" 28 | #include "d_event.h" 29 | 30 | // Size of statusbar. 31 | // Now sensitive for scaling. 32 | #define ST_HEIGHT (32 * SCREEN_MUL) 33 | #define ST_WIDTH SCREENWIDTH 34 | #define ST_Y (SCREENHEIGHT - ST_HEIGHT) 35 | 36 | 37 | // 38 | // STATUS BAR 39 | // 40 | 41 | // Called by main loop. 42 | doom_boolean ST_Responder(event_t* ev); 43 | 44 | // Called by main loop. 45 | void ST_Ticker(void); 46 | 47 | // Called by main loop. 48 | void ST_Drawer(doom_boolean fullscreen, doom_boolean refresh); 49 | 50 | // Called when the console player is spawned on each level. 51 | void ST_Start(void); 52 | 53 | // Called by startup code. 54 | void ST_Init(void); 55 | 56 | 57 | // States for status bar code. 58 | typedef enum 59 | { 60 | AutomapState, 61 | FirstPersonState 62 | } st_stateenum_t; 63 | 64 | 65 | // States for the chat code. 66 | typedef enum 67 | { 68 | StartChatState, 69 | WaitDestState, 70 | GetChatState 71 | } st_chatstateenum_t; 72 | 73 | 74 | doom_boolean ST_Responder(event_t* ev); 75 | 76 | #endif 77 | 78 | //----------------------------------------------------------------------------- 79 | // 80 | // $Log:$ 81 | // 82 | //----------------------------------------------------------------------------- 83 | -------------------------------------------------------------------------------- /src/doom/puredoom/w_wad.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // WAD I/O functions. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __W_WAD__ 23 | #define __W_WAD__ 24 | 25 | 26 | // 27 | // TYPES 28 | // 29 | typedef struct 30 | { 31 | // Should be "IWAD" or "PWAD". 32 | char identification[4]; 33 | int numlumps; 34 | int infotableofs; 35 | } wadinfo_t; 36 | 37 | 38 | typedef struct 39 | { 40 | int filepos; 41 | int size; 42 | char name[8]; 43 | } filelump_t; 44 | 45 | 46 | // 47 | // WADFILE I/O related stuff. 48 | // 49 | typedef struct 50 | { 51 | char name[8]; 52 | void* handle; 53 | int position; 54 | int size; 55 | } lumpinfo_t; 56 | 57 | 58 | extern void** lumpcache; 59 | extern lumpinfo_t* lumpinfo; 60 | extern int numlumps; 61 | 62 | void W_InitMultipleFiles(char** filenames); 63 | void W_Reload(void); 64 | 65 | int W_CheckNumForName(char* name); 66 | int W_GetNumForName(char* name); 67 | 68 | int W_LumpLength(int lump); 69 | void W_ReadLump(int lump, void* dest); 70 | 71 | void* W_CacheLumpNum(int lump, int tag); 72 | void* W_CacheLumpName(char* name, int tag); 73 | 74 | 75 | #endif 76 | 77 | //----------------------------------------------------------------------------- 78 | // 79 | // $Log:$ 80 | // 81 | //----------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /src/doom/puredoom/wi_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Intermission. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __WI_STUFF__ 23 | #define __WI_STUFF__ 24 | 25 | #include "doomdef.h" 26 | 27 | // States for the intermission 28 | typedef enum 29 | { 30 | NoState = -1, 31 | StatCount, 32 | ShowNextLoc 33 | } stateenum_t; 34 | 35 | // Called by main loop, animate the intermission. 36 | void WI_Ticker(void); 37 | 38 | // Called by main loop, 39 | // draws the intermission directly into the screen buffer. 40 | void WI_Drawer(void); 41 | 42 | // Setup for an intermission screen. 43 | void WI_Start(wbstartstruct_t* wbstartstruct); 44 | 45 | #endif 46 | 47 | //----------------------------------------------------------------------------- 48 | // 49 | // $Log:$ 50 | // 51 | //----------------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | zig-wasm-audio-framebuffer demos 6 | 7 | 8 | 9 |

zig-wasm-audio-framebuffer

10 | 22 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/mandelbrot/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | //fn console_write(data:[*]const u8, len:usize) void { 6 | // std.log.info("{s}", .{data[0..len]}); 7 | //} 8 | 9 | // Implement a std.io.Writer backed by console_write() 10 | const ConsoleWriter = struct { 11 | const Writer = std.io.Writer( 12 | *ConsoleWriter, 13 | error{}, 14 | write, 15 | ); 16 | 17 | fn write( 18 | self: *ConsoleWriter, 19 | data: []const u8, 20 | ) error{}!usize { 21 | _ = self; 22 | console_write(data.ptr, data.len); 23 | return data.len; 24 | } 25 | 26 | pub fn writer(self: *ConsoleWriter) Writer { 27 | return .{ .context = self }; 28 | } 29 | }; 30 | 31 | pub fn getWriter() *ConsoleWriter { 32 | return &cw; 33 | } 34 | -------------------------------------------------------------------------------- /src/mandelbrot/mandelbrot.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mandelbrot 6 | 15 | 16 | 17 | 18 | 19 | 37 | 38 | 39 |

40 | 41 |

43 |

44 | Escape function from mandelbrot-gl 45 |

46 |

47 | Click and drag the mouse to select an area to zoom. 48 |

49 | 50 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/mod/bananasplit.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/mod/bananasplit.mod -------------------------------------------------------------------------------- /src/mod/mod.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mod 6 | 7 | 8 | 9 | 10 | 25 | 26 | 27 |

28 | 29 |

30 |

31 | pocketmod, is a small ANSI C library for turning ProTracker MOD files into playable PCM audio
32 | bananasplit.mod is 297KB and is distributed under the Mod Archive Distribution License 33 |

34 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/mod/mod.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const pocketmod = @cImport({ 3 | @cInclude("pocketmod.h"); 4 | }); 5 | 6 | // WebAudio's render quantum size. 7 | const RENDER_QUANTUM_FRAMES = 128; 8 | 9 | var left: [RENDER_QUANTUM_FRAMES]f32 = undefined; 10 | var right: [RENDER_QUANTUM_FRAMES]f32 = undefined; 11 | var leftright: [RENDER_QUANTUM_FRAMES * 2]f32 = undefined; 12 | var sampleRate: f32 = 44100; 13 | var frameCounter: usize = 0; 14 | 15 | var ctx: pocketmod.pocketmod_context = undefined; 16 | const mod_data = @embedFile("bananasplit.mod"); 17 | 18 | export fn setSampleRate(s: f32) void { 19 | sampleRate = s; 20 | 21 | _ = pocketmod.pocketmod_init(&ctx, mod_data, mod_data.len, @as(c_int, @intFromFloat(sampleRate))); 22 | } 23 | 24 | export fn getLeftBufPtr() [*]u8 { 25 | return @ptrCast(&left); 26 | } 27 | 28 | export fn getRightBufPtr() [*]u8 { 29 | return @ptrCast(&right); 30 | } 31 | 32 | export fn renderSoundQuantum() void { 33 | var bytes: usize = RENDER_QUANTUM_FRAMES * 4 * 2; 34 | 35 | // pocketmod produces interleaved l/r/l/r data, so fetch a double batch 36 | const lrbuf: [*]u8 = @ptrCast(&leftright); 37 | bytes = RENDER_QUANTUM_FRAMES * 4 * 2; 38 | var i: usize = 0; 39 | while (i < bytes) { 40 | const count = pocketmod.pocketmod_render(&ctx, lrbuf + i, @as(c_int, @intCast(bytes - i))); 41 | i += @as(usize, @intCast(count)); 42 | } 43 | 44 | // then deinterleave it into the l and r buffers 45 | i = 0; 46 | while (i < RENDER_QUANTUM_FRAMES) : (i += 1) { 47 | left[i] = leftright[i * 2]; 48 | right[i] = leftright[i * 2 + 1]; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/mod/pocketmod.c: -------------------------------------------------------------------------------- 1 | #define POCKETMOD_IMPLEMENTATION 2 | #include "pocketmod.h" 3 | -------------------------------------------------------------------------------- /src/olive/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | //fn console_write(data:[*]const u8, len:usize) void { 6 | // std.log.info("{s}", .{data[0..len]}); 7 | //} 8 | 9 | // Implement a std.io.Writer backed by console_write() 10 | const ConsoleWriter = struct { 11 | const Writer = std.io.Writer( 12 | *ConsoleWriter, 13 | error{}, 14 | write, 15 | ); 16 | 17 | fn write( 18 | self: *ConsoleWriter, 19 | data: []const u8, 20 | ) error{}!usize { 21 | _ = self; 22 | console_write(data.ptr, data.len); 23 | return data.len; 24 | } 25 | 26 | pub fn writer(self: *ConsoleWriter) Writer { 27 | return .{ .context = self }; 28 | } 29 | }; 30 | 31 | pub fn getWriter() *ConsoleWriter { 32 | return &cw; 33 | } 34 | -------------------------------------------------------------------------------- /src/olive/olive.c/.gitignore: -------------------------------------------------------------------------------- 1 | *.ppm 2 | build/ 3 | *.swp 4 | nobuild 5 | nobuild.old -------------------------------------------------------------------------------- /src/olive/olive.c/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Alexey Kutepov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/olive/olive.c/assets/CREDITS.txt: -------------------------------------------------------------------------------- 1 | - https://opengameart.org/content/handpainted-stone-texture 2 | - lavastone-origin.png 3 | - lavastone.png 4 | - oldstone-origin.png 5 | - oldstone.png 6 | -------------------------------------------------------------------------------- /src/olive/olive.c/assets/Lena_112.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/Lena_112.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/lavastone-origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/lavastone-origin.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/lavastone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/lavastone.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/oldstone-origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/oldstone-origin.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/oldstone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/oldstone.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/olivec-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/olivec-200.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/tsodinCup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/tsodinCup.png -------------------------------------------------------------------------------- /src/olive/olive.c/assets/tsodinPog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/assets/tsodinPog.png -------------------------------------------------------------------------------- /src/olive/olive.c/css/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'LibreBaskerville'; 3 | src: url('../fonts/LibreBaskerville-Regular.ttf') format('truetype'); 4 | } 5 | body { 6 | background: #181818; 7 | color: #F0F0F0; 8 | font-family: LibreBaskerville; 9 | margin: auto; 10 | max-width: 960px; 11 | font-size: 16px; 12 | } 13 | p { 14 | padding-bottom: 20px; 15 | line-height: 1.5; 16 | } 17 | h1 { 18 | font-size: 40px; 19 | text-align: center; 20 | padding-top: 40px; 21 | padding-bottom: 40px; 22 | } 23 | h2 { 24 | font-size: 28px; 25 | text-align: left; 26 | padding-top: 20px; 27 | padding-bottom: 40px; 28 | } 29 | h2 a { 30 | color: #F0F0F0; 31 | } 32 | kbd { 33 | display: inline-block; 34 | font-family: monospace; 35 | padding: 3px 5px; 36 | background: #303030; 37 | line-height: 10px; 38 | vertical-align: middle; 39 | text-align: center; 40 | border-radius: 5px; 41 | } 42 | code { 43 | display: inline-block; 44 | font-family: monospace; 45 | } 46 | ul { 47 | padding-bottom: 20px; 48 | list-style: inside square; 49 | } 50 | ul li { 51 | padding-bottom: 10px; 52 | } 53 | .plot { 54 | width: 100%; 55 | padding-bottom: 20px; 56 | } 57 | a { 58 | color: #9090EE; 59 | text-decoration: none; 60 | } 61 | .author { 62 | text-align: center; 63 | padding-bottom: 40px; 64 | font-style: italic; 65 | } 66 | .author a { 67 | color: #F0F0F0; 68 | } 69 | -------------------------------------------------------------------------------- /src/olive/olive.c/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ 2 | v2.0 | 20110126 3 | License: none (public domain) 4 | */ 5 | 6 | html, body, div, span, applet, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | a, abbr, acronym, address, big, cite, code, 9 | del, dfn, em, img, ins, kbd, q, s, samp, 10 | small, strike, strong, sub, sup, tt, var, 11 | b, u, i, center, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, embed, 16 | figure, figcaption, footer, header, hgroup, 17 | menu, nav, output, ruby, section, summary, 18 | time, mark, audio, video { 19 | margin: 0; 20 | padding: 0; 21 | border: 0; 22 | font-size: 100%; 23 | font: inherit; 24 | vertical-align: baseline; 25 | } 26 | /* HTML5 display-role reset for older browsers */ 27 | article, aside, details, figcaption, figure, 28 | footer, header, hgroup, menu, nav, section { 29 | display: block; 30 | } 31 | body { 32 | line-height: 1; 33 | } 34 | ol, ul { 35 | list-style: none; 36 | } 37 | blockquote, q { 38 | quotes: none; 39 | } 40 | blockquote:before, blockquote:after, 41 | q:before, q:after { 42 | content: ''; 43 | content: none; 44 | } 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } 49 | -------------------------------------------------------------------------------- /src/olive/olive.c/demos/cup3d.c: -------------------------------------------------------------------------------- 1 | #include "assets/tsodinCupLowPoly.c" 2 | #include "model3d.c" 3 | -------------------------------------------------------------------------------- /src/olive/olive.c/demos/dots3d.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | 3 | float sqrtf(float x); 4 | float atan2f(float y, float x); 5 | float sinf(float x); 6 | float cosf(float x); 7 | 8 | #define PI 3.14159265359 9 | 10 | #define WIDTH 960 11 | #define HEIGHT 720 12 | #define BACKGROUND_COLOR 0xFF181818 13 | #define GRID_COUNT 10 14 | #define GRID_PAD 0.5/GRID_COUNT 15 | #define GRID_SIZE ((GRID_COUNT - 1)*GRID_PAD) 16 | #define CIRCLE_RADIUS 5 17 | #define Z_START 0.25 18 | #define ABOBA_PADDING 50 19 | 20 | static uint32_t pixels[WIDTH*HEIGHT]; 21 | static float angle = 0; 22 | 23 | Olivec_Canvas vc_render(float dt) 24 | { 25 | angle += 0.25*PI*dt; 26 | 27 | Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH); 28 | 29 | olivec_fill(oc, BACKGROUND_COLOR); 30 | for (int ix = 0; ix < GRID_COUNT; ++ix) { 31 | for (int iy = 0; iy < GRID_COUNT; ++iy) { 32 | for (int iz = 0; iz < GRID_COUNT; ++iz) { 33 | float x = ix*GRID_PAD - GRID_SIZE/2; 34 | float y = iy*GRID_PAD - GRID_SIZE/2; 35 | float z = Z_START + iz*GRID_PAD; 36 | 37 | float cx = 0.0; 38 | float cz = Z_START + GRID_SIZE/2; 39 | 40 | float dx = x - cx; 41 | float dz = z - cz; 42 | 43 | float a = atan2f(dz, dx); 44 | float m = sqrtf(dx*dx + dz*dz); 45 | 46 | dx = cosf(a + angle)*m; 47 | dz = sinf(a + angle)*m; 48 | 49 | x = dx + cx; 50 | z = dz + cz; 51 | 52 | x /= z; 53 | y /= z; 54 | 55 | uint32_t r = ix*255/GRID_COUNT; 56 | uint32_t g = iy*255/GRID_COUNT; 57 | uint32_t b = iz*255/GRID_COUNT; 58 | uint32_t color = 0xFF000000 | (r<<(0*8)) | (g<<(1*8)) | (b<<(2*8)); 59 | olivec_circle(oc, (x + 1)/2*WIDTH, (y + 1)/2*HEIGHT, CIRCLE_RADIUS, color); 60 | } 61 | } 62 | } 63 | 64 | size_t size = 8; 65 | olivec_text(oc, "aboba", ABOBA_PADDING, HEIGHT - ABOBA_PADDING - olivec_default_font.height*size, olivec_default_font, size, 0xFFFFFFFF); 66 | 67 | return oc; 68 | } 69 | -------------------------------------------------------------------------------- /src/olive/olive.c/demos/squish.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | #include "./assets/Lena_112.c" 3 | 4 | #define WIDTH 960 5 | #define HEIGHT 720 6 | 7 | float sinf(float); 8 | 9 | static uint32_t dst[WIDTH*HEIGHT]; 10 | static float global_time = 0; 11 | 12 | #define SRC_SCALE 3 13 | 14 | Olivec_Canvas vc_render(float dt) 15 | { 16 | global_time += dt; 17 | 18 | float t = sinf(10*global_time); 19 | 20 | Olivec_Canvas dst_canvas = olivec_canvas(dst, WIDTH, HEIGHT, WIDTH); 21 | 22 | olivec_fill(dst_canvas, 0xFF181818); 23 | 24 | int factor = 100; 25 | int w = Lena_112_width*SRC_SCALE - t*factor; 26 | int h = Lena_112_height*SRC_SCALE + t*factor; 27 | 28 | olivec_sprite_copy_bilinear( 29 | dst_canvas, 30 | WIDTH/2 - w/2, HEIGHT - h, w, h, 31 | olivec_canvas(Lena_112_pixels, Lena_112_width, Lena_112_height, Lena_112_width)); 32 | 33 | return dst_canvas; 34 | } 35 | -------------------------------------------------------------------------------- /src/olive/olive.c/demos/teapot3d.c: -------------------------------------------------------------------------------- 1 | #include "assets/utahTeapot.c" 2 | #define VC_TERM_SCALE_DOWN_FACTOR 10 3 | #include "model3d.c" 4 | -------------------------------------------------------------------------------- /src/olive/olive.c/demos/triangle.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | 3 | #define WIDTH 960 4 | #define HEIGHT 720 5 | // #define WIDTH 1920 6 | // #define HEIGHT 1080 7 | #define BACKGROUND_COLOR 0xFF181818 8 | #define CIRCLE_RADIUS 100 9 | #define CIRCLE_COLOR 0x99AA2020 10 | 11 | static uint32_t pixels[WIDTH*HEIGHT]; 12 | static float triangle_angle = 0; 13 | static float circle_x = WIDTH/2; 14 | static float circle_y = HEIGHT/2; 15 | static float circle_dx = 100; 16 | static float circle_dy = 100; 17 | 18 | float sqrtf(float x); 19 | float atan2f(float y, float x); 20 | float sinf(float x); 21 | float cosf(float x); 22 | 23 | #define PI 3.14159265359 24 | 25 | static inline void rotate_point(float *x, float *y) 26 | { 27 | float dx = *x - WIDTH/2; 28 | float dy = *y - HEIGHT/2; 29 | float mag = sqrtf(dx*dx + dy*dy); 30 | float dir = atan2f(dy, dx) + triangle_angle; 31 | *x = cosf(dir)*mag + WIDTH/2; 32 | *y = sinf(dir)*mag + HEIGHT/2; 33 | } 34 | 35 | Olivec_Canvas vc_render(float dt) 36 | { 37 | Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH); 38 | 39 | olivec_fill(oc, BACKGROUND_COLOR); 40 | 41 | // Triangle 42 | { 43 | triangle_angle += 0.5f*PI*dt; 44 | 45 | float x1 = WIDTH/2, y1 = HEIGHT/8; 46 | float x2 = WIDTH/8, y2 = HEIGHT/2; 47 | float x3 = WIDTH*7/8, y3 = HEIGHT*7/8; 48 | rotate_point(&x1, &y1); 49 | rotate_point(&x2, &y2); 50 | rotate_point(&x3, &y3); 51 | olivec_triangle3c(oc, x1, y1, x2, y2, x3, y3, 0xFF2020FF, 0xFF20FF20, 0xFFFF2020); 52 | } 53 | 54 | // Circle 55 | { 56 | float x = circle_x + circle_dx*dt; 57 | if (x - CIRCLE_RADIUS < 0 || x + CIRCLE_RADIUS >= WIDTH) { 58 | circle_dx *= -1; 59 | } else { 60 | circle_x = x; 61 | } 62 | 63 | float y = circle_y + circle_dy*dt; 64 | if (y - CIRCLE_RADIUS < 0 || y + CIRCLE_RADIUS >= HEIGHT) { 65 | circle_dy *= -1; 66 | } else { 67 | circle_y = y; 68 | } 69 | 70 | olivec_circle(oc, circle_x, circle_y, CIRCLE_RADIUS, CIRCLE_COLOR); 71 | } 72 | 73 | return oc; 74 | } 75 | -------------------------------------------------------------------------------- /src/olive/olive.c/demos/triangleTex.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | #include "assets/Lena_112.c" 3 | 4 | #define WIDTH 960 5 | #define HEIGHT 720 6 | #define BACKGROUND_COLOR 0xFF181818 7 | 8 | static uint32_t pixels[WIDTH*HEIGHT]; 9 | static float triangle_angle = 0; 10 | 11 | float sqrtf(float x); 12 | float atan2f(float y, float x); 13 | float sinf(float x); 14 | float cosf(float x); 15 | 16 | #define PI 3.14159265359 17 | 18 | Olivec_Canvas vc_render(float dt) 19 | { 20 | Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH); 21 | Olivec_Canvas Lena_112 = olivec_canvas(Lena_112_pixels, Lena_112_width, Lena_112_height, Lena_112_width); 22 | 23 | olivec_fill(oc, BACKGROUND_COLOR); 24 | 25 | // Triangle 26 | { 27 | triangle_angle += 0.5f*PI*dt; 28 | 29 | float ps[4][2]; 30 | float uvs[4][2] = { 31 | {0, 0}, 32 | {1, 0}, 33 | {1, 1}, 34 | {0, 1}, 35 | }; 36 | float len = WIDTH/4; 37 | for (size_t i = 0; i < 4; ++i) { 38 | ps[i][0] = WIDTH/2 + cosf(PI/2*i + triangle_angle)*len; 39 | ps[i][1] = HEIGHT/2 + sinf(PI/2*i + triangle_angle)*len; 40 | } 41 | for (size_t i = 0; i < 2; ++i) { 42 | int i1 = (i*2 + 0)%4; 43 | int i2 = (i*2 + 1)%4; 44 | int i3 = (i*2 + 2)%4; 45 | olivec_triangle3uv_bilinear( 46 | oc, 47 | ps[i1][0], ps[i1][1], 48 | ps[i2][0], ps[i2][1], 49 | ps[i3][0], ps[i3][1], 50 | uvs[i1][0], uvs[i1][1], 51 | uvs[i2][0], uvs[i2][1], 52 | uvs[i3][0], uvs[i3][1], 53 | 1, 1, 1, 54 | Lena_112 55 | ); 56 | } 57 | } 58 | 59 | return oc; 60 | } 61 | -------------------------------------------------------------------------------- /src/olive/olive.c/docs/.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.log 3 | -------------------------------------------------------------------------------- /src/olive/olive.c/docs/3d-projection.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/docs/3d-projection.pdf -------------------------------------------------------------------------------- /src/olive/olive.c/docs/3d-projection.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{tikz} 3 | \usepackage{amsmath} 4 | \begin{document} 5 | \section{3D Projection} 6 | \def\minY{-2} \def\maxY{2} 7 | \def\minZ{-2} \def\maxZ{6} 8 | \def\screenZ{2} 9 | \def\eyeZ{0} \def\eyeY{0} 10 | \def\pZ{3} \def\pY{1} 11 | \begin{tikzpicture} 12 | \draw[-stealth] (\minZ,0) -- (\maxZ,0) node[above]{$z$}; 13 | \draw[-stealth] (0,\minY) -- (0,\maxY) node[above]{$x$}; 14 | \draw[fill] (\eyeZ, \eyeY) circle (.5ex) node[above]{eye $E$}; 15 | \draw[dotted,thick] (\screenZ, \minY) -- (\screenZ, \maxY) node[above]{screen}; 16 | \draw[dotted] (\eyeZ, \eyeY) -- (\pZ, \pY); 17 | \draw[dotted] (\eyeZ, \eyeY) -- (\pZ, -\pY); 18 | \draw[fill] (\pZ, \pY) circle (.5ex) node[above]{$p_1$}; 19 | \draw[fill] (\pZ, -\pY) circle (.5ex) node[above]{$p_2$}; 20 | \draw[fill] (\screenZ, {(\pY - \eyeY)/(\pZ - \eyeZ)*(\screenZ - \eyeZ) + \eyeY}) circle (.5ex) node[above]{$p_1'$}; 21 | \draw[fill] (\screenZ, {-(\pY - \eyeY)/(\pZ - \eyeZ)*(\screenZ - \eyeZ) + \eyeY}) circle (.5ex) node[above]{$p_2'$}; 22 | \end{tikzpicture} 23 | 24 | When we refer to $p$ we mean either $p_1$ or $p_2$. When we refer to $p'$ we mean either $p'_1$ or $p'_2$. 25 | 26 | \begin{align} 27 | & p = (p_x, p_y, p_z) \\ 28 | & p'= (p'_x, p'_y, S_z) \\ 29 | & E = (E_x, E_y, E_z) \\ 30 | \end{align} 31 | 32 | The formula to find $p'$ 33 | 34 | \begin{align} 35 | & p_y' = \frac{(p_y - E_y)(S_z - E_z)}{(p_z - E_z)} + E_y \\ 36 | & p_x' = \frac{(p_x - E_x)(S_z - E_z)}{(p_z - E_z)} + E_x \\ 37 | \end{align} 38 | 39 | If we assume that $E = (0, 0, 0)$ and $S_z = 1$ 40 | 41 | \begin{align} 42 | & p_y' = \frac{p_y}{p_z} \\ 43 | & p_x' = \frac{p_x}{p_z} \\ 44 | \end{align} 45 | 46 | \end{document} -------------------------------------------------------------------------------- /src/olive/olive.c/docs/barycentric.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/docs/barycentric.pdf -------------------------------------------------------------------------------- /src/olive/olive.c/fonts/LibreBaskerville-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/fonts/LibreBaskerville-Regular.ttf -------------------------------------------------------------------------------- /src/olive/olive.c/olive.c: -------------------------------------------------------------------------------- 1 | #define OLIVEC_IMPLEMENTATION 1 2 | #define OLIVECDEF 3 | #include "olive.h" 4 | -------------------------------------------------------------------------------- /src/olive/olive.c/test/.gitignore: -------------------------------------------------------------------------------- 1 | *_actual.png 2 | *_diff.png 3 | -------------------------------------------------------------------------------- /src/olive/olive.c/test/alpha_blending_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/alpha_blending_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/barycentric_overflow_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/barycentric_overflow_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/bilinear_interpolation_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/bilinear_interpolation_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/checker_example_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/checker_example_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/circle_example_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/circle_example_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/draw_line_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/draw_line_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/empty_rect_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/empty_rect_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/fill_circle_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/fill_circle_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/fill_ellipse_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/fill_ellipse_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/fill_rect_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/fill_rect_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/fill_triangle_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/fill_triangle_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/frame_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/frame_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/hello_world_text_rendering_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/hello_world_text_rendering_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/line_edge_cases_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/line_edge_cases_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/lines_circle_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/lines_circle_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/lines_example_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/lines_example_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_empty_rect_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_empty_rect_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_flip_cut_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_flip_cut_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_flip_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_flip_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_null_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_null_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_out_of_bounds_cut_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_out_of_bounds_cut_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/sprite_blend_vs_copy_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/sprite_blend_vs_copy_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/triangle_order_flip_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/triangle_order_flip_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/test/weird_triangle_bug_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/test/weird_triangle_bug_expected.png -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/cup3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/cup3d.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/dots3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/dots3d.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/squish.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/squish.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/teapot3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/teapot3d.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/triangle.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/triangle.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/triangle3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/triangle3d.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/triangle3dTex.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/triangle3dTex.wasm -------------------------------------------------------------------------------- /src/olive/olive.c/wasm/triangleTex.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/olive.c/wasm/triangleTex.wasm -------------------------------------------------------------------------------- /src/olive/olive.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tinygl 6 | 15 | 16 | 17 | 18 | 19 | 37 | 38 | 39 |

40 | 41 |

43 |

44 | olive.c simple immediate mode graphics library. 1000 alpha blended 64x64 sprites. FPS count in top left 45 |

46 | 47 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/olive/renderer.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const olive = @cImport({ 3 | @cInclude("olive.c/olive.h"); 4 | }); 5 | 6 | pub const Surface = struct { 7 | const Self = @This(); 8 | oc: olive.Olivec_Canvas, 9 | width: usize, 10 | height: usize, 11 | 12 | pub fn init(fb: [*]u32, width: usize, height: usize) Self { 13 | return Self{ 14 | .width = width, 15 | .height = height, 16 | .oc = olive.olivec_canvas(fb, width, height, width), 17 | }; 18 | } 19 | }; 20 | 21 | pub const Renderer = struct { 22 | const Self = @This(); 23 | surface: *Surface, 24 | 25 | pub fn init(surface: *Surface) Self { 26 | return Self{ 27 | .surface = surface, 28 | }; 29 | } 30 | 31 | pub fn fill(self: *Self, colour: u32) void { 32 | olive.olivec_fill(self.surface.oc, colour); 33 | } 34 | 35 | pub fn circle(self: *Self, x: i32, y: i32, r: i32, colour: u32) void { 36 | olive.olivec_circle(self.surface.oc, x, y, r, colour); 37 | } 38 | 39 | pub fn sprite_blend(self: *Self, spriteSurface: *Surface, x: i32, y: i32, w: i32, h: i32) void { 40 | olive.olivec_sprite_blend(self.surface.oc, x, y, w, h, spriteSurface.oc); 41 | } 42 | 43 | /// Note, font is incomplete, some glyphs do not appear 44 | pub fn text(self: *Self, x: i32, y: i32, str: []const u8) void { 45 | var buf: [256:0]u8 = undefined; 46 | _ = std.fmt.bufPrintZ(&buf, "{s}", .{str}) catch return; 47 | olive.olivec_text(self.surface.oc, &buf, x, y, olive.olivec_default_font, 2, 0xFFFFFFFF); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /src/olive/zero64.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/olive/zero64.raw -------------------------------------------------------------------------------- /src/olive/zlm.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub const SpecializeOn = @import("zlm-generic.zig").SpecializeOn; 4 | 5 | /// Converts degrees to radian 6 | pub fn toRadians(deg: anytype) @TypeOf(deg) { 7 | return std.math.pi * deg / 180.0; 8 | } 9 | 10 | /// Converts radian to degree 11 | pub fn toDegrees(rad: anytype) @TypeOf(rad) { 12 | return 180.0 * rad / std.math.pi; 13 | } 14 | 15 | // export all vectors by-default to f32 16 | pub usingnamespace SpecializeOn(f32); 17 | -------------------------------------------------------------------------------- /src/sinetone/sinetone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | sinetone 6 | 7 | 8 | 9 | 10 | 46 | 47 | 48 |

49 | 50 |

51 |

52 | Generates independent stereo sine waves 53 |

54 |

55 | Left frequency
56 | 220Hz
57 | Right frequency
58 | 220Hz
59 |

60 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/sinetone/sinetone.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | // WebAudio's render quantum size. 4 | const RENDER_QUANTUM_FRAMES = 128; 5 | 6 | var left: [RENDER_QUANTUM_FRAMES]f32 = undefined; 7 | var right: [RENDER_QUANTUM_FRAMES]f32 = undefined; 8 | var sampleRate: f32 = 44100; 9 | var l_freqHz: f32 = 220; 10 | var r_freqHz: f32 = 220; 11 | 12 | var frameCounter: usize = 0; 13 | 14 | export fn setSampleRate(s: f32) void { 15 | sampleRate = s; 16 | } 17 | 18 | export fn getLeftBufPtr() [*]u8 { 19 | return @ptrCast(&left); 20 | } 21 | 22 | export fn getRightBufPtr() [*]u8 { 23 | return @ptrCast(&right); 24 | } 25 | 26 | export fn setLeftFreq(f: f32) void { 27 | l_freqHz = f; 28 | } 29 | 30 | export fn setRightFreq(f: f32) void { 31 | r_freqHz = f; 32 | } 33 | 34 | export fn renderSoundQuantum() void { 35 | var i: usize = 0; 36 | while (i < RENDER_QUANTUM_FRAMES) : (i += 1) { 37 | left[i] = std.math.sin(2 * std.math.pi * l_freqHz * @as(f32, @floatFromInt(frameCounter)) / sampleRate); 38 | right[i] = std.math.sin(2 * std.math.pi * r_freqHz * @as(f32, @floatFromInt(frameCounter)) / sampleRate); 39 | frameCounter += 1; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/synth/TimGM6mb.sf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/synth/TimGM6mb.sf2 -------------------------------------------------------------------------------- /src/synth/synth.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const ziggysynth = @import("ziggysynth.zig"); 3 | 4 | const SoundFont = ziggysynth.SoundFont; 5 | const Synthesizer = ziggysynth.Synthesizer; 6 | const SynthesizerSettings = ziggysynth.SynthesizerSettings; 7 | 8 | // WebAudio's render quantum size. 9 | const RENDER_QUANTUM_FRAMES = 128; 10 | 11 | var left: [RENDER_QUANTUM_FRAMES]f32 = undefined; 12 | var right: [RENDER_QUANTUM_FRAMES]f32 = undefined; 13 | var sampleRate: f32 = 44100; 14 | var synthesizer: Synthesizer = undefined; 15 | 16 | pub fn logFn( 17 | comptime message_level: std.log.Level, 18 | comptime scope: @TypeOf(.enum_literal), 19 | comptime format: []const u8, 20 | args: anytype, 21 | ) void { 22 | _ = message_level; 23 | _ = scope; 24 | _ = format; 25 | _ = args; 26 | } 27 | 28 | pub const std_options: std.Options = .{ 29 | .logFn = logFn, 30 | }; 31 | 32 | export fn noteOn(note: i32, vel: i32) void { 33 | synthesizer.noteOn(0, note, vel); 34 | } 35 | 36 | export fn noteOff(note: i32) void { 37 | synthesizer.noteOff(0, note); 38 | } 39 | 40 | export fn setSampleRate(s: f32) void { 41 | sampleRate = s; 42 | 43 | // create the synthesizer 44 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 45 | const allocator = gpa.allocator(); 46 | const data = @embedFile("TimGM6mb.sf2"); 47 | var fbs = std.io.fixedBufferStream(data); 48 | const reader = fbs.reader(); 49 | const sound_font = SoundFont.init(allocator, reader) catch unreachable; 50 | var settings = SynthesizerSettings.init(@intFromFloat(s)); 51 | settings.block_size = RENDER_QUANTUM_FRAMES; 52 | synthesizer = Synthesizer.init(allocator, &sound_font, &settings) catch unreachable; 53 | } 54 | 55 | export fn getLeftBufPtr() [*]u8 { 56 | return @ptrCast(&left); 57 | } 58 | 59 | export fn getRightBufPtr() [*]u8 { 60 | return @ptrCast(&right); 61 | } 62 | 63 | export fn renderSoundQuantum() void { 64 | synthesizer.render(&left, &right); 65 | } 66 | -------------------------------------------------------------------------------- /src/terminal/assets.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const assets = @import("assets"); 3 | 4 | const EmbeddedAsset = struct { 5 | []const u8, 6 | []const u8, 7 | }; 8 | 9 | pub const Assets = struct { 10 | pub const ASSET_MAP = std.StaticStringMap([]const u8).initComptime(genMap()); 11 | }; 12 | 13 | fn genMap() [assets.files.len]EmbeddedAsset { 14 | var eas: [assets.files.len]EmbeddedAsset = undefined; 15 | comptime var i = 0; 16 | 17 | inline for (assets.files) |file| { 18 | eas[i][0] = file; 19 | eas[i][1] = @embedFile("assets/" ++ file); 20 | i = i + 1; 21 | } 22 | return eas; 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/terminal/assets/pc-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/assets/pc-bold.ttf -------------------------------------------------------------------------------- /src/terminal/assets/pc.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/assets/pc.ttf -------------------------------------------------------------------------------- /src/terminal/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | 6 | // Implement a std.io.Writer backed by console_write() 7 | const ConsoleWriter = struct { 8 | const Writer = std.io.Writer( 9 | *ConsoleWriter, 10 | error{}, 11 | write, 12 | ); 13 | 14 | fn write( 15 | self: *ConsoleWriter, 16 | data: []const u8, 17 | ) error{}!usize { 18 | _ = self; 19 | console_write(data.ptr, data.len); 20 | return data.len; 21 | } 22 | 23 | pub fn writer(self: *ConsoleWriter) Writer { 24 | return .{ .context = self }; 25 | } 26 | }; 27 | 28 | pub fn getWriter() *ConsoleWriter { 29 | return &cw; 30 | } 31 | -------------------------------------------------------------------------------- /src/terminal/game.zig: -------------------------------------------------------------------------------- 1 | const math = @import("zlm/zlm.zig"); 2 | 3 | pub const Game = struct { 4 | pub usingnamespace @import("renderer.zig"); 5 | pub usingnamespace @import("assets.zig"); 6 | pub const Rect = @import("rect.zig").Rect; 7 | pub const vec2 = math.vec2; 8 | pub const Vec2 = math.Vec2; 9 | }; 10 | -------------------------------------------------------------------------------- /src/terminal/inttypes.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/terminal/olive.c/.gitignore: -------------------------------------------------------------------------------- 1 | *.ppm 2 | build/ 3 | *.swp 4 | nobuild 5 | nobuild.old -------------------------------------------------------------------------------- /src/terminal/olive.c/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Alexey Kutepov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/CREDITS.txt: -------------------------------------------------------------------------------- 1 | - https://opengameart.org/content/handpainted-stone-texture 2 | - lavastone-origin.png 3 | - lavastone.png 4 | - oldstone-origin.png 5 | - oldstone.png 6 | -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/Lena_112.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/Lena_112.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/lavastone-origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/lavastone-origin.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/lavastone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/lavastone.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/oldstone-origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/oldstone-origin.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/oldstone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/oldstone.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/olivec-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/olivec-200.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/tsodinCup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/tsodinCup.png -------------------------------------------------------------------------------- /src/terminal/olive.c/assets/tsodinPog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/assets/tsodinPog.png -------------------------------------------------------------------------------- /src/terminal/olive.c/css/index.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'LibreBaskerville'; 3 | src: url('../fonts/LibreBaskerville-Regular.ttf') format('truetype'); 4 | } 5 | body { 6 | background: #181818; 7 | color: #F0F0F0; 8 | font-family: LibreBaskerville; 9 | margin: auto; 10 | max-width: 960px; 11 | font-size: 16px; 12 | } 13 | p { 14 | padding-bottom: 20px; 15 | line-height: 1.5; 16 | } 17 | h1 { 18 | font-size: 40px; 19 | text-align: center; 20 | padding-top: 40px; 21 | padding-bottom: 40px; 22 | } 23 | h2 { 24 | font-size: 28px; 25 | text-align: left; 26 | padding-top: 20px; 27 | padding-bottom: 40px; 28 | } 29 | h2 a { 30 | color: #F0F0F0; 31 | } 32 | kbd { 33 | display: inline-block; 34 | font-family: monospace; 35 | padding: 3px 5px; 36 | background: #303030; 37 | line-height: 10px; 38 | vertical-align: middle; 39 | text-align: center; 40 | border-radius: 5px; 41 | } 42 | code { 43 | display: inline-block; 44 | font-family: monospace; 45 | } 46 | ul { 47 | padding-bottom: 20px; 48 | list-style: inside square; 49 | } 50 | ul li { 51 | padding-bottom: 10px; 52 | } 53 | .plot { 54 | width: 100%; 55 | padding-bottom: 20px; 56 | } 57 | a { 58 | color: #9090EE; 59 | text-decoration: none; 60 | } 61 | .author { 62 | text-align: center; 63 | padding-bottom: 40px; 64 | font-style: italic; 65 | } 66 | .author a { 67 | color: #F0F0F0; 68 | } 69 | -------------------------------------------------------------------------------- /src/terminal/olive.c/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ 2 | v2.0 | 20110126 3 | License: none (public domain) 4 | */ 5 | 6 | html, body, div, span, applet, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | a, abbr, acronym, address, big, cite, code, 9 | del, dfn, em, img, ins, kbd, q, s, samp, 10 | small, strike, strong, sub, sup, tt, var, 11 | b, u, i, center, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, embed, 16 | figure, figcaption, footer, header, hgroup, 17 | menu, nav, output, ruby, section, summary, 18 | time, mark, audio, video { 19 | margin: 0; 20 | padding: 0; 21 | border: 0; 22 | font-size: 100%; 23 | font: inherit; 24 | vertical-align: baseline; 25 | } 26 | /* HTML5 display-role reset for older browsers */ 27 | article, aside, details, figcaption, figure, 28 | footer, header, hgroup, menu, nav, section { 29 | display: block; 30 | } 31 | body { 32 | line-height: 1; 33 | } 34 | ol, ul { 35 | list-style: none; 36 | } 37 | blockquote, q { 38 | quotes: none; 39 | } 40 | blockquote:before, blockquote:after, 41 | q:before, q:after { 42 | content: ''; 43 | content: none; 44 | } 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } 49 | -------------------------------------------------------------------------------- /src/terminal/olive.c/demos/cup3d.c: -------------------------------------------------------------------------------- 1 | #include "assets/tsodinCupLowPoly.c" 2 | #include "model3d.c" 3 | -------------------------------------------------------------------------------- /src/terminal/olive.c/demos/dots3d.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | 3 | float sqrtf(float x); 4 | float atan2f(float y, float x); 5 | float sinf(float x); 6 | float cosf(float x); 7 | 8 | #define PI 3.14159265359 9 | 10 | #define WIDTH 960 11 | #define HEIGHT 720 12 | #define BACKGROUND_COLOR 0xFF181818 13 | #define GRID_COUNT 10 14 | #define GRID_PAD 0.5/GRID_COUNT 15 | #define GRID_SIZE ((GRID_COUNT - 1)*GRID_PAD) 16 | #define CIRCLE_RADIUS 5 17 | #define Z_START 0.25 18 | #define ABOBA_PADDING 50 19 | 20 | static uint32_t pixels[WIDTH*HEIGHT]; 21 | static float angle = 0; 22 | 23 | Olivec_Canvas vc_render(float dt) 24 | { 25 | angle += 0.25*PI*dt; 26 | 27 | Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH); 28 | 29 | olivec_fill(oc, BACKGROUND_COLOR); 30 | for (int ix = 0; ix < GRID_COUNT; ++ix) { 31 | for (int iy = 0; iy < GRID_COUNT; ++iy) { 32 | for (int iz = 0; iz < GRID_COUNT; ++iz) { 33 | float x = ix*GRID_PAD - GRID_SIZE/2; 34 | float y = iy*GRID_PAD - GRID_SIZE/2; 35 | float z = Z_START + iz*GRID_PAD; 36 | 37 | float cx = 0.0; 38 | float cz = Z_START + GRID_SIZE/2; 39 | 40 | float dx = x - cx; 41 | float dz = z - cz; 42 | 43 | float a = atan2f(dz, dx); 44 | float m = sqrtf(dx*dx + dz*dz); 45 | 46 | dx = cosf(a + angle)*m; 47 | dz = sinf(a + angle)*m; 48 | 49 | x = dx + cx; 50 | z = dz + cz; 51 | 52 | x /= z; 53 | y /= z; 54 | 55 | uint32_t r = ix*255/GRID_COUNT; 56 | uint32_t g = iy*255/GRID_COUNT; 57 | uint32_t b = iz*255/GRID_COUNT; 58 | uint32_t color = 0xFF000000 | (r<<(0*8)) | (g<<(1*8)) | (b<<(2*8)); 59 | olivec_circle(oc, (x + 1)/2*WIDTH, (y + 1)/2*HEIGHT, CIRCLE_RADIUS, color); 60 | } 61 | } 62 | } 63 | 64 | size_t size = 8; 65 | olivec_text(oc, "aboba", ABOBA_PADDING, HEIGHT - ABOBA_PADDING - olivec_default_font.height*size, olivec_default_font, size, 0xFFFFFFFF); 66 | 67 | return oc; 68 | } 69 | -------------------------------------------------------------------------------- /src/terminal/olive.c/demos/squish.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | #include "./assets/Lena_112.c" 3 | 4 | #define WIDTH 960 5 | #define HEIGHT 720 6 | 7 | float sinf(float); 8 | 9 | static uint32_t dst[WIDTH*HEIGHT]; 10 | static float global_time = 0; 11 | 12 | #define SRC_SCALE 3 13 | 14 | Olivec_Canvas vc_render(float dt) 15 | { 16 | global_time += dt; 17 | 18 | float t = sinf(10*global_time); 19 | 20 | Olivec_Canvas dst_canvas = olivec_canvas(dst, WIDTH, HEIGHT, WIDTH); 21 | 22 | olivec_fill(dst_canvas, 0xFF181818); 23 | 24 | int factor = 100; 25 | int w = Lena_112_width*SRC_SCALE - t*factor; 26 | int h = Lena_112_height*SRC_SCALE + t*factor; 27 | 28 | olivec_sprite_copy_bilinear( 29 | dst_canvas, 30 | WIDTH/2 - w/2, HEIGHT - h, w, h, 31 | olivec_canvas(Lena_112_pixels, Lena_112_width, Lena_112_height, Lena_112_width)); 32 | 33 | return dst_canvas; 34 | } 35 | -------------------------------------------------------------------------------- /src/terminal/olive.c/demos/teapot3d.c: -------------------------------------------------------------------------------- 1 | #include "assets/utahTeapot.c" 2 | #define VC_TERM_SCALE_DOWN_FACTOR 10 3 | #include "model3d.c" 4 | -------------------------------------------------------------------------------- /src/terminal/olive.c/demos/triangle.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | 3 | #define WIDTH 960 4 | #define HEIGHT 720 5 | // #define WIDTH 1920 6 | // #define HEIGHT 1080 7 | #define BACKGROUND_COLOR 0xFF181818 8 | #define CIRCLE_RADIUS 100 9 | #define CIRCLE_COLOR 0x99AA2020 10 | 11 | static uint32_t pixels[WIDTH*HEIGHT]; 12 | static float triangle_angle = 0; 13 | static float circle_x = WIDTH/2; 14 | static float circle_y = HEIGHT/2; 15 | static float circle_dx = 100; 16 | static float circle_dy = 100; 17 | 18 | float sqrtf(float x); 19 | float atan2f(float y, float x); 20 | float sinf(float x); 21 | float cosf(float x); 22 | 23 | #define PI 3.14159265359 24 | 25 | static inline void rotate_point(float *x, float *y) 26 | { 27 | float dx = *x - WIDTH/2; 28 | float dy = *y - HEIGHT/2; 29 | float mag = sqrtf(dx*dx + dy*dy); 30 | float dir = atan2f(dy, dx) + triangle_angle; 31 | *x = cosf(dir)*mag + WIDTH/2; 32 | *y = sinf(dir)*mag + HEIGHT/2; 33 | } 34 | 35 | Olivec_Canvas vc_render(float dt) 36 | { 37 | Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH); 38 | 39 | olivec_fill(oc, BACKGROUND_COLOR); 40 | 41 | // Triangle 42 | { 43 | triangle_angle += 0.5f*PI*dt; 44 | 45 | float x1 = WIDTH/2, y1 = HEIGHT/8; 46 | float x2 = WIDTH/8, y2 = HEIGHT/2; 47 | float x3 = WIDTH*7/8, y3 = HEIGHT*7/8; 48 | rotate_point(&x1, &y1); 49 | rotate_point(&x2, &y2); 50 | rotate_point(&x3, &y3); 51 | olivec_triangle3c(oc, x1, y1, x2, y2, x3, y3, 0xFF2020FF, 0xFF20FF20, 0xFFFF2020); 52 | } 53 | 54 | // Circle 55 | { 56 | float x = circle_x + circle_dx*dt; 57 | if (x - CIRCLE_RADIUS < 0 || x + CIRCLE_RADIUS >= WIDTH) { 58 | circle_dx *= -1; 59 | } else { 60 | circle_x = x; 61 | } 62 | 63 | float y = circle_y + circle_dy*dt; 64 | if (y - CIRCLE_RADIUS < 0 || y + CIRCLE_RADIUS >= HEIGHT) { 65 | circle_dy *= -1; 66 | } else { 67 | circle_y = y; 68 | } 69 | 70 | olivec_circle(oc, circle_x, circle_y, CIRCLE_RADIUS, CIRCLE_COLOR); 71 | } 72 | 73 | return oc; 74 | } 75 | -------------------------------------------------------------------------------- /src/terminal/olive.c/demos/triangleTex.c: -------------------------------------------------------------------------------- 1 | #include "vc.c" 2 | #include "assets/Lena_112.c" 3 | 4 | #define WIDTH 960 5 | #define HEIGHT 720 6 | #define BACKGROUND_COLOR 0xFF181818 7 | 8 | static uint32_t pixels[WIDTH*HEIGHT]; 9 | static float triangle_angle = 0; 10 | 11 | float sqrtf(float x); 12 | float atan2f(float y, float x); 13 | float sinf(float x); 14 | float cosf(float x); 15 | 16 | #define PI 3.14159265359 17 | 18 | Olivec_Canvas vc_render(float dt) 19 | { 20 | Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH); 21 | Olivec_Canvas Lena_112 = olivec_canvas(Lena_112_pixels, Lena_112_width, Lena_112_height, Lena_112_width); 22 | 23 | olivec_fill(oc, BACKGROUND_COLOR); 24 | 25 | // Triangle 26 | { 27 | triangle_angle += 0.5f*PI*dt; 28 | 29 | float ps[4][2]; 30 | float uvs[4][2] = { 31 | {0, 0}, 32 | {1, 0}, 33 | {1, 1}, 34 | {0, 1}, 35 | }; 36 | float len = WIDTH/4; 37 | for (size_t i = 0; i < 4; ++i) { 38 | ps[i][0] = WIDTH/2 + cosf(PI/2*i + triangle_angle)*len; 39 | ps[i][1] = HEIGHT/2 + sinf(PI/2*i + triangle_angle)*len; 40 | } 41 | for (size_t i = 0; i < 2; ++i) { 42 | int i1 = (i*2 + 0)%4; 43 | int i2 = (i*2 + 1)%4; 44 | int i3 = (i*2 + 2)%4; 45 | olivec_triangle3uv_bilinear( 46 | oc, 47 | ps[i1][0], ps[i1][1], 48 | ps[i2][0], ps[i2][1], 49 | ps[i3][0], ps[i3][1], 50 | uvs[i1][0], uvs[i1][1], 51 | uvs[i2][0], uvs[i2][1], 52 | uvs[i3][0], uvs[i3][1], 53 | 1, 1, 1, 54 | Lena_112 55 | ); 56 | } 57 | } 58 | 59 | return oc; 60 | } 61 | -------------------------------------------------------------------------------- /src/terminal/olive.c/docs/.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.log 3 | -------------------------------------------------------------------------------- /src/terminal/olive.c/docs/3d-projection.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/docs/3d-projection.pdf -------------------------------------------------------------------------------- /src/terminal/olive.c/docs/3d-projection.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{tikz} 3 | \usepackage{amsmath} 4 | \begin{document} 5 | \section{3D Projection} 6 | \def\minY{-2} \def\maxY{2} 7 | \def\minZ{-2} \def\maxZ{6} 8 | \def\screenZ{2} 9 | \def\eyeZ{0} \def\eyeY{0} 10 | \def\pZ{3} \def\pY{1} 11 | \begin{tikzpicture} 12 | \draw[-stealth] (\minZ,0) -- (\maxZ,0) node[above]{$z$}; 13 | \draw[-stealth] (0,\minY) -- (0,\maxY) node[above]{$x$}; 14 | \draw[fill] (\eyeZ, \eyeY) circle (.5ex) node[above]{eye $E$}; 15 | \draw[dotted,thick] (\screenZ, \minY) -- (\screenZ, \maxY) node[above]{screen}; 16 | \draw[dotted] (\eyeZ, \eyeY) -- (\pZ, \pY); 17 | \draw[dotted] (\eyeZ, \eyeY) -- (\pZ, -\pY); 18 | \draw[fill] (\pZ, \pY) circle (.5ex) node[above]{$p_1$}; 19 | \draw[fill] (\pZ, -\pY) circle (.5ex) node[above]{$p_2$}; 20 | \draw[fill] (\screenZ, {(\pY - \eyeY)/(\pZ - \eyeZ)*(\screenZ - \eyeZ) + \eyeY}) circle (.5ex) node[above]{$p_1'$}; 21 | \draw[fill] (\screenZ, {-(\pY - \eyeY)/(\pZ - \eyeZ)*(\screenZ - \eyeZ) + \eyeY}) circle (.5ex) node[above]{$p_2'$}; 22 | \end{tikzpicture} 23 | 24 | When we refer to $p$ we mean either $p_1$ or $p_2$. When we refer to $p'$ we mean either $p'_1$ or $p'_2$. 25 | 26 | \begin{align} 27 | & p = (p_x, p_y, p_z) \\ 28 | & p'= (p'_x, p'_y, S_z) \\ 29 | & E = (E_x, E_y, E_z) \\ 30 | \end{align} 31 | 32 | The formula to find $p'$ 33 | 34 | \begin{align} 35 | & p_y' = \frac{(p_y - E_y)(S_z - E_z)}{(p_z - E_z)} + E_y \\ 36 | & p_x' = \frac{(p_x - E_x)(S_z - E_z)}{(p_z - E_z)} + E_x \\ 37 | \end{align} 38 | 39 | If we assume that $E = (0, 0, 0)$ and $S_z = 1$ 40 | 41 | \begin{align} 42 | & p_y' = \frac{p_y}{p_z} \\ 43 | & p_x' = \frac{p_x}{p_z} \\ 44 | \end{align} 45 | 46 | \end{document} -------------------------------------------------------------------------------- /src/terminal/olive.c/docs/barycentric.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/docs/barycentric.pdf -------------------------------------------------------------------------------- /src/terminal/olive.c/fonts/LibreBaskerville-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/fonts/LibreBaskerville-Regular.ttf -------------------------------------------------------------------------------- /src/terminal/olive.c/olive.c: -------------------------------------------------------------------------------- 1 | #define OLIVEC_IMPLEMENTATION 1 2 | #define OLIVECDEF 3 | 4 | #include "olive.h" 5 | 6 | -------------------------------------------------------------------------------- /src/terminal/olive.c/test/.gitignore: -------------------------------------------------------------------------------- 1 | *_actual.png 2 | *_diff.png 3 | -------------------------------------------------------------------------------- /src/terminal/olive.c/test/alpha_blending_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/alpha_blending_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/barycentric_overflow_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/barycentric_overflow_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/bilinear_interpolation_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/bilinear_interpolation_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/checker_example_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/checker_example_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/circle_example_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/circle_example_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/draw_line_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/draw_line_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/empty_rect_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/empty_rect_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/fill_circle_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/fill_circle_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/fill_ellipse_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/fill_ellipse_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/fill_rect_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/fill_rect_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/fill_triangle_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/fill_triangle_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/frame_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/frame_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/hello_world_text_rendering_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/hello_world_text_rendering_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/line_edge_cases_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/line_edge_cases_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/lines_circle_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/lines_circle_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/lines_example_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/lines_example_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_empty_rect_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_empty_rect_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_flip_cut_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_flip_cut_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_flip_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_flip_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_null_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_null_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_out_of_bounds_cut_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_out_of_bounds_cut_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/sprite_blend_vs_copy_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/sprite_blend_vs_copy_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/triangle_order_flip_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/triangle_order_flip_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/test/weird_triangle_bug_expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/test/weird_triangle_bug_expected.png -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/cup3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/cup3d.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/dots3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/dots3d.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/squish.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/squish.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/teapot3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/teapot3d.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/triangle.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/triangle.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/triangle3d.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/triangle3d.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/triangle3dTex.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/triangle3dTex.wasm -------------------------------------------------------------------------------- /src/terminal/olive.c/wasm/triangleTex.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/terminal/olive.c/wasm/triangleTex.wasm -------------------------------------------------------------------------------- /src/terminal/stb_truetype.c: -------------------------------------------------------------------------------- 1 | #define STB_TRUETYPE_IMPLEMENTATION 2 | 3 | #include 4 | 5 | #define STBTT_ifloor(x) ((int) floor(x)) 6 | #define STBTT_iceil(x) ((int) ceil(x)) 7 | #define STBTT_sqrt(x) sqrt(x) 8 | #define STBTT_pow(x,y) pow(x,y) 9 | #define STBTT_fmod(x,y) fmod(x,y) 10 | #define STBTT_cos(x) cos(x) 11 | #define STBTT_acos(x) acos(x) 12 | #define STBTT_fabs(x) fabs(x) 13 | #define STBTT_malloc(x,u) ((void)(u),malloc(x)) 14 | #define STBTT_free(x,u) ((void)(u),free(x)) 15 | #define STBTT_assert(x) 16 | #define STBTT_strlen(x) strlen(x) 17 | #define STBTT_memcpy memcpy 18 | #define STBTT_memset memset 19 | 20 | #include "stb_truetype.h" 21 | 22 | -------------------------------------------------------------------------------- /src/terminal/terminal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | terminal 6 | 15 | 16 | 17 | 18 | 19 | 37 | 38 | 39 |

40 | 41 |

43 |

44 | zigtris, a terminal game running in a zvterm terminal emulator 45 |

46 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/terminal/zlm/zlm.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub const SpecializeOn = @import("zlm-generic.zig").SpecializeOn; 4 | 5 | /// Converts degrees to radian 6 | pub fn toRadians(deg: anytype) @TypeOf(deg) { 7 | return std.math.pi * deg / 180.0; 8 | } 9 | 10 | /// Converts radian to degree 11 | pub fn toDegrees(rad: anytype) @TypeOf(rad) { 12 | return 180.0 * rad / std.math.pi; 13 | } 14 | 15 | // export all vectors by-default to f32 16 | pub usingnamespace SpecializeOn(f32); 17 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/BeOS/GLView.h: -------------------------------------------------------------------------------- 1 | #ifndef _glview_h_ 2 | #define _glview_h_ 3 | 4 | #define BGL_RGB 0 5 | #define BGL_INDEX 1 6 | #define BGL_SINGLE 0 7 | #define BGL_DOUBLE 2 8 | #define BGL_DIRECT 0 9 | #define BGL_INDIRECT 4 10 | #define BGL_ACCUM 8 11 | #define BGL_ALPHA 16 12 | #define BGL_DEPTH 32 13 | #define BGL_OVERLAY 64 14 | #define BGL_UNDERLAY 128 15 | #define BGL_STENCIL 512 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | class BGLView : public BView { 25 | public: 26 | BGLView(BRect rect, char *name, 27 | ulong resizingMode, ulong mode, 28 | ulong options); 29 | virtual ~BGLView(); 30 | 31 | void LockGL(); 32 | void UnlockGL(); 33 | void SwapBuffers(); 34 | // BView *EmbeddedView(); 35 | // status_t CopyPixelsOut(BPoint source, BBitmap *dest); 36 | // status_t CopyPixelsIn(BBitmap *source, BPoint dest); 37 | 38 | virtual void ErrorCallback(GLenum errorCode); 39 | virtual void Draw(BRect updateRect); 40 | virtual void AttachedToWindow(); 41 | virtual void AllAttached(); 42 | virtual void DetachedFromWindow(); 43 | virtual void AllDetached(); 44 | virtual void FrameResized(float width, float height); 45 | // virtual status_t Perform(perform_code d, void *arg); 46 | 47 | // 48 | // Methods below are pass-throughs to BView for the moment. 49 | // 50 | 51 | virtual status_t Archive(BMessage *data, bool deep = true) const; 52 | virtual void MessageReceived(BMessage *msg); 53 | virtual void SetResizingMode(uint32 mode); 54 | 55 | virtual void Show(); 56 | virtual void Hide(); 57 | 58 | virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, 59 | BMessage *specifier, int32 form, 60 | const char *property); 61 | virtual status_t GetSupportedSuites(BMessage *data); 62 | //void DirectConnected( direct_buffer_info *info ); 63 | //void EnableDirectMode( bool enabled ); 64 | 65 | private: 66 | ostgl_context *context; 67 | BBitmap *bitmaps[2]; 68 | int currBitmap; 69 | static BLocker locker; 70 | }; 71 | 72 | #endif // _glview_h_ 73 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/BeOS/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=GLView.o 2 | INCLUDES = -I../include 3 | LIB = libGLView.a 4 | 5 | all: $(LIB) 6 | 7 | $(LIB): $(OBJS) 8 | rm -f $(LIB) 9 | ar rcs $(LIB) $(OBJS) 10 | cp $(LIB) ../lib 11 | 12 | clean: 13 | rm -f *~ *.o *.a 14 | 15 | GLView.o: GLView.cpp GLView.h 16 | $(CC) $(CFLAGS) $(INCLUDES) -c GLView.cpp 17 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/Changelog: -------------------------------------------------------------------------------- 1 | version 0.4.1: 2 | - changed license to MIT 3 | - fixed compilation errors 4 | - fixed lighting bug 5 | - fixed color conversions 6 | 7 | version 0.4: 8 | - added 24/32 bit rendering support (Olivier Landemarre - F. Bellard) 9 | - fixed GL_TRIANGLE_STRIP (Olivier Landemarre) 10 | - added gl_malloc, gl_free, gl_zalloc wrappers (Olivier Landemarre) 11 | 12 | version 0.3: 13 | - added NanoX API (nglx) (F. Bellard) 14 | - added gears example and unified GUI in examples (F. Bellard) 15 | - added TGL_FEATURE_RENDER_BITS so that it will be possible to render 16 | natively in 15/16/24 or 32 bits. (F. Bellard) 17 | - interpolated lines (Olivier Landemarre) 18 | - fast no shading case (Olivier Landemarre) 19 | - fast no projection case (Olivier Landemarre) 20 | 21 | version 0.2: Fabrice Bellard 22 | - added 24/32 bpp support. Added some features.h ifdefs. 23 | - fixed some error reporting cases in the examples 24 | - endianness is deduced from the glibc (BYTE_ORDER macro) 25 | 26 | version 0.19: Peder Blekken 27 | - new files BeOS/* src/msghandling.*, src/arrays.*, src/oscontext.c 28 | include/GL/oscontext.h src/features.h 29 | - added support for BeOS, see README.BEOS 30 | - added support for drawing convex polygons with unlimited # of vertices 31 | - added support for GL_LIGHT_MODEL_TWO_SIDE 32 | - added generic rotation code for glopRotate 33 | - added support for opengl 1.1 arrays 34 | - added support for glPolygonOffset, not implemented. 35 | - added glGetFloatv, limited support. 36 | - added some pnames for glGetIntegerv 37 | - added some empty functions in include/GL/gl.h to compile VRMLView 38 | - added GL_VERSION_1_1 define in include/GL/gl.h 39 | - fixed "bug" when context->gl_resize_viewport is not set. 40 | - fixed bug in glBindTexture (didn't accept texture object 0) 41 | 42 | version 0.1: 43 | - Initial revision, Fabrice Bellard 44 | 45 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/INSTALL: -------------------------------------------------------------------------------- 1 | Installation: 2 | 3 | - Edit config.mk and change what is needed. You can also look at 4 | src/zfeatures.h to change very specific details (only useful to tune 5 | TinyGL to your needs). You can link the examples with either OpenGL, 6 | Mesa or TinyGL. 7 | 8 | - Type 'make'. The library 'libTinyGL.a' is copied into './lib'. The 9 | examples are build in './examples'. Only the directories './lib' and 10 | './include' are needed to use TinyGL from another program. 11 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/LICENSE: -------------------------------------------------------------------------------- 1 | TinyGL 2 | 3 | Copyright (c) 1997-2022 Fabrice Bellard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/Makefile: -------------------------------------------------------------------------------- 1 | include config.mk 2 | 3 | all: 4 | ( for f in $(DIRS); do ( cd $$f ; make all ) || exit 1 ; done ) 5 | 6 | clean: 7 | rm -f *~ lib/libTinyGL.a include/GL/*~ TAGS 8 | ( for f in $(DIRS); do ( cd $$f ; make clean ; ) done ) 9 | 10 | install: 11 | ( for f in $(DIRS); do ( cd $$f ; make install ; ) done ) 12 | 13 | 14 | tar: 15 | ( cd .. ; tar zcvf /tmp/TinyGL-0.4.1.tar.gz TinyGL --exclude .svn --exclude TAGS ) 16 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/README.BEOS: -------------------------------------------------------------------------------- 1 | BeOS support for TinyGL, 1998 Peder Blekken 2 | 3 | I implemented (a limited version of) the BGLView class. There is 4 | no DirectWindow support, and some other funtions are missing too, 5 | but it should work ok for most uses. Feel free to use and modify 6 | GLView.cpp and GLView.h in any way you desire. 7 | 8 | You will need to take a look in Makefile to compile the library 9 | under BeOS. For those of you not familiar with using makefiles: too bad :) 10 | 11 | Also, you will probably need to remove /boot/develop/headers/be/opengl 12 | from the BEINCLUDES environment variable. Unfortunately, this means 13 | editing the /boot/beos/system/boot/SetupEnvironment. It might be possible 14 | to just make sure the TinyGL path is before Be's OpenGL in the include-paths 15 | though. But I prefer to remove /boot/develop/headers/be/opengl, since I 16 | often use Mesa as well. It is a better to add the OpenGL include path in your 17 | makefile; or BeIDE project if that is what you use. 18 | 19 | Contact me for any reason: 20 | 21 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/config.mk: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | # C compiler 3 | 4 | # linux 5 | CC= gcc 6 | CFLAGS= -g -Wall -O2 7 | LFLAGS= 8 | 9 | # for BeOS PPC 10 | #CC= mwcc 11 | #CFLAGS= -I. -i- 12 | #LFLAGS= 13 | 14 | ##################################################################### 15 | # TinyGL configuration 16 | 17 | ##################################################################### 18 | # Select window API for TinyGL: 19 | 20 | # standard X11 GLX like API 21 | TINYGL_USE_GLX=y 22 | 23 | # BEOS API 24 | #TINYGL_USE_BEOS=y 25 | 26 | # Micro Windows NanoX API 27 | #TINYGL_USE_NANOX=y 28 | 29 | ##################################################################### 30 | # X11 configuration (for the examples only) 31 | 32 | ifdef TINYGL_USE_GLX 33 | # Linux 34 | UI_LIBS= -L/usr/X11R6/lib -lX11 -lXext 35 | UI_INCLUDES= 36 | # Solaris 37 | #UI_LIBS= -L/usr/X11/lib -lX11 -lXext -lsocket -lnsl 38 | #UI_INCLUDES= 39 | 40 | UI_OBJS=x11.o 41 | endif 42 | 43 | ##################################################################### 44 | # Micro windowX11 configuration (for the examples only) 45 | 46 | ifdef TINYGL_USE_NANOX 47 | UI_LIBS= -lnano-X -lmwengine -lmwdrivers -lmwfonts 48 | UI_INCLUDES= 49 | 50 | # X11 target for nanoX 51 | UI_LIBS+= -L/usr/X11R6/lib -lX11 -lXext 52 | 53 | UI_OBJS=nanox.o 54 | endif 55 | 56 | ##################################################################### 57 | # OpenGL configuration (for the examples only) 58 | 59 | # use TinyGL 60 | GL_LIBS= -L../lib -lTinyGL 61 | GL_INCLUDES= -I../include 62 | GL_DEPS= ../lib/libTinyGL.a 63 | 64 | # use Mesa 65 | #GL_LIBS= -lMesaGL 66 | #GL_INCLUDES= 67 | #GL_DEPS= 68 | 69 | # use OpenGL 70 | #GL_LIBS= -lGL 71 | #GL_INCLUDES= 72 | #GL_DEPS= 73 | 74 | #################################################################### 75 | # Compile and link control 76 | 77 | # UNIX systems 78 | DIRS= src examples 79 | 80 | # BeOS 81 | # DIRS= src BeOS 82 | 83 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/examples/Makefile: -------------------------------------------------------------------------------- 1 | include ../config.mk 2 | 3 | PROGS = mech texobj gears spin 4 | 5 | all: $(PROGS) 6 | 7 | clean: 8 | rm -f core *.o *~ $(PROGS) 9 | 10 | mech: mech.o glu.o $(UI_OBJS) $(GL_DEPS) 11 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 12 | 13 | texobj: texobj.o $(UI_OBJS) $(GL_DEPS) 14 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 15 | 16 | gears: gears.o $(UI_OBJS) $(GL_DEPS) 17 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 18 | 19 | spin: spin.o $(UI_OBJS) $(GL_DEPS) 20 | $(CC) $(LFLAGS) $^ -o $@ $(GL_LIBS) $(UI_LIBS) -lm 21 | 22 | .c.o: 23 | $(CC) $(CFLAGS) $(GL_INCLUDES) $(UI_INCLUDES) -c $*.c 24 | 25 | mech.o: glu.h 26 | 27 | glu.o: glu.h 28 | 29 | ui.o: ui.h 30 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/examples/glu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/tinygl/TinyGL/examples/glu.c -------------------------------------------------------------------------------- /src/tinygl/TinyGL/examples/glu.h: -------------------------------------------------------------------------------- 1 | 2 | void gluPerspective( GLdouble fovy, GLdouble aspect, 3 | GLdouble zNear, GLdouble zFar ); 4 | 5 | typedef struct { 6 | int draw_style; 7 | } GLUquadricObj; 8 | 9 | #define GLU_LINE 0 10 | 11 | GLUquadricObj *gluNewQuadric(void); 12 | void gluQuadricDrawStyle(GLUquadricObj *obj, int style); 13 | 14 | void gluSphere(GLUquadricObj *qobj, 15 | float radius,int slices,int stacks); 16 | void gluCylinder( GLUquadricObj *qobj, 17 | GLdouble baseRadius, GLdouble topRadius, GLdouble height, 18 | GLint slices, GLint stacks ); 19 | void gluDisk( GLUquadricObj *qobj, 20 | GLdouble innerRadius, GLdouble outerRadius, 21 | GLint slices, GLint loops ); 22 | 23 | void drawTorus(float rc, int numc, float rt, int numt); 24 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/examples/ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tk like ui 3 | */ 4 | void draw( void ); 5 | void idle( void ); 6 | GLenum key(int k, GLenum mask); 7 | void reshape( int width, int height ); 8 | void init( void ); 9 | int ui_loop(int argc, char **argv, const char *name); 10 | void tkSwapBuffers(void); 11 | 12 | #define KEY_UP 0xe000 13 | #define KEY_DOWN 0xe001 14 | #define KEY_LEFT 0xe002 15 | #define KEY_RIGHT 0xe003 16 | #define KEY_ESCAPE 0xe004 17 | 18 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/include/GL/nglx.h: -------------------------------------------------------------------------------- 1 | #ifndef NGLX_H 2 | #define NGLX_H 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef void *NGLXContext; 12 | typedef GR_DRAW_ID NGLXDrawable; 13 | 14 | extern NGLXContext nglXCreateContext( NGLXContext shareList, int flags ); 15 | 16 | extern void nglXDestroyContext( NGLXContext ctx ); 17 | 18 | extern int nglXMakeCurrent( NGLXDrawable drawable, 19 | NGLXContext ctx); 20 | 21 | extern void nglXSwapBuffers( NGLXDrawable drawable ); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/include/GL/oscontext.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_osbuffer_h_ 2 | #define _tgl_osbuffer_h_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct { 9 | void **zbs; 10 | void **framebuffers; 11 | int numbuffers; 12 | int xsize, ysize; 13 | } ostgl_context; 14 | 15 | ostgl_context * 16 | ostgl_create_context(const int xsize, 17 | const int ysize, 18 | const int depth, 19 | void **framebuffers, 20 | const int numbuffers); 21 | void 22 | ostgl_delete_context(ostgl_context *context); 23 | 24 | void 25 | ostgl_make_current(ostgl_context *context, const int index); 26 | 27 | void 28 | ostgl_resize(ostgl_context * context, 29 | const int xsize, 30 | const int ysize, 31 | void **framebuffers); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* _tgl_osbuffer_h_ */ 38 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/include/GLView.h: -------------------------------------------------------------------------------- 1 | #ifndef _glview_h_ 2 | #define _glview_h_ 3 | 4 | #define BGL_RGB 0 5 | #define BGL_INDEX 1 6 | #define BGL_SINGLE 0 7 | #define BGL_DOUBLE 2 8 | #define BGL_DIRECT 0 9 | #define BGL_INDIRECT 4 10 | #define BGL_ACCUM 8 11 | #define BGL_ALPHA 16 12 | #define BGL_DEPTH 32 13 | #define BGL_OVERLAY 64 14 | #define BGL_UNDERLAY 128 15 | #define BGL_STENCIL 512 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | class BGLView : public BView { 25 | public: 26 | BGLView(BRect rect, char *name, 27 | ulong resizingMode, ulong mode, 28 | ulong options); 29 | virtual ~BGLView(); 30 | 31 | void LockGL(); 32 | void UnlockGL(); 33 | void SwapBuffers(); 34 | // BView *EmbeddedView(); 35 | // status_t CopyPixelsOut(BPoint source, BBitmap *dest); 36 | // status_t CopyPixelsIn(BBitmap *source, BPoint dest); 37 | 38 | virtual void ErrorCallback(GLenum errorCode); 39 | virtual void Draw(BRect updateRect); 40 | virtual void AttachedToWindow(); 41 | virtual void AllAttached(); 42 | virtual void DetachedFromWindow(); 43 | virtual void AllDetached(); 44 | virtual void FrameResized(float width, float height); 45 | // virtual status_t Perform(perform_code d, void *arg); 46 | 47 | // 48 | // Methods below are pass-throughs to BView for the moment. 49 | // 50 | 51 | virtual status_t Archive(BMessage *data, bool deep = true) const; 52 | virtual void MessageReceived(BMessage *msg); 53 | virtual void SetResizingMode(uint32 mode); 54 | 55 | virtual void Show(); 56 | virtual void Hide(); 57 | 58 | virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, 59 | BMessage *specifier, int32 form, 60 | const char *property); 61 | virtual status_t GetSupportedSuites(BMessage *data); 62 | //void DirectConnected( direct_buffer_info *info ); 63 | //void EnableDirectMode( bool enabled ); 64 | 65 | private: 66 | ostgl_context *context; 67 | BBitmap *bitmaps[2]; 68 | int currBitmap; 69 | static BLocker locker; 70 | }; 71 | 72 | #endif // _glview_h_ 73 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/Makefile: -------------------------------------------------------------------------------- 1 | include ../config.mk 2 | 3 | OBJS= api.o list.o vertex.o init.o matrix.o texture.o \ 4 | misc.o clear.o light.o clip.o select.o get.o error.o \ 5 | zbuffer.o zline.o zdither.o ztriangle.o \ 6 | zmath.o image_util.o oscontext.o msghandling.o \ 7 | arrays.o specbuf.o memory.o 8 | ifdef TINYGL_USE_GLX 9 | OBJS += glx.o 10 | endif 11 | ifdef TINYGL_USE_NANOX 12 | OBJS += nglx.o 13 | endif 14 | 15 | INCLUDES = -I../include 16 | LIB = libTinyGL.a 17 | 18 | all: $(LIB) 19 | 20 | $(LIB): $(OBJS) 21 | rm -f $(LIB) 22 | ar rcs $(LIB) $(OBJS) 23 | cp $(LIB) ../lib 24 | 25 | clean: 26 | rm -f *~ *.o *.a 27 | 28 | .c.o: 29 | $(CC) $(CFLAGS) $(INCLUDES) -c $*.c 30 | 31 | clip.o: zgl.h zfeatures.h 32 | vertex.o: zgl.h zfeatures.h 33 | light.o: zgl.h zfeatures.h 34 | matrix.o: zgl.h zfeatures.h 35 | list.o: zgl.h opinfo.h zfeatures.h 36 | arrays.c: zgl.h zfeatures.h 37 | specbuf.o: zgl.h zfeatures.h 38 | glx.o: zgl.h zfeatures.h 39 | nglx.o: zgl.h zfeatures.h 40 | zline.o: zgl.h zfeatures.h zline.h 41 | 42 | ztriangle.o: ztriangle.c ztriangle.h zgl.h zfeatures.h 43 | $(CC) $(CFLAGS) -Wno-uninitialized $(INCLUDES) -c $*.c 44 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/clear.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | 4 | void glopClearColor(GLContext *c,GLParam *p) 5 | { 6 | c->clear_color.v[0]=p[1].f; 7 | c->clear_color.v[1]=p[2].f; 8 | c->clear_color.v[2]=p[3].f; 9 | c->clear_color.v[3]=p[4].f; 10 | } 11 | void glopClearDepth(GLContext *c,GLParam *p) 12 | { 13 | c->clear_depth=p[1].f; 14 | } 15 | 16 | 17 | void glopClear(GLContext *c,GLParam *p) 18 | { 19 | int mask=p[1].i; 20 | int z=0; 21 | int r=(int)(c->clear_color.v[0]*65535); 22 | int g=(int)(c->clear_color.v[1]*65535); 23 | int b=(int)(c->clear_color.v[2]*65535); 24 | 25 | /* TODO : correct value of Z */ 26 | 27 | ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z, 28 | mask & GL_COLOR_BUFFER_BIT,r,g,b); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zgl.h" 3 | 4 | void gl_fatal_error(char *format, ...) 5 | { 6 | // FIXME 7 | // va_list ap; 8 | // 9 | // va_start(ap,format); 10 | // 11 | // fprintf(stderr,"TinyGL: fatal error: "); 12 | // vfprintf(stderr,format,ap); 13 | // fprintf(stderr,"\n"); 14 | // exit(1); 15 | // 16 | // va_end(ap); 17 | } 18 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/get.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | void glGetIntegerv(int pname,int *params) 4 | { 5 | GLContext *c=gl_get_context(); 6 | 7 | switch(pname) { 8 | case GL_VIEWPORT: 9 | params[0]=c->viewport.xmin; 10 | params[1]=c->viewport.ymin; 11 | params[2]=c->viewport.xsize; 12 | params[3]=c->viewport.ysize; 13 | break; 14 | case GL_MAX_MODELVIEW_STACK_DEPTH: 15 | *params = MAX_MODELVIEW_STACK_DEPTH; 16 | break; 17 | case GL_MAX_PROJECTION_STACK_DEPTH: 18 | *params = MAX_PROJECTION_STACK_DEPTH; 19 | break; 20 | case GL_MAX_LIGHTS: 21 | *params = MAX_LIGHTS; 22 | break; 23 | case GL_MAX_TEXTURE_SIZE: 24 | *params = 256; /* not completely true, but... */ 25 | break; 26 | case GL_MAX_TEXTURE_STACK_DEPTH: 27 | *params = MAX_TEXTURE_STACK_DEPTH; 28 | break; 29 | default: 30 | gl_fatal_error("glGet: option not implemented"); 31 | break; 32 | } 33 | } 34 | 35 | void glGetFloatv(int pname, float *v) 36 | { 37 | int i; 38 | int mnr = 0; /* just a trick to return the correct matrix */ 39 | GLContext *c = gl_get_context(); 40 | switch (pname) { 41 | case GL_TEXTURE_MATRIX: 42 | mnr++; 43 | case GL_PROJECTION_MATRIX: 44 | mnr++; 45 | case GL_MODELVIEW_MATRIX: 46 | { 47 | float *p = &c->matrix_stack_ptr[mnr]->m[0][0];; 48 | for (i = 0; i < 4; i++) { 49 | *v++ = p[0]; 50 | *v++ = p[4]; 51 | *v++ = p[8]; 52 | *v++ = p[12]; 53 | p++; 54 | } 55 | } 56 | break; 57 | case GL_LINE_WIDTH: 58 | *v = 1.0f; 59 | break; 60 | case GL_LINE_WIDTH_RANGE: 61 | v[0] = v[1] = 1.0f; 62 | break; 63 | case GL_POINT_SIZE: 64 | *v = 1.0f; 65 | break; 66 | case GL_POINT_SIZE_RANGE: 67 | v[0] = v[1] = 1.0f; 68 | default: 69 | //fprintf(stderr,"warning: unknown pname in glGetFloatv()\n"); 70 | // FIXME 71 | break; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory allocator for TinyGL 3 | */ 4 | #include "zgl.h" 5 | 6 | /* modify these functions so that they suit your needs */ 7 | 8 | void gl_free(void *p) 9 | { 10 | free(p); 11 | } 12 | 13 | void *gl_malloc(int size) 14 | { 15 | return malloc(size); 16 | } 17 | 18 | void *gl_zalloc(int size) 19 | { 20 | return calloc(1, size); 21 | } 22 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/msghandling.c: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | 4 | #define NDEBUG 5 | 6 | #ifdef NDEBUG 7 | #define NO_DEBUG_OUTPUT 8 | #endif 9 | 10 | /* Use this function to output messages when something unexpected 11 | happens (which might be an indication of an error). *Don't* use it 12 | when there's internal errors in the code - these should be handled 13 | by asserts. */ 14 | void 15 | tgl_warning(const char *format, ...) 16 | { 17 | #ifndef NO_DEBUG_OUTPUT 18 | va_list args; 19 | va_start(args, format); 20 | fprintf(stderr, "*WARNING* "); 21 | vfprintf(stderr, format, args); 22 | va_end(args); 23 | #endif /* !NO_DEBUG_OUTPUT */ 24 | } 25 | 26 | /* This function should be used for debug output only. */ 27 | void 28 | tgl_trace(const char *format, ...) 29 | { 30 | #ifndef NO_DEBUG_OUTPUT 31 | va_list args; 32 | va_start(args, format); 33 | fprintf(stderr, "*DEBUG* "); 34 | vfprintf(stderr, format, args); 35 | va_end(args); 36 | #endif /* !NO_DEBUG_OUTPUT */ 37 | } 38 | 39 | /* Use this function to output info about things in the code which 40 | should be fixed (missing handling of special cases, important 41 | features not implemented, known bugs/buglets, ...). */ 42 | void 43 | tgl_fixme(const char *format, ...) 44 | { 45 | #ifndef NO_DEBUG_OUTPUT 46 | va_list args; 47 | va_start(args, format); 48 | fprintf(stderr, "*FIXME* "); 49 | vfprintf(stderr, format, args); 50 | va_end(args); 51 | #endif /* !NO_DEBUG_OUTPUT */ 52 | } 53 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/msghandling.h: -------------------------------------------------------------------------------- 1 | #ifndef _msghandling_h_ 2 | #define _msghandling_h_ 3 | 4 | extern void tgl_warning(const char *text, ...); 5 | extern void tgl_trace(const char *text, ...); 6 | extern void tgl_fixme(const char *text, ...); 7 | 8 | #endif /* _msghandling_h_ */ 9 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/opinfo.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | ADD_OP(Color,7,"%f %f %f %f %d %d %d") 4 | ADD_OP(TexCoord,4,"%f %f %f %f") 5 | ADD_OP(EdgeFlag,1,"%d") 6 | ADD_OP(Normal,3,"%f %f %f") 7 | 8 | ADD_OP(Begin,1,"%C") 9 | ADD_OP(Vertex,4,"%f %f %f %f") 10 | ADD_OP(End,0,"") 11 | 12 | ADD_OP(EnableDisable,2,"%C %d") 13 | 14 | ADD_OP(MatrixMode,1,"%C") 15 | ADD_OP(LoadMatrix,16,"") 16 | ADD_OP(LoadIdentity,0,"") 17 | ADD_OP(MultMatrix,16,"") 18 | ADD_OP(PushMatrix,0,"") 19 | ADD_OP(PopMatrix,0,"") 20 | ADD_OP(Rotate,4,"%f %f %f %f") 21 | ADD_OP(Translate,3,"%f %f %f") 22 | ADD_OP(Scale,3,"%f %f %f") 23 | 24 | ADD_OP(Viewport,4,"%d %d %d %d") 25 | ADD_OP(Frustum,6,"%f %f %f %f %f %f") 26 | 27 | ADD_OP(Material,6,"%C %C %f %f %f %f") 28 | ADD_OP(ColorMaterial,2,"%C %C") 29 | ADD_OP(Light,6,"%C %C %f %f %f %f") 30 | ADD_OP(LightModel,5,"%C %f %f %f %f") 31 | 32 | ADD_OP(Clear,1,"%d") 33 | ADD_OP(ClearColor,4,"%f %f %f %f") 34 | ADD_OP(ClearDepth,1,"%f") 35 | 36 | ADD_OP(InitNames,0,"") 37 | ADD_OP(PushName,1,"%d") 38 | ADD_OP(PopName,0,"") 39 | ADD_OP(LoadName,1,"%d") 40 | 41 | ADD_OP(TexImage2D,9,"%d %d %d %d %d %d %d %d %d") 42 | ADD_OP(BindTexture,2,"%C %d") 43 | ADD_OP(TexEnv,7,"%C %C %C %f %f %f %f") 44 | ADD_OP(TexParameter,7,"%C %C %C %f %f %f %f") 45 | ADD_OP(PixelStore,2,"%C %C") 46 | 47 | ADD_OP(ShadeModel,1,"%C") 48 | ADD_OP(CullFace,1,"%C") 49 | ADD_OP(FrontFace,1,"%C") 50 | ADD_OP(PolygonMode,2,"%C %C") 51 | 52 | ADD_OP(CallList,1,"%d") 53 | ADD_OP(Hint,2,"%C %C") 54 | 55 | /* special opcodes */ 56 | ADD_OP(EndList,0,"") 57 | ADD_OP(NextBuffer,1,"%p") 58 | 59 | /* opengl 1.1 arrays */ 60 | ADD_OP(ArrayElement, 1, "%d") 61 | ADD_OP(EnableClientState, 1, "%C") 62 | ADD_OP(DisableClientState, 1, "%C") 63 | ADD_OP(VertexPointer, 4, "%d %C %d %p") 64 | ADD_OP(ColorPointer, 4, "%d %C %d %p") 65 | ADD_OP(NormalPointer, 3, "%C %d %p") 66 | ADD_OP(TexCoordPointer, 4, "%d %C %d %p") 67 | 68 | /* opengl 1.1 polygon offset */ 69 | ADD_OP(PolygonOffset, 2, "%f %f") 70 | 71 | #undef ADD_OP 72 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/oscontext.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zbuffer.h" 3 | #include "zgl.h" 4 | #include 5 | //#include 6 | //#include 7 | 8 | static int buffercnt = 0; 9 | 10 | ostgl_context * 11 | ostgl_create_context(const int xsize, 12 | const int ysize, 13 | const int depth, 14 | void **framebuffers, 15 | const int numbuffers) 16 | { 17 | ostgl_context *context; 18 | int i; 19 | ZBuffer *zb; 20 | 21 | assert(depth == 16); /* support for other depths must include bpp 22 | convertion */ 23 | assert(numbuffers >= 1); 24 | 25 | context = gl_malloc(sizeof(ostgl_context)); 26 | assert(context); 27 | context->zbs = gl_malloc(sizeof(void*)*numbuffers); 28 | context->framebuffers = gl_malloc(sizeof(void*)*numbuffers); 29 | 30 | assert(context->zbs != NULL && context->framebuffers != NULL); 31 | 32 | for (i = 0; i < numbuffers; i++) { 33 | context->framebuffers[i] = framebuffers[i]; 34 | zb = ZB_open(xsize, ysize, ZB_MODE_5R6G5B, 0, NULL, NULL, framebuffers[i]); 35 | if (zb == NULL) { 36 | //fprintf(stderr, "Error while initializing Z buffer\n"); 37 | //exit(1); 38 | //FIXME 39 | } 40 | context->zbs[i] = zb; 41 | } 42 | if (++buffercnt == 1) { 43 | glInit(context->zbs[0]); 44 | } 45 | context->xsize = xsize; 46 | context->ysize = ysize; 47 | context->numbuffers = numbuffers; 48 | return context; 49 | } 50 | 51 | void 52 | ostgl_delete_context(ostgl_context *context) 53 | { 54 | int i; 55 | for (i = 0; i < context->numbuffers; i++) { 56 | ZB_close(context->zbs[i]); 57 | } 58 | gl_free(context->zbs); 59 | gl_free(context->framebuffers); 60 | gl_free(context); 61 | 62 | if (--buffercnt == 0) { 63 | glClose(); 64 | } 65 | } 66 | 67 | void 68 | ostgl_make_current(ostgl_context *oscontext, const int idx) 69 | { 70 | GLContext *context = gl_get_context(); 71 | assert(idx < oscontext->numbuffers); 72 | context->zb = oscontext->zbs[idx]; 73 | } 74 | 75 | void 76 | ostgl_resize(ostgl_context *context, 77 | const int xsize, 78 | const int ysize, 79 | void **framebuffers) 80 | { 81 | int i; 82 | for (i = 0; i < context->numbuffers; i++) { 83 | ZB_resize(context->zbs[i], framebuffers[i], xsize, ysize); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/specbuf.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | #include "msghandling.h" 3 | //#include 4 | //#include 5 | 6 | static void calc_buf(GLSpecBuf *buf, const float shininess) 7 | { 8 | int i; 9 | float val, inc; 10 | val = 0.0f; 11 | inc = 1.0f/SPECULAR_BUFFER_SIZE; 12 | for (i = 0; i <= SPECULAR_BUFFER_SIZE; i++) { 13 | buf->buf[i] = zpow(val, shininess); 14 | val += inc; 15 | } 16 | } 17 | 18 | GLSpecBuf * 19 | specbuf_get_buffer(GLContext *c, const int shininess_i, 20 | const float shininess) 21 | { 22 | GLSpecBuf *found, *oldest; 23 | found = oldest = c->specbuf_first; 24 | while (found && found->shininess_i != shininess_i) { 25 | if (found->last_used < oldest->last_used) { 26 | oldest = found; 27 | } 28 | found = found->next; 29 | } 30 | if (found) { /* hey, found one! */ 31 | found->last_used = c->specbuf_used_counter++; 32 | return found; 33 | } 34 | if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { 35 | /* create new buffer */ 36 | GLSpecBuf *buf = gl_malloc(sizeof(GLSpecBuf)); 37 | if (!buf) gl_fatal_error("could not allocate specular buffer"); 38 | c->specbuf_num_buffers++; 39 | buf->next = c->specbuf_first; 40 | c->specbuf_first = buf; 41 | buf->last_used = c->specbuf_used_counter++; 42 | buf->shininess_i = shininess_i; 43 | calc_buf(buf, shininess); 44 | return buf; 45 | } 46 | /* overwrite the lru buffer */ 47 | /*tgl_trace("overwriting spec buffer :(\n");*/ 48 | oldest->shininess_i = shininess_i; 49 | oldest->last_used = c->specbuf_used_counter++; 50 | calc_buf(oldest, shininess); 51 | return oldest; 52 | } 53 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/specbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_specbuf_h_ 2 | #define _tgl_specbuf_h_ 3 | 4 | /* Max # of specular light pow buffers */ 5 | #define MAX_SPECULAR_BUFFERS 8 6 | /* # of entries in specular buffer */ 7 | #define SPECULAR_BUFFER_SIZE 1024 8 | /* specular buffer granularity */ 9 | #define SPECULAR_BUFFER_RESOLUTION 1024 10 | 11 | typedef struct GLSpecBuf { 12 | int shininess_i; 13 | int last_used; 14 | float buf[SPECULAR_BUFFER_SIZE+1]; 15 | struct GLSpecBuf *next; 16 | } GLSpecBuf; 17 | 18 | GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, 19 | const float shininess); 20 | void specbuf_cleanup(GLContext *c); /* free all memory used */ 21 | 22 | #endif /* _tgl_specbuf_h_ */ 23 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/zfeatures.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_features_h_ 2 | #define _tgl_features_h_ 3 | 4 | /* It is possible to enable/disable (compile time) features in this 5 | header file. */ 6 | 7 | #define TGL_FEATURE_ARRAYS 1 8 | #define TGL_FEATURE_DISPLAYLISTS 1 9 | #define TGL_FEATURE_POLYGON_OFFSET 1 10 | 11 | /* 12 | * Matrix of internal and external pixel formats supported. 'Y' means 13 | * supported. 14 | * 15 | * External 8 16 24 32 16 | * Internal 17 | * 15 . . . . 18 | * 16 Y Y Y Y 19 | * 24 . Y Y . 20 | * 32 . Y . Y 21 | * 22 | * 23 | * 15 bpp does not work yet (although it is easy to add it - ask me if 24 | * you need it). 25 | * 26 | * Internal pixel format: see TGL_FEATURE_RENDER_BITS 27 | * External pixel format: see TGL_FEATURE_xxx_BITS 28 | */ 29 | 30 | /* enable various convertion code from internal pixel format (usually 31 | 16 bits per pixel) to any external format */ 32 | //#define TGL_FEATURE_16_BITS 1 33 | //#define TGL_FEATURE_8_BITS 1 34 | //#define TGL_FEATURE_24_BITS 1 35 | #define TGL_FEATURE_32_BITS 1 36 | 37 | 38 | //#define TGL_FEATURE_RENDER_BITS 15 39 | //#define TGL_FEATURE_RENDER_BITS 16 40 | //#define TGL_FEATURE_RENDER_BITS 24 41 | #define TGL_FEATURE_RENDER_BITS 32 42 | 43 | #endif /* _tgl_features_h_ */ 44 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/zline.c: -------------------------------------------------------------------------------- 1 | //#include 2 | #include "zbuffer.h" 3 | 4 | #define ZCMP(z,zpix) ((z) >= (zpix)) 5 | 6 | void ZB_plot(ZBuffer * zb, ZBufferPoint * p) 7 | { 8 | unsigned short *pz; 9 | PIXEL *pp; 10 | int zz; 11 | 12 | pz = zb->zbuf + (p->y * zb->xsize + p->x); 13 | pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB); 14 | zz = p->z >> ZB_POINT_Z_FRAC_BITS; 15 | if (ZCMP(zz, *pz)) { 16 | #if TGL_FEATURE_RENDER_BITS == 24 17 | pp[0]=p->r>>8; 18 | pp[1]=p->g>>8; 19 | pp[2]=p->b>>8; 20 | #else 21 | *pp = RGB_TO_PIXEL(p->r, p->g, p->b); 22 | #endif 23 | *pz = zz; 24 | } 25 | } 26 | 27 | #define INTERP_Z 28 | static void ZB_line_flat_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2, 29 | int color) 30 | { 31 | #include "zline.h" 32 | } 33 | 34 | /* line with color interpolation */ 35 | #define INTERP_Z 36 | #define INTERP_RGB 37 | static void ZB_line_interp_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 38 | { 39 | #include "zline.h" 40 | } 41 | 42 | /* no Z interpolation */ 43 | 44 | static void ZB_line_flat(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2, 45 | int color) 46 | { 47 | #include "zline.h" 48 | } 49 | 50 | #define INTERP_RGB 51 | static void ZB_line_interp(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 52 | { 53 | #include "zline.h" 54 | } 55 | 56 | void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 57 | { 58 | int color1, color2; 59 | 60 | color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b); 61 | color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b); 62 | 63 | /* choose if the line should have its color interpolated or not */ 64 | if (color1 == color2) { 65 | ZB_line_flat_z(zb, p1, p2, color1); 66 | } else { 67 | ZB_line_interp_z(zb, p1, p2); 68 | } 69 | } 70 | 71 | void ZB_line(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 72 | { 73 | int color1, color2; 74 | 75 | color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b); 76 | color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b); 77 | 78 | /* choose if the line should have its color interpolated or not */ 79 | if (color1 == color2) { 80 | ZB_line_flat(zb, p1, p2, color1); 81 | } else { 82 | ZB_line_interp(zb, p1, p2); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/zmath.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringtailsoftware/zig-wasm-audio-framebuffer/51debb33c632416389f216fa85d183bc6b3addcb/src/tinygl/TinyGL/src/zmath.c -------------------------------------------------------------------------------- /src/tinygl/TinyGL/src/zmath.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZMATH__ 2 | #define __ZMATH__ 3 | 4 | /* Matrix & Vertex */ 5 | 6 | typedef struct { 7 | float m[4][4]; 8 | } M4; 9 | 10 | typedef struct { 11 | float m[3][3]; 12 | } M3; 13 | 14 | typedef struct { 15 | float m[3][4]; 16 | } M34; 17 | 18 | 19 | #define X v[0] 20 | #define Y v[1] 21 | #define Z v[2] 22 | #define W v[3] 23 | 24 | typedef struct { 25 | float v[3]; 26 | } V3; 27 | 28 | typedef struct { 29 | float v[4]; 30 | } V4; 31 | 32 | void gl_M4_Id(M4 *a); 33 | int gl_M4_IsId(M4 *a); 34 | void gl_M4_Move(M4 *a,M4 *b); 35 | void gl_MoveV3(V3 *a,V3 *b); 36 | void gl_MulM4V3(V3 *a,M4 *b,V3 *c); 37 | void gl_MulM3V3(V3 *a,M4 *b,V3 *c); 38 | 39 | void gl_M4_MulV4(V4 * a,M4 *b,V4 * c); 40 | void gl_M4_InvOrtho(M4 *a,M4 b); 41 | void gl_M4_Inv(M4 *a,M4 *b); 42 | void gl_M4_Mul(M4 *c,M4 *a,M4 *b); 43 | void gl_M4_MulLeft(M4 *c,M4 *a); 44 | void gl_M4_Transpose(M4 *a,M4 *b); 45 | void gl_M4_Rotate(M4 *c,float t,int u); 46 | int gl_V3_Norm(V3 *a); 47 | 48 | V3 gl_V3_New(float x,float y,float z); 49 | V4 gl_V4_New(float x,float y,float z,float w); 50 | 51 | int gl_Matrix_Inv(float *r,float *m,int n); 52 | 53 | #endif /* __ZMATH__ */ 54 | -------------------------------------------------------------------------------- /src/tinygl/console.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | var cw = ConsoleWriter{}; 3 | 4 | extern fn console_write(data: [*]const u8, len: usize) void; 5 | //fn console_write(data:[*]const u8, len:usize) void { 6 | // std.log.info("{s}", .{data[0..len]}); 7 | //} 8 | 9 | // Implement a std.io.Writer backed by console_write() 10 | const ConsoleWriter = struct { 11 | const Writer = std.io.Writer( 12 | *ConsoleWriter, 13 | error{}, 14 | write, 15 | ); 16 | 17 | fn write( 18 | self: *ConsoleWriter, 19 | data: []const u8, 20 | ) error{}!usize { 21 | _ = self; 22 | console_write(data.ptr, data.len); 23 | return data.len; 24 | } 25 | 26 | pub fn writer(self: *ConsoleWriter) Writer { 27 | return .{ .context = self }; 28 | } 29 | }; 30 | 31 | pub fn getWriter() *ConsoleWriter { 32 | return &cw; 33 | } 34 | -------------------------------------------------------------------------------- /src/tinygl/tinygl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tinygl 6 | 15 | 16 | 17 | 18 | 19 | 37 | 38 | 39 |

40 | 41 |

43 |

44 | TinyGL portable software GL renderer. Cursor keys to rotate 45 |

46 | 47 |
https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer/ 48 | 49 | 50 | 51 | --------------------------------------------------------------------------------