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
Issues
  • 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
  • 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
  • Op2 soundbank OPL improvements

    Op2 soundbank OPL improvements

    Did a variety of fixes and improvements to OP2 soundbank playback. I played back this midi using DMXOPL's GENMIDI.op2 (v1.11) and recorded the results before and after the changes. The difference is striking if you ask me. Midi, op2 soundbank, and output ogg's have been attached as test_files.zip.

    OP2 volume

    Added a volume argument to opl_render because it was not respecting the playmusic volume. I'm not 100% sure I did this in the best way possible but I noticed there was already code in dos.h for applying volume when outputting to modbuffer, so I specified the volume for opl_render when using modbuffer as 1.0f to not double apply the volume

    OP2 second voice

    Added the instrument second voice feature of OP2 soundbanks. This is used by OP2 soundbanks to make instruments sound better by using 2 voices (or 4 operators) for an instrument. This is particularly used by modern OP2 soundbanks such as the popular permissively licensed DMXOPL soundbanks (https://github.com/sneakernets/DMXOPL) to enhance audio quality.

    This meant loading a second bank of timbres for OP2 soundbanks as well as storing OP2 instrument flags in the opl_t struct and storing whether the current soundbank is OP2. This entailed various changes:

    • notes2voices has been changed from channel-notes to channel-notes-instrumentvoice. This allows 2 voices to play for a note, one for each instrumental voice in an OP2 soundbank.
    • voices2notes now has a voiceindex field that records whether it's a 1st or 2nd instrumental voice (0 or 1)
    • switching which timbre to use (opl_gmtimbres or opl_gmtimbres_voice2) in several locations
    • opl_midi_noteoff and opl_midi_noteon now call opl_midi_noteoff_op2 and opl_midi_noteon_op2 respectively with instrumental voice indices of 0 and 1 to trigger both instrumental voices where appropriate
    • opl_loadbank_op2 has been split into opl_loadbank_op2 and opl_load_op2_voice and rewritten so it loads both instrumental voices as well as stores the instrument header
    • Because OP2 soundbanks apply additional fine tuning to the 2nd voice when present this is applied separately to any existing finetune value in opl_loadbank_op2

    OP2 bugfixes

    • getinstrument was returning the wrong index for OP2 percussive instruments and has now been fixed
    • The OP2 soundbank loading routine had what I believed to be an error where percussion instruments weren't loaded correctly and overwriting earlier instruments, this has been fixed
    opened by Enichan 1
  • Add toggle for CRT mode on and off

    Add toggle for CRT mode on and off

    Hi,

    Currently F11 toggles between full screen and windowed, but it might be also nice to be able to toggle the crt mode off. I find the crt mode works with some screens well, and on lower res screens, it can lead to a kind of banding effect. I guess this is down to non integer scaling? Just guessing. Anyway, a toggle would help.

    Chris

    opened by ainslec 1
  • 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 domvhscrap 6
  • 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 171 Jun 19, 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 47 Apr 12, 2022
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 253 Jun 20, 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 2k Jun 29, 2022
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 75 Jun 29, 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 60 Jun 19, 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 218 Jul 2, 2022
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 25 May 27, 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 17 Sep 27, 2021
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 4 Jan 8, 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 2 Nov 14, 2021
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.3k Jun 28, 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.5k Jun 27, 2022
Skynet is a lightweight online game framework

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

云风 11.3k Jun 27, 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 3 Oct 14, 2021
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 9 Jun 7, 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