dos-like is a programming library/framework, kind of like a tiny game engin

Related tags

Game dos-like
Overview

build

dos-like

dos-like examples

dos-like is a programming library/framework, kind of like a tiny game engine, for writing games and programs with a similar feel to MS-DOS productions from the early 90s. But rather than writing code that would run on a real DOS machine, dos-like is about making programs which runs on modern platforms like Windows, Mac and Linux, but which attempts to recreate the look, feel, and sound of old DOS programs.

It includes a bunch of examples of classic DOS techniques and effects, a few of which can be seen above.

For more information and screenshots, please see the project home at https://mattiasgustavsson.itch.io/dos-like

Operating

While running, you can use F11 to toggle between fullscreen and windowed mode.

To start in windowed mode, add the flag -w or --window to the commandline when launching.

Building

dos-like does not make use of any complicated build systems - a simple command line call to the compiler is all that is needed to build both your program and thee engine itself.

Windows

Tiny C Compiler for windows is included. To build all samples, run build_all.bat. To build individual samples, do:

  tcc\tcc source\stranded.c source\dos.c

where stranded.c should be replaced with the sample you like to build.

Alternatively, from a Visual Studio Developer Command Prompt, do:

  cl source\stranded.c source\dos.c

where stranded.c should be replaced with the sample you like to build.

Mac

To build on Mac (which I don't test myself, but might work):

  clang source/stranded.c source/dos.c -lSDL2 -lGLEW -framework OpenGL

where stranded.c should be replaced with the sample you like to build.

SDL2 and GLEW are required - if you don't have them installed you can do so by running

  brew install sdl2 glew  

Linux

To build on Linux (which I don't test myself, but might work):

  gcc source/stranded.c source/dos.c -lSDL2 -lGLEW -lGL -lm -lpthread

where stranded.c should be replaced with the sample you like to build.

SDL2 and GLEW are required - if you don't have them installed you can do so by running

  sudo apt-get install libsdl2-dev
  sudo apt-get install libglew-dev
Comments
  • DISABLE_SCREEN_FRAME disabling black borders too

    DISABLE_SCREEN_FRAME disabling black borders too

    Hi, I think this is a useful mod for the ones that want to completely disable the frame and the black borders. I also made some cleaning in the function tsample removing the parameters offs and resolution because they're not used in function.

    opened by domenicomuti 7
  • WebAssembly (HTML5) target

    WebAssembly (HTML5) target

    This PR adds full WebAssembly support to dos-like.

    All the samples are available to be viewed/played on the github-io page of my repo: https://schellingb.github.io/dos-like/

    Before merging, there are a few things worth to maybe have a discussion about.

    There are no real threads in WebAssembly readily available so I chose to use coroutines to emulate the threaded nature of native dos-like to keep the API intact while being a regular single threaded JavaScript application on the web.

    The way I kept the amount of #ifdef __wasm__ in dos.h as low as I could was to add a wasm platform to thread.h with mostly fake functions (where threads/mutex do nothing and atomics are just regular variables). I contemplated not including thread.h on the wasm build target and adding #ifndef __wasm__ around all the concurrency control code in dos.h. Might result in a cleaner implementation overall?

    We talked on Twitter about how, due to the coroutine nature, the users main loop must somehow end up calling waitvbl from time to time to switch the context back to dos.h and how I added forced waitvbl calls to swapbuffers/readkeys/readchars. I can't really think of a better alternative so hopefully that's fine. Maybe as an improvement it could detect/remember that waitvbl isn't being called but swapbuffers is, and then do waitvbl every time instead of only every third time swapbuffers is called?

    The JavaScript code embedded in the new WASM part of app.h is not adhering to the code style of the C code around it. Could be made matching the C style or could be left as is because it is not C after all.

    Another thing is the "wasm" directory I added to the repository root. Could be considered annoying to people who aren't interested in it. As explained in the README addition, It needs a bunch of things (llvm, node, wajic) anyway so it could be kept external as well.

    Speaking of, the README should probably link to the deployed web versions. I didn't want to add absolute links to my github-io pages or github repo so my changes use relative links only.

    That's about it of things I can think of. If there's any request for change or concern, let me know!

    opened by schellingb 6
  • Fix to work on Mac and update README.md and .gitignore

    Fix to work on Mac and update README.md and .gitignore

    I've tested all three supported types of builds against the changes in this pull request (building with tcc on Linux with Wine, building on Linux, and even building both Apple Silicon and Intel Mac builds), and tested that all types of builds run successfully.

    I changed how the Linux and Mac build commands receive SDL2, because the previous way SDL2 was provided didn't work on Apple Silicon using Homebrew, but the change fixes that. And using sdl2-config is the "right way" to use SDL2 with manually-written compile commands, because it provides some stuff SDL2 needs beyond -lSDL2.

    In the process of fixing it for Mac, I created a CMake build script to help with development, as using CMake makes it easier to develop in many IDEs. Plus, it compiles the base dos-like library separately from the samples, so all of the samples compile faster.

    opened by nightmareci 5
  • Crashes on Linux/Xorg

    Crashes on Linux/Xorg

    This crashes on Linux for me (using a Xorg session, not Wayland), the issue seems unrelated to #2:

    X Error of failed request:  BadWindow (invalid Window parameter)
      Major opcode of failed request:  40 (X_TranslateCoords)
      Resource id in failed request:  0x6005c9
      Serial number of failed request:  270
      Current serial number in output stream:  270
    

    Commenting out SDL_HideWindow( app->window ); in dos.h fixed the issue for me, but not sure if it's a reasonable fix.

    opened by thp 4
  • SegFault on startup (Debian Linux)

    SegFault on startup (Debian Linux)

    Example programs segfault on startup.

    I've tracked it down to (I think) the exit_flag field in internal_t being uninitialised at the time of SDL initialisation.

    int app_run( int (*app_proc)( app_t*, void* ), void* user_data, void* memctx, void* logctx, void* fatalctx )
        {
        app_t* app = (app_t*) APP_MALLOC( memctx, sizeof( app_t ) );
        memset( app, 0, (int)sizeof( app_t ) );
        app->memctx = memctx;
        app->logctx = logctx;
        app->fatalctx = fatalctx;
        app->interpolation = APP_INTERPOLATION_LINEAR;
        app->screenmode = APP_SCREENMODE_FULLSCREEN;
    
        int result = 0xff;
    
        if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
        {
            goto init_failed;
        }
    
    .
    .
    .
    
        result = app_proc( app, user_data );
    

    This is the full stack trace (line numbers are wrong - my GDB version is out of date by the looks of it)

    #0  thread_atomic_int_load (atomic=0x40) at source/libs/thread.h:999
    #1  0x000055555555c522 in shutdown () at source/dos.h:441
    #2  0x00007ffff771e8f2 in xcb_disconnect () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
    #3  0x00007ffff784fc2f in XCloseDisplay () from /usr/lib/x86_64-linux-gnu/libX11.so.6
    #4  0x00007ffff7f217b9 in X11_Available () at /home/steve/src_local/SDL2-2.0.10/src/video/x11/SDL_x11video.c:101
    #5  0x00007ffff7eee6d6 in SDL_VideoInit_REAL (driver_name=<optimized out>, [email protected]=0x0)
        at /home/steve/src_local/SDL2-2.0.10/src/video/SDL_video.c:501
    #6  0x00007ffff7e3fcf7 in SDL_InitSubSystem_REAL (flags=62001) at /home/steve/src_local/SDL2-2.0.10/src/SDL.c:170
    #7  0x00005555555648ab in app_run (app_proc=0x555555561c02 <app_proc>, user_data=0x7fffffffd580, memctx=0x0, 
        logctx=0x0, fatalctx=0x0) at source/libs/app.h:3374
    #8  0x0000555555582267 in main (argc=1, argv=0x7fffffffd678) at source/dos.h:2864
    

    If I alter shutdown() in dos.h to return 0, rather than atomic loading internal->exit_flag then the programs run file but that is obviously a poor solution.

    opened by JetSetIlly 4
  • LuaJIT bindings

    LuaJIT bindings

    Hello, I am trying to get some bindings for this going with LuaJIT. I've compiled dos.h using this:

    gcc -shared -fPIC -o dos.so source/dos.c `sdl2-config --libs --cflags` -lGLEW -lGL -lm -lpthread
    

    and I am trying to test some initial graphics functions with the following LuaJIT code:

    local ffi = require "ffi"
    ffi.cdef[[
       void circle( int x, int y, int r );
       enum videomode_t {
        videomode_40x25_8x8,
        videomode_40x25_9x16,
        videomode_80x25_8x8,
        videomode_80x25_8x16,
        videomode_80x25_9x16,
        videomode_80x43_8x8,
        videomode_80x50_8x8,
        videomode_320x200,
        videomode_320x240,
        videomode_320x400,
        videomode_640x200,
        videomode_640x350,
        videomode_640x400,
        videomode_640x480,
       };
    
       void setvideomode( enum videomode_t mode );
       void setdoublebuffer( int enabled );
    ]]
    
    local dos = ffi.load("~/dos-like/libdos.so", true)
    

    This works, but trying to call any dos functions fails with a segfault, assumedly because the initialization stuff isn't being called. Do you have any suggestions for connecting LuaJIT to the app_proc function?

    opened by LJNIC 3
  • Add loadwavbuf() for in-memory WAV loading

    Add loadwavbuf() for in-memory WAV loading

    This is mostly a copy'n'paste of loadwav(), calling drwav_open_memory_and_read_pcm_frames_s16() instead of drwav_open_file_and_read_pcm_frames_s16(). Might make sense to refactor and have only one internal implementation that just uses a buffer and read the file contents like is done in installuserfont() (and that "load the complete file into memory" might make sense to be in a separate function), but I'll leave that up to you :)

    opened by thp 3
  • No license

    No license

    Without a license file or licensing information in README.md it is hard to know if how this can be used to create own games/demos/content. Some of the source files contains licensing info but it is conflicting and on a file-by-file basis. Would be good to clarify.

    opened by johanberntsson 3
  • Can't lower volume using media keys when running dos-like compiled executable

    Can't lower volume using media keys when running dos-like compiled executable

    I was running a dos like game (stranded) and it was really loud, but I found that my volume up and volume down buttons on my keyboard did not work. This is the first time something like this has happened with my keyboard in 5 years of having it. Not sure how easy it is to test if you don't have media buttons on your own keyboard.

    Just reporting it here in case it helps the project.

    opened by ainslec 2
  • Free Pascal bindings please? (both FPIDE and Lazarus bindings for both windows and linux)

    Free Pascal bindings please? (both FPIDE and Lazarus bindings for both windows and linux)

    Can I have both FPIDE and Lazarus bindings for at least 64 bit Windows 10 as well as a target for 64-bit Linux as well for those willing to go with Free Pascal for linux? This should be a treat for those still having problems with the plain Free Pascal SDL2 package on Github.

    I very much appreciate it.

    opened by TheRealHamtaro126 1
  • support readchars() on SDL builds

    support readchars() on SDL builds

    Hi Mattias,

    I fixed the readchars() SDL problem so I could extinguish the fire in the burn example program. The sound example (mentioned in #29) works now too. Tested on Ubuntu.

    Sam


    In the libs/app.h event processing for SDL, APP_INPUT_CHAR events were not being generated so dos.h's readchars() would never return any data. As a result, the burn and sound example programs would not respond to user input.

    The SDL_TEXTINPUT SDL event appears to be the appropriate SDL event to drive the APP_INPUT_CHAR app events.

    opened by samuelbrian 1
  • Add documentation to dos.h

    Add documentation to dos.h

    Should hopefully resolve #23.

    • Documentation was added to each public facing symbol in dos.h. Most of it had already been written when I was working on dos-like-rs. Still, some validation on their accuracy would be much appreciated.
    • Added Doxyfile configuration file, for easy documentation generation. All you have to do is install Doxygen and run doxygen.
    • Updated .gitignore to ignore generated docs
    opened by Enet4 0
  • dos.h needs comments

    dos.h needs comments

    Hi, love the library but it's kind of difficult to work out what all the functions do in dos.h without experimentation sometimes (yes - even with the source). It'd be nice to have comments in the file, or maybe even a standalone document that shows all the functions and their parameters.

    opened by ainslec 1
Releases(wasm-env)
Owner
Mattias Gustavsson
https://twitter.com/Mattias_G
Mattias Gustavsson
tiny game made in ~15 hours on stream

A small game made entirely on live stream over about 15 hours. I intend to add more documentation and clarify some of the code and assets over the next few days.

Noel Berry 182 Dec 26, 2022
A Tiny 2D OpenGL based C++ Game Engine that is fast, lightweight and comes with a level editor.

A Tiny 2D OpenGL based C++ Game Engine that is fast, lightweight and comes with a level editor.

Samuel Rasquinha 59 Jan 3, 2023
A tiny webserver for game development

Webby - A simple web server for game debugging Webby is a web server intended for debugging tools inside a game or other program with a continously ru

Andreas Fredriksson 264 Dec 14, 2022
Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World.

OpenXRay OpenXRay is an improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. S

null 2.2k Jan 1, 2023
Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve external game process read/write with minimum footprint.

Launcher Abuser Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve ex

Ricardo Nacif 80 Nov 25, 2022
Game Boy, Game Boy Color, and Game Boy Advanced Emulator

SkyEmu SkyEmu is low level cycle accurate GameBoy, GameBoy Color and Game Boy Advance emulator that I have been developing in my spare time. Its prima

Sky 321 Jan 4, 2023
An OpenGL Engine Written In C Using A Very OOP-Like Way Of Programming

A Simple Engine in its very first stages of becoming a, Game Engine or just a framework for making games using OpenGL. Here are the features of the Op

DevHedron 26 Jul 9, 2022
Project 1945 is a top down scroller game made with SDL2, CMake and programmed in C as a project of study for the Italian Videogames Academy for the 3rd year course of Videogames programming.

Project 1945 is a top down scroller game made with SDL2, CMake and programmed in C as a project of study for the Italian Videogames Academy for the 3rd year course of Videogames programming. The game is based on the old videogame 1945: The Final Front of the 2002.

null 19 Dec 30, 2022
A programming game, in which your goal is to help a group of dwarves establish a small outpost in the middle of a dangerous forest.

"Since they were to come in the days of the power of Melkor, Aulë made the dwarves strong to endure. Therefore they are stone-hard, stubborn, fast in

Alexey Nikolaev 6 Sep 29, 2022
Recreation of the MineStorm game for a student programming project.

MineStorm General information This project is a student project done for ISART Digital by Rémi SERRA and Alexandre PERCHÉ. The goal was to recreate th

Rémi Serra 1 Dec 7, 2022
This is the source repo for the book Game Programming Patterns

Note: Now that the book is done, I'm not actively working on it. There are only so many hours in the day, and I have other projects that need my love,

Bob Nystrom 3.4k Dec 30, 2022
Cute Framework (CF for short) is the cutest framework available for making 2D games in C/C++

Cute Framework (CF for short) is the cutest framework available for making 2D games in C/C++. CF comprises of different features, where the various features avoid inter-dependencies. In this way using CF is about picking and choosing which pieces are needed for your game

null 314 Dec 26, 2022
TIC-80 is a fantasy computer for making, playing and sharing tiny games.

TIC-80 is a fantasy computer for making, playing and sharing tiny games.

Vadim Grigoruk 3.8k Jan 4, 2023
Skynet is a lightweight online game framework

Skynet is a lightweight online game framework which can be used in many other fields.

云风 11.7k Dec 31, 2022
sdl based game framework

Hallow Engine an sdl-based game framework Install Procedure Install SDL2[https://libsdl.org] and take the .h(header) files from the include/ folder, t

Hallow - The Game Framework 6 Nov 24, 2021
A simple game framework written in C++ using SDL

SGF SGF (Simple Game Framework) is, as the name implies; a very simple and easy to use game framework written in C++ using SDL. Currently the project

Cam K. 1 Nov 4, 2021
A simple shooter game like Space Invaders that runs on QMK Firmware.

About A simple shooter game like Space Invaders that runs on QMK Firmware. What is it like? Player's Manual English: manual_en.md Japanese: manual_jp.

null 5 Sep 30, 2022
A flutter package for making game levels map like candy crush or similar games using flutter with ability to be horizontal or vertical

Game Levels Scrolling Map A package for making game levels map like candy crush or similar games using flutter with ability to be horizontal or vertic

Mohamed Sayed 12 Oct 26, 2022
A Minecraft like game with basic rendering, movement, block placement.. All made from scratch

Voxel-Game-Demo A Minecraft like game with basic rendering, movement, block placement.. All made from scratch Downlod Pre-compiled binaries (executabl

null 1 Dec 30, 2021