Skip to content

Commit

Permalink
First commit of something actually working, at least with my demo file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyoyo committed Dec 26, 2022
0 parents commit b65e14a
Show file tree
Hide file tree
Showing 13 changed files with 2,336 additions and 0 deletions.
502 changes: 502 additions & 0 deletions COPYING

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
SOURCES_DIR=./src
BUILD_DIR=./build
DIST_DIR=./dist
RSC_DIR=./rsc

CC=m68k-atari-mint-gcc
CFLAGS=-c -O3
LINKFLAGS=-lz -s -Wl,--gc-sections

# VASM PARAMETERS
ASM=vasmm68k_mot
ASMFLAGS=-Faout -quiet -x -m68000 -spaces -showopt

all: prepare dist

prepare:
mkdir -p $(BUILD_DIR)

clean-compile : clean buffer.o screen.o main.o

sndhisr.o: prepare
$(ASM) $(ASMFLAGS) $(SOURCES_DIR)/sndhisr.s -o $(BUILD_DIR)/sndhisr.o

sndh.o: prepare
$(CC) $(CFLAGS) $(SOURCES_DIR)/sndh.c -o $(BUILD_DIR)/sndh.o

stvn.o: prepare
$(CC) $(CFLAGS) $(SOURCES_DIR)/stvn.c -o $(BUILD_DIR)/stvn.o

line.o: prepare
$(CC) $(CFLAGS) $(SOURCES_DIR)/line.c -o $(BUILD_DIR)/line.o

main: stvn.o line.o sndh.o sndhisr.o
$(CC) \
$(BUILD_DIR)/*.o \
-o $(BUILD_DIR)/stvn.prg $(LINKFLAGS);

dist: main
mkdir -p $(DIST_DIR)
cp $(BUILD_DIR)/stvn.prg $(DIST_DIR)
m68k-atari-mint-strip -s $(DIST_DIR)/stvn.prg
cp -R $(RSC_DIR)/* $(DIST_DIR)

clean:
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)

153 changes: 153 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# STVN
A very simple visual novel engine for Atari ST on monochrome high-res mode.

![stvn](/assets/stvn.png)

## Building
To build this, you need the following:
* GNU make
* m68k-atari-mint gcc toolchain
* vasmm68k_mot

## Prerequistes
* Atari ST (STe if you want to use DMA SNDH files)
* 1024KiB RAM, since mintlib refuses to init on 512K models. Everyone have 4MiB nowadays, right?
* Any TOS version should work (tested only on TOS 2.06)

## Running
* Provide a script file following the documented syntax
* Edit STVN.INI to meet your needs: script file and SNDH memory buffer, which should be the size of your largest SNDH file
* Run STVN.PRG from GEM Desktop.

## Key bindings
* 'Space' to advance
* 'q' Quit
* 's' Save state
* 'l' Load state
* 'b' Go back 1 text block
* 'h' Show help screen

## STVN.INI settings
As a sample, use the following:
```
STEST.VNS
B20000
```
'S' line is the script file
'B' line is the SNDH buffer space
Defaults: ``STVN.VNS`` & ``20000``

## Supported formats / limitations:
* For pictures: PI1/PI3 monochrome, uncompressed 32KiB files.
The palette isn't used, only the first 25600 bytes are read (640x360 image, leaving 40 pixels for text, 4 lines)

For audio: any SNDH with a working playback routine compatible with gwEm's sndhlib
Both can be gzipped.

Savestates: 4 supported, adding more would be trivial.
10 VN choices binary "registers", adding more wouldn't be very hard.
Scripts can be 999999 lines long.

All resource files must be placed in the 'data' subdirectory.

## Syntax:
Each line starts with an operand, like:
``IATARI.PI3``

Supported operands:
* 'W' : Wait for input

This is where most interaction will happen.

Like saving/loading, waiting for 'space', quitting, etc...

* 'I' : Change background image

Syntax: ``I[file]`` like ``IFILE.PI3``

Expected format is PI3, can (should) be gzipped, and is loaded entirely before being copied to video memory.

Only the first 320 lines are loaded and drawn, the rest of the screen being used for the text area.

A few bytes can thus be saved, for example bv removing the 400-lines padding code in pbmtopi3 source.

As the picture is loaded in RAM before being copied in vram, this operand will use 32000 bytes of RAM during operation, freed after.

This will obviously erase all sprites and clear the internal sprite list.

* 'S' : Sayer change

Syntax: ``Sname`` like `SToyoyo`

Obviously, this will reset character lines to 0.

This is used as the save pointer and will also reset the text box.

* 'T' : Text line

Syntax: ``Ttext`` like ``THere's a text line``

Line wrapping is disabled, so make sure a line isn't more than 79 characters!

* 'P' : Change music

Syntax: ``P[file]`` like ``PFILE.SND``

Expected format is uncompressed SNDH (use unice68), but can and should be gzipped, and is loaded entirely before starting its playing routine.

This uses gwEm's sndhlib code, which should be pretty robust, but I'm not responsible for bugged replay routines in SNDH files...

Note: Be sure to adjust the 'B' Line in STVN.INI to match the *uncompressed* size of your largest tune. The default is 20000 bytes.

* 'J' : Jump to label

Syntax: ``J[label]`` like `JLBL1```

A label 4 bytes sequence at the beginning of a line

* 'C' : Offer a choice and store it in a register

Key '1' entered: store 0

Key '2' entered: store 1

Syntax: ``C[register number]`` like ``C0``

Also offer the same interactions as a 'W' line.

* 'R' : Redraw the background picture.

More precisely, copy back the buffer of last loaded one into video memory.

This will obviously erase all sprites and clear the internal sprite list.

* 'B' : Jump to label if register is set.

Syntax: ``B[register number][label]`` like ``B0LBL1``

* 'D' : Wait the specified number of milliseconds (max 99999).

Syntax: ``D[msec]`` like ``D2000``

* 'A' : Load and draw a sprite in video memory.

Syntax: ``A[XXX][YYY][file]`` like ``A000000TOYO.SPR``

The expected format is derived from XPM, can (should) be gzipped and is plotted as it's read.

A converter script is provided.

Screen boundary are checked during drawing, but you can draw on the text area if you want.

More precicely: X coordinates after 640 are ignored and Y coordinates after 400 ends the drawing routine.

This can use quite some memory: 1 byte per pixel, allocated in 1024 bytes blocks, freed after operation.

And this is still drawn slower than a full screen image.

They're tracked as much as I could during load & back routines, so what *should* happen is:

* If you load a save, both background & sprites ('A' lines) encoutered between the lasts 'I' or 'R' lines are drawn.
* If you go back and neither background & sprites changes: nothing is drawn
* If you go back and there's a background change, this will also trigger a sprite draw pass.
* If you go back to the 'S' line just before a 'A' Line, it will trigger a draw pass too. This is by design: When the 'S' line happens, the sprite doesn't exist yet.
Binary file added assets/stvn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions demo/stdemo.vns
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
PTEST.SNZ
ISTREET.PIZ
SHinata
TI love taking nighttime strolls!
TI usually walk until down.
TI might be a night owl...
TOr, maybe it's just I like walking.
W
SHinata
TI want to write many lines today.
TOh, what happened?
TDid it clear the text box?
TYes it did!
A100000HINA.SPZ
W
SHinata
TWhat do I do?
T1:Stay?
T2:Leave?
C0
B0LSC2
SKana
TI want to say something too!
A500000HINA.SPZ
W
SHinata
TWhat I was saying again? And my line count even went back to 0...
W
SHinata
TAnyway...
W
LSC2
Pcubase.snd
ISTREET01.PI3
SHinata
TLet's just go out, which resets it again.
TSeems the music is different, too?
W
SHinata
TAnd well, it feels better.
T\o/
W
SHinata
TA last line before I go.
W
Psos.snd
IHOUSE.PI3
SHinata
TTadaima!
TThat's nice.
A200000HINA.SPZ
W
B0LSC3
SHinata
TBut I'll need to quit soon.
W
SHinata
TSadly
W
JLSC4
LSC3
SHinata
TOk!
W
SHinata
TI'll watch a movie.
W
SHinata
TThen take a nap.
W
LSC4

4 changes: 4 additions & 0 deletions demo/xpmtospr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

[ "$1" == "" ] && echo "Usage: $(basename $0) [xpm file]" && exit 1
tail -n +7 "$1" | sed 's/"//g' | sed 's/,//g' | sed 's/}//g' | sed 's/;//g' | sed 's/"//g' | sed 's/+/0/g' | sed 's/\./1/g'
2 changes: 2 additions & 0 deletions rsc/stvn.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SSTDEMO.VNS
B20000
Loading

0 comments on commit b65e14a

Please sign in to comment.