├── VERSION ├── .vscode └── settings.json ├── msvs ├── ssj.rc ├── cell.rc ├── resource.h ├── resource1.h ├── resource2.h ├── lib │ ├── libmng.lib │ ├── zlib.lib │ └── libpng16.lib ├── neosphere.rc ├── spheredev.ico ├── spherical.ico ├── packages.config └── neosphere.sln ├── assets ├── system │ ├── icon.png │ ├── system.rfn │ ├── system.rws │ ├── pointer.png │ ├── up_arrow.png │ ├── down_arrow.png │ ├── oozaru │ │ ├── favicon.ico │ │ ├── assets │ │ │ ├── default.rfn │ │ │ ├── default.frag.glsl │ │ │ └── default.vert.glsl │ │ ├── oozaru.json │ │ ├── logo-dark.svg │ │ ├── logo-light.svg │ │ ├── index.html │ │ ├── scripts │ │ │ ├── utilities.js │ │ │ └── version.js │ │ ├── runtime │ │ │ ├── sphere-runtime.js │ │ │ ├── focus-target.js │ │ │ ├── pact.js │ │ │ └── logger.js │ │ └── styles.css │ ├── template │ │ ├── images │ │ │ └── justSaiyan.png │ │ ├── music │ │ │ └── vegetaSSj.ogg │ │ ├── Cellscript.js.tmpl │ │ └── scripts │ │ │ └── main.js.tmpl │ ├── system.ini │ ├── scripts │ │ ├── time.js │ │ ├── math.js │ │ ├── colors.js │ │ ├── graphics.js │ │ ├── named_parameters.js │ │ ├── timed_animation.js │ │ ├── timer.js │ │ ├── convert.js │ │ ├── audio.js │ │ ├── animation.js │ │ ├── oldsphere.js │ │ ├── screen.js │ │ ├── old_spriteset.js │ │ ├── input.js │ │ ├── clock.js │ │ ├── layers.js │ │ └── intro.js │ ├── cell_modules │ │ └── cell-runtime.js │ ├── shaders │ │ ├── default.frag.glsl │ │ └── default.vert.glsl │ ├── game_modules │ │ ├── sphere-runtime.js │ │ ├── focus-target.js │ │ └── pact.js │ └── runtime │ │ └── logger.js └── gdk-cp.bat ├── .gitattributes ├── desktop ├── mimetypes │ ├── neosphere.xml │ ├── application-x-sphere-s2gm.svg │ ├── application-x-sphere-sgm.svg │ └── application-x-sphere-spk.svg ├── neosphere.desktop └── sphere-icon.svg ├── .gitignore ├── license ├── dyad.txt ├── chakracore.txt └── tinydir.txt ├── vendor ├── civetweb │ └── sort.inl └── md5 │ └── md5.h ├── LICENSE.txt ├── CHECKLIST.md ├── src ├── ssj │ ├── help.h │ ├── host.h │ ├── utility.h │ ├── session.h │ ├── listing.h │ ├── ssj.h │ ├── backtrace.h │ ├── parser.h │ └── utility.c ├── cell │ ├── tileset.h │ ├── spk_writer.h │ ├── tool.h │ ├── cell.h │ ├── image.h │ ├── build.h │ ├── module.h │ ├── target.h │ ├── visor.h │ └── utility.h ├── shared │ ├── console.h │ ├── compress.h │ ├── version.h │ ├── posix.h │ ├── xoroshiro.h │ ├── unicode.h │ ├── console.c │ ├── encoding.h │ ├── lstring.h │ └── vector.h └── neosphere │ ├── profiler.h │ ├── obstruction.h │ ├── logger.h │ ├── atlas.h │ ├── windowstyle.h │ ├── table.h │ ├── script.h │ ├── debugger.h │ ├── module.h │ ├── legacy.h │ ├── animation.h │ ├── event_loop.h │ ├── pegasus.h │ ├── color.h │ ├── dispatch.h │ ├── source_map.h │ ├── blend_op.h │ ├── byte_array.h │ ├── vanilla.h │ ├── kev_file.h │ └── utility.h ├── INSTALL.md └── manpages └── neosphere.1 /VERSION: -------------------------------------------------------------------------------- 1 | 5.10.1 -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.rulers": [ 79, 119 ], 3 | } -------------------------------------------------------------------------------- /msvs/ssj.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/ssj.rc -------------------------------------------------------------------------------- /msvs/cell.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/cell.rc -------------------------------------------------------------------------------- /msvs/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/resource.h -------------------------------------------------------------------------------- /msvs/resource1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/resource1.h -------------------------------------------------------------------------------- /msvs/resource2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/resource2.h -------------------------------------------------------------------------------- /msvs/lib/libmng.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/lib/libmng.lib -------------------------------------------------------------------------------- /msvs/lib/zlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/lib/zlib.lib -------------------------------------------------------------------------------- /msvs/neosphere.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/neosphere.rc -------------------------------------------------------------------------------- /msvs/spheredev.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/spheredev.ico -------------------------------------------------------------------------------- /msvs/spherical.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/spherical.ico -------------------------------------------------------------------------------- /msvs/lib/libpng16.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/msvs/lib/libpng16.lib -------------------------------------------------------------------------------- /assets/system/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/icon.png -------------------------------------------------------------------------------- /assets/system/system.rfn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/system.rfn -------------------------------------------------------------------------------- /assets/system/system.rws: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/system.rws -------------------------------------------------------------------------------- /assets/system/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/pointer.png -------------------------------------------------------------------------------- /assets/system/up_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/up_arrow.png -------------------------------------------------------------------------------- /assets/gdk-cp.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | path %~dp0;%PATH% 3 | cd /d %USERPROFILE% 4 | echo. 5 | spherun --version 6 | -------------------------------------------------------------------------------- /assets/system/down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/down_arrow.png -------------------------------------------------------------------------------- /assets/system/oozaru/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/oozaru/favicon.ico -------------------------------------------------------------------------------- /assets/system/oozaru/assets/default.rfn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/oozaru/assets/default.rfn -------------------------------------------------------------------------------- /assets/system/template/images/justSaiyan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/template/images/justSaiyan.png -------------------------------------------------------------------------------- /assets/system/template/music/vegetaSSj.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spheredev/neosphere/HEAD/assets/system/template/music/vegetaSSj.ogg -------------------------------------------------------------------------------- /assets/system/system.ini: -------------------------------------------------------------------------------- 1 | Font=system.rfn 2 | WindowStyle=system.rws 3 | Arrow=pointer.png 4 | UpArrow=up_arrow.png 5 | DownArrow=down_arrow.png 6 | -------------------------------------------------------------------------------- /assets/system/scripts/time.js: -------------------------------------------------------------------------------- 1 | function Delay(milliseconds) 2 | { 3 | var start = GetTime(); 4 | while (start + milliseconds > GetTime()) { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /assets/system/oozaru/oozaru.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Oozaru", 3 | "publisher": "Where'd She Go?", 4 | "version": "0.7.1", 5 | "copyright": "© 2025 Where'd She Go?" 6 | } -------------------------------------------------------------------------------- /assets/system/scripts/math.js: -------------------------------------------------------------------------------- 1 | function DegreesToRadians(degrees) { 2 | return (degrees * Math.PI / 180.0); 3 | } 4 | 5 | function RadiansToDegrees(radians) { 6 | return (radians * 180.0 / Math.PI); 7 | } -------------------------------------------------------------------------------- /msvs/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /assets/system/scripts/colors.js: -------------------------------------------------------------------------------- 1 | Black = CreateColor(0, 0, 0, 255); 2 | White = CreateColor(255, 255, 255, 255); 3 | Red = CreateColor(255, 0, 0, 255); 4 | Green = CreateColor(0, 255, 0, 255); 5 | Blue = CreateColor(0, 0, 255, 255); 6 | Cyan = CreateColor(0, 255, 255, 255); 7 | Magenta = CreateColor(255, 0, 255, 255); 8 | Yellow = CreateColor(255, 255, 0, 255); 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /assets/system/scripts/graphics.js: -------------------------------------------------------------------------------- 1 | // by rizen 2 | // to be updated later 3 | 4 | 5 | function TraceRectangle(x, y, w, h, c) { 6 | --w; --h; 7 | Line(x, y, x+w, y, c); 8 | Line(x, y, x, y+h, c); 9 | Line(x+w, y, x+w, y+h, c); 10 | Line(x, y+h, x+w, y+h, c); 11 | } 12 | 13 | function TracePoly(x, y, c) { 14 | for (i = 1; i this.next_update) { 14 | this.animation.readNextFrame(); 15 | this.next_update = GetTime() + this.animation.getDelay(); 16 | } 17 | 18 | this.animation.drawFrame(x, y); 19 | } 20 | -------------------------------------------------------------------------------- /desktop/mimetypes/neosphere.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sphere game package 5 | 6 | 7 | 8 | 9 | 10 | 11 | Sphere game manifest 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /desktop/neosphere.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Name=neoSphere 4 | Comment=neoSphere is a lightweight 2D game engine which uses JavaScript for game coding. The engine boasts a high level of compatibility with the original Sphere RPG engine originally designed by Chad Austin, but includes many enhancements, such as a new JSON game manifest format and the ability to single-step through game code using the SSj command-line debugger. 5 | Exec=neosphere 6 | MimeType=application/x-sphere-spk;application/x-sphere-sgm; 7 | Icon=sphere-icon 8 | Terminal=false; 9 | Type=Application 10 | Categories=Application;Development; 11 | -------------------------------------------------------------------------------- /assets/system/scripts/timer.js: -------------------------------------------------------------------------------- 1 | function Timer() 2 | { 3 | this.start = GetTime(); 4 | this.total = 0; 5 | this.paused = false; 6 | } 7 | 8 | 9 | Timer.prototype.pause = function() { 10 | if (this.paused == false) { 11 | this.total += (GetTime() - this.start); 12 | this.paused = true; 13 | } 14 | } 15 | 16 | 17 | Timer.prototype.unpause = function() { 18 | if (this.paused == true) { 19 | this.start = GetTime(); 20 | this.paused = false; 21 | } 22 | } 23 | 24 | 25 | Timer.prototype.getMilliseconds = function() { 26 | if (this.paused) { 27 | return this.total; 28 | } else { 29 | return (this.total + GetTime() - this.start); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /assets/system/scripts/convert.js: -------------------------------------------------------------------------------- 1 | function ScreenX(mapx) 2 | { 3 | return MapToScreenX(0, mapx); 4 | } 5 | 6 | function ScreenY(mapy) 7 | { 8 | return MapToScreenY(0, mapy); 9 | } 10 | 11 | function TopX() 12 | { 13 | if (ScreenX(GetCameraX()) >= GetScreenWidth() / 2) 14 | return GetCameraX() - ScreenX(GetCameraX()); 15 | else 16 | return 0; 17 | } 18 | 19 | function TopY() 20 | { 21 | if (ScreenY(GetCameraY()) >= GetScreenHeight() / 2) 22 | return GetCameraY() - ScreenY(GetCameraY()); 23 | else 24 | return 0;} 25 | 26 | function MapX(screenx) 27 | { 28 | // return TopX() + MapToScreenX(0, screenx); 29 | return ScreenToMapX(0, screenx); 30 | } 31 | 32 | function MapY(screeny) 33 | { 34 | // return TopY() + MapToScreenY(0, screeny); 35 | return ScreenToMapY(0, screeny); 36 | } 37 | -------------------------------------------------------------------------------- /desktop/sphere-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | bin/ 3 | dep/ 4 | dist/ 5 | msw/ 6 | msw64/ 7 | msvs/debug/ 8 | msvs/debug64/ 9 | msvs/obj/ 10 | msvs/obj64/ 11 | msvs/packages/ 12 | msvs/profile/ 13 | msvs/profile64/ 14 | obj/ 15 | setup/*.exe 16 | 17 | # Code::Blocks cruft 18 | cbp/debug 19 | cbp/*.layout 20 | cbp/*.depends 21 | 22 | # Windows cruft 23 | Desktop.ini 24 | Thumbs.db 25 | ehthumbs.db 26 | $RECYCLE.BIN/ 27 | *.lnk 28 | 29 | # OS X cruft 30 | .DS_Store 31 | .AppleDouble 32 | .LSOverride 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | .AppleDB 37 | .AppleDesktop 38 | Network Trash Folder 39 | Temporary Items 40 | .apdisk 41 | 42 | # Windows Installer files 43 | *.cab 44 | *.msi 45 | *.msm 46 | *.msp 47 | 48 | # Visual Studio build cruft 49 | .vs/ 50 | *.VC.db 51 | *.sdf 52 | *.opensdf 53 | *.opendb 54 | *.suo 55 | *.user 56 | *.aps 57 | *.obj 58 | *.idb 59 | *.pdb 60 | *.tlog 61 | 62 | # SCons build cruft 63 | *.dblite 64 | -------------------------------------------------------------------------------- /assets/system/oozaru/logo-dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /assets/system/oozaru/logo-light.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /desktop/mimetypes/application-x-sphere-s2gm.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /desktop/mimetypes/application-x-sphere-sgm.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /desktop/mimetypes/application-x-sphere-spk.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /assets/system/scripts/audio.js: -------------------------------------------------------------------------------- 1 | var Sphere_Audio = new Object; 2 | 3 | with (Sphere_Audio) { 4 | Music = undefined; 5 | Sounds = new Array(16); 6 | CurrentSound = 0; 7 | } 8 | 9 | 10 | function ChangeMusic(filename) 11 | { 12 | with (Sphere_Audio) { 13 | if (Music != undefined) { 14 | Music.stop(); 15 | } 16 | 17 | if (filename.length != 0) { 18 | Music = LoadSound(filename); 19 | Music.play(true); 20 | } 21 | } 22 | } 23 | 24 | 25 | function PlaySound(filename) 26 | { 27 | with (Sphere_Audio) { 28 | 29 | // stop the current sound 30 | if (Sounds[CurrentSound] != undefined) { 31 | Sounds[CurrentSound].stop(); 32 | } 33 | 34 | // load new one 35 | Sounds[CurrentSound] = LoadSound(filename); 36 | Sounds[CurrentSound].play(false); 37 | 38 | // go to the next sound 39 | CurrentSound++; 40 | if (CurrentSound >= Sounds.length) { 41 | CurrentSound = 0; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /assets/system/scripts/animation.js: -------------------------------------------------------------------------------- 1 | function Animation(){ 2 | this.images = new Array(); 3 | this.timing = new Array(); 4 | this.tempTime = GetTime(); 5 | this.total = 0; 6 | } 7 | 8 | Animation.prototype.addImage = function(unknown, timing){ 9 | if(typeof unknown == "string"){ 10 | this.images[this.images.length] = LoadImage(unknown); 11 | } else { 12 | this.images[this.images.length] = unknown; 13 | } 14 | this.timing[this.timing.length] = this.total + timing; 15 | this.total += timing; 16 | } 17 | 18 | Animation.prototype.reset = function(){ 19 | this.tempTime = GetTime(); 20 | } 21 | 22 | Animation.prototype.blit = function(x, y){ 23 | while(GetTime() - this.tempTime >= this.total){ 24 | this.tempTime += this.total; 25 | } 26 | for(var i = 0; i < this.timing.length; i++){ 27 | if(GetTime() - this.tempTime < this.timing[i]){ 28 | this.images[i].blit(x, y); 29 | return; 30 | } 31 | } 32 | // Abort("Timing error, please please please tell fenix that his code sucks."); 33 | } -------------------------------------------------------------------------------- /license/dyad.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 rxi 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /assets/system/oozaru/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Oozaru: Sphere for the Web 5 | 6 | 11 | 12 | 13 | 14 | 21 |
22 |
23 | 24 |
25 |

26 |

27 | Oozaru JS Game Engine
28 | Click to Start 29 |

30 |
31 |
32 |
33 |

34 | 			
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /license/chakracore.txt: -------------------------------------------------------------------------------- 1 | ChakraCore 2 | The MIT License (MIT) 3 | 4 | Copyright (c) Microsoft Corporation 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /assets/system/scripts/oldsphere.js: -------------------------------------------------------------------------------- 1 | EvaluateSystemScript("colors.js"); 2 | 3 | 4 | function ClearScreen() 5 | { 6 | ApplyColorMask(Black); 7 | } 8 | 9 | 10 | function Delay(time) 11 | { 12 | var until = GetTime() + time; 13 | while (GetTime() < until) { 14 | } 15 | } 16 | 17 | 18 | // old font stuff 19 | var system_font = GetSystemFont(); 20 | 21 | 22 | function SetFont(filename) 23 | { 24 | system_font = LoadFont(filename); 25 | } 26 | 27 | function DrawText(x, y, text) 28 | { 29 | system_font.drawText(x, y, text); 30 | } 31 | 32 | function SetTextColor(color) 33 | { 34 | system_font.setColorMask(color); 35 | } 36 | 37 | function StringWidth(str) 38 | { 39 | system_font.getStringWidth(str); 40 | } 41 | 42 | function GetFontHeight() 43 | { 44 | system_font.getHeight(); 45 | } 46 | 47 | function DrawTextBox(x, y, w, h, offset, text) 48 | { 49 | system_font.drawTextBox(x, y, w, h, offset, text); 50 | } 51 | 52 | // old window stuff 53 | 54 | var system_windowstyle = GetSystemWindowStyle(); 55 | 56 | function SetWindowStyle(filename) 57 | { 58 | system_windowstyle = LoadWindowStyle(filename); 59 | } 60 | 61 | function DrawWindow(x,y, w, h) 62 | { 63 | system_windowstyle.drawWindow(x, y, w, h); 64 | } 65 | -------------------------------------------------------------------------------- /assets/system/scripts/screen.js: -------------------------------------------------------------------------------- 1 | EvaluateSystemScript("colors.js"); 2 | 3 | 4 | function ClearScreen() 5 | { 6 | ApplyColorMask(Black); 7 | } 8 | 9 | 10 | function FadeOut(milliseconds) 11 | { 12 | FadeToColor(milliseconds, Black); 13 | } 14 | 15 | 16 | function FadeIn(milliseconds) 17 | { 18 | FadeFromColor(milliseconds, Black); 19 | } 20 | 21 | 22 | function FadeToColor(msecs, clr) 23 | { 24 | var image = GrabImage(0, 0, GetScreenWidth(), GetScreenHeight()); 25 | var color = CreateColor(clr.red, clr.green, clr.blue, clr.alpha); 26 | 27 | var time = GetTime(); 28 | while (GetTime() - time < msecs) { 29 | color.alpha = (GetTime() - time) * 255 / msecs; 30 | image.blit(0, 0); 31 | ApplyColorMask(color); 32 | FlipScreen(); 33 | } 34 | 35 | color.alpha = 255; 36 | image.blit(0, 0); 37 | ApplyColorMask(color); 38 | FlipScreen(); 39 | 40 | image.blit(0, 0); 41 | } 42 | 43 | 44 | function FadeFromColor(msecs, clr) 45 | { 46 | var image = GrabImage(0, 0, GetScreenWidth(), GetScreenHeight()); 47 | var color = CreateColor(clr.red, clr.green, clr.blue, clr.alpha); 48 | 49 | var time = GetTime(); 50 | while (GetTime() - time < msecs) 51 | { 52 | color.alpha = 255 - (GetTime() - time) * 255 / msecs; 53 | image.blit(0, 0); 54 | ApplyColorMask(color); 55 | FlipScreen(); 56 | } 57 | 58 | color.alpha = 0; 59 | image.blit(0, 0); 60 | ApplyColorMask(color); 61 | FlipScreen(); 62 | 63 | image.blit(0, 0); 64 | } 65 | -------------------------------------------------------------------------------- /license/tinydir.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2016, tinydir authors: 2 | - Cong Xu 3 | - Lautis Sun 4 | - Baudouin Feildel 5 | - Andargor 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /vendor/civetweb/sort.inl: -------------------------------------------------------------------------------- 1 | /* Sort function. */ 2 | /* from https://github.com/bel2125/sort_r */ 3 | 4 | static void 5 | mg_sort(void *data, 6 | size_t elemcount, 7 | size_t elemsize, 8 | int (*compfunc)(const void *data1, const void *data2, void *userarg), 9 | void *userarg) 10 | { 11 | /* We cannot use qsort_r here. For a detailed reason, see 12 | * https://github.com/civetweb/civetweb/issues/1048#issuecomment-1047093014 13 | * https://stackoverflow.com/questions/39560773/different-declarations-of-qsort-r-on-mac-and-linux 14 | */ 15 | 16 | /* We use ShellSort here with this gap sequence: https://oeis.org/A102549 */ 17 | size_t A102549[9] = {1, 4, 10, 23, 57, 132, 301, 701, 1750}; 18 | size_t gap, i, j, k; 19 | int Aidx; 20 | void *tmp = alloca(elemsize); 21 | 22 | for (Aidx = 8; Aidx >= 0; Aidx--) { 23 | gap = A102549[Aidx]; 24 | if (gap > (elemcount / 2)) { 25 | continue; 26 | } 27 | for (i = 0; i < gap; i++) { 28 | for (j = i; j < elemcount; j += gap) { 29 | memcpy(tmp, (void *)((size_t)data + elemsize * j), elemsize); 30 | 31 | for (k = j; k >= gap; k -= gap) { 32 | void *cmp = (void *)((size_t)data + elemsize * (k - gap)); 33 | int cmpres = compfunc(cmp, tmp, userarg); 34 | if (cmpres > 0) { 35 | memcpy((void *)((size_t)data + elemsize * k), 36 | cmp, 37 | elemsize); 38 | } else { 39 | break; 40 | } 41 | } 42 | memcpy((void *)((size_t)data + elemsize * k), tmp, elemsize); 43 | } 44 | } 45 | } 46 | } 47 | 48 | /* end if sort.inl */ 49 | -------------------------------------------------------------------------------- /vendor/md5/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 3 | * MD5 Message-Digest Algorithm (RFC 1321). 4 | * 5 | * Homepage: 6 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 7 | * 8 | * Author: 9 | * Alexander Peslyak, better known as Solar Designer 10 | * 11 | * This software was written by Alexander Peslyak in 2001. No copyright is 12 | * claimed, and the software is hereby placed in the public domain. 13 | * In case this attempt to disclaim copyright and place the software in the 14 | * public domain is deemed null and void, then the software is 15 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 16 | * general public under the following terms: 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted. 20 | * 21 | * There's ABSOLUTELY NO WARRANTY, express or implied. 22 | * 23 | * See md5.c for more information. 24 | */ 25 | 26 | #ifdef HAVE_OPENSSL 27 | #include 28 | #elif !defined(_MD5_H) 29 | #define _MD5_H 30 | 31 | /* Any 32-bit or wider unsigned integer data type will do */ 32 | typedef unsigned int MD5_u32plus; 33 | 34 | typedef struct { 35 | MD5_u32plus lo, hi; 36 | MD5_u32plus a, b, c, d; 37 | unsigned char buffer[64]; 38 | MD5_u32plus block[16]; 39 | } MD5_CTX; 40 | 41 | extern void MD5_Init(MD5_CTX *ctx); 42 | extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); 43 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | neoSphere JavaScript game platform 2 | Copyright (c) 2015-2025, Where'd She Go? 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the name of Spherical nor the names of its contributors may be used 16 | to endorse or promote products derived from this software without specific 17 | prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /CHECKLIST.md: -------------------------------------------------------------------------------- 1 | neoSphere Release Checklist 2 | =========================== 3 | 4 | Prepare the Release 5 | ------------------- 6 | 7 | The following changes should be made in a separate commit. The first line of 8 | the commit message should be `neoSphere X.Y.Z`, where `X.Y.Z` is the version 9 | number of the release, and a tag `vX.Y.Z` should be created which points to 10 | this new commit. 11 | 12 | * Version number in `VERSION` 13 | * Version number in Win32 resources (`msvs/*.rc`) 14 | * Version number in `src/shared/version.h` 15 | * Version number and release date in manual pages (`manpages/*`) 16 | * Version number, release date, and changelog entries in `CHANGELOG.md` 17 | * Version number in `setup/neoSphereSetup.iss` 18 | 19 | 20 | Build the Release 21 | ----------------- 22 | 23 | * In Windows using Visual Studio 2022: 24 | - Run `git clean -xdf`, then build the following project configurations: 25 | + **neoSphere:** x64 Redist, x64 Console, Win32 Redist, Win32 Console 26 | + **Cell:** x64 Console, Win32 Console 27 | + **SSj:** x64 Console, Win32 Console 28 | + **Plugin:** AnyCPU Release 29 | - Compile `setup/neoSphereSetup.iss` using the latest version of Inno Setup 30 | - `neoSphereSetup-X.Y.Z-msw.exe` will be in `setup/` 31 | 32 | * Using a 64-bit installation of Ubuntu: 33 | - Run `make clean all dist` 34 | - `neosphere_X.Y.Z.tar.gz` will be in `dist/` 35 | 36 | 37 | Unleash the Beast! 38 | ------------------ 39 | 40 | * Drink a bunch of Monster drinks, at least 812 cans, and then... 41 | 42 | * Post a release to GitHub pointing at the new Git tag, and upload the 43 | following files built above: 44 | - `neoSphereSetup-X.Y.Z-msw.exe` 45 | - `neosphere-X.Y.Z.tar.gz` 46 | -------------------------------------------------------------------------------- /src/ssj/help.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_HELP_H_INCLUDED 34 | #define SSJ_HELP_H_INCLUDED 35 | 36 | void help_print (const char* command_name); 37 | 38 | #endif // !SSJ_HELP_H_INCLUDED 39 | -------------------------------------------------------------------------------- /src/ssj/host.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_HOST_H_INCLUDED 34 | #define SSJ_HOST_H_INCLUDED 35 | 36 | bool host_run (const path_t* game_path); 37 | 38 | #endif // !SSJ_HOST_H_INCLUDED 39 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | neoSphere Installation Instructions 2 | =================================== 3 | 4 | neoSphere compiles on all three major platforms (Windows, Linux, and macOS). 5 | This file contains instructions for how to compile and install neoSphere for 6 | Windows and Linux; macOS is more complicated and you will probably have to set 7 | up your own build harness. 8 | 9 | Before you get started, you will need to download the ChakraCore binaries for 10 | your platform here, as they are too large to include in the neoSphere 11 | repository: 12 | 13 | https://github.com/chakra-core/ChakraCore/releases 14 | 15 | Copy `ChakraCore.lib` (and for Windows builds, `ChakraCore.dll`) into `dep/lib` 16 | and the following header files into `dep/include`: 17 | 18 | * `ChakraCommon.h` 19 | * `ChakraCommonWindows.h` 20 | * `ChakraCore.h` 21 | * `ChakraCoreVersion.h` 22 | * `ChakraCoreWindows.h` 23 | * `ChakraDebug.h` 24 | 25 | 26 | Windows 27 | ------- 28 | 29 | You can build a complete 64-bit distribution of Sphere using the included 30 | Visual Studio solution `sphere.sln` located in `msvs/`. Visual Studio 2022 or 31 | later is required, which can be downloaded free of charge here: 32 | 33 | [Download Microsoft Visual Studio] 34 | (https://visualstudio.microsoft.com/) 35 | 36 | Allegro is available through NuGet, and static libraries and/or source are 37 | included for all other dependencies besides ChakraCore, so no additional 38 | software is required to build for Windows. 39 | 40 | 41 | Linux 42 | ----- 43 | 44 | neoSphere depends on Allegro 5, libmng, and zlib. All of these are usually 45 | available through your distribution's package manager. 46 | 47 | Once you have Allegro and other necessary dependencies installed, simply switch 48 | to the directory where you checked out Sphere and run `make` on the command 49 | line. This will build neoSphere and all GDK tools in `bin/`. To install Sphere 50 | on your system, follow this up with `sudo make install`. 51 | -------------------------------------------------------------------------------- /assets/system/template/Cellscript.js.tmpl: -------------------------------------------------------------------------------- 1 | /* 2 | * this is your game's Cellscript, used to instruct the Cell compiler how to 3 | * build your game. like a Sphere game, the Cellscript is written in 4 | * JavaScript, however with a different set of functions tailored for compiling 5 | * and packaging games. 6 | */ 7 | 8 | // describe the game we're building. everything in Sphere.Game gets written to 9 | // the game manifest (game.json) at the end of the build. 10 | 11 | describe({{ 12 | // target the Sphere v2 API. 13 | version: 2, 14 | 15 | // the lowest API level your code requires. if a game's targeted API level 16 | // isn't supported by the version of the engine used to run it, an error 17 | // message will be displayed to let the user know they need to upgrade. 18 | apiLevel: 3, 19 | 20 | name: "{0}", 21 | author: "{1}", 22 | summary: "{2}", 23 | resolution: '{3}', 24 | 25 | // the SphereFS path of the JavaScript module used to bootstrap the game. 26 | // if the main module has a callable default export, that export will be 27 | // called automatically. if the default export is a class, the class will 28 | // be instantiated using `new` and `.start()` will be called on the 29 | // resulting object. 30 | main: '@/scripts/main.js', 31 | }}); 32 | 33 | 34 | // this tells Cell which files to copy from the source tree when packaging the 35 | // game. see the Cell API documentation for more information. in general: 36 | // 37 | // install(destDir, files(filter[, recursive])); 38 | // 39 | // note: paths beginning with `@/` specify a file or directory within the 40 | // file system of the game being built. in Cell, a bare path, e.g. 41 | // `path/to/file`, is relative to the location of the Cellscript, not the 42 | // game's JSON manifest like in Sphere. 43 | 44 | install('scripts', files('scripts/*.js', true)); 45 | 46 | install('@/', files('icon.png')); 47 | install('images', files('images/*.png', true)); 48 | install('music', files('music/*.ogg', true)); 49 | -------------------------------------------------------------------------------- /assets/system/scripts/old_spriteset.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////// 2 | 3 | function Spriteset(spriteset) { 4 | this.spriteset = spriteset; 5 | } 6 | 7 | /////////////////////////////////////////////////////////// 8 | 9 | Spriteset.prototype.getFrame = function(direction_index, frame_index) { 10 | return (this.spriteset.images[this.spriteset.directions[direction_index].frames[frame_index].index]); 11 | } 12 | 13 | /////////////////////////////////////////////////////////// 14 | 15 | Spriteset.prototype.getNumFrames = function(direction_index){ 16 | // returns total frames for the direction index 17 | return (this.spriteset.directions[direction_index].frames.length); 18 | } 19 | 20 | /////////////////////////////////////////////////////////// 21 | 22 | Spriteset.getNumDirections = function() { 23 | return (this.spriteset.directions.length); 24 | } 25 | 26 | /////////////////////////////////////////////////////////// 27 | 28 | var OldLoadSpriteset = LoadSpriteset; 29 | var OldSetPersonDirection = SetPersonDirection; 30 | var OldGetPersonDirection = GetPersonDirection; 31 | 32 | /////////////////////////////////////////////////////////// 33 | 34 | function init_old_spriteset_code() { 35 | LoadSpriteset = function(filename) { 36 | return new Spriteset(OldLoadSpriteset(filename)); 37 | } 38 | 39 | SetPersonDirection = function(name, direction_index) { 40 | OldSetPersonDirection(name, GetPersonSpriteset(name).directions[direction_index].name); 41 | } 42 | 43 | GetPersonDirection = function(name) { 44 | var direction = OldGetPersonDirection(name); 45 | for (var i = 0, spriteset = GetPersonSpriteset(name); i < spriteset.directions.length; ++i) 46 | if (spriteset.directions[i].name == direction) 47 | return (i); 48 | return 0; 49 | } 50 | 51 | } 52 | 53 | /////////////////////////////////////////////////////////// 54 | 55 | init_old_spriteset_code(); 56 | 57 | /////////////////////////////////////////////////////////// 58 | -------------------------------------------------------------------------------- /assets/system/cell_modules/cell-runtime.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | // Sphere Runtime shared modules 34 | export { default as DataStream } from 'data-stream'; 35 | export { default as from } from 'from'; 36 | export { default as Logger } from 'logger'; 37 | export { default as Random } from 'random'; 38 | -------------------------------------------------------------------------------- /src/cell/tileset.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL__TILESET_H_INCLUDED 34 | #define CELL__TILESET_H_INCLUDED 35 | 36 | #include "image.h" 37 | #include "path.h" 38 | 39 | void build_tileset (const path_t* path, const image_t* image, int tile_width, int tile_height); 40 | 41 | #endif // !CELL__TILESET_H_INCLUDED 42 | -------------------------------------------------------------------------------- /src/ssj/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_UTILITY_H_INCLUDED 34 | #define SSJ_UTILITY_H_INCLUDED 35 | 36 | #include 37 | 38 | void* fslurp (const char* filename, size_t* out_size); 39 | void launch_url (const char* url); 40 | void stall (double time); 41 | 42 | #endif // !SSJ_UTILITY_H_INCLUDED 43 | -------------------------------------------------------------------------------- /src/shared/console.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_CONSOLE_H_INCLUDED 34 | #define SPHERE_CONSOLE_H_INCLUDED 35 | 36 | void console_init (int verbosity); 37 | void console_error (const char* fmt, ...); 38 | void console_log (int level, const char* fmt, ...); 39 | void console_warn (int level, const char* fmt, ...); 40 | 41 | #endif // !SPHERE_CONSOLE_H_INCLUDED 42 | -------------------------------------------------------------------------------- /src/shared/compress.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_COMPRESS_H_INCLUDED 34 | #define SPHERE_COMPRESS_H_INCLUDED 35 | 36 | #include 37 | 38 | void* z_deflate (const void* data, size_t size, int level, size_t *out_output_size); 39 | void* z_inflate (const void* data, size_t size, size_t max_inflate, size_t *out_output_size); 40 | 41 | #endif // !SPHERE_COMPRESS_H_INCLUDED 42 | -------------------------------------------------------------------------------- /assets/system/oozaru/assets/default.frag.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * Oozaru JavaScript game engine 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of miniSphere nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifdef GL_ES 34 | precision mediump float; 35 | #endif 36 | 37 | uniform sampler2D al_tex; 38 | uniform bool al_use_tex; 39 | 40 | varying vec4 auto_color; 41 | varying vec2 auto_texcoord; 42 | 43 | void main() 44 | { 45 | gl_FragColor = al_use_tex 46 | ? auto_color * texture2D(al_tex, auto_texcoord) 47 | : auto_color; 48 | } 49 | -------------------------------------------------------------------------------- /assets/system/oozaru/assets/default.vert.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * Oozaru JavaScript game engine 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of miniSphere nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | attribute vec4 al_color; 34 | attribute vec4 al_pos; 35 | attribute vec2 al_texcoord; 36 | 37 | uniform mat4 al_projview_matrix; 38 | 39 | varying vec4 auto_color; 40 | varying vec2 auto_texcoord; 41 | 42 | void main() 43 | { 44 | gl_Position = al_projview_matrix * al_pos; 45 | auto_color = al_color; 46 | auto_texcoord = al_texcoord; 47 | } 48 | -------------------------------------------------------------------------------- /src/neosphere/profiler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_PROFILER_H_INCLUDED 34 | #define NEOSPHERE_PROFILER_H_INCLUDED 35 | 36 | #include "jsal.h" 37 | 38 | void profiler_init (void); 39 | void profiler_uninit (void); 40 | bool profiler_enabled (void); 41 | js_ref_t* profiler_attach_to (js_ref_t* function, const char* description); 42 | 43 | #endif // !NEOSPHERE_PROFILER_H_INCLUDED 44 | -------------------------------------------------------------------------------- /src/ssj/session.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_SESSION_H_INCLUDED 34 | #define SSJ_SESSION_H_INCLUDED 35 | 36 | #include "inferior.h" 37 | #include "parser.h" 38 | 39 | typedef struct session session_t; 40 | 41 | session_t* session_new (inferior_t* inferior); 42 | void session_free (session_t* ses); 43 | void session_run (session_t* ses, bool run_now); 44 | 45 | #endif // !SSJ_SESSION_H_INCLUDED 46 | -------------------------------------------------------------------------------- /manpages/neosphere.1: -------------------------------------------------------------------------------- 1 | .TH NEOSPHERE 1 "2025-11-27" "neoSphere 5.10.1" "Sphere: the JavaScript game platform" 2 | .SH NAME 3 | neosphere \- lightweight JavaScript-powered game engine 4 | .SH SYNOPSIS 5 | .nh 6 | .na 7 | .TP 11 8 | .B neosphere 9 | [\fB\-\-fullscreen\fR | \fB\-\-windowed\fR] 10 | [\fB\-\-frameskip \fImaxframes\fR] 11 | .RI [ spkfile ] 12 | .RI [ arguments ] 13 | .ad 14 | .hy 15 | .SH DESCRIPTION 16 | neoSphere is a general-purpose game engine which uses JavaScript for game coding. 17 | It is a mostly compatible reimplementation of the Sphere game engine developed by Chad Austin (it is not a fork), boasting better performance and several new features and enhancements. 18 | .P 19 | When run with no arguments, neoSphere will launch with a menu allowing you to choose from a list of installed Sphere games. 20 | You can also pass the name of an 21 | .I .spk 22 | (Sphere game PacKage) file on the command line to launch that game directly. 23 | .P 24 | When developing a game, 25 | .BR spherun (1) 26 | should be used to launch the engine instead of 27 | .BR neosphere (1). 28 | This enables a number of features useful during game development, such as debugging using 29 | .BR ssj (1) 30 | and engine logging via the 31 | .B \-\-verbose 32 | option. 33 | .SH OPTIONS 34 | .B Important note: 35 | .br 36 | Unrecognized options to the 37 | .BR neophere (1) 38 | command will be silently ignored. 39 | .P 40 | .IP \fB\-\-fullscreen 41 | Starts neoSphere in fullscreen mode. This is the default when starting the engine using the 42 | .BR neosphere (1) 43 | command. 44 | .IP \fB\-\-windowed 45 | Starts neoSphere in windowed mode. 46 | .IP \fB\-\-frameskip 47 | neoSphere skips rendering frames when it can't keep up with a game's requested framerate. 48 | To ensure games remain playable, no more than 5 consecutive frames will be skipped by default. 49 | This option may be used to change the maximum to deal with slow machines; note, however, that games can override the value you provide. 50 | .SH BUGS 51 | Report any bugs found in neoSphere or the Sphere GDK tools to: 52 | .br 53 | .B Bruce Pascoe 54 | .SH "SEE ALSO" 55 | .BR spherun (1), 56 | .BR cell (1), 57 | .BR ssj (1) 58 | -------------------------------------------------------------------------------- /src/shared/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_VERSION_H_INCLUDED 34 | #define SPHERE_VERSION_H_INCLUDED 35 | 36 | #define SPHERE_ENGINE_NAME "neoSphere" 37 | #define SPHERE_COMPILER_NAME "Cell" 38 | #define SPHERE_DEBUGGER_NAME "SSj" 39 | 40 | #define SPHERE_VERSION "5.10.1" 41 | 42 | #define SPHERE_API_VERSION 2 43 | #define SPHERE_API_LEVEL 4 44 | #define SPHERE_API_LEVEL_STABLE 3 45 | 46 | #endif // !SPHERE_VERSION_H_INCLUDED 47 | -------------------------------------------------------------------------------- /src/cell/spk_writer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_SPK_WRITER_H_INCLUDED 34 | #define CELL_SPK_WRITER_H_INCLUDED 35 | 36 | #include "fs.h" 37 | 38 | typedef struct spk_writer spk_writer_t; 39 | 40 | spk_writer_t* spk_create (const char* filename); 41 | void spk_close (spk_writer_t* writer); 42 | bool spk_add_file (spk_writer_t* writer, fs_t* fs, const char* filename, const char* spk_pathname); 43 | 44 | #endif // !CELL_SPK_WRITER_H_INCLUDED 45 | -------------------------------------------------------------------------------- /src/cell/tool.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_TOOL_H_INCLUDED 34 | #define CELL_TOOL_H_INCLUDED 35 | 36 | #include "fs.h" 37 | #include "visor.h" 38 | 39 | typedef struct tool tool_t; 40 | 41 | tool_t* tool_new (const char* verb); 42 | tool_t* tool_ref (tool_t* tool); 43 | void tool_unref (tool_t* tool); 44 | bool tool_run (tool_t* tool, visor_t* visor, const fs_t* fs, const path_t* out_path, vector_t* in_paths); 45 | 46 | #endif // !CELL_TOOL_H_INCLUDED 47 | -------------------------------------------------------------------------------- /assets/system/shaders/default.frag.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifdef GL_ES 34 | precision mediump float; 35 | #endif 36 | 37 | // texturing parameters courtesy of Allegro 38 | uniform sampler2D al_tex; 39 | uniform bool al_use_tex; 40 | 41 | // input from vertex shader 42 | varying vec4 varying_color; 43 | varying vec2 varying_texcoord; 44 | 45 | void main() 46 | { 47 | gl_FragColor = al_use_tex 48 | ? varying_color * texture2D(al_tex, varying_texcoord) 49 | : varying_color; 50 | } 51 | -------------------------------------------------------------------------------- /assets/system/shaders/default.vert.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | // texture and transformation parameters courtesy of Allegro 34 | attribute vec4 al_color; 35 | attribute vec4 al_pos; 36 | attribute vec2 al_texcoord; 37 | uniform mat4 al_projview_matrix; 38 | 39 | // input to fragment shader 40 | varying vec4 varying_color; 41 | varying vec2 varying_texcoord; 42 | 43 | void main() 44 | { 45 | gl_Position = al_projview_matrix * al_pos; 46 | varying_color = al_color; 47 | varying_texcoord = al_texcoord; 48 | } 49 | -------------------------------------------------------------------------------- /assets/system/oozaru/scripts/utilities.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Oozaru: Sphere for the Web 3 | * Copyright (c) 2016-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | export 34 | function fullURL(url) 35 | { 36 | const anchor = document.createElement('a'); 37 | anchor.setAttribute("href", url); 38 | return anchor.cloneNode(false).href; 39 | } 40 | 41 | export 42 | function isConstructible(object) 43 | { 44 | const ctorProxy = new Proxy(object, { 45 | construct() { return {}; } 46 | }); 47 | try { 48 | Reflect.construct(ctorProxy, []); 49 | return true; 50 | } 51 | catch { 52 | return false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/neosphere/obstruction.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_OBSTRUCTION_H_INCLUDED 34 | #define NEOSPHERE_OBSTRUCTION_H_INCLUDED 35 | 36 | typedef struct obsmap obsmap_t; 37 | 38 | obsmap_t* obsmap_new (void); 39 | void obsmap_free (obsmap_t* obsmap); 40 | bool obsmap_add_line (obsmap_t* obsmap, rect_t line); 41 | bool obsmap_test_line (const obsmap_t* obsmap, rect_t line); 42 | bool obsmap_test_rect (const obsmap_t* obsmap, rect_t rect); 43 | 44 | #endif // !NEOSPHERE_OBSTRUCTION_H_INCLUDED 45 | -------------------------------------------------------------------------------- /src/ssj/listing.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_LISTING_H_INCLUDED 34 | #define SSJ_LISTING_H_INCLUDED 35 | 36 | typedef struct listing listing_t; 37 | 38 | listing_t* listing_new (const char* text); 39 | void listing_free (listing_t* it); 40 | int listing_cloc (const listing_t* it); 41 | const char* listing_get_line (const listing_t* it, int line_index); 42 | void listing_print (const listing_t* it, int lineno, int num_lines, int active_lineno); 43 | 44 | #endif // !SSJ_LISTING_H_INCLUDED 45 | -------------------------------------------------------------------------------- /src/cell/cell.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #include "posix.h" 34 | 35 | #include "jsal.h" 36 | #include "lstring.h" 37 | #include "path.h" 38 | #include "utility.h" 39 | #include "vector.h" 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #if !defined(_WIN32) 51 | #include 52 | #include 53 | #else 54 | #include 55 | #include 56 | #endif 57 | 58 | #include "version.h" 59 | -------------------------------------------------------------------------------- /src/neosphere/logger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_LOGGER_H_INCLUDED 34 | #define NEOSPHERE_LOGGER_H_INCLUDED 35 | 36 | typedef struct logger logger_t; 37 | 38 | logger_t* logger_new (const char* filename); 39 | logger_t* logger_ref (logger_t* logger); 40 | void logger_unref (logger_t* logger); 41 | bool logger_begin_block (logger_t* logger, const char* title); 42 | void logger_end_block (logger_t* logger); 43 | void logger_write (logger_t* logger, const char* prefix, const char* text); 44 | 45 | #endif // !NEOSPHERE_LOGGER_H_INCLUDED 46 | -------------------------------------------------------------------------------- /src/shared/posix.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_POSIX_H_INCLUDED 34 | #define SPHERE_POSIX_H_INCLUDED 35 | 36 | #if defined(_MSC_VER) 37 | 38 | #if !defined(_CRT_NONSTDC_NO_WARNINGS) 39 | #define _CRT_NONSTDC_NO_WARNINGS 40 | #endif 41 | 42 | #if !defined(_CRT_SECURE_NO_WARNINGS) 43 | #define _CRT_SECURE_NO_WARNINGS 44 | #endif 45 | 46 | #if !defined(_USE_MATH_DEFINES) 47 | #define _USE_MATH_DEFINES 48 | #endif 49 | 50 | #define strcasecmp stricmp 51 | #define strtok_r strtok_s 52 | 53 | #if _MSC_VER < 1900 54 | #define snprintf _snprintf 55 | #endif 56 | 57 | #endif 58 | 59 | #endif // !SPHERE_POSIX_H_INCLUDED 60 | -------------------------------------------------------------------------------- /assets/system/scripts/input.js: -------------------------------------------------------------------------------- 1 | function GetString(x, y, font, max_chars) 2 | { 3 | var background = GrabImage(0, 0, GetScreenWidth(), GetScreenHeight()); 4 | 5 | var str = ""; 6 | var cursor_position = 0; 7 | 8 | // No max given, default to 256 9 | if (typeof(max_chars) != "number") { 10 | max_chars = 256; 11 | } 12 | 13 | while (true) { 14 | 15 | background.blit(0, 0); 16 | font.drawText(x, y, str); 17 | font.drawText(x - 1 + font.getStringWidth(str.slice(0, cursor_position), cursor_position), y, (Math.sin(GetTime()>>8) > 0) ? "|" : " "); 18 | 19 | FlipScreen(); 20 | 21 | while (AreKeysLeft()) { 22 | 23 | var key = GetKey(); 24 | switch (key) { 25 | 26 | // done 27 | case KEY_ENTER: { 28 | return str; 29 | } 30 | 31 | // backspace 32 | case KEY_BACKSPACE: { 33 | if (str != "") { 34 | str = str.slice(0, cursor_position - 1) + str.slice(cursor_position + 1); 35 | } 36 | if (cursor_position > 0) 37 | cursor_position -= 1; 38 | break; 39 | } 40 | 41 | // delete 42 | case KEY_DELETE : { 43 | if (str != "") { 44 | str = str.slice(0, cursor_position ) + str.slice(cursor_position +1 ); 45 | } 46 | 47 | break; 48 | } 49 | 50 | case KEY_LEFT: { 51 | if (cursor_position > 0) 52 | cursor_position -= 1; 53 | break; 54 | } 55 | 56 | case KEY_RIGHT: { 57 | if (cursor_position <= str.length - 1) 58 | cursor_position += 1; 59 | break; 60 | } 61 | 62 | case KEY_HOME: { 63 | cursor_position = 0; 64 | break; 65 | } 66 | 67 | case KEY_END: { 68 | cursor_position = str.length; 69 | break; 70 | } 71 | 72 | default: { 73 | var shift = IsKeyPressed(KEY_SHIFT); 74 | if (GetKeyString(key, shift) != "" && (str.length < max_chars)) { 75 | str = str.slice(0, cursor_position) + GetKeyString(key, shift) + str.slice(cursor_position); 76 | cursor_position += 1; 77 | } 78 | } 79 | } // end switch 80 | 81 | } // end while (keys left) 82 | 83 | } // end while (true) 84 | } 85 | -------------------------------------------------------------------------------- /assets/system/scripts/clock.js: -------------------------------------------------------------------------------- 1 | // Game clock object by WIP 2 | 3 | // Modified slightly by tunginobi to correctly show time 4 | // after the hours, minutes and/or seconds have been 5 | // changed or loaded. 6 | 7 | // This is a function that will create a game clock object. 8 | // Just use the function clock.getTime() and it will 9 | // return an object with seconds, minutes and hours 10 | // Note: You must start the clock before it will give 11 | // the correct time 12 | 13 | function Clock() 14 | { 15 | this.started = 0; 16 | this.seconds = 0; 17 | this.minutes = 0; 18 | this.hours = 0; 19 | } 20 | 21 | // Example: var GameClock = new Clock(); 22 | 23 | Clock.prototype.start = function() 24 | { 25 | this.started = GetTime(); 26 | } 27 | 28 | // Example: GameClock.start(); 29 | 30 | Clock.prototype.getTime = function(a) 31 | { 32 | var current = GetTime() - this.started; 33 | var secs = ""; 34 | var mins = ""; 35 | var hours = ""; 36 | 37 | if (Math.floor((current)/1000 + this.seconds) % 60 < 10) 38 | secs += "0"; 39 | secs += Math.floor((current)/1000 + this.seconds) % 60; 40 | 41 | if (Math.floor((current + this.seconds * 1000)/1000/60 + this.minutes) % 60 < 10) 42 | mins += "0"; 43 | mins += Math.floor((current + this.seconds * 1000)/1000/60 + this.minutes) % 60; 44 | 45 | if (Math.floor((current + this.seconds * 1000 + this.minutes * 60 * 1000)/1000/60/60 + this.hours) % 60 < 100) 46 | hours += "0"; 47 | if (Math.floor((current + this.seconds * 1000 + this.minutes * 60 * 1000)/1000/60/60 + this.hours) % 60 < 10) 48 | hours += "0"; 49 | hours += Math.floor((current + this.seconds * 1000 + this.minutes * 60 * 1000)/1000/60/60 + this.hours) % 60; 50 | 51 | if (a == true) 52 | return [hours, mins, secs]; 53 | else 54 | return hours + ":" + mins + ":" + secs; 55 | } 56 | 57 | // Example: 58 | // font.drawText(10, 10, clock.getTime()); 59 | // 60 | // Every time you want to start keeping track of time, 61 | // start the clock. If you are loading a game, you should 62 | // load the time into the clock object. That way, it can keep 63 | // correct time with a loaded game. 64 | // 65 | // clock.getTime(true) returns the time in an array 66 | // Example: 67 | // var time = clock.getTime(true); 68 | // font.drawText(10, 10, time[0]); // Hours 69 | // font.drawText(10, 20, time[1]); // Minutes 70 | // font.drawText(10, 30, time[2]); // Seconds 71 | -------------------------------------------------------------------------------- /src/neosphere/atlas.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_ATLAS_H_INCLUDED 34 | #define NEOSPHERE_ATLAS_H_INCLUDED 35 | 36 | #include "image.h" 37 | 38 | typedef struct atlas atlas_t; 39 | 40 | atlas_t* atlas_new (int num_images, int max_width, int max_height); 41 | void atlas_free (atlas_t* atlas); 42 | image_t* atlas_image (const atlas_t* atlas); 43 | rect_t atlas_xy (const atlas_t* atlas, int image_index); 44 | image_t* atlas_load (atlas_t* atlas, file_t* file, int index, int width, int height); 45 | void atlas_lock (atlas_t* atlas, bool keep_contents); 46 | void atlas_unlock (atlas_t* atlas); 47 | 48 | #endif // !NEOSPHERE_ATLAS_H_INCLUDED 49 | -------------------------------------------------------------------------------- /src/neosphere/windowstyle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_WINDOWSTYLE_H_INCLUDED 34 | #define NEOSPHERE_WINDOWSTYLE_H_INCLUDED 35 | 36 | #include "color.h" 37 | 38 | typedef struct windowstyle windowstyle_t; 39 | 40 | windowstyle_t* winstyle_load (const char* filename); 41 | windowstyle_t* winstyle_ref (windowstyle_t* it); 42 | void winstyle_unref (windowstyle_t* it); 43 | color_t winstyle_get_mask (const windowstyle_t* it); 44 | void winstyle_set_mask (windowstyle_t* it, color_t color); 45 | void winstyle_draw (windowstyle_t* it, int x, int y, int width, int height); 46 | 47 | #endif // !NEOSPHERE_WINDOWSTYLE_H_INCLUDED 48 | -------------------------------------------------------------------------------- /assets/system/template/scripts/main.js.tmpl: -------------------------------------------------------------------------------- 1 | /* 2 | * {0} 3 | * (c) {1} {2} 4 | */ 5 | 6 | import {{ Music, Prim, Task, Random }} from 'sphere-runtime'; 7 | 8 | export default 9 | class MyGame extends Task 10 | {{ 11 | constructor() 12 | {{ 13 | super(); // call the `Task` constructor 14 | }} 15 | 16 | async on_startUp() 17 | {{ 18 | /* 19 | * put code in here to initialize your game on startup--setting up 20 | * data, loading resources, etc. use `this` to associate things with 21 | * the Game object. 22 | */ 23 | 24 | this.image = await Texture.fromFile('@/images/justSaiyan.png'); 25 | this.x = 0; 26 | this.y = 0; 27 | this.xVel = 1; 28 | this.yVel = 1; 29 | 30 | // avoid boredom by playing some background music! 31 | await Music.play('@/music/vegetaSSj.ogg'); 32 | }} 33 | 34 | on_update() 35 | {{ 36 | /* 37 | * put code in here to update game state, for example moving character 38 | * sprites or updating animations. this will be called once per frame 39 | * at a rate determined by the value of screen.frameRate. 40 | */ 41 | 42 | this.x += this.xVel; 43 | this.y += this.yVel; 44 | if (this.x <= 0) {{ 45 | this.x = 0; 46 | this.xVel = 1; 47 | }} 48 | else if (this.x >= Surface.Screen.width - this.image.width) {{ 49 | this.x = Surface.Screen.width - this.image.width; 50 | this.xVel = -1; 51 | }} 52 | if (this.y <= 0) {{ 53 | this.y = 0; 54 | this.yVel = 1; 55 | }} 56 | else if (this.y >= Surface.Screen.height - this.image.height) {{ 57 | this.y = Surface.Screen.height - this.image.height; 58 | this.yVel = -1; 59 | }} 60 | }} 61 | 62 | on_render() 63 | {{ 64 | /* 65 | * put code in here to draw things each frame. don't do anything 66 | * other than drawing-related things here, as render calls can be 67 | * skipped and are not guaranteed to match the frame rate. 68 | */ 69 | 70 | const sW = Surface.Screen.width; 71 | const sH = Surface.Screen.height; 72 | 73 | Prim.fill(Surface.Screen, Color.DodgerBlue); 74 | Prim.drawSolidEllipse(Surface.Screen, sW / 2, sH / 2, sW / 4, sH / 4, Color.Chartreuse, Color.DarkGreen); 75 | Prim.drawEllipse(Surface.Screen, sW / 2, sH / 2, sW / 4, sH / 4, Color.Black); 76 | 77 | Prim.blit(Surface.Screen, this.x, this.y, this.image); 78 | Prim.drawRectangle(Surface.Screen, this.x, this.y, this.image.width, this.image.height, 2, Color.Black); 79 | }} 80 | }} 81 | -------------------------------------------------------------------------------- /src/cell/image.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_IMAGE_H_INCLUDED 34 | #define CELL_IMAGE_H_INCLUDED 35 | 36 | #include 37 | 38 | #include "fs.h" 39 | 40 | typedef struct image image_t; 41 | 42 | image_t* image_load (const fs_t* fs, const char* pathname); 43 | void image_free (image_t* image); 44 | int image_height (const image_t* image); 45 | uint32_t* image_bitmap (const image_t* image, size_t *out_size); 46 | int image_width (const image_t* image); 47 | bool image_save (const image_t* image, const fs_t* fs, const char* filename); 48 | image_t* image_slice (const image_t* image, int x, int y, int width, int height); 49 | 50 | #endif // !CELL_IMAGE_H_INCLUDED 51 | -------------------------------------------------------------------------------- /src/ssj/ssj.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifdef _MSC_VER 34 | #define _USE_MATH_DEFINES 35 | #endif 36 | 37 | #include "posix.h" 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #if !defined(_WIN32) 50 | #include 51 | #include 52 | #include 53 | #else 54 | #include 55 | #endif 56 | 57 | #include "lstring.h" 58 | #include "path.h" 59 | #include "vector.h" 60 | 61 | #include "version.h" 62 | 63 | bool launch_game (path_t* game_path); 64 | char* strnewf (const char* fmt, ...); 65 | -------------------------------------------------------------------------------- /src/neosphere/table.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_TABLE_H_INCLUDED 34 | #define NEOSPHERE_TABLE_H_INCLUDED 35 | 36 | #include 37 | 38 | typedef struct table table_t; 39 | 40 | table_t* table_new (const char* title, bool has_totals); 41 | void table_free (table_t* it); 42 | int table_add_column (table_t* it, const char* name_fmt, ...); 43 | void table_add_number (table_t* it, int column, long long value); 44 | void table_add_percentage (table_t* it, int column, double value); 45 | void table_add_text (table_t* it, int column, const char* text); 46 | void table_print (const table_t* it); 47 | 48 | #endif // !NEOSPHERE_TABLE_H_INCLUDED 49 | -------------------------------------------------------------------------------- /src/shared/xoroshiro.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_XOROSHIRO_H_INCLUDED 34 | #define SPHERE_XOROSHIRO_H_INCLUDED 35 | 36 | #include 37 | #include 38 | 39 | typedef struct xoro xoro_t; 40 | 41 | xoro_t* xoro_new (uint64_t seed); 42 | xoro_t* xoro_ref (xoro_t* xoro); 43 | void xoro_unref (xoro_t* xoro); 44 | void xoro_get_state (xoro_t* xoro, char* buffer); 45 | bool xoro_set_state (xoro_t* xoro, const char* snapshot); 46 | double xoro_gen_double (xoro_t* xoro); 47 | uint64_t xoro_gen_uint (xoro_t* xoro); 48 | void xoro_jump (xoro_t* xoro); 49 | void xoro_reseed (xoro_t* xoro, uint64_t seed); 50 | 51 | #endif // !SPHERE_XOROSHIRO_H_INCLUDED 52 | -------------------------------------------------------------------------------- /src/neosphere/script.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_SCRIPT_H_INCLUDED 34 | #define NEOSPHERE_SCRIPT_H_INCLUDED 35 | 36 | typedef struct script script_t; 37 | 38 | void scripts_init (void); 39 | void scripts_uninit (void); 40 | bool script_eval (const char* filename); 41 | script_t* script_new (const lstring_t* script, const char* fmt_name, ...); 42 | script_t* script_new_function (int stack_index); 43 | script_t* script_new_method (int stack_index); 44 | script_t* script_ref (script_t* script); 45 | void script_unref (script_t* script); 46 | void script_run (script_t* script, bool allow_reentry); 47 | 48 | #endif // !NEOSPHERE_SCRIPT_H_INCLUDED 49 | -------------------------------------------------------------------------------- /src/shared/unicode.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_UNICODE_H_INCLUDED 34 | #define SPHERE_UNICODE_H_INCLUDED 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | typedef 41 | enum utf8_ret 42 | { 43 | UTF8_OK, 44 | UTF8_CODEPOINT, 45 | UTF8_CONTINUE, 46 | UTF8_ERROR, 47 | UTF8_RETRY, 48 | } utf8_ret_t; 49 | 50 | typedef struct utf8_decode utf8_decode_t; 51 | 52 | utf8_decode_t* utf8_decode_start (bool strict); 53 | utf8_ret_t utf8_decode_end (utf8_decode_t* cx); 54 | utf8_ret_t utf8_decode_next (utf8_decode_t* cx, uint8_t byte, uint32_t *out_codepoint); 55 | size_t utf8_emit (uint32_t codepoint, uint8_t* *p_ptr); 56 | 57 | #endif // !SPHERE_UNICODE_H_INCLUDED 58 | -------------------------------------------------------------------------------- /src/neosphere/debugger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_DEBUGGER_H_INCLUDED 34 | #define NEOSPHERE_DEBUGGER_H_INCLUDED 35 | 36 | #include "color.h" 37 | #include "ki.h" 38 | 39 | typedef 40 | enum ssj_mode 41 | { 42 | SSJ_OFF, 43 | SSJ_PASSIVE, 44 | SSJ_ACTIVE, 45 | } ssj_mode_t; 46 | 47 | void debugger_init (ssj_mode_t ssj_mode, bool allow_remote); 48 | void debugger_uninit (void); 49 | void debugger_update (void); 50 | bool debugger_attached (void); 51 | color_t debugger_color (void); 52 | const char* debugger_compiler (void); 53 | const char* debugger_name (void); 54 | void debugger_log (const char* text, ki_log_op_t op, bool use_console); 55 | 56 | #endif // !NEOSPHERE_DEBUGGER_H_INCLUDED 57 | -------------------------------------------------------------------------------- /assets/system/oozaru/runtime/sphere-runtime.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | export { default as Console } from './console.js'; 34 | export { default as FocusTarget } from './focus-target.js'; 35 | export { default as Music } from './music.js'; 36 | export { default as Pact } from './pact.js'; 37 | export { default as Prim } from './prim.js'; 38 | export { default as Scene } from './scene.js'; 39 | export { default as Task, default as Thread } from './task.js'; 40 | export { default as Tween, Easing } from './tween.js'; 41 | 42 | // Sphere Runtime shared modules 43 | export { default as DataStream } from './data-stream.js'; 44 | export { default as from, Query } from './from.js'; 45 | export { default as Logger } from './logger.js'; 46 | export { default as Random } from './random.js'; 47 | -------------------------------------------------------------------------------- /assets/system/game_modules/sphere-runtime.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | export default 34 | class RT 35 | { 36 | static get Version() { return 0; } 37 | } 38 | 39 | export { default as Console } from 'console'; 40 | export { default as FocusTarget } from 'focus-target'; 41 | export { default as Music } from 'music'; 42 | export { default as Pact } from 'pact'; 43 | export { default as Prim } from 'prim'; 44 | export { default as Scene } from 'scene'; 45 | export { default as Task, default as Thread } from 'task'; 46 | export { default as Tween, Easing } from 'tween'; 47 | 48 | // Sphere Runtime shared modules 49 | export { default as DataStream } from 'data-stream'; 50 | export { default as from, Query } from 'from'; 51 | export { default as Logger } from 'logger'; 52 | export { default as Random } from 'random'; 53 | -------------------------------------------------------------------------------- /src/neosphere/module.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_MODULE_H_INCLUDED 34 | #define NEOSPHERE_MODULE_H_INCLUDED 35 | 36 | typedef struct module_ref module_ref_t; 37 | 38 | typedef 39 | enum module_type 40 | { 41 | MODULE_COMMONJS, 42 | MODULE_ESM, 43 | MODULE_JSON, 44 | } module_type_t; 45 | 46 | void modules_init (int api_level); 47 | bool module_eval (const char* specifier, bool node_compatible); 48 | module_ref_t* module_resolve (const char* specifier, const char* importer, bool node_compatible); 49 | void module_free (module_ref_t* it); 50 | const char* module_pathname (const module_ref_t* it); 51 | module_type_t module_type (const module_ref_t* it); 52 | bool module_exec (module_ref_t* it); 53 | 54 | #endif // !NEOSPHERE_MODULE_H_INCLUDED 55 | -------------------------------------------------------------------------------- /src/neosphere/legacy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_LEGACY_H_INCLUDED 34 | #define NEOSPHERE_LEGACY_H_INCLUDED 35 | 36 | typedef struct socket_v1 socket_v1_t; 37 | 38 | socket_v1_t* socket_v1_new_client (const char* hostname, int port); 39 | socket_v1_t* socket_v1_new_server (int port); 40 | socket_v1_t* socket_v1_ref (socket_v1_t* it); 41 | void socket_v1_unref (socket_v1_t* it); 42 | bool socket_v1_connected (socket_v1_t* it); 43 | void socket_v1_close (socket_v1_t* it); 44 | int socket_v1_bytes_avail (const socket_v1_t* it); 45 | int socket_v1_read (socket_v1_t* it, void* buffer, int num_bytes); 46 | void socket_v1_write (socket_v1_t* it, const void* data, int num_bytes); 47 | 48 | #endif // !NEOSPHERE_LEGACY_H_INCLUDED 49 | -------------------------------------------------------------------------------- /src/ssj/backtrace.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_BACKTRACE_H_INCLUDED 34 | #define SSJ_BACKTRACE_H_INCLUDED 35 | 36 | typedef struct backtrace backtrace_t; 37 | 38 | backtrace_t* backtrace_new (void); 39 | void backtrace_free (backtrace_t* obj); 40 | int backtrace_len (const backtrace_t* obj); 41 | const char* backtrace_get_call_name (const backtrace_t* obj, int index); 42 | const char* backtrace_get_filename (const backtrace_t* obj, int index); 43 | int backtrace_get_linenum (const backtrace_t* obj, int index); 44 | bool backtrace_add (backtrace_t* obj, const char* call_name, const char* filename, int line_no); 45 | void backtrace_print (const backtrace_t* obj, int active_frame, bool show_all); 46 | 47 | #endif // !SSJ_BACKTRACE_H_INCLUDED 48 | -------------------------------------------------------------------------------- /src/cell/build.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_BUILD_H_INCLUDED 34 | #define CELL_BUILD_H_INCLUDED 35 | 36 | enum cell_class 37 | { 38 | CELL_DIR_STREAM = 300, 39 | CELL_FILE_STREAM, 40 | CELL_IMAGE, 41 | CELL_RNG, 42 | CELL_TARGET, 43 | CELL_TEXT_DEC, 44 | CELL_TEXT_ENC, 45 | CELL_TOOL, 46 | }; 47 | 48 | typedef struct build build_t; 49 | 50 | build_t* build_new (const path_t* source_path, const path_t* out_path, bool debuggable); 51 | void build_free (build_t* build); 52 | bool build_clean (build_t* build); 53 | bool build_eval (build_t* build, const char* filename); 54 | bool build_init_dir (build_t* build); 55 | bool build_package (build_t* build, const char* filename, bool rebuilding); 56 | bool build_run (build_t* build, bool rebuilding); 57 | 58 | #endif // !CELL_BUILD_H_INCLUDED 59 | -------------------------------------------------------------------------------- /src/cell/module.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_MODULE_H_INCLUDED 34 | #define CELL_MODULE_H_INCLUDED 35 | 36 | #include "fs.h" 37 | 38 | typedef struct module_ref module_ref_t; 39 | 40 | typedef 41 | enum module_type 42 | { 43 | MODULE_COMMONJS, 44 | MODULE_ESM, 45 | MODULE_JSON, 46 | } module_type_t; 47 | 48 | void modules_init (fs_t* fs, bool strict_imports); 49 | bool module_eval (const char* specifier, bool node_compatible); 50 | module_ref_t* module_resolve (const char* specifier, const char* importer, bool node_compatible); 51 | void module_free (module_ref_t* it); 52 | const char* module_pathname (const module_ref_t* it); 53 | module_type_t module_type (const module_ref_t* it); 54 | bool module_exec (module_ref_t* it); 55 | 56 | #endif // !CELL_MODULE_H_INCLUDED 57 | -------------------------------------------------------------------------------- /assets/system/game_modules/focus-target.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | import from from 'from'; 34 | 35 | let focusQueue = []; 36 | 37 | export default 38 | class FocusTarget 39 | { 40 | get [Symbol.toStringTag]() { return 'FocusTarget'; } 41 | 42 | constructor(options) 43 | { 44 | options = Object.assign({}, { 45 | priority: 0.0, 46 | }, options); 47 | 48 | this._priority = options.priority; 49 | } 50 | 51 | get hasFocus() 52 | { 53 | return focusQueue[focusQueue.length - 1] === this; 54 | } 55 | 56 | dispose() 57 | { 58 | this.yield(); 59 | } 60 | 61 | takeFocus() 62 | { 63 | focusQueue = from(focusQueue) 64 | .without(this) 65 | .plus(this) 66 | .ascending(it => it._priority) 67 | .toArray(); 68 | } 69 | 70 | yield() 71 | { 72 | focusQueue = from(focusQueue) 73 | .without(this) 74 | .toArray(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/neosphere/animation.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_ANIMATION_H_INCLUDED 34 | #define NEOSPHERE_ANIMATION_H_INCLUDED 35 | 36 | #if defined(NEOSPHERE_MNG_SUPPORT) 37 | 38 | typedef struct animation animation_t; 39 | 40 | animation_t* animation_new (const char* path); 41 | animation_t* animation_ref (animation_t* anim); 42 | void animation_unref (animation_t* anim); 43 | int animation_delay (const animation_t* anim); 44 | image_t* animation_frame (const animation_t* anim); 45 | int animation_height (const animation_t* anim); 46 | int animation_num_frames (const animation_t* anim); 47 | int animation_width (const animation_t* anim); 48 | bool animation_update (animation_t* anim); 49 | 50 | #endif 51 | 52 | #endif // !NEOSPHERE_ANIMATION_H_INCLUDED 53 | -------------------------------------------------------------------------------- /assets/system/scripts/layers.js: -------------------------------------------------------------------------------- 1 | var gLayerTileDetails = new Array(); 2 | 3 | /** 4 | returns the index of the tile 'name' 5 | returns -1 if the tile doesn't exist 6 | */ 7 | function GetTileIndex(name) { 8 | var index = -1; 9 | for (var i = 0; i < GetNumTiles(); i++) { 10 | if (GetTileName(i) == name) { 11 | index = i; 12 | break; 13 | } 14 | } 15 | return index; 16 | } 17 | 18 | 19 | /** 20 | returns the index of the layer 'layer_name' 21 | returns -1 if the layer doesn't exist 22 | */ 23 | function GetLayerIndex(layer_name) { 24 | var index = -1; 25 | for (var i = 0; i < GetNumLayers(); i++) { 26 | if (GetLayerName(i) == layer_name) { 27 | index = i; 28 | break; 29 | } 30 | } 31 | return index; 32 | } 33 | 34 | function ConvertLayer(layer_index, tile_index, dont_remember_details) { 35 | // init 36 | if (!dont_remember_details) { 37 | gLayerTileDetails[layer_index] = new Object(); 38 | gLayerTileDetails[layer_index].tile_index = tile_index; 39 | gLayerTileDetails[layer_index].tiles = new Array(GetLayerWidth(layer_index)); 40 | for (var i = 0; i < GetLayerWidth(layer_index); ++i) 41 | gLayerTileDetails[layer_index].tiles[i] = new Array(GetLayerHeight(layer_index)); 42 | } 43 | 44 | // store and change tile 45 | for (var j = 0; j < GetLayerWidth(layer_index); ++j) 46 | { 47 | for (var k = 0; k < GetLayerHeight(layer_index); ++k) { 48 | if (!dont_remember_details) 49 | gLayerTileDetails[layer_index].tiles[j][k] = GetTile(j, k, layer_index); 50 | SetTile(j, k, layer_index, tile_index); 51 | } 52 | } 53 | } 54 | 55 | function ClearLayerTileDetails(layer_index) { 56 | gLayerTileDetails[layer_index] = new Object(); 57 | gLayerTileDetails[layer_index].tiles = undefined; 58 | gLayerTileDetails[layer_index].tile_index = undefined; 59 | } 60 | 61 | function RevertLayer(layer_index) { 62 | for (var j = 0; j < GetLayerWidth(layer_index); ++j) 63 | { 64 | for (var k = 0; k < GetLayerHeight(layer_index); ++k) { 65 | SetTile(j, k, layer_index, gLayerTileDetails[layer_index].tiles[j][k]); 66 | } 67 | } 68 | ClearLayerTileDetails(layer_index); 69 | } 70 | 71 | function IsLayerConverted(layer_index) { 72 | return (gLayerTileDetails[layer_index] != undefined && gLayerTileDetails[layer_index].tile_index != undefined); 73 | } 74 | 75 | function ToggleLayer(layer_index, tile_index) { 76 | if (IsLayerConverted(layer_index)) 77 | RevertLayer(layer_index); 78 | else 79 | ConvertLayer(layer_index, tile_index, false); 80 | } 81 | -------------------------------------------------------------------------------- /assets/system/oozaru/runtime/focus-target.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | import from from './from.js'; 34 | 35 | let focusQueue = []; 36 | 37 | export default 38 | class FocusTarget 39 | { 40 | get [Symbol.toStringTag]() { return 'FocusTarget'; } 41 | 42 | constructor(options) 43 | { 44 | options = Object.assign({}, { 45 | priority: 0.0, 46 | }, options); 47 | 48 | this._priority = options.priority; 49 | } 50 | 51 | get hasFocus() 52 | { 53 | return focusQueue[focusQueue.length - 1] === this; 54 | } 55 | 56 | dispose() 57 | { 58 | this.yield(); 59 | } 60 | 61 | takeFocus() 62 | { 63 | focusQueue = from(focusQueue) 64 | .without(this) 65 | .plus(this) 66 | .ascending(it => it._priority) 67 | .toArray(); 68 | } 69 | 70 | yield() 71 | { 72 | focusQueue = from(focusQueue) 73 | .without(this) 74 | .toArray(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /assets/system/oozaru/scripts/version.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Oozaru: Sphere for the Web 3 | * Copyright (c) 2016-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | import Fido from './fido.js'; 34 | 35 | var releaseData; 36 | 37 | export default 38 | class Version 39 | { 40 | static async initialize() 41 | { 42 | releaseData = await Fido.fetchJSON('oozaru.json'); 43 | } 44 | 45 | static get apiLevel() 46 | { 47 | return 4; 48 | } 49 | 50 | static get apiVersion() 51 | { 52 | return 2; 53 | } 54 | 55 | static get copyright() 56 | { 57 | return releaseData.copyright; 58 | } 59 | 60 | static get engine() 61 | { 62 | return typeof releaseData.name === 'string' 63 | ? releaseData.name : "Oozaru"; 64 | } 65 | 66 | static get version() 67 | { 68 | return typeof releaseData.version === 'string' 69 | ? releaseData.version : "WiP"; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/cell/target.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_TARGET_H_INCLUDED 34 | #define CELL_TARGET_H_INCLUDED 35 | 36 | #include "fs.h" 37 | #include "tool.h" 38 | #include "visor.h" 39 | 40 | typedef struct target target_t; 41 | 42 | target_t* target_new (const path_t* name, fs_t* fs, const path_t* path, tool_t* tool, time_t timestamp, bool tracked); 43 | target_t* target_ref (target_t* target); 44 | void target_free (target_t* target); 45 | const path_t* target_name (const target_t* target); 46 | const path_t* target_path (const target_t* target); 47 | const path_t* target_source_path (const target_t* target); 48 | void target_add_source (target_t* target, target_t* source); 49 | bool target_build (target_t* target, visor_t* visor, bool force_build); 50 | 51 | #endif // !CELL_TARGET_H_INCLUDED 52 | -------------------------------------------------------------------------------- /src/neosphere/event_loop.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_EVENT_LOOP_H_INCLUDED 34 | #define NEOSPHERE_EVENT_LOOP_H_INCLUDED 35 | 36 | #include "sockets.h" 37 | 38 | void events_init (void); 39 | void events_uninit (void); 40 | bool events_exiting (void); 41 | int events_get_frame_rate (void); 42 | void events_set_frame_rate (int frame_rate); 43 | void events_accept_client (server_t* server); 44 | void events_close_socket (socket_t* socket); 45 | void events_connect_to (socket_t* socket, const char* hostname, int port); 46 | void events_read_socket (socket_t* socket, int num_bytes); 47 | bool events_run_main_loop (void); 48 | void events_write_socket (socket_t* socket, const void* data, int num_bytes); 49 | void events_tick (int api_version, bool clear_screen, int framerate); 50 | 51 | #endif // !NEOSPHERE_EVENT_LOOP_H_INCLUDED 52 | -------------------------------------------------------------------------------- /assets/system/game_modules/pact.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | const kResolve = Symbol('promise resolve'); 34 | const kReject = Symbol('promise reject'); 35 | 36 | export default 37 | class Pact extends Promise 38 | { 39 | get [Symbol.toStringTag]() { return 'Pact'; } 40 | get [Symbol.species]() { return Promise; } 41 | 42 | constructor(executor = null) 43 | { 44 | let resolveFunction; 45 | let rejectFunction; 46 | super((resolve, reject) => { 47 | resolveFunction = resolve; 48 | rejectFunction = reject; 49 | if (typeof executor === 'function') 50 | return executor(resolve, reject); 51 | }); 52 | this[kResolve] = resolveFunction; 53 | this[kReject] = rejectFunction; 54 | } 55 | 56 | reject(reason) 57 | { 58 | this[kReject](reason); 59 | } 60 | 61 | resolve(value) 62 | { 63 | this[kResolve](value); 64 | } 65 | 66 | toPromise() 67 | { 68 | return Promise.resolve(this); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /assets/system/oozaru/runtime/pact.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | const kResolve = Symbol('promise resolve'); 34 | const kReject = Symbol('promise reject'); 35 | 36 | export default 37 | class Pact extends Promise 38 | { 39 | get [Symbol.toStringTag]() { return 'Pact'; } 40 | get [Symbol.species]() { return Promise; } 41 | 42 | constructor(executor = null) 43 | { 44 | let resolveFunction; 45 | let rejectFunction; 46 | super((resolve, reject) => { 47 | resolveFunction = resolve; 48 | rejectFunction = reject; 49 | if (typeof executor === 'function') 50 | return executor(resolve, reject); 51 | }); 52 | this[kResolve] = resolveFunction; 53 | this[kReject] = rejectFunction; 54 | } 55 | 56 | reject(reason) 57 | { 58 | this[kReject](reason); 59 | } 60 | 61 | resolve(value) 62 | { 63 | this[kResolve](value); 64 | } 65 | 66 | toPromise() 67 | { 68 | return Promise.resolve(this); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/neosphere/pegasus.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_PEGASUS_H_INCLUDED 34 | #define NEOSPHERE_PEGASUS_H_INCLUDED 35 | 36 | enum pegasus_type 37 | { 38 | PEGASUS_BLENDER = 200, 39 | PEGASUS_COLOR, 40 | PEGASUS_DIR_STREAM, 41 | PEGASUS_FILE_STREAM, 42 | PEGASUS_FONT, 43 | PEGASUS_INDEX_LIST, 44 | PEGASUS_JOB_TOKEN, 45 | PEGASUS_JOYSTICK, 46 | PEGASUS_KEYBOARD, 47 | PEGASUS_MIXER, 48 | PEGASUS_MODEL, 49 | PEGASUS_MOUSE, 50 | PEGASUS_QUERY, 51 | PEGASUS_RNG, 52 | PEGASUS_SAMPLE, 53 | PEGASUS_SERVER, 54 | PEGASUS_SHADER, 55 | PEGASUS_SHAPE, 56 | PEGASUS_SOCKET, 57 | PEGASUS_SOUND, 58 | PEGASUS_SOUND_STREAM, 59 | PEGASUS_SURFACE, 60 | PEGASUS_TEXT_DEC, 61 | PEGASUS_TEXT_ENC, 62 | PEGASUS_TEXTURE, 63 | PEGASUS_TRANSFORM, 64 | PEGASUS_VERTEX_LIST, 65 | }; 66 | 67 | void pegasus_init (int api_level, int target_api_level); 68 | void pegasus_uninit (void); 69 | 70 | #endif // !NEOSPHERE_PEGASUS_H_INCLUDED 71 | -------------------------------------------------------------------------------- /src/neosphere/color.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_COLOR_H_INCLUDED 34 | #define NEOSPHERE_COLOR_H_INCLUDED 35 | 36 | typedef 37 | struct color 38 | { 39 | uint8_t r; 40 | uint8_t g; 41 | uint8_t b; 42 | uint8_t a; 43 | } color_t; 44 | 45 | typedef 46 | struct color_fx 47 | { 48 | int rn, rr, rg, rb; 49 | int gn, gr, gg, gb; 50 | int bn, br, bg, bb; 51 | } color_fx_t; 52 | 53 | ALLEGRO_COLOR nativecolor (color_t color); 54 | color_t mk_color (uint8_t r, uint8_t g, uint8_t b, uint8_t a); 55 | color_t color_mix (color_t color, color_t other, float w1, float w2); 56 | color_t color_transform (color_t color, color_fx_t matrix); 57 | color_fx_t mk_color_fx (int rn, int rr, int rg, int rb, int gn, int gr, int gg, int gb, int bn, int br, int bg, int bb); 58 | color_fx_t color_fx_mix (color_fx_t mat1, color_fx_t mat2, int w1, int w2); 59 | 60 | #endif // !NEOSPHERE_COLOR_H_INCLUDED 61 | -------------------------------------------------------------------------------- /src/cell/visor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_VISOR_H_INCLUDED 34 | #define CELL_VISOR_H_INCLUDED 35 | 36 | typedef struct visor visor_t; 37 | 38 | visor_t* visor_new (void); 39 | void visor_free (visor_t* visor); 40 | vector_t* visor_filenames (const visor_t* visor); 41 | int visor_num_errors (const visor_t* visor); 42 | int visor_num_warns (const visor_t* visor); 43 | void visor_add_file (visor_t* visor, const char* filename); 44 | void visor_begin_op (visor_t* visor, const char* fmt, ...); 45 | void visor_end_op (visor_t* visor); 46 | void visor_error (visor_t* visor, const char* fmt, ...); 47 | void visor_print (visor_t* visor, const char* fmt, ...); 48 | void visor_prompt (visor_t* visor, const char* prompt, char* buffer, size_t bufsize); 49 | void visor_warn (visor_t* visor, const char* fmt, ...); 50 | 51 | #endif // !CELL_VISOR_H_INCLUDED 52 | -------------------------------------------------------------------------------- /src/ssj/parser.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SSJ_PARSER_H_INCLUDED 34 | #define SSJ_PARSER_H_INCLUDED 35 | 36 | typedef struct command command_t; 37 | 38 | typedef 39 | enum token_tag 40 | { 41 | TOK_ANY, 42 | TOK_ERROR, 43 | TOK_FILE_LINE, 44 | TOK_NUMBER, 45 | TOK_REF, 46 | TOK_STRING, 47 | } token_tag_t; 48 | 49 | command_t* command_parse (const char* string); 50 | void command_free (command_t* it); 51 | int command_len (const command_t* it); 52 | token_tag_t command_get_tag (const command_t* it, int index); 53 | unsigned int command_get_handle (const command_t* it, int index); 54 | int command_get_int (const command_t* it, int index); 55 | double command_get_float (const command_t* it, int index); 56 | const char* command_get_rest (const command_t* it, int index); 57 | const char* command_get_string (const command_t* it, int index); 58 | 59 | #endif // !SSJ_PARSER_H_INCLUDED 60 | -------------------------------------------------------------------------------- /src/neosphere/dispatch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_DISPATCH_H_INCLUDED 34 | #define NEOSPHERE_DISPATCH_H_INCLUDED 35 | 36 | #include "script.h" 37 | 38 | typedef 39 | enum job_type 40 | { 41 | JOB_ON_EXIT, 42 | JOB_ON_RENDER, 43 | JOB_ON_TICK, 44 | JOB_ON_UPDATE, 45 | JOB_TYPE_MAX, 46 | } job_type_t; 47 | 48 | void dispatch_init (void); 49 | void dispatch_uninit (void); 50 | bool dispatch_busy (void); 51 | bool dispatch_can_exit (void); 52 | void dispatch_cancel (int64_t token); 53 | void dispatch_cancel_all (bool recurring, bool also_critical); 54 | int64_t dispatch_defer (script_t* script, int timeout, job_type_t hint, bool critical); 55 | void dispatch_pause (int64_t token, bool paused); 56 | int64_t dispatch_recur (script_t* script, double priority, bool background, job_type_t hint); 57 | bool dispatch_run (job_type_t hint); 58 | 59 | #endif // !NEOSPHERE_DISPATCH_H_INCLUDED 60 | -------------------------------------------------------------------------------- /src/neosphere/source_map.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_SOURCE_MAP_H_INCLUDED 34 | #define NEOSPHERE_SOURCE_MAP_H_INCLUDED 35 | 36 | typedef 37 | struct mapping 38 | { 39 | const char* filename; 40 | int line; 41 | int column; 42 | } mapping_t; 43 | 44 | void source_map_init (void); 45 | void source_map_uninit (void); 46 | const char* source_map_alias_of (const char* url); 47 | const char* source_map_url_of (const char* alias); 48 | const char* source_map_source_text (const char* filename); 49 | bool source_map_add_alias (const char* url, const char* alias); 50 | bool source_map_add_map (const char* url, js_ref_t* content); 51 | bool source_map_add_source (const char* filename, const char* text); 52 | mapping_t source_map_lookup (const char* url, int line, int column); 53 | mapping_t source_map_reverse (const char* filename, int line, int column); 54 | 55 | #endif // !NEOSPHERE_SOURCE_MAP_H_INCLUDED 56 | -------------------------------------------------------------------------------- /src/shared/console.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #include "console.h" 34 | 35 | #include 36 | #include 37 | 38 | static int s_verbosity = -1; 39 | 40 | void 41 | console_init(int verbosity) 42 | { 43 | s_verbosity = verbosity; 44 | } 45 | 46 | void 47 | console_error(const char* fmt, ...) 48 | { 49 | va_list ap; 50 | 51 | printf("\33[31;1merror:\33[m "); 52 | va_start(ap, fmt); 53 | vprintf(fmt, ap); 54 | va_end(ap); 55 | fputs("\n", stdout); 56 | } 57 | 58 | void 59 | console_log(int level, const char* fmt, ...) 60 | { 61 | va_list ap; 62 | 63 | if (level > s_verbosity) 64 | return; 65 | printf("log: "); 66 | va_start(ap, fmt); 67 | vprintf(fmt, ap); 68 | va_end(ap); 69 | fputs("\n", stdout); 70 | } 71 | 72 | void 73 | console_warn(int level, const char* fmt, ...) 74 | { 75 | va_list ap; 76 | 77 | if (level > s_verbosity) 78 | return; 79 | printf("\33[33;1mwarning:\33[m "); 80 | va_start(ap, fmt); 81 | vprintf(fmt, ap); 82 | va_end(ap); 83 | fputs("\n", stdout); 84 | } 85 | -------------------------------------------------------------------------------- /src/shared/encoding.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_ENCODING_H_INCLUDED 34 | #define SPHERE_ENCODING_H_INCLUDED 35 | 36 | #include 37 | #include 38 | #include "lstring.h" 39 | 40 | typedef struct decoder decoder_t; 41 | typedef struct encoder encoder_t; 42 | 43 | decoder_t* decoder_new (bool fatal, bool ignore_bom); 44 | decoder_t* decoder_ref (decoder_t* decoder); 45 | void decoder_free (decoder_t* decoder); 46 | bool decoder_fatal (const decoder_t* decoder); 47 | bool decoder_ignore_bom (const decoder_t* decoder); 48 | lstring_t* decoder_finish (decoder_t* decoder); 49 | lstring_t* decoder_run (decoder_t* decoder, const uint8_t* buffer, size_t size); 50 | encoder_t* encoder_new (void); 51 | encoder_t* encoder_ref (encoder_t* encoder); 52 | void encoder_free (encoder_t* encoder); 53 | uint8_t* encoder_run (encoder_t* encoder, const lstring_t* string, size_t *out_size); 54 | 55 | #endif // !SPHERE_ENCODING_H_INCLUDED 56 | -------------------------------------------------------------------------------- /src/cell/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef CELL_UTILITY_H_INCLUDED 34 | #define CELL_UTILITY_H_INCLUDED 35 | 36 | #include 37 | #include 38 | 39 | void jsal_push_lstring_t (const lstring_t* string); 40 | lstring_t* jsal_require_lstring_t (int at_index); 41 | const char* jsal_require_pathname (int index, const char* origin_name, bool need_write); 42 | int fcopy (const char* src_filename, const char* dst_filename, int skip_if_exists); 43 | bool fexist (const char* filename); 44 | void* fslurp (const char* filename, size_t *out_size); 45 | bool fspew (const void* buffer, size_t size, const char* filename); 46 | char* strescq (const char* input, char quote_char); 47 | char* strfmt (const char* format, ...); 48 | char* strnewf (const char* fmt, ...); 49 | bool wildcmp (const char* filename, const char* pattern); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/shared/lstring.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_LSTRING_H_INCLUDED 34 | #define SPHERE_LSTRING_H_INCLUDED 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | typedef struct lstring lstring_t; 42 | 43 | lstring_t* lstr_new (const char* cstr); 44 | lstring_t* lstr_newf (const char* fmt, ...); 45 | lstring_t* lstr_vnewf (const char* fmt, va_list args); 46 | lstring_t* lstr_from_cp1252 (const char* text, size_t length); 47 | lstring_t* lstr_from_utf8 (const char* text, size_t length, bool strip_bom); 48 | void lstr_free (lstring_t* string); 49 | const char* lstr_cstr (const lstring_t* string); 50 | lstring_t* lstr_cat (const lstring_t* string1, const lstring_t* string2); 51 | int lstr_cmp (const lstring_t* string1, const lstring_t* string2); 52 | lstring_t* lstr_dup (const lstring_t* string); 53 | size_t lstr_len (const lstring_t* string); 54 | 55 | #endif // !SPHERE_LSTRING_H_INCLUDED 56 | -------------------------------------------------------------------------------- /assets/system/runtime/logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | export default 34 | class Logger 35 | { 36 | get [Symbol.toStringTag]() { return 'Logger'; } 37 | 38 | constructor(fileName) 39 | { 40 | this._textEncoder = new TextEncoder(); 41 | this._stream = new FileStream(fileName, FileOp.Update); 42 | this._groups = []; 43 | 44 | let timestamp = new Date().toISOString(); 45 | let logLine = `LOG FILE OPENED: ${timestamp}`; 46 | this._stream.write(this._textEncoder.encode(`\n${logLine}\n`)); 47 | } 48 | 49 | beginGroup(text) 50 | { 51 | text = text.toString(); 52 | this.write(`BEGIN: ${text}`); 53 | this._groups.push(text); 54 | } 55 | 56 | endGroup() 57 | { 58 | let groupName = this._groups.pop(); 59 | this.write(`END: ${groupName}`); 60 | } 61 | 62 | write(text) 63 | { 64 | text = text.toString(); 65 | let timestamp = new Date().toISOString(); 66 | this._stream.write(this._textEncoder.encode(`${timestamp} .. `)); 67 | for (let i = 0; i < this._groups.length; ++i) 68 | this._stream.write(this._textEncoder.encode(" ")); 69 | this._stream.write(this._textEncoder.encode(`${text}\n`)); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /assets/system/oozaru/runtime/logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | export default 34 | class Logger 35 | { 36 | get [Symbol.toStringTag]() { return 'Logger'; } 37 | 38 | constructor(fileName) 39 | { 40 | this._textEncoder = new TextEncoder(); 41 | this._stream = new FileStream(fileName, FileOp.Update); 42 | this._groups = []; 43 | 44 | let timestamp = new Date().toISOString(); 45 | let logLine = `LOG FILE OPENED: ${timestamp}`; 46 | this._stream.write(this._textEncoder.encode(`\n${logLine}\n`)); 47 | } 48 | 49 | beginGroup(text) 50 | { 51 | text = text.toString(); 52 | this.write(`BEGIN: ${text}`); 53 | this._groups.push(text); 54 | } 55 | 56 | endGroup() 57 | { 58 | let groupName = this._groups.pop(); 59 | this.write(`END: ${groupName}`); 60 | } 61 | 62 | write(text) 63 | { 64 | text = text.toString(); 65 | let timestamp = new Date().toISOString(); 66 | this._stream.write(this._textEncoder.encode(`${timestamp} .. `)); 67 | for (let i = 0; i < this._groups.length; ++i) 68 | this._stream.write(this._textEncoder.encode(" ")); 69 | this._stream.write(this._textEncoder.encode(`${text}\n`)); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/neosphere/blend_op.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_BLEND_OP_H_INCLUDED 34 | #define NEOSPHERE_BLEND_OP_H_INCLUDED 35 | 36 | typedef struct blend_op blend_op_t; 37 | 38 | typedef 39 | enum blend_type 40 | { 41 | BLEND_OP_ADD, 42 | BLEND_OP_SUB, 43 | BLEND_OP_SUB_INV, 44 | BLEND_OP_MAX, 45 | } blend_type_t; 46 | 47 | typedef 48 | enum blend_factor 49 | { 50 | BLEND_ALPHA, 51 | BLEND_CONST, 52 | BLEND_DEST, 53 | BLEND_INV_ALPHA, 54 | BLEND_INV_CONST, 55 | BLEND_INV_DEST, 56 | BLEND_INV_SRC, 57 | BLEND_ONE, 58 | BLEND_SRC, 59 | BLEND_ZERO, 60 | BLEND_FACTOR_MAX, 61 | } blend_factor_t; 62 | 63 | blend_op_t* blend_op_new_asym (blend_type_t color_op, blend_factor_t sfc, blend_factor_t tfc, blend_type_t alpha_op, blend_factor_t sfa, blend_factor_t tfa); 64 | blend_op_t* blend_op_new_sym (blend_type_t op_type, blend_factor_t sf, blend_factor_t tf); 65 | blend_op_t* blend_op_ref (blend_op_t* it); 66 | void blend_op_unref (blend_op_t* it); 67 | void blend_op_set_const (blend_op_t* it, float r, float g, float b, float a); 68 | void blend_op_apply (const blend_op_t* it); 69 | 70 | #endif // !NEOSPHERE_BLEND_OP_H_INCLUDED 71 | -------------------------------------------------------------------------------- /src/neosphere/byte_array.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_BYTE_ARRAY_H_INCLUDED 34 | #define NEOSPHERE_BYTE_ARRAY_H_INCLUDED 35 | 36 | typedef struct bytearray bytearray_t; 37 | 38 | bytearray_t* bytearray_new (int size); 39 | bytearray_t* bytearray_from_buffer (const void* buffer, int size); 40 | bytearray_t* bytearray_from_lstring (const lstring_t* string); 41 | bytearray_t* bytearray_ref (bytearray_t* array); 42 | void bytearray_unref (bytearray_t* array); 43 | uint8_t* bytearray_buffer (bytearray_t* array); 44 | int bytearray_len (bytearray_t* array); 45 | bytearray_t* bytearray_concat (bytearray_t* array1, bytearray_t* array2); 46 | bytearray_t* bytearray_deflate (bytearray_t* array, int level); 47 | uint8_t bytearray_get (bytearray_t* array, int index); 48 | bytearray_t* bytearray_inflate (bytearray_t* array, int max_size); 49 | void bytearray_set (bytearray_t* array, int index, uint8_t value); 50 | bytearray_t* bytearray_slice (bytearray_t* array, int start, int length); 51 | 52 | #endif // !NEOSPHERE_BYTE_ARRAY_H_INCLUDED 53 | -------------------------------------------------------------------------------- /src/neosphere/vanilla.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_VANILLA_H_INCLUDED 34 | #define NEOSPHERE_VANILLA_H_INCLUDED 35 | 36 | #include "byte_array.h" 37 | #include "jsal.h" 38 | #include "script.h" 39 | #include "spriteset.h" 40 | 41 | enum vanilla_class 42 | { 43 | SV1_ANIMATION = 100, 44 | SV1_BYTE_ARRAY, 45 | SV1_COLOR, 46 | SV1_COLOR_MATRIX, 47 | SV1_FILE, 48 | SV1_FONT, 49 | SV1_IMAGE, 50 | SV1_LOGGER, 51 | SV1_RAW_FILE, 52 | SV1_SOCKET, 53 | SV1_SOUND, 54 | SV1_SOUND_EFFECT, 55 | SV1_SPRITESET, 56 | SV1_SURFACE, 57 | SV1_WINDOW_STYLE, 58 | }; 59 | 60 | void vanilla_init (void); 61 | void vanilla_uninit (void); 62 | 63 | void jsal_push_sphere_bytearray (bytearray_t* array); 64 | void jsal_push_sphere_color (color_t color); 65 | void jsal_push_sphere_font (font_t* font); 66 | void jsal_push_sphere_spriteset (spriteset_t* spriteset); 67 | color_t jsal_require_sphere_color (int index); 68 | color_fx_t jsal_require_sphere_color_fx (int index); 69 | script_t* jsal_require_sphere_script (int index, const char* name); 70 | spriteset_t* jsal_require_sphere_spriteset (int index); 71 | 72 | #endif // !NEOSPHERE_VANILLA_H_INCLUDED 73 | -------------------------------------------------------------------------------- /src/neosphere/kev_file.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_FILE_H_INCLUDED 34 | #define NEOSPHERE_FILE_H_INCLUDED 35 | 36 | #include "game.h" 37 | 38 | typedef struct kev_file kev_file_t; 39 | 40 | kev_file_t* kev_open (game_t* game, const char* filename, bool can_create); 41 | void kev_close (kev_file_t* it); 42 | int kev_num_keys (kev_file_t* it); 43 | const char* kev_get_key (kev_file_t* it, int index); 44 | bool kev_read_bool (kev_file_t* it, const char* key, bool def_value); 45 | double kev_read_float (kev_file_t* it, const char* key, double def_value); 46 | int kev_read_int (kev_file_t* it, const char* key, int def_value); 47 | const char* kev_read_string (kev_file_t* it, const char* key, const char* def_value); 48 | bool kev_save (kev_file_t* it); 49 | void kev_write_bool (kev_file_t* it, const char* key, bool value); 50 | void kev_write_float (kev_file_t* it, const char* key, double value); 51 | void kev_write_int (kev_file_t* it, const char* key, int value); 52 | void kev_write_string (kev_file_t* it, const char* key, const char* value); 53 | 54 | #endif // !NEOSPHERE_FILE_H_INCLUDED 55 | -------------------------------------------------------------------------------- /assets/system/scripts/intro.js: -------------------------------------------------------------------------------- 1 | //System script by Tim Fitz aka FireMoth. 2 | //Claim this is your own, and I will kill you. 3 | 4 | function Intro () 5 | { 6 | if( !(this instanceof Intro) ) return new Intro( ); 7 | this.obj = new Array(); 8 | this.step = -GetScreenHeight(); 9 | this.speed = 1; 10 | this.font = new Array(); 11 | this.images = new Array(); 12 | this.height = new Array(); 13 | this.type = new Array(); // I hate doing this. 14 | this.color = new Array(); 15 | this.height[-1]=0; // I dunno how to eliminate this. Oh well! It works! Who cares! 16 | this.gradsize=GetScreenHeight()/16; 17 | this.grad=true; 18 | this.lheight=0; 19 | this.spacing=0; 20 | } 21 | 22 | Intro.prototype.addText = function (string,fnt,clr) 23 | { 24 | if (fnt == undefined) fnt = GetSystemFont(); 25 | if (clr == undefined) clr = CreateColor(255,255,255); 26 | if (string == undefined) return false; //You dumbfuck. 27 | with (this) 28 | { 29 | var c = obj.length; 30 | height[c]=lheight+height[c-1]; 31 | lheight=fnt.getHeight()+spacing; 32 | obj[c]=string; 33 | color[c]=clr; 34 | type[c]="String"; 35 | font[c]=fnt; 36 | } 37 | return true; 38 | } 39 | 40 | Intro.prototype.addImage = function (image) 41 | { 42 | if (image == undefined) return false; //You asshole. 43 | with (this) 44 | { 45 | var c = obj.length; 46 | height[c]=lheight+height[c-1]; 47 | lheight=image.height+spacing; 48 | obj[c]=image; 49 | type[c]="Image"; 50 | } 51 | } 52 | 53 | Intro.prototype.addSpace = function (spc) 54 | { 55 | this.lheight += spc; //Wow, that was painless! 56 | } 57 | 58 | Intro.prototype.play = function (spd) 59 | { 60 | with (this) 61 | { 62 | if (spd !== undefined) speed=spd; 63 | step=-GetScreenHeight(); 64 | while (!loopStep()) {FlipScreen()} 65 | } 66 | } 67 | 68 | Intro.prototype.loopStep = function () 69 | { 70 | with (this) 71 | { 72 | draw(); 73 | step+=speed; 74 | if ( step > height[height.length-1]+lheight) return true; 75 | return false; 76 | } 77 | } 78 | 79 | Intro.prototype.draw = function () 80 | { 81 | with (this) 82 | { 83 | for (var n = 0; n 37 | #include 38 | 39 | #if defined(_WIN32) 40 | #include 41 | #else 42 | #include 43 | #endif 44 | 45 | void* 46 | fslurp(const char* filename, size_t* out_size) 47 | { 48 | char* buffer; 49 | FILE* file = NULL; 50 | size_t read_size; 51 | 52 | if (!(file = fopen(filename, "rb"))) 53 | return NULL; 54 | fseek(file, 0, SEEK_END); 55 | read_size = (size_t)ftell(file); 56 | if (out_size != NULL) 57 | *out_size = read_size; 58 | if (!(buffer = (char*)malloc(read_size + 1))) 59 | goto on_error; 60 | fseek(file, 0, SEEK_SET); 61 | if (fread(buffer, 1, read_size, file) != read_size) 62 | goto on_error; 63 | buffer[read_size] = '\0'; 64 | fclose(file); 65 | return buffer; 66 | 67 | on_error: 68 | fclose(file); 69 | return NULL; 70 | } 71 | 72 | void 73 | launch_url(const char* url) 74 | { 75 | char* command; 76 | 77 | #if defined(_WIN32) 78 | command = strnewf("start %s", url); 79 | #elif defined(__APPLE__) 80 | command = strnewf("open %s", url); 81 | #else 82 | command = strnewf("xdg-open %s", url); 83 | #endif 84 | system(command); 85 | free(command); 86 | } 87 | 88 | void 89 | stall(double time) 90 | { 91 | #if defined(_WIN32) 92 | Sleep((DWORD)(1000.0 * time)); 93 | #else 94 | usleep((useconds_t)(1000000.0 * time)); 95 | #endif 96 | } 97 | -------------------------------------------------------------------------------- /assets/system/oozaru/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | align-items: center; 3 | background-color: #222; 4 | color: #CC7; 5 | display: flex; 6 | flex-direction: column; 7 | font-size: 11pt; 8 | height: 100vh; 9 | margin: 0; 10 | } 11 | 12 | #menu { 13 | align-items: center; 14 | background-color: #CCC; 15 | display: flex; 16 | color: #000; 17 | border-bottom-left-radius: 0.5rem; 18 | border-bottom-right-radius: 0.5rem; 19 | box-shadow: 2pt 2pt 4pt #000, -2pt -2pt 4pt #000; 20 | font-family: system-ui; 21 | flex-direction: row; 22 | padding: 0.25em 0.5em; 23 | } 24 | 25 | #menu > * { 26 | margin: 0.25rem; 27 | } 28 | 29 | #menu > #title { 30 | line-height: 1; 31 | padding-right: 1em; 32 | text-align: right; 33 | } 34 | 35 | #menu > #title > #name { 36 | color: #000; 37 | font-variant: small-caps; 38 | font-weight: bold; 39 | } 40 | 41 | #menu > #title > #copyright { 42 | font-size: 8pt; 43 | padding-right: 1em; 44 | } 45 | 46 | #menu > .game { 47 | cursor: pointer; 48 | filter: grayscale(100%); 49 | transition: filter 0.25s ease; 50 | } 51 | 52 | #menu > .game.running { 53 | filter: unset; 54 | } 55 | 56 | #menu > .game:hover { 57 | filter: unset; 58 | } 59 | 60 | #menu > .game:active { 61 | filter: brightness(150%); 62 | } 63 | 64 | #tv { 65 | align-items: center; 66 | background: #224; 67 | border-radius: 1rem; 68 | box-shadow: 4pt 4pt 8pt #000, -4pt -4pt 8pt #000; 69 | color: #CCC; 70 | display: flex; 71 | flex-direction: column; 72 | font-family: system-ui; 73 | margin: auto; 74 | padding: 1rem; 75 | text-align: center; 76 | } 77 | 78 | #tv > * { 79 | margin: 1rem; 80 | } 81 | 82 | #tv canvas { 83 | background-color: #000; 84 | border: 1px solid #000; 85 | flex: none; 86 | image-rendering: pixelated; 87 | } 88 | 89 | #tv hr { 90 | background-color: #448; 91 | border-color: #336; 92 | width: 100%; 93 | } 94 | 95 | #tv pre { 96 | background-color: #111; 97 | border: 1px solid #444; 98 | box-shadow: 4px 4px 8px #000, -4px -4px 8px #000; 99 | color: #CCC; 100 | margin: 0; 101 | overflow: auto; 102 | padding: 1em !important; 103 | text-align: left; 104 | } 105 | 106 | #tv ul { 107 | list-style-position: inside; 108 | padding: 0; 109 | } 110 | 111 | #tv #screen-container { 112 | position: relative; 113 | } 114 | 115 | #tv #overlay { 116 | position: absolute; 117 | pointer-events: none; 118 | transition: opacity 0.25s ease; 119 | left: 195px; 120 | top: 150px; 121 | width: 250px; 122 | height: 150px; 123 | } 124 | 125 | #tv #panel { 126 | align-items: flex-start; 127 | display: flex; 128 | flex-direction: row-reverse; 129 | justify-content: center; 130 | padding: 0.5rem; 131 | } 132 | 133 | #tv #panel > * { 134 | padding: 0; 135 | } 136 | 137 | #tv #readout { 138 | background-color: #300; 139 | border: 1px solid #700; 140 | box-shadow: 4px 4px 8px #200, -4px -4px 8px #200; 141 | color: #FCC; 142 | display: none; 143 | margin-right: 1rem; 144 | width: auto; 145 | } 146 | 147 | #tv #readout::first-line { 148 | font-weight: bold; 149 | } 150 | 151 | #tv #readout.visible { 152 | display: unset; 153 | } 154 | -------------------------------------------------------------------------------- /src/shared/vector.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef SPHERE_VECTOR_H_INCLUDED 34 | #define SPHERE_VECTOR_H_INCLUDED 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | typedef struct vector vector_t; 41 | 42 | typedef 43 | struct iter 44 | { 45 | vector_t* vector; 46 | void* ptr; 47 | int index; 48 | } iter_t; 49 | 50 | vector_t* vector_new (size_t pitch); 51 | vector_t* vector_dup (const vector_t* vector); 52 | void vector_free (vector_t* vector); 53 | int vector_len (const vector_t* vector); 54 | void vector_clear (vector_t* vector); 55 | iter_t vector_enum (vector_t* vector); 56 | void* vector_get (const vector_t* vector, int index); 57 | bool vector_insert (vector_t* vector, int index, const void* in_object); 58 | bool vector_pop (vector_t* it, int num_items); 59 | bool vector_push (vector_t* vector, const void* in_object); 60 | void vector_put (vector_t* vector, int index, const void* in_object); 61 | void vector_remove (vector_t* vector, int index); 62 | bool vector_reserve (vector_t* it, int min_items); 63 | bool vector_resize (vector_t* vector, int new_size); 64 | vector_t* vector_sort (vector_t* vector, int(*comparer)(const void* in_a, const void* in_b)); 65 | 66 | void* iter_next (iter_t* inout_iter); 67 | void iter_remove (iter_t* iter); 68 | 69 | #endif // !SPHERE_VECTOR_H_INCLUDED 70 | -------------------------------------------------------------------------------- /src/neosphere/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sphere: the JavaScript game platform 3 | * Copyright (c) 2015-2025, Where'd She Go? 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Spherical nor the names of its contributors may be 17 | * used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | #ifndef NEOSPHERE_UTILITY_H_INCLUDED 34 | #define NEOSPHERE_UTILITY_H_INCLUDED 35 | 36 | #include "game.h" 37 | #include "geometry.h" 38 | #include "lstring.h" 39 | #include "path.h" 40 | 41 | const path_t* app_data_path (void); 42 | const path_t* assets_path (void); 43 | const path_t* engine_path (void); 44 | const path_t* home_path (void); 45 | 46 | bool fread_rect16 (file_t* file, rect_t* out_rect); 47 | bool fread_rect32 (file_t* file, rect_t* out_rect); 48 | image_t* fread_image (file_t* file, int width, int height); 49 | image_t* fread_image_slice (file_t* file, image_t* parent, int x, int y, int width, int height); 50 | bool fwrite_image (file_t* file, image_t* image); 51 | 52 | int jsal_push_lstring_t (const lstring_t* string); 53 | lstring_t* jsal_require_lstring_t (int index); 54 | const char* jsal_require_pathname (int index, const char* origin_name, bool v1_mode, bool need_write); 55 | const char* md5sum (const void* data, size_t size); 56 | lstring_t* read_lstring (file_t* file, bool trim_null); 57 | lstring_t* read_lstring_raw (file_t* file, size_t length, bool trim_nul); 58 | char* strnewf (const char* fmt, ...); 59 | bool write_lstring (file_t* file, const lstring_t* string, bool include_nul); 60 | 61 | #endif // !NEOSPHERE_UTILITY_H_INCLUDED 62 | --------------------------------------------------------------------------------