This commit is contained in:
Vilyaem 2025-01-11 06:05:10 -05:00
commit 75fa9c9dec
27 changed files with 2104 additions and 0 deletions

16
README.md Normal file
View file

@ -0,0 +1,16 @@
# SERAPHIM
![Screenshot](screenshot.png)
Video:http://vilyaem.xyz/videos/Seraphim%20Baremetal%20X86%20Demon%20Shooter.mkv
Seraphim is a baremetal x86-16bit shooter game written in C and Assembly.
You are an angel shooting at demons. Public Domain.
It runs well on DOSBOX and QEMU.
Monero XMR:48Sxa8J6518gqp4WeGtQ4rLe6SctPrEnnCqm6v6ydjLwRPi9Uh9gvVuUsU2AEDw75meTHCNY8KfU6Txysom4Bn5qPKMJ75w
Wownero WOW:WW2L2yC6DMg7GArAH3nqXPA6UBoRogf64GodceqA32SeZQpx27xd6rqN82e36KE48a8SAMSoXDB5WawAgVEFKfkw1Q5KSGfX9
Liberapay: https://liberapay.com/vilyaem/donate

7
c.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
cl
yasm x86boot.asm
gcc -O3 -std=c99 -m32 -march=i386 -fno-PIC -nostdlib -ffreestanding \
-o dos.com -Wl,--nmagic,--script=com.ld main.c && dosbox dos.com \
&& cat x86boot dos.com > seraphim.img #\
#&& qemu-system-x86_64 seraphim.img

311
caesar.spk Normal file
View file

@ -0,0 +1,311 @@
int song[] = {0,0xFFF,72,
144,0x00,72,
144,0xFFF,71,
288,0x00,71,
288,0xFFF,72,
433,0x00,72,
433,0xFFF,74,
576,0x00,74,
576,0xFFF,74,
721,0x00,74,
721,0xFFF,76,
865,0x00,76,
865,0xFFF,72,
1298,0x00,72,
1298,0xFFF,74,
1732,0x00,74,
1732,0xFFF,76,
1877,0x00,76,
1877,0xFFF,77,
2020,0x00,77,
2020,0xFFF,79,
2165,0x00,79,
2165,0xFFF,79,
2309,0x00,79,
2309,0xFFF,79,
2453,0x00,79,
2453,0xFFF,79,
2597,0x00,79,
2597,0xFFF,76,
2741,0x00,76,
2741,0xFFF,77,
2886,0x00,77,
2886,0xFFF,81,
303,0x00,81,
303,0xFFF,76,
34,0x00,76,
34,0xFFF,72,
3609,0x00,72,
3609,0xFFF,71,
3753,0x00,71,
3753,0xFFF,72,
3897,0x00,72,
3897,0xFFF,74,
4041,0x00,74,
4041,0xFFF,74,
4185,0x00,74,
4185,0xFFF,76,
4330,0x00,76,
4330,0xFFF,72,
4762,0x00,72,
4762,0xFFF,74,
5197,0x00,74,
5197,0xFFF,76,
5341,0x00,76,
5341,0xFFF,77,
5486,0x00,77,
5486,0xFFF,79,
5629,0x00,79,
5629,0xFFF,79,
5774,0x00,79,
5774,0xFFF,79,
5918,0x00,79,
5918,0xFFF,79,
6062,0x00,79,
6062,0xFFF,76,
6206,0x00,76,
6206,0xFFF,77,
635,0x00,77,
635,0xFFF,81,
95,0x00,81,
95,0xFFF,76,
6927,0x00,76,
6927,0xFFF,76,
7143,0x00,76,
7143,0xFFF,77,
7359,0x00,77,
7359,0xFFF,72,
7505,0x00,72,
7505,0xFFF,79,
765,0x00,79,
765,0xFFF,72,
7794,0x00,72,
7794,0xFFF,77,
8011,0x00,77,
8011,0xFFF,72,
8226,0x00,72,
8226,0xFFF,79,
8371,0x00,79,
8371,0xFFF,71,
8515,0x00,71,
8515,0xFFF,79,
8659,0x00,79,
8659,0xFFF,74,
8803,0x00,74,
8803,0xFFF,76,
8948,0x00,76,
8948,0xFFF,76,
9092,0x00,76,
9092,0xFFF,72,
9308,0x00,72,
9308,0xFFF,76,
9524,0x00,76,
9524,0xFFF,79,
9633,0x00,79,
9633,0xFFF,76,
9741,0x00,76,
9741,0xFFF,79,
9849,0x00,79,
9849,0xFFF,76,
9957,0x00,76,
9957,0xFFF,76,
10173,0x00,76,
10173,0xFFF,79,
1039,0x00,79,
1039,0xFFF,76,
10606,0x00,76,
10606,0xFFF,77,
10822,0x00,77,
10822,0xFFF,72,
10967,0x00,72,
10967,0xFFF,79,
1111,0x00,79,
1111,0xFFF,72,
11255,0x00,72,
11255,0xFFF,77,
11471,0x00,77,
11471,0xFFF,72,
11687,0x00,72,
11687,0xFFF,79,
11831,0x00,79,
11831,0xFFF,71,
11976,0x00,71,
11976,0xFFF,79,
1212,0x00,79,
1212,0xFFF,74,
122,0x00,74,
122,0xFFF,76,
12408,0x00,76,
12408,0xFFF,76,
12553,0x00,76,
12553,0xFFF,72,
12769,0x00,72,
12769,0xFFF,76,
12985,0x00,76,
12985,0xFFF,79,
13093,0x00,79,
13093,0xFFF,76,
13202,0x00,76,
13202,0xFFF,79,
1331,0x00,79,
1331,0xFFF,76,
13418,0x00,76,
13418,0xFFF,76,
13634,0x00,76,
13634,0xFFF,79,
13851,0x00,79,
13851,0xFFF,72,
13996,0x00,72,
13996,0xFFF,71,
14141,0x00,71,
14141,0xFFF,72,
14285,0x00,72,
14285,0xFFF,74,
14429,0x00,74,
14429,0xFFF,74,
14573,0x00,74,
14573,0xFFF,76,
14718,0x00,76,
14718,0xFFF,72,
15151,0x00,72,
15151,0xFFF,74,
15585,0x00,74,
15585,0xFFF,76,
15728,0x00,76,
15728,0xFFF,77,
15872,0x00,77,
15872,0xFFF,79,
16017,0x00,79,
16017,0xFFF,79,
16161,0x00,79,
16161,0xFFF,79,
16306,0x00,79,
16306,0xFFF,79,
149,0x00,79,
149,0xFFF,76,
16594,0x00,76,
16594,0xFFF,77,
16738,0x00,77,
16738,0xFFF,81,
16883,0x00,81,
16883,0xFFF,76,
17315,0x00,76,
17315,0xFFF,72,
17459,0x00,72,
17459,0xFFF,71,
17605,0x00,71,
17605,0xFFF,72,
17747,0x00,72,
17747,0xFFF,74,
17892,0x00,74,
17892,0xFFF,74,
18036,0x00,74,
18036,0xFFF,76,
1818,0x00,76,
1818,0xFFF,72,
18614,0x00,72,
18614,0xFFF,74,
19046,0x00,74,
19046,0xFFF,76,
19193,0x00,76,
19193,0xFFF,77,
19337,0x00,77,
19337,0xFFF,79,
19482,0x00,79,
19482,0xFFF,79,
19626,0x00,79,
19626,0xFFF,79,
19770,0x00,79,
1977,0xFFF,79,
19914,0x00,79,
19914,0xFFF,76,
20058,0x00,76,
20058,0xFFF,77,
20203,0x00,77,
20203,0xFFF,81,
20347,0x00,81,
20347,0xFFF,76,
20779,0x00,76,
20779,0xFFF,76,
20995,0x00,76,
20995,0xFFF,77,
21212,0x00,77,
21212,0xFFF,72,
21355,0x00,72,
21355,0xFFF,79,
21501,0x00,79,
21501,0xFFF,72,
21861,0x00,77,
21861,0xFFF,72,
22077,0x00,72,
22077,0xFFF,79,
22221,0x00,79,
22221,0xFFF,71,
22365,0x00,71,
22365,0xFFF,79,
22510,0x00,79,
22510,0xFFF,74,
22654,0x00,74,
22654,0xFFF,76,
22799,0x00,76,
22799,0xFFF,76,
22944,0x00,76,
22944,0xFFF,72,
23160,0x00,72,
23160,0xFFF,76,
23377,0x00,76,
23377,0xFFF,79,
23485,0x00,79,
23485,0xFFF,76,
23593,0x00,76,
23593,0xFFF,79,
23701,0x00,79,
23701,0xFFF,76,
23809,0x00,76,
23809,0xFFF,76,
24026,0x00,76,
24026,0xFFF,79,
24242,0x00,79,
24242,0xFFF,76,
24458,0x00,76,
24458,0xFFF,77,
24675,0x00,77,
24675,0xFFF,72,
24818,0x00,72,
24818,0xFFF,79,
24963,0x00,79,
24963,0xFFF,72,
25107,0x00,72,
25107,0xFFF,77,
25324,0x00,77,
25324,0xFFF,72,
25540,0x00,72,
25540,0xFFF,79,
25684,0x00,79,
25684,0xFFF,71,
25828,0x00,71,
25828,0xFFF,79,
25973,0x00,79,
25973,0xFFF,74,
26116,0x00,74,
26116,0xFFF,76,
2626,0x00,76,
2626,0xFFF,76,
205,0x00,76,
205,0xFFF,72,
26622,0x00,72,
26622,0xFFF,76,
26837,0x00,76,
26837,0xFFF,79,
26946,0x00,79,
26946,0xFFF,76,
27053,0x00,76,
27053,0xFFF,79,
27162,0x00,79,
27162,0xFFF,76,
27270,0x00,76,
27270,0xFFF,76,
27486,0x00,76,
27486,0xFFF,79,
0xDDD
};

16
com.ld Normal file
View file

@ -0,0 +1,16 @@
OUTPUT_FORMAT(binary)
SECTIONS
{
. = 0x0100;
.text :
{
*(.text);
}
.data :
{
*(.data);
*(.bss);
*(.rodata);
}
_heap = ALIGN(4);
}

3
dmn.xbm Normal file

File diff suppressed because one or more lines are too long

BIN
dos.com Executable file

Binary file not shown.

BIN
jsdos/seraphim.zip Normal file

Binary file not shown.

View file

@ -0,0 +1,193 @@
[sdl]
autolock=false
fullscreen=false
fulldouble=false
fullresolution=original
windowresolution=original
output=surface
sensitivity=100
waitonerror=true
priority=higher,normal
mapperfile=mapper-jsdos.map
usescancodes=true
vsync=false
[dosbox]
machine=svga_s3
language=
captures=capture
memsize=16
[cpu]
core=auto
cputype=auto
cycles=fixed 800
cycleup=10
cycledown=20
[mixer]
nosound=false
rate=44100
blocksize=1024
prebuffer=20
[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=none
[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]
echo off
mount c .
c:
type jsdos~1/readme.txt
echo on
S.COM

View file

@ -0,0 +1,9 @@
Please visit our website:
_ __
(_)____ ____/ /___ _____ _________ ____ ___
/ / ___/_____/ __ / __ \/ ___// ___/ __ \/ __ `__ \
/ (__ )_____/ /_/ / /_/ (__ )/ /__/ /_/ / / / / / /
__/ /____/ \__,_/\____/____(_)___/\____/_/ /_/ /_/
/___/

13
jsdos/seraphim/c.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
cl
yasm x86boot.asm
#gcc -O3 -std=c99 -m32 -march=i386 -fno-PIC -nostdlib -ffreestanding \
#-o dos.com -Wl,--nmagic,--script=com.ld main.c && dosbox dos.com \
#&& cat x86boot dos.com > seraphim.img \
#&& qemu-system-x86_64 seraphim.img
#gcc -O3 -std=c99 -m32 -march=i386 -fno-PIC -nostdlib -ffreestanding \
#-o dos.com -Wl,--nmagic,--script=com.ld main.c
gcc -g -std=c99 -m32 -march=i386 -fno-PIC -nostdlib -ffreestanding \
-o dos.com -Wl,--nmagic,--script=com.ld main.c

311
jsdos/seraphim/caesar.spk Normal file
View file

@ -0,0 +1,311 @@
int song[] = {0,0xFFF,72,
144,0x00,72,
144,0xFFF,71,
288,0x00,71,
288,0xFFF,72,
433,0x00,72,
433,0xFFF,74,
576,0x00,74,
576,0xFFF,74,
721,0x00,74,
721,0xFFF,76,
865,0x00,76,
865,0xFFF,72,
1298,0x00,72,
1298,0xFFF,74,
1732,0x00,74,
1732,0xFFF,76,
1877,0x00,76,
1877,0xFFF,77,
2020,0x00,77,
2020,0xFFF,79,
2165,0x00,79,
2165,0xFFF,79,
2309,0x00,79,
2309,0xFFF,79,
2453,0x00,79,
2453,0xFFF,79,
2597,0x00,79,
2597,0xFFF,76,
2741,0x00,76,
2741,0xFFF,77,
2886,0x00,77,
2886,0xFFF,81,
303,0x00,81,
303,0xFFF,76,
34,0x00,76,
34,0xFFF,72,
3609,0x00,72,
3609,0xFFF,71,
3753,0x00,71,
3753,0xFFF,72,
3897,0x00,72,
3897,0xFFF,74,
4041,0x00,74,
4041,0xFFF,74,
4185,0x00,74,
4185,0xFFF,76,
4330,0x00,76,
4330,0xFFF,72,
4762,0x00,72,
4762,0xFFF,74,
5197,0x00,74,
5197,0xFFF,76,
5341,0x00,76,
5341,0xFFF,77,
5486,0x00,77,
5486,0xFFF,79,
5629,0x00,79,
5629,0xFFF,79,
5774,0x00,79,
5774,0xFFF,79,
5918,0x00,79,
5918,0xFFF,79,
6062,0x00,79,
6062,0xFFF,76,
6206,0x00,76,
6206,0xFFF,77,
635,0x00,77,
635,0xFFF,81,
95,0x00,81,
95,0xFFF,76,
6927,0x00,76,
6927,0xFFF,76,
7143,0x00,76,
7143,0xFFF,77,
7359,0x00,77,
7359,0xFFF,72,
7505,0x00,72,
7505,0xFFF,79,
765,0x00,79,
765,0xFFF,72,
7794,0x00,72,
7794,0xFFF,77,
8011,0x00,77,
8011,0xFFF,72,
8226,0x00,72,
8226,0xFFF,79,
8371,0x00,79,
8371,0xFFF,71,
8515,0x00,71,
8515,0xFFF,79,
8659,0x00,79,
8659,0xFFF,74,
8803,0x00,74,
8803,0xFFF,76,
8948,0x00,76,
8948,0xFFF,76,
9092,0x00,76,
9092,0xFFF,72,
9308,0x00,72,
9308,0xFFF,76,
9524,0x00,76,
9524,0xFFF,79,
9633,0x00,79,
9633,0xFFF,76,
9741,0x00,76,
9741,0xFFF,79,
9849,0x00,79,
9849,0xFFF,76,
9957,0x00,76,
9957,0xFFF,76,
10173,0x00,76,
10173,0xFFF,79,
1039,0x00,79,
1039,0xFFF,76,
10606,0x00,76,
10606,0xFFF,77,
10822,0x00,77,
10822,0xFFF,72,
10967,0x00,72,
10967,0xFFF,79,
1111,0x00,79,
1111,0xFFF,72,
11255,0x00,72,
11255,0xFFF,77,
11471,0x00,77,
11471,0xFFF,72,
11687,0x00,72,
11687,0xFFF,79,
11831,0x00,79,
11831,0xFFF,71,
11976,0x00,71,
11976,0xFFF,79,
1212,0x00,79,
1212,0xFFF,74,
122,0x00,74,
122,0xFFF,76,
12408,0x00,76,
12408,0xFFF,76,
12553,0x00,76,
12553,0xFFF,72,
12769,0x00,72,
12769,0xFFF,76,
12985,0x00,76,
12985,0xFFF,79,
13093,0x00,79,
13093,0xFFF,76,
13202,0x00,76,
13202,0xFFF,79,
1331,0x00,79,
1331,0xFFF,76,
13418,0x00,76,
13418,0xFFF,76,
13634,0x00,76,
13634,0xFFF,79,
13851,0x00,79,
13851,0xFFF,72,
13996,0x00,72,
13996,0xFFF,71,
14141,0x00,71,
14141,0xFFF,72,
14285,0x00,72,
14285,0xFFF,74,
14429,0x00,74,
14429,0xFFF,74,
14573,0x00,74,
14573,0xFFF,76,
14718,0x00,76,
14718,0xFFF,72,
15151,0x00,72,
15151,0xFFF,74,
15585,0x00,74,
15585,0xFFF,76,
15728,0x00,76,
15728,0xFFF,77,
15872,0x00,77,
15872,0xFFF,79,
16017,0x00,79,
16017,0xFFF,79,
16161,0x00,79,
16161,0xFFF,79,
16306,0x00,79,
16306,0xFFF,79,
149,0x00,79,
149,0xFFF,76,
16594,0x00,76,
16594,0xFFF,77,
16738,0x00,77,
16738,0xFFF,81,
16883,0x00,81,
16883,0xFFF,76,
17315,0x00,76,
17315,0xFFF,72,
17459,0x00,72,
17459,0xFFF,71,
17605,0x00,71,
17605,0xFFF,72,
17747,0x00,72,
17747,0xFFF,74,
17892,0x00,74,
17892,0xFFF,74,
18036,0x00,74,
18036,0xFFF,76,
1818,0x00,76,
1818,0xFFF,72,
18614,0x00,72,
18614,0xFFF,74,
19046,0x00,74,
19046,0xFFF,76,
19193,0x00,76,
19193,0xFFF,77,
19337,0x00,77,
19337,0xFFF,79,
19482,0x00,79,
19482,0xFFF,79,
19626,0x00,79,
19626,0xFFF,79,
19770,0x00,79,
1977,0xFFF,79,
19914,0x00,79,
19914,0xFFF,76,
20058,0x00,76,
20058,0xFFF,77,
20203,0x00,77,
20203,0xFFF,81,
20347,0x00,81,
20347,0xFFF,76,
20779,0x00,76,
20779,0xFFF,76,
20995,0x00,76,
20995,0xFFF,77,
21212,0x00,77,
21212,0xFFF,72,
21355,0x00,72,
21355,0xFFF,79,
21501,0x00,79,
21501,0xFFF,72,
21861,0x00,77,
21861,0xFFF,72,
22077,0x00,72,
22077,0xFFF,79,
22221,0x00,79,
22221,0xFFF,71,
22365,0x00,71,
22365,0xFFF,79,
22510,0x00,79,
22510,0xFFF,74,
22654,0x00,74,
22654,0xFFF,76,
22799,0x00,76,
22799,0xFFF,76,
22944,0x00,76,
22944,0xFFF,72,
23160,0x00,72,
23160,0xFFF,76,
23377,0x00,76,
23377,0xFFF,79,
23485,0x00,79,
23485,0xFFF,76,
23593,0x00,76,
23593,0xFFF,79,
23701,0x00,79,
23701,0xFFF,76,
23809,0x00,76,
23809,0xFFF,76,
24026,0x00,76,
24026,0xFFF,79,
24242,0x00,79,
24242,0xFFF,76,
24458,0x00,76,
24458,0xFFF,77,
24675,0x00,77,
24675,0xFFF,72,
24818,0x00,72,
24818,0xFFF,79,
24963,0x00,79,
24963,0xFFF,72,
25107,0x00,72,
25107,0xFFF,77,
25324,0x00,77,
25324,0xFFF,72,
25540,0x00,72,
25540,0xFFF,79,
25684,0x00,79,
25684,0xFFF,71,
25828,0x00,71,
25828,0xFFF,79,
25973,0x00,79,
25973,0xFFF,74,
26116,0x00,74,
26116,0xFFF,76,
2626,0x00,76,
2626,0xFFF,76,
205,0x00,76,
205,0xFFF,72,
26622,0x00,72,
26622,0xFFF,76,
26837,0x00,76,
26837,0xFFF,79,
26946,0x00,79,
26946,0xFFF,76,
27053,0x00,76,
27053,0xFFF,79,
27162,0x00,79,
27162,0xFFF,76,
27270,0x00,76,
27270,0xFFF,76,
27486,0x00,76,
27486,0xFFF,79,
0xDDD
};

16
jsdos/seraphim/com.ld Normal file
View file

@ -0,0 +1,16 @@
OUTPUT_FORMAT(binary)
SECTIONS
{
. = 0x0100;
.text :
{
*(.text);
}
.data :
{
*(.data);
*(.bss);
*(.rodata);
}
_heap = ALIGN(4);
}

3
jsdos/seraphim/dmn.xbm Normal file

File diff suppressed because one or more lines are too long

BIN
jsdos/seraphim/dos.com Executable file

Binary file not shown.

View file

@ -0,0 +1,2 @@
[cpu]
cycles=fixed 1000

584
jsdos/seraphim/main.c Normal file
View file

@ -0,0 +1,584 @@
/*********************************************
* Description - Seraphim, Baremetal x86
* topdown shooter
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
__asm__ (".code16gcc\n"
"call dosmain\n"
"mov $0x4C,%ah\n"
"int $0x21\n");
/*----------PREPROCESSOR----------*/
#define COM1_PORT 0x3F8
#define VGA_RESX 320
#define VGA_RESY 200
#define VGA_MEM 0x9E6E0 /*This standards-wise should be 0xA0000*/
#define VGA_END VGA_MEM+VGA_RESX*VGA_RESY
#define FB_MEM VGA_END+32 /*Framebuffer location*/
#define FB_END FB_MEM+VGA_RESX*VGA_RESY
#define FG_COL 15
#define BG_COL 9
#define DMNS 4
#define BULLETS 64
#define SERAPH_MVSPEED 4
#define DMN_MVSPEED 3
#define KBDDVORAK 1
#define SONGTICKRT 3
/*monochromatic graphics*/
#include "seraph.xbm"
#include "dmn.xbm"
/*the song*/
#include "caesar.spk"
/*Typedef sucks*/
typedef char i8;
typedef int i16;
typedef unsigned char u8;
typedef unsigned int u16;
typedef void vo;
/*----------DATA STRUCTURES----------*/
typedef struct{
i16 x;
i16 y;
}Entity;
/*----------GLOBALS----------*/
i16 i,j;
Entity dmns[DMNS];
Entity fballs[BULLETS];
i16 fballptr = 0;
i16 sx = VGA_RESX/2-80;
i16 sy = VGA_RESY-100;
u8 frame = 0;
i16 songtick = 0;
/*keyboard scancode tables*/
#ifdef KBDQWERTY
u8 kbdmap[128]={0,27,'1','2','3','4','5','6','7',
'8','9','0','-','=','\b','\t','q','w','e','r','t','y','u','i','o','p','[',']',
'\n',0,'a','s','d','f','g','h','j','k','l',';','\'','`',0,'\\','z','x',
'c','v','b','n','m',',','.','/',0,'*',0,' ',0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,'-',0,0,0,'+',0,0,0,0,0,0,0,0,0};
#endif
#ifdef KBDDVORAK
u8 kbdmap[128]={0,27,'1','2','3','4','5','6','7',
'8','9','0','[',']','\b','\t','\'',',','.','p','y','f','g','c','r','l','/','=',
'\n',0,'a','o','e','u','i','d','h','t','n','s','-','`',0,'\\',';','q',
'j','k','x','b','m','w','v','z',0,'*',0,' ',0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,'-',0,0,0,'+',0,0,0,0,0,0,0,0,0};
#endif
/*----------FUNCTIONS----------*/
/*********************************************
* Description - Outb, write byte to IO port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo OutB(u8 value, i16 port){
__asm__ volatile ("outb %0, %1" : : "a"(value), "Nd"(port));
}
/*********************************************
* Description - Inb, read a byte from IO port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline u8 InB(i16 port){
u8 value;
__asm__ volatile ("inb %1, %0" : "=a"(value) : "Nd"(port));
return value;
}
/*********************************************
* Description - Put string text
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Puts(i8 *string){
__asm__ volatile ("mov $0xe0,%%bl\n"
"mov $0x09, %%ah\n"
"int $0x21\n"
: /* no output */
: "d"(string)
: "ah");
}
/*********************************************
* Description - Put a character
* Author - Vilyaem
* Date - May 16 2024
* *******************************************/
static inline vo PutChar(i16 c){
__asm__ volatile (/*"movl %0,%%ax\n"*/
"mov $0x02, %%ah\n"
"int $0x21\n"
: /*no output*/
: "r"(c)
: "eax");
}
/*********************************************
* Description - Start the PC Speaker
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline i16 Beep(i16 freq){
i16 div;
u8 tmp;
/*Set the PIT to the desired frequency*/
div = 1193180 / (u8)freq;
OutB(0x43, 0xb6);
OutB(0x42, (u8) (div) );
OutB(0x42, (u8) (div >> 8));
/*And play the sound using the PC speaker*/
tmp = InB(0x61);
if (tmp != (tmp | 3)) {
OutB(0x61, tmp | 3);
}
}
/*********************************************
* Description - Stop the PC Speaker
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo BeepOff(vo){
__asm__ volatile("in $0x61,%al\n"
"and $0xfc,%al\n"
"out %al,$0x61\n"
);
}
/*********************************************
* Description - Clear the screen in text mode,
* then move the cursor to the top right
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo TextClear(vo){
/*Clear the screen*/
__asm__ volatile("mov $0x06,%ah\n"
"mov $0,%al\n"
"mov $0x07,%bh\n"
"mov $0,%cx\n"
"mov $0x184F,%dx\n"
"int $0x10\n"
/*Set the cursor to the top left*/
"mov $0x02,%ah\n"
"mov $0x00,%bh\n"
"mov $0x00,%dh\n"
"mov $0x00,%dl\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Set Text Cursor Position
* TODO
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline vo SetCursorPos(i16 x, i16 y){
/*Set X and Y*/
__asm__ volatile(
"mov $0x02,%ah\n"
"mov $0x00,%bh\n"
"mov $0x00,%dh\n"
"mov $0x00,%dl\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Set text colours
* TODO
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo SetTextColour(i16 fg, i16 bg){
__asm__ volatile ("mov $0x9, %%ah\n"
"mov $9,%%bl\n"
"mov $9,%%cx\n"
"int $0x10\n"
: /*no output*/
: "r"(fg),"r"(bg)
: );
}
/*********************************************
* Description - Turn on VGA mode
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Vga(vo){
__asm__ volatile(
"mov $0x0013,%ax\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Turn off VGA mode
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo VgaOff(vo){
__asm__ volatile(
"mov $0x0003,%ax\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Plot a pixel in VGA
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo VgaPutPx(i16 x, i16 y, u8 vgacol){
u8* location = (u8*)VGA_MEM + VGA_RESX * y + x;
*location = vgacol;
}
/*********************************************
* Description - Shut the machine down via
* reset vector or triple fault
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Shutdown(vo){
__asm__ volatile("jmp 0xFFFF");
}
/*********************************************
* Description - Get a key press
* Reads straight from the IO port then
* picks from scancode table
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline i8 GetKey(vo){
i8 c;
c = kbdmap[InB(0x60)];
return c;
}
/*********************************************
* Description - Wipe the VGA screen
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline vo VgaClear(i16 col){
u8* loc = (u8*)VGA_MEM;
u8* dest = (u8*)VGA_END;
while((u8*)loc != (u8*)dest){
*loc=col;
++loc;
}
}
/*********************************************
* Description - Our Oracle
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline i16 GetOracle(vo){
u16 oracle;
__asm__ volatile("rdtsc\nmov %%eax,%0" : "=a" (oracle));
return oracle;
}
/*********************************************
* Description - Sleep for an amount of time
*
* 1000 is one second
* this is a nasty hacktogether
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Sleep(i16 time){
i16 nexttime = GetOracle() + time;
while(GetOracle() <= nexttime){
}
}
/*********************************************
* Description - Convert i16egers into strings
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline i8* Int2Str(i16 num, i8* string){
if(num == 0){
*string = '0';
*(string+1) = 0;
return string;
}
i8* start = string;
if(num < 0 ){
*start = '-';
num *= -1;
++start;
}
while(num > 0 ){
*start = '0' + num % 10;
num /= 10;
++start;
}
*start = 0;
i8* end = start - 1;
start = string + (*string == '-');
while(end > start ){
i8 t = *start;
*start = *end;
*end = t;
++start;
end--;
}
return string;
}
/*********************************************
* Description - Output data to serial port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo SerialWrite(u8 data){
OutB(data,COM1_PORT);
}
/*********************************************
* Description - Output text to serial port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo SerialPuts(u8 msg[]){
for(i = 0; msg[i] != '$';++i){
SerialWrite(msg[i]);
}
SerialWrite('\n');
SerialWrite('\r');
}
/*********************************************
* Description - Paint the framebuffer to VGA
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrFlip(){
u8* fbloc = (u8*)FB_MEM;
u8* loc = (u8*)VGA_MEM;
u8* dest = (u8*)VGA_END;
while((u8*)loc != (u8*)dest){
*loc=*fbloc;
++loc;
++fbloc;
}
}
/*********************************************
* Description - Put a pixel on the framebuffer
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrPutPx(i16 x, i16 y, u8 col){
if(x <= VGA_RESX && y <= VGA_RESY && x >= 0 && y >= 0){
*(u8*)(FB_MEM + VGA_RESX * y + x) = col;
}
}
/*********************************************
* Description - Clear the framebuffer
* given a colour
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrClear(u8 col){
u8* loc = (u8*)FB_MEM;
u8* dest = (u8*)FB_END;
while((u8*)loc != (u8*)dest){
*loc=col;
++loc;
}
}
/*********************************************
* Description - Draw an XBM image
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrDrawXBM(u8 xbm[], i16 xpos, i16 ypos, i16 width, i16 height){
i16 bwidth = (width + 7) / 8;
for (i16 y = 0; y != height; ++y) {
for (i16 x = 0; x != width; ++x) {
i16 pix = (i16)xbm[y * bwidth + x / 8];
i16 mask = (i16)(1 << (x % 8));
if((pix & mask)){
GrPutPx(x+xpos,y+ypos,FG_COL);
}
}
}
}
/*********************************************
* Description - Get 16-bit random integer
* in range
* Author - Vilyaem
* Date - May 17 2024
* *******************************************/
static inline i16 I16RandRange(i16 min, i16 max){
i16 low,high;
__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
return (i16)((high << 4) | low) % max + min;
}
/*********************************************
* Description - Cheap 2D distance via Chebyshev
* Author - William King
* Date - Mar 12 2024
* *******************************************/
static inline i16 DistCheb(int x0, int y0, int x1, int y1){
x0 = x1 > x0 ? x1 - x0 : x0 - x1;
y0 = y1 > y0 ? y1 - y0 : y0 - y1;
return x0 > y0 ? x0 : y0;
}
/*********************************************
* Description - Fire a fireball
* Author - Vilyaem
* Date - May 17 2024
* *******************************************/
static inline vo FireBall(){
fballs[fballptr].x = sx + 75;
fballs[fballptr].y = sy + 20;
++fballptr;
if(fballptr >= BULLETS){
fballptr = 0;
}
}
/*********************************************
* Description - Draw a fireball
* Author - Vilyaem
* Date - May 19 2024
* *******************************************/
static inline vo DrawFireball(int x, int y){
i16 size = y / 2;
if(size >= 1){
for(j = 0; j != 64;++j){
GrPutPx(x+I16RandRange(0,size),y+I16RandRange(0,size),FG_COL);
GrPutPx(x-I16RandRange(0,size),y+I16RandRange(0,size),FG_COL);
GrPutPx(x+I16RandRange(0,size),y-I16RandRange(0,size),FG_COL);
GrPutPx(x-I16RandRange(0,size),y-I16RandRange(0,size),FG_COL);
}
}
}
/*********************************************
* Description - Main
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
i16 dosmain(vo){
u8 sstr[] = { 'V','I','L','Y','A','E','M','$'};
SerialPuts(sstr);
/*Init*/
Vga();
for(i = 0; i != DMNS;++i){
dmns[i].x = I16RandRange(10,220);
dmns[i].y = -96-I16RandRange(10,50);
}
for(i = 0; i != BULLETS;++i){
fballs[i].x = 0;
fballs[i].y = -40;
}
while(1){
GrClear(BG_COL);
/*Handle and draw demons*/
for(i = 0; i != DMNS;++i){
dmns[i].y += DMN_MVSPEED;
if(dmns[i].y > 600){
dmns[i].y = -96-I16RandRange(10,50);
dmns[i].x = I16RandRange(10,220);
}
for(j = 0; j != DMNS;++j){
if(DistCheb(dmns[i].x,dmns[i].y,fballs[j].x,fballs[i].y) <= 80){
dmns[i].y = -96-I16RandRange(10,50);
dmns[i].x = I16RandRange(10,220);
}
}
if(dmns[i].y >= -40){
GrDrawXBM(dmn_bits,dmns[i].x,dmns[i].y,dmn_width,dmn_height);
}
}
/*Handle and draw fireballs*/
for(i = 0; i != fballptr;++i){
if(fballs[i].y >= -40){
fballs[i].y -= DMN_MVSPEED;
DrawFireball(fballs[i].x,fballs[i].y);
}
}
/*Draw player*/
GrDrawXBM(seraph_bits,sx,sy,seraph_width,seraph_height);
/*Paint to VGA Memory*/
GrFlip();
/*Input*/
switch(GetKey()){
case ',': sy -= SERAPH_MVSPEED;break;
case 'a': sx -= SERAPH_MVSPEED;break;
case 'e': sx += SERAPH_MVSPEED;break;
case 'o': sy += SERAPH_MVSPEED;break;
case ' ': FireBall();break;
case 'x': Shutdown();break;
default:Beep(100);BeepOff();break;
}
DrawFireball(VGA_RESX/2,VGA_RESY/2);
/*Keep the player in bounds
like a magnet, they can obviously
still fly away*/
if(sy < 0-3){
sy += 3;
}
else if(sy > VGA_RESY-64){
sy -= 3;
}
else if(sx < 0-3){
sx += 3;
}
else if(sx > VGA_RESY+3){
sx -= 3;
}
}
return 0;
}

File diff suppressed because one or more lines are too long

BIN
jsdos/seraphim/seraphim.img Normal file

Binary file not shown.

BIN
jsdos/seraphim/seraphim.zip Normal file

Binary file not shown.

BIN
jsdos/seraphim/x86boot Normal file

Binary file not shown.

View file

@ -0,0 +1,15 @@
;NASM X86 bootloader
BITS 16
org 0x7c00
mov ax, 0
mov es, ax
mov ah, 0x02 ; Read Sectors From Drive
mov al, 8 ; sector count
mov ch, 0 ; cylinder
mov cl, 2 ; sector
mov dh, 0 ; head
mov bx, 0x500 ; destination address
int 0x13
jmp 0:0x500
times 510 -( $ - $$ ) db 0
db 0x55, 0xaa

582
main.c Normal file
View file

@ -0,0 +1,582 @@
/*********************************************
* Description - Seraphim, Baremetal x86
* topdown shooter
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
__asm__ (".code16gcc\n"
"call dosmain\n"
"mov $0x4C,%ah\n"
"int $0x21\n");
/*----------PREPROCESSOR----------*/
#define COM1_PORT 0x3F8
#define VGA_RESX 320
#define VGA_RESY 200
#define VGA_MEM 0x9E6E0 /*This standards-wise should be 0xA0000*/
#define VGA_END VGA_MEM+VGA_RESX*VGA_RESY
#define FB_MEM VGA_END+32 /*Framebuffer location*/
#define FB_END FB_MEM+VGA_RESX*VGA_RESY
#define FG_COL 15
#define BG_COL 9
#define DMNS 4
#define BULLETS 64
#define SERAPH_MVSPEED 4
#define DMN_MVSPEED 3
#define KBDDVORAK 1
#define SONGTICKRT 3
/*monochromatic graphics*/
#include "seraph.xbm"
#include "dmn.xbm"
/*the song*/
#include "caesar.spk"
/*Typedef sucks*/
typedef char i8;
typedef int i16;
typedef unsigned char u8;
typedef unsigned int u16;
typedef void vo;
/*----------DATA STRUCTURES----------*/
typedef struct{
i16 x;
i16 y;
}Entity;
/*----------GLOBALS----------*/
i16 i,j;
Entity dmns[DMNS];
Entity fballs[BULLETS];
i16 fballptr = 0;
i16 sx = VGA_RESX/2-80;
i16 sy = VGA_RESY-100;
u8 frame = 0;
i16 songtick = 0;
/*keyboard scancode tables*/
#ifdef KBDQWERTY
u8 kbdmap[128]={0,27,'1','2','3','4','5','6','7',
'8','9','0','-','=','\b','\t','q','w','e','r','t','y','u','i','o','p','[',']',
'\n',0,'a','s','d','f','g','h','j','k','l',';','\'','`',0,'\\','z','x',
'c','v','b','n','m',',','.','/',0,'*',0,' ',0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,'-',0,0,0,'+',0,0,0,0,0,0,0,0,0};
#endif
#ifdef KBDDVORAK
u8 kbdmap[128]={0,27,'1','2','3','4','5','6','7',
'8','9','0','[',']','\b','\t','\'',',','.','p','y','f','g','c','r','l','/','=',
'\n',0,'a','o','e','u','i','d','h','t','n','s','-','`',0,'\\',';','q',
'j','k','x','b','m','w','v','z',0,'*',0,' ',0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,'-',0,0,0,'+',0,0,0,0,0,0,0,0,0};
#endif
/*----------FUNCTIONS----------*/
/*********************************************
* Description - Outb, write byte to IO port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo OutB(u8 value, i16 port){
__asm__ volatile ("outb %0, %1" : : "a"(value), "Nd"(port));
}
/*********************************************
* Description - Inb, read a byte from IO port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline u8 InB(i16 port){
u8 value;
__asm__ volatile ("inb %1, %0" : "=a"(value) : "Nd"(port));
return value;
}
/*********************************************
* Description - Put string text
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Puts(i8 *string){
__asm__ volatile ("mov $0xe0,%%bl\n"
"mov $0x09, %%ah\n"
"int $0x21\n"
: /* no output */
: "d"(string)
: "ah");
}
/*********************************************
* Description - Put a character
* Author - Vilyaem
* Date - May 16 2024
* *******************************************/
static inline vo PutChar(i16 c){
__asm__ volatile (/*"movl %0,%%ax\n"*/
"mov $0x02, %%ah\n"
"int $0x21\n"
: /*no output*/
: "r"(c)
: "eax");
}
/*********************************************
* Description - Start the PC Speaker
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline i16 Beep(i16 freq){
i16 div;
u8 tmp;
/*Set the PIT to the desired frequency*/
div = 1193180 / (u8)freq;
OutB(0x43, 0xb6);
OutB(0x42, (u8) (div) );
OutB(0x42, (u8) (div >> 8));
/*And play the sound using the PC speaker*/
tmp = InB(0x61);
if (tmp != (tmp | 3)) {
OutB(0x61, tmp | 3);
}
}
/*********************************************
* Description - Stop the PC Speaker
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo BeepOff(vo){
__asm__ volatile("in $0x61,%al\n"
"and $0xfc,%al\n"
"out %al,$0x61\n"
);
}
/*********************************************
* Description - Clear the screen in text mode,
* then move the cursor to the top right
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo TextClear(vo){
/*Clear the screen*/
__asm__ volatile("mov $0x06,%ah\n"
"mov $0,%al\n"
"mov $0x07,%bh\n"
"mov $0,%cx\n"
"mov $0x184F,%dx\n"
"int $0x10\n"
/*Set the cursor to the top left*/
"mov $0x02,%ah\n"
"mov $0x00,%bh\n"
"mov $0x00,%dh\n"
"mov $0x00,%dl\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Set Text Cursor Position
* TODO
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline vo SetCursorPos(i16 x, i16 y){
/*Set X and Y*/
__asm__ volatile(
"mov $0x02,%ah\n"
"mov $0x00,%bh\n"
"mov $0x00,%dh\n"
"mov $0x00,%dl\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Set text colours
* TODO
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo SetTextColour(i16 fg, i16 bg){
__asm__ volatile ("mov $0x9, %%ah\n"
"mov $9,%%bl\n"
"mov $9,%%cx\n"
"int $0x10\n"
: /*no output*/
: "r"(fg),"r"(bg)
: );
}
/*********************************************
* Description - Turn on VGA mode
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Vga(vo){
__asm__ volatile(
"mov $0x0013,%ax\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Turn off VGA mode
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo VgaOff(vo){
__asm__ volatile(
"mov $0x0003,%ax\n"
"int $0x10\n"
);
}
/*********************************************
* Description - Plot a pixel in VGA
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo VgaPutPx(i16 x, i16 y, u8 vgacol){
u8* location = (u8*)VGA_MEM + VGA_RESX * y + x;
*location = vgacol;
}
/*********************************************
* Description - Shut the machine down via
* reset vector or triple fault
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Shutdown(vo){
__asm__ volatile("jmp 0xFFFF");
}
/*********************************************
* Description - Get a key press
* Reads straight from the IO port then
* picks from scancode table
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline i8 GetKey(vo){
i8 c;
c = kbdmap[InB(0x60)];
return c;
}
/*********************************************
* Description - Wipe the VGA screen
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline vo VgaClear(i16 col){
u8* loc = (u8*)VGA_MEM;
u8* dest = (u8*)VGA_END;
while((u8*)loc != (u8*)dest){
*loc=col;
++loc;
}
}
/*********************************************
* Description - Our Oracle
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline i16 GetOracle(vo){
u16 oracle;
__asm__ volatile("rdtsc\nmov %%eax,%0" : "=a" (oracle));
return oracle;
}
/*********************************************
* Description - Sleep for an amount of time
*
* 1000 is one second
* this is a nasty hacktogether
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
static inline vo Sleep(i16 time){
i16 nexttime = GetOracle() + time;
while(GetOracle() <= nexttime){
}
}
/*********************************************
* Description - Convert i16egers into strings
* Author - Vilyaem
* Date - May 14 2024
* *******************************************/
static inline i8* Int2Str(i16 num, i8* string){
if(num == 0){
*string = '0';
*(string+1) = 0;
return string;
}
i8* start = string;
if(num < 0 ){
*start = '-';
num *= -1;
++start;
}
while(num > 0 ){
*start = '0' + num % 10;
num /= 10;
++start;
}
*start = 0;
i8* end = start - 1;
start = string + (*string == '-');
while(end > start ){
i8 t = *start;
*start = *end;
*end = t;
++start;
end--;
}
return string;
}
/*********************************************
* Description - Output data to serial port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo SerialWrite(u8 data){
OutB(data,COM1_PORT);
}
/*********************************************
* Description - Output text to serial port
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo SerialPuts(u8 msg[]){
for(i = 0; msg[i] != '$';++i){
SerialWrite(msg[i]);
}
SerialWrite('\n');
SerialWrite('\r');
}
/*********************************************
* Description - Paint the framebuffer to VGA
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrFlip(){
u8* fbloc = (u8*)FB_MEM;
u8* loc = (u8*)VGA_MEM;
u8* dest = (u8*)VGA_END;
while((u8*)loc != (u8*)dest){
*loc=*fbloc;
++loc;
++fbloc;
}
}
/*********************************************
* Description - Put a pixel on the framebuffer
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrPutPx(i16 x, i16 y, u8 col){
if(x <= VGA_RESX && y <= VGA_RESY && x >= 0 && y >= 0){
*(u8*)(FB_MEM + VGA_RESX * y + x) = col;
}
}
/*********************************************
* Description - Clear the framebuffer
* given a colour
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrClear(u8 col){
u8* loc = (u8*)FB_MEM;
u8* dest = (u8*)FB_END;
while((u8*)loc != (u8*)dest){
*loc=col;
++loc;
}
}
/*********************************************
* Description - Draw an XBM image
* Author - Vilyaem
* Date - May 15 2024
* *******************************************/
static inline vo GrDrawXBM(u8 xbm[], i16 xpos, i16 ypos, i16 width, i16 height){
i16 bwidth = (width + 7) / 8;
for (i16 y = 0; y != height; ++y) {
for (i16 x = 0; x != width; ++x) {
i16 pix = (i16)xbm[y * bwidth + x / 8];
i16 mask = (i16)(1 << (x % 8));
if((pix & mask)){
GrPutPx(x+xpos,y+ypos,FG_COL);
}
}
}
}
/*********************************************
* Description - Get 16-bit random integer
* in range
* Author - Vilyaem
* Date - May 17 2024
* *******************************************/
static inline i16 I16RandRange(i16 min, i16 max){
i16 low,high;
__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
return (i16)((high << 4) | low) % max + min;
}
/*********************************************
* Description - Cheap 2D distance via Chebyshev
* Author - William King
* Date - Mar 12 2024
* *******************************************/
static inline i16 DistCheb(int x0, int y0, int x1, int y1){
x0 = x1 > x0 ? x1 - x0 : x0 - x1;
y0 = y1 > y0 ? y1 - y0 : y0 - y1;
return x0 > y0 ? x0 : y0;
}
/*********************************************
* Description - Fire a fireball
* Author - Vilyaem
* Date - May 17 2024
* *******************************************/
static inline vo FireBall(){
fballs[fballptr].x = sx + 75;
fballs[fballptr].y = sy + 20;
++fballptr;
if(fballptr >= BULLETS){
fballptr = 0;
}
}
/*********************************************
* Description - Draw a fireball
* Author - Vilyaem
* Date - May 19 2024
* *******************************************/
static inline vo DrawFireball(int x, int y){
i16 size = y / 2;
if(size >= 1){
for(j = 0; j != 64;++j){
GrPutPx(x+I16RandRange(0,size),y+I16RandRange(0,size),FG_COL);
GrPutPx(x-I16RandRange(0,size),y+I16RandRange(0,size),FG_COL);
GrPutPx(x+I16RandRange(0,size),y-I16RandRange(0,size),FG_COL);
GrPutPx(x-I16RandRange(0,size),y-I16RandRange(0,size),FG_COL);
}
}
}
/*********************************************
* Description - Main
* Author - Vilyaem
* Date - May 12 2024
* *******************************************/
i16 dosmain(vo){
u8 sstr[] = { 'V','I','L','Y','A','E','M','$'};
SerialPuts(sstr);
/*Init*/
Vga();
for(i = 0; i != DMNS;++i){
dmns[i].x = I16RandRange(10,220);
dmns[i].y = -96-I16RandRange(10,50);
}
for(i = 0; i != BULLETS;++i){
fballs[i].x = 0;
fballs[i].y = -40;
}
while(1){
GrClear(BG_COL);
/*Handle and draw demons*/
for(i = 0; i != DMNS;++i){
dmns[i].y += DMN_MVSPEED;
if(dmns[i].y > 600){
dmns[i].y = -96-I16RandRange(10,50);
dmns[i].x = I16RandRange(10,220);
}
for(j = 0; j != DMNS;++j){
if(DistCheb(dmns[i].x,dmns[i].y,fballs[j].x,fballs[i].y) <= 80){
dmns[i].y = -96-I16RandRange(10,50);
dmns[i].x = I16RandRange(10,220);
}
}
if(dmns[i].y >= -40){
GrDrawXBM(dmn_bits,dmns[i].x,dmns[i].y,dmn_width,dmn_height);
}
}
/*Handle and draw fireballs*/
for(i = 0; i != fballptr;++i){
if(fballs[i].y >= -40){
fballs[i].y -= DMN_MVSPEED;
DrawFireball(fballs[i].x,fballs[i].y);
}
}
/*Draw player*/
GrDrawXBM(seraph_bits,sx,sy,seraph_width,seraph_height);
/*Paint to VGA Memory*/
GrFlip();
/*Input*/
switch(GetKey()){
case ',': sy -= SERAPH_MVSPEED;break;
case 'a': sx -= SERAPH_MVSPEED;break;
case 'e': sx += SERAPH_MVSPEED;break;
case 'o': sy += SERAPH_MVSPEED;break;
case ' ': FireBall();break;
case 'x': Shutdown();break;
default:Beep(100);BeepOff();break;
}
DrawFireball(VGA_RESX/2,VGA_RESY/2);
/*Keep the player in bounds
like a magnet, they can obviously
still fly away*/
if(sy < 0-3){
sy += 3;
}
else if(sy > VGA_RESY-64){
sy -= 3;
}
else if(sx < 0-3){
sx += 3;
}
else if(sx > VGA_RESY+3){
sx -= 3;
}
}
return 0;
}

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

4
seraph.xbm Normal file

File diff suppressed because one or more lines are too long

BIN
seraphim.img Normal file

Binary file not shown.

BIN
x86boot Normal file

Binary file not shown.

15
x86boot.asm Normal file
View file

@ -0,0 +1,15 @@
;NASM X86 bootloader
BITS 16
org 0x7c00
mov ax, 0
mov es, ax
mov ah, 0x02 ; Read Sectors From Drive
mov al, 8 ; sector count
mov ch, 0 ; cylinder
mov cl, 2 ; sector
mov dh, 0 ; head
mov bx, 0x500 ; destination address
int 0x13
jmp 0:0x500
times 510 -( $ - $$ ) db 0
db 0x55, 0xaa