diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-29 23:32:41 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-29 23:32:41 +0100 |
commit | 2941ac6b8ecc1fd96b886219795f5d7e55bb85d8 (patch) | |
tree | 9786ef28b990199e353bea285d6d5ecdb0a45e31 | |
download | gold-mine-run-2941ac6b8ecc1fd96b886219795f5d7e55bb85d8.tar.gz gold-mine-run-2941ac6b8ecc1fd96b886219795f5d7e55bb85d8.zip |
Initial import
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | LICENSE | 20 | ||||
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | README.md | 29 | ||||
-rw-r--r-- | TODO.md | 27 | ||||
-rw-r--r-- | dosbox.conf | 245 | ||||
-rw-r--r-- | src/Makefile | 25 | ||||
-rw-r--r-- | src/main.c | 33 | ||||
-rw-r--r-- | src/vga.c | 24 | ||||
-rw-r--r-- | src/vga.h | 9 |
10 files changed, 436 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d13553e --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.o +*.swp +*~ +Makefile.deps +game.exe +CWSDPMI.EXE +local-env @@ -0,0 +1,20 @@ +Copyright (c) 2023 Juan J. Martinez <jjm@usebox.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0c23670 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +all: + #make -C tools + #make -C data + make -j -C src all + +run: all + dosbox -config dosbox.conf + +clean: + #make -C data clean + make -C src clean + +cleanall: + make -C src clean + #make -C tools clean + +.PHONY: all clean run diff --git a/README.md b/README.md new file mode 100644 index 0000000..00976a6 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# ??? DOS game + +## Requirements + +Running the game: + +- MS/DOS or compatible +- A DOS extender, e.g. [CWSDPMI](http://sandmann.dotster.com/cwsdpmi/) +- 386 or later +- Some RAM! (TBD) + +Development: + +- GNU Make +- DJGPP C (using GCC 12.1.0; other may work) +- DOSBOX + +For DJGPP I recommend cross-compilation using [build-djgpp](https://github.com/andrewwutw/build-djgpp/). + +You can build the game with `make` and run it in DOSBOX with `make run`. + +## Author + +This was made by [Juan J. Martinez](https://www.usebox.net/jjm/about/me/). + +The code is licensed MIT, the assets [CC-SA-NC](https://creativecommons.org/licenses/by-sa/2.0/). + +Homepage: https://git.usebox.net/???/about/ + @@ -0,0 +1,27 @@ +# TODO + +- drawing + - set palette + - sw blitter +- time + - vga vsync + - tick counter +- input + - keyboard + - joystick? +- entity system + - free/used lists + - player +- sound + - SB samples + - MOD player? + - ADLIB music? +- data (embedded in EXE) + - image data: PNG + - map data: JSON +- screens + - menu + - game over + +# REVIEW + diff --git a/dosbox.conf b/dosbox.conf new file mode 100644 index 0000000..40a3657 --- /dev/null +++ b/dosbox.conf @@ -0,0 +1,245 @@ +# This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox)
+# Lines starting with a # are commentlines and are ignored by DOSBox.
+# They are used to (briefly) document the effect of each option.
+
+[sdl]
+# fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back)
+# fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox.
+# fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768).
+# Using your monitor's native resolution with aspect=true might give the best results.
+# If you end up with small window on a large screen, try an output different from surface.
+# windowresolution: Scale the window to this size IF the output device supports hardware scaling.
+# (output=surface does not!)
+# output: What video system to use for output.
+# Possible values: surface, overlay, opengl, openglnb, ddraw.
+# autolock: Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock)
+# sensitivity: Mouse sensitivity.
+# waitonerror: Wait before closing the console if dosbox has an error.
+# priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized.
+# pause is only valid for the second entry.
+# Possible values: lowest, lower, normal, higher, highest, pause.
+# mapperfile: File used to load/save the key/event mappings from. Resetmapper only works with the defaul value.
+# usescancodes: Avoid usage of symkeys, might not work on all operating systems.
+
+fullscreen=false
+fulldouble=false
+fullresolution=original
+windowresolution=original
+output=opengl
+autolock=true
+sensitivity=100
+waitonerror=true
+priority=higher,normal
+mapperfile=mapper-0.74.map
+usescancodes=true
+
+[dosbox]
+# language: Select another language file.
+# machine: The type of machine tries to emulate.
+# Possible values: hercules, cga, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe.
+# captures: Directory where things like wave, midi, screenshot get captured.
+# memsize: Amount of memory DOSBox has in megabytes.
+# This value is best left at its default to avoid problems with some games,
+# though few games might require a higher value.
+# There is generally no speed advantage when raising this value.
+
+language=
+machine=svga_s3
+captures=capture
+memsize=64
+
+[render]
+# frameskip: How many frames DOSBox skips before drawing one.
+# aspect: Do aspect correction, if your output method doesn't support scaling this can slow things down!.
+# scaler: Scaler used to enlarge/enhance low resolution modes.
+# If 'forced' is appended, then the scaler will be used even if the result might not be desired.
+# Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x.
+
+frameskip=0
+aspect=false
+scaler=normal2x
+
+[cpu]
+# core: CPU Core used in emulation. auto will switch to dynamic if available and appropriate.
+# Possible values: auto, dynamic, normal, simple.
+# cputype: CPU Type used in emulation. auto is the fastest choice.
+# Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch.
+# cycles: Amount of instructions DOSBox tries to emulate each millisecond.
+# Setting this value too high results in sound dropouts and lags.
+# Cycles can be set in 3 ways:
+# 'auto' tries to guess what a game needs.
+# It usually works, but can fail for certain games.
+# 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails.
+# (Example: fixed 4000).
+# 'max' will allocate as much cycles as your computer is able to handle.
+#
+# Possible values: auto, fixed, max.
+# cycleup: Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12)
+# cycledown: Setting it lower than 100 will be a percentage.
+
+core=auto
+cputype=auto
+cycles=max
+cycleup=10
+cycledown=20
+
+[mixer]
+# nosound: Enable silent mode, sound is still emulated though.
+# rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality.
+# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
+# blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged.
+# Possible values: 1024, 2048, 4096, 8192, 512, 256.
+# prebuffer: How many milliseconds of data to keep on top of the blocksize.
+
+nosound=false
+rate=44100
+blocksize=1024
+prebuffer=20
+
+[midi]
+# mpu401: Type of MPU-401 to emulate.
+# Possible values: intelligent, uart, none.
+# mididevice: Device that will receive the MIDI data from MPU-401.
+# Possible values: default, win32, alsa, oss, coreaudio, coremidi, none.
+# midiconfig: Special configuration options for the device driver. This is usually the id of the device you want to use.
+# See the README/Manual for more details.
+
+mpu401=intelligent
+mididevice=default
+midiconfig=
+
+[sblaster]
+# sbtype: Type of Soundblaster to emulate. gb is Gameblaster.
+# Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none.
+# sbbase: The IO address of the soundblaster.
+# Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300.
+# irq: The IRQ number of the soundblaster.
+# Possible values: 7, 5, 3, 9, 10, 11, 12.
+# dma: The DMA number of the soundblaster.
+# Possible values: 1, 5, 0, 3, 6, 7.
+# hdma: The High DMA number of the soundblaster.
+# Possible values: 1, 5, 0, 3, 6, 7.
+# sbmixer: Allow the soundblaster mixer to modify the DOSBox mixer.
+# oplmode: Type of OPL emulation. On 'auto' the mode is determined by sblaster type. All OPL modes are Adlib-compatible, except for 'cms'.
+# Possible values: auto, cms, opl2, dualopl2, opl3, none.
+# oplemu: Provider for the OPL emulation. compat might provide better quality (see oplrate as well).
+# Possible values: default, compat, fast.
+# oplrate: Sample rate of OPL music emulation. Use 49716 for highest quality (set the mixer rate accordingly).
+# Possible values: 44100, 49716, 48000, 32000, 22050, 16000, 11025, 8000.
+
+sbtype=sb16
+sbbase=220
+irq=7
+dma=1
+hdma=5
+sbmixer=true
+oplmode=auto
+oplemu=default
+oplrate=44100
+
+[gus]
+# gus: Enable the Gravis Ultrasound emulation.
+# gusrate: Sample rate of Ultrasound emulation.
+# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
+# gusbase: The IO base address of the Gravis Ultrasound.
+# Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300.
+# gusirq: The IRQ number of the Gravis Ultrasound.
+# Possible values: 5, 3, 7, 9, 10, 11, 12.
+# gusdma: The DMA channel of the Gravis Ultrasound.
+# Possible values: 3, 0, 1, 5, 6, 7.
+# ultradir: Path to Ultrasound directory. In this directory
+# there should be a MIDI directory that contains
+# the patch files for GUS playback. Patch sets used
+# with Timidity should work fine.
+
+gus=false
+gusrate=44100
+gusbase=240
+gusirq=5
+gusdma=3
+ultradir=C:\ULTRASND
+
+[speaker]
+# pcspeaker: Enable PC-Speaker emulation.
+# pcrate: Sample rate of the PC-Speaker sound generation.
+# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
+# tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'.
+# Possible values: auto, on, off.
+# tandyrate: Sample rate of the Tandy 3-Voice generation.
+# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
+# disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible).
+
+pcspeaker=true
+pcrate=44100
+tandy=auto
+tandyrate=44100
+disney=true
+
+[joystick]
+# joysticktype: Type of joystick to emulate: auto (default), none,
+# 2axis (supports two joysticks),
+# 4axis (supports one joystick, first joystick used),
+# 4axis_2 (supports one joystick, second joystick used),
+# fcs (Thrustmaster), ch (CH Flightstick).
+# none disables joystick emulation.
+# auto chooses emulation depending on real joystick(s).
+# (Remember to reset dosbox's mapperfile if you saved it earlier)
+# Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, none.
+# timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away).
+# autofire: continuously fires as long as you keep the button pressed.
+# swap34: swap the 3rd and the 4th axis. can be useful for certain joysticks.
+# buttonwrap: enable button wrapping at the number of emulated buttons.
+
+joysticktype=auto
+timed=true
+autofire=false
+swap34=false
+buttonwrap=false
+
+[serial]
+# serial1: set type of device connected to com port.
+# Can be disabled, dummy, modem, nullmodem, directserial.
+# Additional parameters must be in the same line in the form of
+# parameter:value. Parameter for all types is irq (optional).
+# for directserial: realport (required), rxdelay (optional).
+# (realport:COM1 realport:ttyS0).
+# for modem: listenport (optional).
+# for nullmodem: server, rxdelay, txdelay, telnet, usedtr,
+# transparent, port, inhsocket (all optional).
+# Example: serial1=modem listenport:5000
+# Possible values: dummy, disabled, modem, nullmodem, directserial.
+# serial2: see serial1
+# Possible values: dummy, disabled, modem, nullmodem, directserial.
+# serial3: see serial1
+# Possible values: dummy, disabled, modem, nullmodem, directserial.
+# serial4: see serial1
+# Possible values: dummy, disabled, modem, nullmodem, directserial.
+
+serial1=dummy
+serial2=dummy
+serial3=disabled
+serial4=disabled
+
+[dos]
+# xms: Enable XMS support.
+# ems: Enable EMS support.
+# umb: Enable UMB support.
+# keyboardlayout: Language code of the keyboard layout (or none).
+
+xms=true
+ems=true
+umb=true
+keyboardlayout=auto
+
+[ipx]
+# ipx: Enable ipx over UDP/IP emulation.
+
+ipx=false
+
+[autoexec]
+mount c .
+c:
+call game.exe
+pause
+exit
+
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..94b83eb --- /dev/null +++ b/src/Makefile @@ -0,0 +1,25 @@ +BIN := ../game.exe +CC := i586-pc-msdosdjgpp-gcc +CFLAGS := -I. -c -Wall -pedantic -O2 -march=i386 +LDFLAGS := -s + +SRCS := $(wildcard *.c) +OBJS := $(SRCS:.c=.o) + +all: $(BIN) + +$(BIN): $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +.c.o: + $(CC) $(CFLAGS) $< -o $@ + +clean: + rm -f $(BIN) *.o Makefile.deps + +Makefile.deps: $(SRCS) + $(CC) $(CFLAGS) -MM *.[ch] > Makefile.deps + +.PHONY: all clean + +include Makefile.deps diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..5b315df --- /dev/null +++ b/src/main.c @@ -0,0 +1,33 @@ +#include <stdint.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <conio.h> + +#include "vga.h" + +int main(int argc, char *argv[]) +{ + /* set VGA 320x200, 256 col */ + set_mode(0x13); + + uint8_t *screen = open_framebuffer(); + if (!screen) + { + fprintf(stderr, "ERROR: failed to open the framebuffer\n"); + return 1; + } + + for (int i = 0; i < 320 * 200 * 10; i++) + screen[rand() % (320 * 200)] = rand() % 255; + + printf("Hello DOS!\n"); + + getch(); + + set_mode(3); + close_framebuffer(); + + return 0; +} diff --git a/src/vga.c b/src/vga.c new file mode 100644 index 0000000..5badd82 --- /dev/null +++ b/src/vga.c @@ -0,0 +1,24 @@ +#include <stdlib.h> +#include <stdint.h> +#include <dpmi.h> +#include <sys/nearptr.h> + +uint8_t *open_framebuffer() +{ + if (__djgpp_nearptr_enable() == 0) + return NULL; + + return (uint8_t *)(0xa0000 + __djgpp_conventional_base); +} + +void close_framebuffer() +{ + __djgpp_nearptr_disable(); +} + +void set_mode(uint8_t mode) +{ + __dpmi_regs regs = { 0 }; + regs.x.ax = mode; + __dpmi_int(0x10, ®s); +} diff --git a/src/vga.h b/src/vga.h new file mode 100644 index 0000000..f35e6dd --- /dev/null +++ b/src/vga.h @@ -0,0 +1,9 @@ +#ifndef _VGA_H +#define _VGA_H + +uint8_t *open_framebuffer(); +void close_framebuffer(); + +void set_mode(uint8_t mode); + +#endif // _VGA_H |