Initial commit

This commit is contained in:
2024-05-23 19:38:02 +03:00
commit e434b96ec2
27 changed files with 6381 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.obj
*.exe
*.html
__temp*.*

21
4kdemo.compofiller Normal file
View File

@ -0,0 +1,21 @@
# Compofiller Studio project file
PROJECT_NAME=MyProject
PROJECT_INFO_FILE=prod.nfo
PROJECT_SCREENSHOT=
# Currently active config file name
ACTIVE_CONFIG=base.config
# ------- GUI options/preferences --------
# Automatically rebuild DLLs when things have changed?
AUTOREBUILD_DLLS=1
# Keep the previous audio buffer when rebuilding DLLs, allocating a new fresh buffer?
# Even if the previous audio is kept, a new audio rendering thread is started.
KEEP_AUDIO=1
# ------ Timings and texts editor options/preferences ------
AUTO_LOCATE_TO_ACTIVE_TEXT=1

1758
4klang.asm Normal file

File diff suppressed because it is too large Load Diff

22
4klang.h Normal file
View File

@ -0,0 +1,22 @@
// some useful song defines for 4klang
#define SAMPLE_RATE 44100
#define BPM 120.000000
#define MAX_INSTRUMENTS 3
#define MAX_PATTERNS 50
#define PATTERN_SIZE_SHIFT 4
#define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
#define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
#define SAMPLES_PER_TICK 5512
#define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
#define POLYPHONY 1
#define INTEGER_16BIT
#define SAMPLE_TYPE short
#define WINDOWS_OBJECT
// declaration of the external synth render function, you'll always need that
extern "C" void __stdcall _4klang_render(void*);
// declaration of the external envelope buffer. access only if you're song was exported with that option
extern "C" float _4klang_envelope_buffer;
// declaration of the external note buffer. access only if you're song was exported with that option
extern "C" int _4klang_note_buffer;

621
4klang.inc Normal file
View File

@ -0,0 +1,621 @@
%macro export_func 1
global _%1
_%1:
%endmacro
%define USE_SECTIONS
%define SAMPLE_RATE 44100
%define MAX_INSTRUMENTS 3
%define MAX_VOICES 1
%define HLD 1
%define BPM 120.000000
%define MAX_PATTERNS 50
%define PATTERN_SIZE_SHIFT 4
%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
%define SAMPLES_PER_TICK 5512
%define DEF_LFO_NORMALIZE 0.0000453515
%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
%define GO4K_USE_16BIT_OUTPUT
;%define GO4K_USE_GROOVE_PATTERN
;%define GO4K_USE_ENVELOPE_RECORDINGS
;%define GO4K_USE_NOTE_RECORDINGS
%define GO4K_CLIP_OUTPUT
%define GO4K_USE_DLL
%define GO4K_USE_GLOBAL_DLL
%define GO4K_USE_ENV_CHECK
%define GO4K_USE_VCO_CHECK
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCF_CHECK
%define GO4K_USE_VCF_MOD_FM
%define GO4K_USE_VCF_HIGH
%define GO4K_USE_VCF_BAND
%define GO4K_USE_VCF_PEAK
%define GO4K_USE_DST_CHECK
%define GO4K_USE_DLL_CHORUS
%define GO4K_USE_DLL_CHORUS_CLAMP
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_FSTG_CHECK
%define GO4K_USE_WAVESHAPER_CLIP
%define MAX_DELAY 65536
%define MAX_UNITS 64
%define MAX_UNIT_SLOTS 16
%define GO4K_BEGIN_CMDDEF(def_name)
%define GO4K_END_CMDDEF db 0
%define GO4K_BEGIN_PARAMDEF(def_name)
%define GO4K_END_PARAMDEF
GO4K_ENV_ID equ 1
%macro GO4K_ENV 5
db %1
db %2
db %3
db %4
db %5
%endmacro
%define ATTAC(val) val
%define DECAY(val) val
%define SUSTAIN(val) val
%define RELEASE(val) val
%define GAIN(val) val
struc go4kENV_val
.attac resd 1
.decay resd 1
.sustain resd 1
.release resd 1
.gain resd 1
.size
endstruc
struc go4kENV_wrk
.state resd 1
.level resd 1
.gm resd 1
.am resd 1
.dm resd 1
.sm resd 1
.rm resd 1
.size
endstruc
%define ENV_STATE_ATTAC 0
%define ENV_STATE_DECAY 1
%define ENV_STATE_SUSTAIN 2
%define ENV_STATE_RELEASE 3
%define ENV_STATE_OFF 4
GO4K_VCO_ID equ 2
%macro GO4K_VCO 8
db %1
db %2
%ifdef GO4K_USE_VCO_PHASE_OFFSET
db %3
%endif
%ifdef GO4K_USE_VCO_GATE
db %4
%endif
db %5
%ifdef GO4K_USE_VCO_SHAPE
db %6
%endif
db %7
db %8
%endmacro
%define TRANSPOSE(val) val
%define DETUNE(val) val
%define PHASE(val) val
%define GATES(val) val
%define COLOR(val) val
%define SHAPE(val) val
%define FLAGS(val) val
%define SINE 0x01
%define TRISAW 0x02
%define PULSE 0x04
%define NOISE 0x08
%define LFO 0x10
%define GATE 0x20
%define VCO_STEREO 0x40
struc go4kVCO_val
.transpose resd 1
.detune resd 1
%ifdef GO4K_USE_VCO_PHASE_OFFSET
.phaseofs resd 1
%endif
%ifdef GO4K_USE_VCO_GATE
.gate resd 1
%endif
.color resd 1
%ifdef GO4K_USE_VCO_SHAPE
.shape resd 1
%endif
.gain resd 1
.flags resd 1
.size
endstruc
struc go4kVCO_wrk
.phase resd 1
.tm resd 1
.dm resd 1
.fm resd 1
.pm resd 1
.cm resd 1
.sm resd 1
.gm resd 1
.phase2 resd 1
.size
endstruc
GO4K_VCF_ID equ 3
%macro GO4K_VCF 3
db %1
db %2
db %3
%endmacro
%define LOWPASS 0x1
%define HIGHPASS 0x2
%define BANDPASS 0x4
%define BANDSTOP 0x3
%define ALLPASS 0x7
%define PEAK 0x8
%define STEREO 0x10
%define FREQUENCY(val) val
%define RESONANCE(val) val
%define VCFTYPE(val) val
struc go4kVCF_val
.freq resd 1
.res resd 1
.type resd 1
.size
endstruc
struc go4kVCF_wrk
.low resd 1
.high resd 1
.band resd 1
.freq resd 1
.fm resd 1
.rm resd 1
.low2 resd 1
.high2 resd 1
.band2 resd 1
.size
endstruc
GO4K_DST_ID equ 4
%macro GO4K_DST 3
db %1
%ifdef GO4K_USE_DST_SH
db %2
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%else
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%endif
%endmacro
%define DRIVE(val) val
%define SNHFREQ(val) val
%define FLAGS(val) val
struc go4kDST_val
.drive resd 1
%ifdef GO4K_USE_DST_SH
.snhfreq resd 1
%endif
.flags resd 1
.size
endstruc
struc go4kDST_wrk
.out resd 1
.snhphase resd 1
.dm resd 1
.sm resd 1
.out2 resd 1
.size
endstruc
GO4K_DLL_ID equ 5
%macro GO4K_DLL 8
db %1
db %2
db %3
%ifdef GO4K_USE_DLL_DAMP
db %4
%endif
%ifdef GO4K_USE_DLL_CHORUS
db %5
db %6
%endif
db %7
db %8
%endmacro
%define PREGAIN(val) val
%define DRY(val) val
%define FEEDBACK(val) val
%define DEPTH(val) val
%define DAMP(val) val
%define DELAY(val) val
%define COUNT(val) val
struc go4kDLL_val
.pregain resd 1
.dry resd 1
.feedback resd 1
%ifdef GO4K_USE_DLL_DAMP
.damp resd 1
%endif
%ifdef GO4K_USE_DLL_CHORUS
.freq resd 1
.depth
%endif
.delay resd 1
.count resd 1
.size
endstruc
struc go4kDLL_wrk
.index resd 1
.store resd 1
.dcin resd 1
.dcout resd 1
%ifdef GO4K_USE_DLL_CHORUS
.phase resd 1
%endif
.buffer resd MAX_DELAY
.size
endstruc
struc go4kDLL_wrk2
.pm resd 1
.fm resd 1
.im resd 1
.dm resd 1
.sm resd 1
.am resd 1
.size
endstruc
GO4K_FOP_ID equ 6
%macro GO4K_FOP 1
db %1
%endmacro
%define OP(val) val
%define FOP_POP 0x1
%define FOP_ADDP 0x2
%define FOP_MULP 0x3
%define FOP_PUSH 0x4
%define FOP_XCH 0x5
%define FOP_ADD 0x6
%define FOP_MUL 0x7
%define FOP_ADDP2 0x8
%define FOP_LOADNOTE 0x9
%define FOP_MULP2 0xa
struc go4kFOP_val
.flags resd 1
.size
endstruc
struc go4kFOP_wrk
.size
endstruc
GO4K_FST_ID equ 7
%macro GO4K_FST 2
db %1
dw %2
%endmacro
%define AMOUNT(val) val
%define DEST(val) val
%define FST_SET 0x0000
%define FST_ADD 0x4000
%define FST_POP 0x8000
struc go4kFST_val
.amount resd 1
.op1 resd 1
.size
endstruc
struc go4kFST_wrk
.size
endstruc
GO4K_PAN_ID equ 8
%macro GO4K_PAN 1
%ifdef GO4K_USE_PAN
db %1
%endif
%endmacro
%define PANNING(val) val
struc go4kPAN_val
%ifdef GO4K_USE_PAN
.panning resd 1
%endif
.size
endstruc
struc go4kPAN_wrk
.pm resd 1
.size
endstruc
GO4K_OUT_ID equ 9
%macro GO4K_OUT 2
db %1
%ifdef GO4K_USE_GLOBAL_DLL
db %2
%endif
%endmacro
%define AUXSEND(val) val
struc go4kOUT_val
.gain resd 1
%ifdef GO4K_USE_GLOBAL_DLL
.auxsend resd 1
%endif
.size
endstruc
struc go4kOUT_wrk
.am resd 1
.gm resd 1
.size
endstruc
GO4K_ACC_ID equ 10
%macro GO4K_ACC 1
db %1
%endmacro
%define OUTPUT 0
%define AUX 8
%define ACCTYPE(val) val
struc go4kACC_val
.acctype resd 1
.size
endstruc
struc go4kACC_wrk
.size
endstruc
%ifdef GO4K_USE_FLD
GO4K_FLD_ID equ 11
%macro GO4K_FLD 1
db %1
%endmacro
%define VALUE(val) val
struc go4kFLD_val
.value resd 1
.size
endstruc
struc go4kFLD_wrk
.vm resd 1
.size
endstruc
%endif
%ifdef GO4K_USE_GLITCH
GO4K_GLITCH_ID equ 12
%macro GO4K_GLITCH 5
db %1
db %2
db %3
db %4
db %5
%endmacro
%define ACTIVE(val) val
%define SLICEFACTOR(val)val
%define PITCHFACTOR(val)val
%define SLICESIZE(val) val
struc go4kGLITCH_val
.active resd 1
.dry resd 1
.dsize resd 1
.dpitch resd 1
.slicesize resd 1
.size
endstruc
struc go4kGLITCH_wrk
.index resd 1
.store resd 1
.slizesize resd 1
.slicepitch resd 1
.unused resd 1
.buffer resd MAX_DELAY
.size
endstruc
struc go4kGLITCH_wrk2
.am resd 1
.dm resd 1
.sm resd 1
.pm resd 1
.size
endstruc
%endif
%ifdef GO4K_USE_FSTG
GO4K_FSTG_ID equ 13
%macro GO4K_FSTG 2
db %1
dw %2
%endmacro
struc go4kFSTG_val
.amount resd 1
.op1 resd 1
.size
endstruc
struc go4kFSTG_wrk
.size
endstruc
%endif
struc go4k_instrument
.release resd 1
.note resd 1
.workspace resd MAX_UNITS*MAX_UNIT_SLOTS
.dlloutl resd 1
.dlloutr resd 1
.outl resd 1
.outr resd 1
.size
endstruc
struc go4k_synth
.instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES
.global resb go4k_instrument.size * MAX_VOICES
.size
endstruc
%ifdef USE_SECTIONS
section .g4kmuc1 data align=1
%else
section .data align=1
%endif
go4k_patterns
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
db 48, HLD, HLD, 48, HLD, HLD, 43, HLD, 41, HLD, HLD, 41, 0, 0, 0, 0,
db 41, HLD, HLD, 41, HLD, HLD, 43, HLD, 48, HLD, HLD, 48, 0, 0, 0, 0,
db 43, HLD, HLD, 43, HLD, HLD, 46, HLD, 48, HLD, HLD, 48, 0, 0, 0, 0,
db 41, HLD, HLD, 41, HLD, HLD, 53, HLD, 41, HLD, HLD, 41, 0, 0, 0, 0,
db 48, HLD, HLD, 48, HLD, HLD, 60, HLD, 48, HLD, HLD, 48, 0, 0, 0, 0,
db 0, 0, 84, HLD, HLD, HLD, 79, 0, 82, 79, 0, 77, 0, 75, HLD, 0,
db 72, 0, 72, 0, 75, 0, 82, 79, HLD, HLD, 79, 0, 0, 0, 0, 0,
db 72, 0, 72, 0, 75, 0, 75, 72, HLD, HLD, 72, 0, 0, 0, 0, 0,
db 87, HLD, HLD, HLD, 0, 0, 84, 0, 0, 0, 84, 0, 84, 0, 0, 0,
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 82, 0, 84, 82, 79,
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, HLD, 0, 89, 0, 87, 0,
db 89, HLD, HLD, HLD, 0, 0, 84, 0, 0, 0, 84, 0, 84, 0, 0, 0,
db 75, HLD, HLD, 75, HLD, HLD, 70, HLD, 68, HLD, HLD, 68, 0, 0, 0, 0,
db 68, HLD, HLD, 68, HLD, HLD, 70, HLD, 75, HLD, HLD, 75, 0, 0, 0, 0,
db 70, HLD, HLD, 70, HLD, HLD, 70, HLD, 75, HLD, HLD, 75, 0, 0, 0, 0,
db 68, HLD, HLD, 68, HLD, HLD, 70, HLD, HLD, 70, HLD, HLD, 70, HLD, 0, 0,
db 68, HLD, HLD, 68, HLD, HLD, 68, HLD, 70, HLD, HLD, 70, 0, 0, 70, HLD,
db 70, HLD, HLD, 70, HLD, HLD, 75, HLD, HLD, 75, HLD, HLD, 75, HLD, 0, 0,
db 70, HLD, HLD, 70, HLD, HLD, 70, HLD, 75, HLD, HLD, 75, 0, 0, 75, HLD,
go4k_patterns_end
%ifdef USE_SECTIONS
section .g4kmuc2 data align=1
%else
section .data
%endif
go4k_pattern_lists
Instrument0List db 0, 0, 0, 0, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 0, 0, 0, 0, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 0, 0,
Instrument1List db 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 6, 8, 6, 7, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 9, 11, 12, 11, 12, 0, 6, 7, 6, 8, 6, 7, 6, 8, 9, 11, 9, 0, 6, 7, 6, 8, 0, 0,
Instrument2List db 13, 14, 13, 15, 13, 14, 13, 15, 13, 14, 13, 15, 13, 14, 13, 15, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19, 16, 17, 18, 19, 13, 14, 13, 15, 13, 14, 13, 15, 13, 14, 13, 0, 13, 14, 13, 15, 0, 0,
go4k_pattern_lists_end
%ifdef USE_SECTIONS
section .g4kmuc3 data align=1
%else
section .data
%endif
go4k_synth_instructions
GO4K_BEGIN_CMDDEF(Instrument0)
db GO4K_ENV_ID
db GO4K_ENV_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument1)
db GO4K_ENV_ID
db GO4K_ENV_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument2)
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Global)
db GO4K_ACC_ID
db GO4K_DLL_ID
db GO4K_FOP_ID
db GO4K_DLL_ID
db GO4K_FOP_ID
db GO4K_ACC_ID
db GO4K_FOP_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
go4k_synth_instructions_end
%ifdef USE_SECTIONS
section .g4kmuc4 data align=1
%else
section .data
%endif
go4k_synth_parameter_values
GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_ENV ATTAC(5),DECAY(85),SUSTAIN(107),RELEASE(0),GAIN(128)
GO4K_ENV ATTAC(59),DECAY(95),SUSTAIN(0),RELEASE(64),GAIN(91)
GO4K_FST AMOUNT(80),DEST(6*MAX_UNIT_SLOTS+4+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(20),RESONANCE(23),VCFTYPE(LOWPASS)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(64), AUXSEND(0)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument1)
GO4K_ENV ATTAC(23),DECAY(66),SUSTAIN(20),RELEASE(64),GAIN(128)
GO4K_ENV ATTAC(75),DECAY(77),SUSTAIN(20),RELEASE(64),GAIN(128)
GO4K_FST AMOUNT(92),DEST(6*MAX_UNIT_SLOTS+4+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(PULSE)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(38),RESONANCE(45),VCFTYPE(BANDPASS)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCF FREQUENCY(56),RESONANCE(80),VCFTYPE(BANDSTOP)
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(35),DEPTH(57),DELAY(17),COUNT(1)
GO4K_FOP OP(FOP_XCH)
GO4K_VCF FREQUENCY(45),RESONANCE(94),VCFTYPE(BANDSTOP)
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(8),DEPTH(61),DELAY(18),COUNT(1)
GO4K_OUT GAIN(64), AUXSEND(0)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument2)
GO4K_ENV ATTAC(36),DECAY(75),SUSTAIN(0),RELEASE(64),GAIN(128)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(89),GAIN(128),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(68),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(89),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_ADDP)
GO4K_VCO TRANSPOSE(71),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(85),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCF FREQUENCY(36),RESONANCE(49),VCFTYPE(BANDPASS)
GO4K_FOP OP(FOP_XCH)
GO4K_VCF FREQUENCY(49),RESONANCE(28),VCFTYPE(BANDPASS)
GO4K_OUT GAIN(46), AUXSEND(0)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Global)
GO4K_ACC ACCTYPE(AUX)
GO4K_DLL PREGAIN(40),DRY(128),FEEDBACK(113),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(1),COUNT(8)
GO4K_FOP OP(FOP_XCH)
GO4K_DLL PREGAIN(40),DRY(128),FEEDBACK(103),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(9),COUNT(8)
GO4K_FOP OP(FOP_XCH)
GO4K_ACC ACCTYPE(OUTPUT)
GO4K_FOP OP(FOP_ADDP2)
GO4K_OUT GAIN(64), AUXSEND(16)
GO4K_END_PARAMDEF
go4k_synth_parameter_values_end
%ifdef USE_SECTIONS
section .g4kmuc5 data align=1
%else
section .data
%endif
%ifdef GO4K_USE_DLL
global _go4k_delay_times
_go4k_delay_times
dw 0
dw 1116
dw 1188
dw 1276
dw 1356
dw 1422
dw 1492
dw 1556
dw 1618
dw 1140
dw 1212
dw 1300
dw 1380
dw 1446
dw 1516
dw 1580
dw 1642
dw 22050
dw 16537
%endif

55
BuildDLLs.script Normal file
View File

@ -0,0 +1,55 @@
# Compofiller Studio
# by Yzi
#
# BuildDLLs.script
#
# WE HAVE MANY TYPES OF SCRIPT FILES
#
# Build scripts
# * common variables/definitions script, which "bakes" stuff from configs into variables
# * DLL (test/debug) master script
# * EXE (run/release) master script
#
# Settings/configuration scripts
# * Project global script (which also serves as the project file?)
# * Configuration scripts (1 per configuration)
#
# SHADER_FILE
# Explanation of automatically set target variables
# $@ expands to the target (i.e. text that's before the colon ':')
# $< expands to the first prerequisite (i.e. the first space-delimited string that's after the colon ':')
# $^ expands to all prerequisites (i.e. the whole text that's after the colon ':')
include $(PROJECT_FILE)
include $(CONFIG_FILE)
include common.script
# Audio debug/test DLL
debug_4klang.obj: debug_4klang_wrapper.asm 4klang.asm 4klang.inc
$(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) $(FORCED_4KLANG_OPTS) -o $@ $<
debug_audio.obj: debug_audio.asm errormsg.inc
$(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) -o $@ $<
debug_audio.dll: debug_audio.obj debug_4klang.obj
$(DEBUG_LINKER_EXE) $(DEBUG_LINKER_OPTS) -o $@ $^ $(DEBUG_LINKER_AUDIO_LIBS_PARAMS)
# Visuals debug/test DLL
#shader_code.obj: shader_code.asm $(SHADER_FILE)
# $(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) $(VISUALS_ASM_OPTS) -o $@ $<
debug_visuals.obj: debug_visuals.asm errormsg.inc
$(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) $(VISUALS_ASM_OPTS) -o $@ $<
#debug_visuals.dll: debug_visuals.obj shader_code.obj
debug_visuals.dll: debug_visuals.obj
$(DEBUG_LINKER_EXE) $(DEBUG_LINKER_OPTS) -o $@ $^ $(DEBUG_LINKER_VISUALS_LIBS_PARAMS)

31
BuildEXE.script Normal file
View File

@ -0,0 +1,31 @@
# Compofiller Studio
# by Yzi
#
# BuildEXE.script
include $(PROJECT_FILE)
include $(CONFIG_FILE)
include common.script
PREPROCESS_SHADER_EXE="$(PROGRAM_DIR)\Tools\PreprocessShader.exe"
TEMP_PROCESSED_SHADER_FILE=__temp_processed_shader.glsl
4klang.obj: 4klang.asm 4klang.inc
$(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) $(FORCED_4KLANG_OPTS) -o $@ $<
$(TEMP_PROCESSED_SHADER_FILE): $(SHADER_FILE)
$(PREPROCESS_SHADER_EXE) $< $@
shader_code.obj: shader_code.asm $(TEMP_PROCESSED_SHADER_FILE)
$(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) $(VISUALS_ASM_OPTS) \
-DTEMP_PROCESSED_SHADER_FILE=$(QUOTE)$(TEMP_PROCESSED_SHADER_FILE)$(QUOTE) -o $@ $<
exemain.obj: exemain.asm
$(ASSEMBLER_EXE) $(ASSEMBLER_OPTS) $(VISUALS_ASM_OPTS) -o $@ $<
$(OUTPUT_EXE_NAME): exemain.obj shader_code.obj 4klang.obj
$(FINAL_LINKER_EXE) $(FINAL_LINKER_OPTS) $(FINAL_LINKER_OUT_OPT)$@ $^ $(FINAL_LINKER_LIBS_PARAMS)

20
MinifyShader.script Normal file
View File

@ -0,0 +1,20 @@
# Compofiller Studio
# by Yzi
#
# MinifyShader.script
#
# This script runs Shader Minifier
#
# Compofiller Studio provides this script with the SOURCE_FILE and DESTINATION_FILE variables
CLEAN_SHADER_EXE="$(PROGRAM_DIR)\Tools\CleanShader.exe"
TEMP_CLEANED_SHADER_FILE=__temp_cleaned_shader.glsl
# the clean-up tries to remove stuff that Shader Minifier can't handle
$(TEMP_CLEANED_SHADER_FILE): $(SOURCE_FILE)
$(CLEAN_SHADER_EXE) $< $@
$(DESTINATION_FILE):
"$(PROGRAM_DIR)\Tools\ShaderMinifier\shader_minifier.exe" $(TEMP_CLEANED_SHADER_FILE) -o $(DESTINATION_FILE)

11
RunEXE.script Normal file
View File

@ -0,0 +1,11 @@
# Compofiller Studio
# by Yzi
#
# RunEXE.script
include $PROJECT_FILE
include $CONFIG_FILE
run:
$OUTPUT_EXE_NAME

71
base.config Normal file
View File

@ -0,0 +1,71 @@
# Compofiller Studio by Yzi
#
# Base configuration file
########### Music #############
MUSIC_4KLANG_INC_FILE=
MUSIC_BEATS_PER_BAR=4.0
########### Visuals ############
SHADER_FILE=shader.glsl
RESOLUTION_X=1920
RESOLUTION_Y=1080
USE_TIME_UNIFORM=1
TIME_UNIFORM_NAME='time'
USE_RESOLUTION_UNIFORM=1
RESOLUTION_UNIFORM_NAME='resolution'
# Frame-to-texture, mipmaps
TWO_PASS_RENDERING=1
FRAME_TO_TEXTURE=0
USE_MIPMAP=0
SECOND_PASS_NEGATIVE_TIME=1
# Texts
USE_TEXTS=1
USE_TEXTS_UNIFORM=1
TEXTS_UNIFORM_NAME='texts'
TEXT_BITMAP_RESOLUTION_X=1024
TEXT_BITMAP_RESOLUTION_Y=1024
TEXT_FONT_NAME='Arial'
TEXT_FONT_SIZE=120
TEXT_FONT_STRIKEOUT=0
TEXT_FONT_UNDERLINE=0
TEXT_FONT_ITALIC=0
TEXT_FONT_WEIGHT=256
TEXT_FONT_ORIENTATION=0
TEXT_FONT_ESCAPEMENT=0
TEXT_FONT_WIDTH=0
TEXT_CHARACTER_EXTRA_SPACING=0
USE_WIDECHAR_TEXTS=0
########### Time base ###########
USE_TIME_DIVIDER_IN_X86_CODE=1
TIME_DIVIDER=88200.000
TIME_BASE=bars
AUDIO_DELAY=2048
PROD_END_TIME=4411648
########### Final product ###########
# The name of the final EXE
OUTPUT_EXE_NAME=testing.exe
# this is just the name/text of the GUI option, not the name of the linker executable
EXE_LINKER_PROGRAM=Crinkler
QUOTE=\"
CRINKLER_ORDERTRIES=100
AUDIO_BUFFER_ALLOCATED_LENGTH=4411648
AUDIO_SAMPLING_RATE=44100
LOOP_END=5.0
LOOP_START=3.0
LOOP_ENABLED=0
TIME_DIVIDER_INT=88200

108
common.script Normal file
View File

@ -0,0 +1,108 @@
# Compofiller Studio by Yzi
#
# Parameter construction rules that both/all build scripts need, but can't reside in
# .config scripts, unless we support "deferred expansion". Which we don't, at least yet.
#
# Note about spaces in path names:
#
# Any file name/path that includes $(PROGRAM_DIR) must be enclosed in quotes, like
# "$(PROGRAM_DIR)\Tools\Crinkler\crinkler.exe" or "$(PROGRAM_DIR)\Libs", because
# PROGRAM_DIR might contain spaces.
#
# Paths that are relative to the project directory, don't have to be enclosed in quotes,
# because Compofiller Studio changes the current directory to the project directory.
# All you have to do is make sure the file names don't contain spaces.
#
VISUALS_USE_TIME_UNIFORM_DEFINE=-DUSE_TIME_UNIFORM=$(USE_TIME_UNIFORM)
VISUALS_TIME_UNIFORM_NAME_DEFINE=-DTIME_UNIFORM_NAME=$(TIME_UNIFORM_NAME)
VISUALS_USE_RESOLUTION_UNIFORM_DEFINE=-DUSE_RESOLUTION_UNIFORM=$(USE_RESOLUTION_UNIFORM)
VISUALS_RESOLUTION_UNIFORM_NAME_DEFINE=-DRESOLUTION_UNIFORM_NAME=$(RESOLUTION_UNIFORM_NAME)
VISUALS_ASM_OPTS=$(VISUALS_USE_TIME_UNIFORM_DEFINE) $(VISUALS_USE_RESOLUTION_UNIFORM_DEFINE) \
$(VISUALS_TIME_UNIFORM_NAME_DEFINE) $(VISUALS_RESOLUTION_UNIFORM_NAME_DEFINE) \
-DTWO_PASS_RENDERING=$(TWO_PASS_RENDERING) -DFRAME_TO_TEXTURE=$(FRAME_TO_TEXTURE) \
-DUSE_MIPMAP=$(USE_MIPMAP) -DSECOND_PASS_NEGATIVE_TIME=$(SECOND_PASS_NEGATIVE_TIME) \
-DRESOLUTION_X=$(RESOLUTION_X) -DRESOLUTION_Y=$(RESOLUTION_Y) \
-DTIME_DIVIDER=$(TIME_DIVIDER) -DTIME_DIVIDER_INT=$(TIME_DIVIDER_INT) \
-DAUDIO_SAMPLING_RATE=$(AUDIO_SAMPLING_RATE) \
-DAUDIO_DELAY=$(AUDIO_DELAY) \
-DAUDIO_BUFFER_ALLOCATED_LENGTH=$(AUDIO_BUFFER_ALLOCATED_LENGTH) \
-DPROD_END_TIME=$(PROD_END_TIME) \
-DTEXT_BITMAP_RESOLUTION_X=$(TEXT_BITMAP_RESOLUTION_X) -DTEXT_BITMAP_RESOLUTION_Y=$(TEXT_BITMAP_RESOLUTION_Y) \
"-DTEXT_FONT_NAME=$(TEXT_FONT_NAME)" -DTEXT_FONT_SIZE=$(TEXT_FONT_SIZE) \
-DTEXT_FONT_STRIKEOUT=$(TEXT_FONT_STRIKEOUT) \
-DTEXT_FONT_UNDERLINE=$(TEXT_FONT_UNDERLINE) \
-DTEXT_FONT_ITALIC=$(TEXT_FONT_ITALIC) \
-DTEXT_FONT_WEIGHT=$(TEXT_FONT_WEIGHT) \
-DTEXT_FONT_ORIENTATION=$(TEXT_FONT_ORIENTATION) \
-DTEXT_FONT_ESCAPEMENT=$(TEXT_FONT_ESCAPEMENT) \
-DTEXT_FONT_WIDTH=$(TEXT_FONT_WIDTH) \
-DTEXT_CHARACTER_EXTRA_SPACING=$(TEXT_CHARACTER_EXTRA_SPACING) \
-DTEXTS_UNIFORM_NAME=$(TEXTS_UNIFORM_NAME) \
-DUSE_TEXTS=$(USE_TEXTS) -DUSE_TEXTS_UNIFORM=$(USE_TEXTS_UNIFORM) \
-DUSE_WIDECHAR_TEXTS=$(USE_WIDECHAR_TEXTS)
# this doesn't need to go to the assembler anymore, because the shader goes via PreprocessShader.exe to a hard-coded file name
# -DSHADER_FILE=$(QUOTE)$(SHADER_FILE)$(QUOTE)
# We force 16 bit output. This prevents non-working audio and crash, when a 32 bit float format song is given.
FORCED_4KLANG_OPTS=-DGO4K_USE_16BIT_OUTPUT
ASSEMBLER_PROGRAM=yasm
########### Tools ###########
ASSEMBLER_EXE="$(PROGRAM_DIR)\Tools\NASM\nasm.exe"
ASSEMBLER_OPTS=-f win32 -w-orphan-labels
# You could try this to get debug symbols, but it just doesn't seem to work.
#ASSEMBLER_OPTS=-w-orphan-labels -f win32 -F cv8 -g
# Linker for building the DLLs for testing in the GUI
DEBUG_LINKER_EXE="$(PROGRAM_DIR)\Tools\Linker\ld.exe"
# Library path. Where are the .lib files located?
LIB_PATH="$(PROGRAM_DIR)\Libs"
######## Things for the debug DLL ########
DEBUG_LINKER_OPTS=--dll -entry=DllMain@12 -L $(LIB_PATH)
# Windows library import files needed for linking the DLL
DEBUG_LINKER_COMMON_LIBS_PARAMS=-l kernel32 -l user32
# for audio DLL
DEBUG_LINKER_AUDIO_LIBS_PARAMS=-l winmm $(DEBUG_LINKER_COMMON_LIBS_PARAMS)
# for visuals DLL
DEBUG_LINKER_VISUALS_LIBS_PARAMS=$(DEBUG_LINKER_COMMON_LIBS_PARAMS) -l gdi32 -l opengl32
########## EXE linker things ###########
ifeq ($(EXE_LINKER_PROGRAM),Crinkler)
# Crinkler settings
# Linker for building standalone EXE files for running
FINAL_LINKER_EXE="$(PROGRAM_DIR)\Tools\Crinkler\crinkler.exe"
FINAL_LINKER_OPTS=/SUBSYSTEM:WINDOWS /ENTRY:t /COMPMODE:SLOW /HASHSIZE:200 /HASHTRIES:50 /ORDERTRIES:$(CRINKLER_ORDERTRIES) \
/UNSAFEIMPORT /LIBPATH:$(LIB_PATH) /REPORT:crinkler_report.html /PROGRESSGUI
FINAL_LINKER_OUT_OPT=/OUT:
FINAL_LINKER_GENERAL_LIBS_PARAMS=kernel32.lib user32.lib
FINAL_LINKER_AUDIO_LIBS_PARAMS=winmm.lib
FINAL_LINKER_VISUALS_LIBS_PARAMS=gdi32.lib opengl32.lib
FINAL_LINKER_LIBS_PARAMS=$(FINAL_LINKER_GENERAL_LIBS_PARAMS) $(FINAL_LINKER_AUDIO_LIBS_PARAMS) $(FINAL_LINKER_VISUALS_LIBS_PARAMS)
else
# GNU ld settings
FINAL_LINKER_EXE="$(PROGRAM_DIR)\Tools\Linker\ld.exe"
FINAL_LINKER_OPTS=-e t -L $(LIB_PATH)
FINAL_LINKER_OUT_OPT=-o
FINAL_LINKER_GENERAL_LIBS_PARAMS=-l kernel32 -l user32
FINAL_LINKER_AUDIO_LIBS_PARAMS=-l winmm
FINAL_LINKER_VISUALS_LIBS_PARAMS=-l gdi32 -l opengl32
FINAL_LINKER_LIBS_PARAMS=$(FINAL_LINKER_GENERAL_LIBS_PARAMS) $(FINAL_LINKER_AUDIO_LIBS_PARAMS) $(FINAL_LINKER_VISUALS_LIBS_PARAMS)
endif

35
debug_4klang_wrapper.asm Normal file
View File

@ -0,0 +1,35 @@
; Compofiller Studio by Yzi
; Wrapper for 4klang.asm, so we can get our debug/test DLL to export the constants.
%include "4klang.asm"
music_sample_rate:
dd SAMPLE_RATE
music_bpm:
dd __float32__(%[BPM])
music_length_samples:
dd MAX_SAMPLES
%macro EXPORT_FUNC 1
export %1
global _%1
_%1:
%1:
%endmacro
EXPORT_FUNC GetMusicSampleRate
mov eax, dword [music_sample_rate]
ret
EXPORT_FUNC GetMusicBPM
; mov eax, dword [music_bpm]
fld dword [music_bpm]
ret
EXPORT_FUNC GetMusicLengthSamples
mov eax, dword [music_length_samples]
ret

426
debug_audio.asm Normal file
View File

@ -0,0 +1,426 @@
; yasm -f win32 -o dlltest.obj dlltest.asm
; ld --dll -entry=DllMain@12 -L C:\utils -o dlltest.dll dlltest.obj -l user32
; Compofiller Studio by Yzi
;
; Debug DLL for music stuff
;
%include "errormsg.inc"
section .text
; .start:
global DllMain@12
DllMain@12: ; This code is required in .dll files
mov eax,1
ret 12
; extern _midiOutOpen@20
; extern __imp__midiOutOpen@20
; extern _midiOutShortMsg@8
; extern __imp__midiOutShortMsg@8
; extern _timeGetTime@0
; extern __imp__timeGetTime@0
loppu:
push 0
call [__imp__ExitProcess@4]
ret
extern _MessageBeep@4
extern __imp__MessageBeep@4
beepquit:
push 0xFFFFFFFF
call [__imp__MessageBeep@4]
jmp loppu
; ------------------------------ STUFF FOR PCM/4KLANG MUSIC -------------------------
;section .bss
; .bss declares an uninitialized data section
section .data
; !!! TODO sampling rate is coded in two places now, here and 4klang.ini
audio_sampling_rate equ 44100
;audio_length_seconds equ (2*60)
;audio_length_samples equ (audio_length_seconds*audio_sampling_rate*2)
audio_thread_handle: dd 0
; "rendered audio buffer" means the rendered audio length,
; as opposed to "playback buffer" which might be
; - shorter, if we start playback from the middle of rendered audio
; - longer, if we play all the way from start to end of demo, and there's a positive audio offset/delay
rendered_audio_buffer_ptr: dd 0
; loop parameters
audio_loop_enabled: dd 0
; resw audio_length_samples
global hWaveOut
hWaveOut: dd 0
; Flags for WaveHDR.dwFlags
WHDR_BEGINLOOP equ 4
WHDR_ENDLOOP equ 8
section .data
global WaveHDR
WaveHDR:
audio_playback_buffer_ptr:
WaveHDR_lpData: dd 0
audio_playback_length_bytes:
WaveHDR_dwBufferLength: dd 0 ; audio_length_samples*2 ; audio buffer length in bytes
WaveHDR_dwBytesRecorded: dd 0
WaveHDR_dwUser: dd 0
WaveHDR_dwFlags: dd 0
WaveHDR_dwLoops: dd 0
WaveHDR_lpNext: dd 0
WaveHDR_reserved: dd 0
; long GetPosition() {
; static MMTIME MMTime = { TIME_SAMPLES, 0};
; waveOutGetPosition(hWaveOut, &MMTime, sizeof(MMTIME));
; return (MMTime.u.sample);
; }
global pcmFormat
pcmFormat:
pcmFormat_wFormatTag: dw 1 ; WAVE_FORMAT_PCM
pcmFormat_nChannels: dw 2 ; stereo
pcmFormat_nSamplesPerSec: dd audio_sampling_rate
pcmFormat_nAvgBytesPerSec: dd audio_sampling_rate*4 ; for buffer estimation
pcmFormat_nBlockAlign: dw 4 ; block size of data
pcmFormat_wBitsPerSample: dw 16
pcmFormat_cbSize: dw 0
; void Play() {
; static WAVEHDR WaveHDR = { (LPSTR)(myMuzik), MZK_NUMSAMPLESC * 2};
; // Define output format
; static WAVEFORMATEX pcmFormat = {
; WAVE_FORMAT_PCM, // WORD wFormatTag; /* format type */
; 2, // WORD nChannels; /* number of channels (i.e. mono, stereo...) */
; 44100, // DWORD nSamplesPerSec; /* sample rate */
; 4 * 44100, // DWORD nAvgBytesPerSec; /* for buffer estimation */
; 4, // WORD nBlockAlign; /* block size of data */
; 16, // WORD wBitsPerSample; /* number of bits per sample of mono data */
; 0, // WORD cbSize; /* the count in bytes of the size of */
; };
global MMTime
; MMTIME is a "union" struct that can be used for many different contents based on the first
MMTime: dd 2 ; wType: TIME_SAMPLES = 2
MMTime_sample: dd 0 ; actual position value
db 0, 0, 0, 0 ; some room for other cases
; -----------------
section .text
; the __imp__ versions refer to the corresponding import address table entries
; 4klang
extern __4klang_render@4
; General Windows stuff
extern _ExitProcess@4
extern __imp__ExitProcess@4
extern _CreateThread@24
extern __imp__CreateThread@24
extern _TerminateThread@8
extern __imp__TerminateThread@8
extern _Sleep@4
extern __imp__Sleep@4
extern _WaitForSingleObject@8
extern __imp_WaitForSingleObject@8
; Windows Multimedia
extern _waveOutOpen@24
extern __imp__waveOutOpen@24
extern _waveOutPrepareHeader@12
extern __imp__waveOutPrepareHeader@12
extern _waveOutWrite@12
extern __imp__waveOutWrite@12
extern _waveOutGetPosition@12
extern __imp__waveOutGetPosition@12
extern _waveOutReset@4
extern __imp__waveOutReset@4
extern _waveOutClose@4
extern __imp__waveOutClose@4
export GetRenderedAudioBufferPtr
global _GetRenderedAudioBufferPtr
_GetRenderedAudioBufferPtr:
GetRenderedAudioBufferPtr:
mov eax, dword [rendered_audio_buffer_ptr]
ret
export SetRenderedAudioBufferPtr
global _SetRenderedAudioBufferPtr
_SetRenderedAudioBufferPtr:
SetRenderedAudioBufferPtr:
mov eax, [esp+4]
mov [rendered_audio_buffer_ptr], eax
ret 4
export StartAudioRendererThread
global _StartAudioRendererThread
_StartAudioRendererThread
StartAudioRendererThread:
push 0
push 0
push dword [rendered_audio_buffer_ptr]
push __4klang_render@4
push 0
push 0
;call _CreateThread@24
call [__imp__CreateThread@24]
mov [audio_thread_handle], eax
FAIL_ON_WINDOWS_ERROR CreateThread_string
ret
export KillAudioRendererThread
global _KillAudioRendererThread
_KillAudioRendererThread
KillAudioRendererThread:
; already killed by this function, or never even started?
cmp dword [audio_thread_handle], 0
je noeijuu
push 0
push dword [audio_thread_handle]
call _WaitForSingleObject@8
cmp eax, 0 ; WAIT_OBJECT_0 = 0
je already_died
; now we hope that the thread doesn't finish after windows told us it's "still alive"
; but before we get to call TerminateThread
push 0
push dword [audio_thread_handle]
call [__imp__TerminateThread@8]
FAIL_ON_WINDOWS_ERROR TerminateThread_string
; short sleep and let's hope for the best
push 50
call [__imp__Sleep@4]
already_died:
mov dword [audio_thread_handle], 0
noeijuu:
ret
export GetWaveOutHandle
global _GetWaveOutHandle
_GetWaveOutHandle
GetWaveOutHandle:
mov eax, [hWaveOut]
ret
export GetAudioRendererThreadHandle
global _GetAudioRendererThreadHandle
_GetAudioRendererThreadHandle
GetAudioRendererThreadHandle:
mov eax, [audio_thread_handle]
ret
export GetAudioPlaybackBufferPtr
global _GetAudioPlaybackBufferPtr
_GetAudioPlaybackBufferPtr:
GetAudioPlaybackBufferPtr:
mov eax, dword [audio_playback_buffer_ptr]
ret
export SetAudioPlaybackBufferPtr
global _SetAudioPlaybackBufferPtr
_SetAudioPlaybackBufferPtr:
SetAudioPlaybackBufferPtr:
mov eax, [esp+4]
mov [audio_playback_buffer_ptr], eax
ret 4
export GetAudioPlaybackBufferLengthBytes
global _GetAudioPlaybackBufferLengthBytes
_GetAudioPlaybackBufferLengthBytes:
GetAudioPlaybackBufferLengthBytes:
mov eax, [audio_playback_length_bytes]
ret
export SetAudioPlaybackBufferLengthBytes
global _SetAudioPlaybackBufferLengthBytes
_SetAudioPlaybackBufferLengthBytes:
SetAudioPlaybackBufferLengthBytes:
mov eax, [esp+4]
mov [audio_playback_length_bytes], eax
ret 4
; For GNU ld to be able to create a DLL from our object code, it has to
; have both _Play and Play symbols and _Play as global.
;export Play
;global _Play
; _Play:
;Play:
;call StartAudioRendererThread
; Wait a bit so that the 4klang's renderer thread gets well ahead of playback position
; push 200
; call [__imp__Sleep@4]
;call StartAudio
; mov eax, 1
; ret
section .data
global CreateThread_string
CreateThread_string db 'CreateThread', 0
global TerminateThread_string
TerminateThread_string db 'TerminateThread', 0
global waveOutOpen_string
waveOutOpen_string db 'waveOutOpen', 0
global waveOutPrepareHeader_string
waveOutPrepareHeader_string db 'waveOutPrepareHeader', 0
global waveOutWrite_string
waveOutWrite_string db 'waveOutWrite', 0
global waveOutReset_string
waveOutReset_string db 'waveOutReset', 0
global waveOutClose_string
waveOutClose_string db 'waveOutClose', 0
global waveOutGetPosition_string
waveOutGetPosition_string db 'waveOutGetPosition', 0
section .text
export StartAudio
global _StartAudio
_StartAudio:
StartAudio:
mov dword [WaveHDR_dwFlags], 0
mov dword [WaveHDR_dwLoops], 0
cmp dword [audio_loop_enabled], 0
je no_looping
mov dword [WaveHDR_dwFlags], WHDR_BEGINLOOP + WHDR_ENDLOOP
mov dword [WaveHDR_dwLoops], -1
no_looping:
push 0
push 0
push 0
push pcmFormat
push -1
push hWaveOut
call [__imp__waveOutOpen@24]
FAIL_ON_WINMM_ERROR waveOutOpen_string
push 32 ; sizeof(WaveHDR)
push WaveHDR
push DWORD [hWaveOut]
call [__imp__waveOutPrepareHeader@12]
FAIL_ON_WINMM_ERROR waveOutPrepareHeader_string
push 32 ; sizeof(WaveHDR)
push WaveHDR
push DWORD [hWaveOut]
call [__imp__waveOutWrite@12]
FAIL_ON_WINMM_ERROR waveOutWrite_string
mov eax, 1
ret
export StopAudio
global _StopAudio
_StopAudio:
StopAudio:
push DWORD [hWaveOut]
call [__imp__waveOutReset@4]
FAIL_ON_WINMM_ERROR waveOutReset_string
push DWORD [hWaveOut]
call [__imp__waveOutClose@4]
FAIL_ON_WINMM_ERROR waveOutClose_string
mov DWORD [hWaveOut], 0
mov eax, 1
ret
; // _4klang_render(myMuzik);
; CreateThread(0, 0, (LPTHREAD_START_ROUTINE)_4klang_render, myMuzik, 0, 0);
; Sleep(200);
; waveOutOpen( &hWaveOut, WAVE_MAPPER, &pcmFormat, NULL, 0, CALLBACK_NULL );
; waveOutPrepareHeader( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
; waveOutWrite ( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
;}
; ---- GetPosition returns the current audio playback position ----
export GetCurrentAudioPosition
global _GetCurrentAudioPosition
_GetCurrentAudioPosition:
GetCurrentAudioPosition:
push 12 ; sizeof MMTIME struct
push MMTime
push DWORD [hWaveOut]
call [__imp__waveOutGetPosition@12]
FAIL_ON_WINMM_ERROR waveOutGetPosition_string
mov eax, [MMTime_sample]
ret
;export SetPosition
;global _SetPosition
;_SetPosition:
;SetPosition:
; TODO
; ret 4
; This isn't actually used, using Winmm audio for seamless looping is too much trouble
export SetAudioLoopEnabled
global _SetAudioLoopEnabled
_SetAudioLoopEnabled:
SetAudioLoopEnabled:
mov eax, [esp+4]
mov [audio_loop_enabled], eax
ret 4
; -------------------- ^^^^^ END OF MUSIC / AUDIO DATA STUFF ^^^^^ --------------------

BIN
debug_audio.dll Normal file

Binary file not shown.

1519
debug_visuals.asm Normal file

File diff suppressed because it is too large Load Diff

BIN
debug_visuals.dll Normal file

Binary file not shown.

210
errormsg.inc Normal file
View File

@ -0,0 +1,210 @@
section .text
align 16
%macro EXPORT_FUNC 1
export %1
global _%1
_%1:
%1:
%endmacro
; ---------------------------- Error message stuff ------------------------
extern _MessageBoxA@16
extern __imp__MessageBoxA@16
extern _GetLastError@0
extern __imp__GetLastError@0
extern _FormatMessageA@28
extern __imp__FormatMessageA@28
extern _LocalFree@4
extern __imp__LocalFree@4
section .data
GL_FALSE equ 0
GL_NO_ERROR equ 0
MMSYSERR_NOERROR equ 0
LANG_NEUTRAL equ 0
FORMAT_MESSAGE_ALLOCATE_BUFFER equ 0x00000100
FORMAT_MESSAGE_FROM_SYSTEM equ 0x00001000
error_message_buffer_ptr: dd 0
error_message_id: dd 0
error_message_caption:
db 'Errare humanum est', 0
last_failed_operation: dd 0
last_failed_operation_info: dd 0
EXPORT_FUNC GetLastFailedOperation
mov eax, [last_failed_operation]
ret
EXPORT_FUNC GetLastFailedOperationInfo
mov eax, [last_failed_operation_info]
ret
section .text
; IN: eax : message id from GetLastError
; IN: on stack : caption string
global ShowLastWindowsErrorMessageWithCaption
ShowLastWindowsErrorMessageWithCaption:
mov [error_message_id], eax
mov eax, [esp+4]
push 0 ; _In_opt_ va_list *Arguments
push 0 ; _In_ DWORD nSize,
push error_message_buffer_ptr ; _Out_ LPTSTR lpBuffer
push LANG_NEUTRAL ; _In_ DWORD dwLanguageId
push dword [error_message_id] ; _In_ DWORD dwMessageId
push 0 ; _In_opt_ LPCVOID lpSource
push FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM ; _In_ DWORD dwFlags
call [__imp__FormatMessageA@28]
push 0
push eax
push dword [error_message_buffer_ptr]
push 0
call [__imp__MessageBoxA@16]
push dword [error_message_buffer_ptr]
call [__imp__LocalFree@4]
ret 4
; IN: on stack : caption string
global ShowErrorMessage
ShowErrorMessage:
mov eax, [esp+4]
push 0
push error_message_caption
push eax
push 0
call [__imp__MessageBoxA@16]
ret 4
______
; --- This is for WinAPI stuff. Return value 0 means success.
;%macro RET_ON_WINDOWS_ERROR 1
;cmp eax, 0
;jne %%skip
;call _GetLastError@0
;cmp eax, 0
;jne %%skip_message
;push %1
;call ShowLastWindowsErrorMessageWithCaption
;%%skip_message:
;ret
;%%skip:
;%endmacro
%macro FAIL_ON_WINDOWS_ERROR 1
cmp eax, 0
jne %%skip
call _GetLastError@0
cmp eax, 0
jne %%skip_message
push %1
call ShowLastWindowsErrorMessageWithCaption
%%skip_message:
push 0
call [__imp__ExitProcess@4]
%%skip:
%endmacro
%macro CLEAR_LAST_FAILED_OPERATION_INFO 0
mov dword [last_failed_operation], 0
mov dword [last_failed_operation_info], 0
%endmacro
; --- For OpenGL stuff. glGetError() return value 0 i.e. GL_NO_ERROR means no error.
; param 1: where to jump,
; param 2: what address to set to last_failed_operation
%macro JUMP_ON_GL_ERROR 2
call [__imp__glGetError@0]
cmp eax, GL_NO_ERROR
je %%skip
mov dword [last_failed_operation], %2
mov dword [last_failed_operation_info], 0
jmp %1
%%skip:
%endmacro
; param 1: where to jump,
; param 2: address (string pointer) to set to last_failed_operation
; param 3: address (string pointer) to set to last_failed_operation_info
%macro JUMP_ON_GL_ERROR_EXT 3
call [__imp__glGetError@0]
cmp eax, GL_NO_ERROR
je %%skip
mov dword [last_failed_operation], %2
mov dword [last_failed_operation_info], %3
jmp %1
%%skip:
%endmacro
%macro FAIL_ON_GL_ERROR 1
call [__imp__glGetError@0]
cmp eax, GL_NO_ERROR
je %%skip
; call _GetLastError@0
; cmp eax, 0
; jne %%skip_message
push %1
call ShowErrorMessage
push 0
call [__imp__ExitProcess@4]
%%skip:
%endmacro
; --- For Windows Multimedia stuff. Return value 0 i.e. MMSYSERR_NOERROR means no error.
%macro FAIL_ON_WINMM_ERROR 1
cmp eax, MMSYSERR_NOERROR
je %%skip
; call _GetLastError@0
; cmp eax, 0
; jne %%skip_message
push %1
call ShowErrorMessage
push 0
call [__imp__ExitProcess@4]
%%skip:
%endmacro
; %macro _FAIL_ON_WINMM_ERROR 1
; %endmacro

944
exemain.asm Normal file
View File

@ -0,0 +1,944 @@
; Compofiller Studio by Yzi 2018
;
; Main program for .exe builds
;
;
; There is room for further size-optimizations. Look at the crinkler_report.html to try and find ways to reduce the final size.
; Try to do anything differently. Inline vs. function call? mov vs. push/pop combinations? different orderings for push/pop if you can?
; Try un-defining SLEEP_TO_LET_MUSIC_THREAD_GET_A_HEAD_START.
; Remove the safety padding at the end of the DEVMODE struct.
; ------------------------------------------------- map individual features to needed USE_... stuff
%include "map_features_to_use_defines.inc"
%define SLEEP_TO_LET_MUSIC_THREAD_GET_A_HEAD_START
%ifdef SLEEP_TO_LET_MUSIC_THREAD_GET_A_HEAD_START
%define USE_SLEEP
%endif
%ifdef USE_TEXTS
%include "timings_and_texts.inc"
%endif
; -------------------------------------------------
%include "glconstants.inc"
; screen related variables
section .scrn0 data align=1
; pixel format descriptor - we save some bytes by overlapping the DEVMODE struct with the PIXELFORMATDESCRIPTOR struct
global pfd
pfd:
db 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
DMSCREENSETTINGS: ; DEVMODE struct
db 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
dd RESOLUTION_X
dw RESOLUTION_Y ; <-- we could cut this to just a word and hope that the highest 2 bytes and the rest of the struct is empty (remove the safety padding below)
; the resolution bytes are like:
; db 0x00, 0x05, 0x00, 0x00 ; 1280
; db 0xD0, 0x02 ; 720
; remove this safety padding if you want to try and save a byte or two
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
; ------------------------------ STUFF FOR PCM/4KLANG MUSIC -------------------------
section .audio1 bss align=1
;section .audio1 data align=1
; .bss declares an uninitialized data section
;audio_sampling_rate equ 44100
;audio_length_seconds equ (8*60)
;audio_length_samples equ (audio_length_seconds*audio_sampling_rate*2)
global hWaveOut
; HWAVEOUT hWaveOut
hWaveOut: resd 1
global rendered_audio_data
rendered_audio_data: resb (AUDIO_BUFFER_ALLOCATED_LENGTH*4)
section .audio2 data align=1
global WaveHDR
WaveHDR:
WaveHDR_lpData: dd rendered_audio_data
WaveHDR_dwBufferLength: dd (AUDIO_BUFFER_ALLOCATED_LENGTH * 4) ; audio buffer length in bytes
WaveHDR_dwBytesRecorded: dd 0
WaveHDR_dwUser: dd 0
WaveHDR_dwFlags: dd 0
WaveHDR_dwLoops: dd 0
WaveHDR_lpNext: dd 0
WaveHDR_reserved: dd 0
section .audio3 data align=1
global pcmFormat
pcmFormat:
pcmFormat_wFormatTag: dw 1 ; format type WAVE_FORMAT_PCM
pcmFormat_nChannels: dw 2 ; number of channels: stereo
pcmFormat_nSamplesPerSec: dd AUDIO_SAMPLING_RATE ; sample rate
pcmFormat_nAvgBytesPerSec: dd (AUDIO_SAMPLING_RATE*4) ; for buffer estimation
pcmFormat_nBlockAlign: dw 4 ; block size of data
pcmFormat_wBitsPerSample: dw 16 ; number of bits per sample of mono data
pcmFormat_cbSize: dw 0
section .audio4 data align=1
global MMTime
; MMTIME is a "union" struct that can be used for many different content types based on the first field
MMTime: dd 2 ; wType: TIME_SAMPLES = 2
MMTime_sample: dd 0 ; actual position value
db 0, 0, 0, 0 ; some room for other cases
section .shader1 data align=1
extern shader_glsl
section .shader2 data align=1
global seireripointteri
seireripointteri:
dd shader_glsl
%ifdef USE_TIME_UNIFORM
%ifdef TIME_DIVIDER_IS_INTEGER
time_divider: dd (%[TIME_DIVIDER])
%else
time_divider: dd __float32__(%[TIME_DIVIDER])
%endif
; time_uniform_loc: dd 0
time_uniform_name: db TIME_UNIFORM_NAME, 0
%endif ; USE_TIME_UNIFORM
%ifdef USE_RESOLUTION_UNIFORM
resolution_uniform_loc: dd 0
resolution_uniform_name: db RESOLUTION_UNIFORM_NAME, 0
%endif ; USE_RESOLUTION_UNIFORM
%ifdef USE_UNIFORMS
gl_program: dd 0
%endif
section .gl1 data align=1
global glUseProgram_string
glUseProgram_string:
db "glUseProgram", 0
section .gl2 data align=1
global glCreateShaderProgramv_string
glCreateShaderProgramv_string:
db "glCreateShaderProgramv", 0
%ifdef USE_UNIFORMS
section .gl3 data align=1
global glUniform1f_string
glUniform1f_string: db 'glUniform1f', 0
section .gl4 data align=1
global glUniform2f_string
glUniform2f_string: db 'glUniform2f', 0
section .gl5 data align=1
global glGetUniformLocation_string
glGetUniformLocation_string: db 'glGetUniformLocation', 0
glUniform1i_string: db 'glUniform1i', 0
%endif
%ifdef USE_TEXTURES
%ifdef USE_MIPMAP
glGenerateMipmap_string: db 'glGenerateMipmap', 0
%endif
%endif
%ifdef USE_TEXTURES
section .gl3t data align=1
global glActiveTexture_string
glActiveTexture_string: db 'glActiveTexture', 0
%endif
section .text
extern _ChangeDisplaySettingsA@8
extern __imp__ChangeDisplaySettingsA@8
extern _CreateWindowExA@48
extern __imp__CreateWindowExA@48
extern _GetDC@4
extern __imp__GetDC@4
extern _ChoosePixelFormat@8
extern __imp__ChoosePixelFormat@8
extern _SetPixelFormat@12
extern __imp__SetPixelFormat@12
extern _wglCreateContext@4
extern __imp__wglCreateContext@4
extern _wglMakeCurrent@8
extern __imp__wglMakeCurrent@8
extern _wglGetProcAddress@4
extern __imp__wglGetProcAddress@4
extern _PeekMessageA@20
extern __imp__PeekMessageA@20
extern _ShowCursor@4
extern __imp__ShowCursor@4
extern _midiOutOpen@20
extern __imp__midiOutOpen@20
extern _midiOutShortMsg@8
extern __imp__midiOutShortMsg@8
extern _timeGetTime@0
extern __imp__timeGetTime@0
extern _glRecti@16
extern __imp__glRecti@16
extern _glColor3s@12
extern __imp__glColor3s@12
extern _glColor3us@12
extern __imp__glColor3us@12
extern _SwapBuffers@4
extern __imp__SwapBuffers@4
extern _GetAsyncKeyState@4
extern __imp__GetAsyncKeyState@4
extern _ExitProcess@4
extern __imp__ExitProcess@4
%ifdef USE_TEXTURES
extern _glBindTexture@8
extern __imp__glBindTexture@8
extern _glTexParameteri@12
extern __imp__glTexParameteri@12
extern _glCopyTexImage2D@32
extern __imp__glCopyTexImage2D@32
%endif
; %define USE_TEXTS
%ifdef USE_TEXTS
extern _glBindTexture@8
extern __imp__glBindTexture@8
extern _glTexParameteri@12
extern __imp__glTexParameteri@12
extern _glTexImage2D@36
extern __imp__glTexImage2D@36
; --- functions --- Gdi32.Lib
; CreateCompatibleDC@4 HDC CreateCompatibleDC(HDC hdc)
extern _CreateCompatibleDC@4
extern __imp__CreateCompatibleDC@4
; CreateDIBSection@24 HBITMAP CreateDIBSection(HDC hdc, CONST BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset)
extern _CreateDIBSection@24
extern __imp__CreateDIBSection@24
; CreateFontA@56 HFONT CreateFontA(int cHeight, int cWidth, int cEscapement, int cOrientation, int cWeight, DWORD bItalic, DWORD bUnderline, DWORD bStrikeOut, DWORD iCharSet, DWORD iOutPrecision, DWORD iClipPrecision, DWORD iQuality, DWORD iPitchAndFamily, LPCSTR pszFaceName)
extern _CreateFontA@56
extern __imp__CreateFontA@56
; SelectObject@8 HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h)
extern _SelectObject@8
extern __imp__SelectObject@8
; EHK<48> SetBkColor@8 COLORREF SetBkColor(HDC hdc, COLORREF color)
extern _SetBkColor@8
extern __imp__SetBkColor@8
; SetTextColor@8 COLORREF SetTextColor(HDC hdc, COLORREF color)
extern _SetTextColor@8
extern __imp__SetTextColor@8
%if TEXT_CHARACTER_EXTRA_SPACING > 0
; SetTextCharacterExtra@8 int SetTextCharacterExtra(HDC hdc, int extra)
extern _SetTextCharacterExtra@8
extern __imp__SetTextCharacterExtra@8
%endif
; HGDIOBJ GetStockObject(int i)
extern _GetStockObject@4
extern __imp__GetStockObject@4
; --- functions --- User32.Lib
; DrawText@20 int DrawText(HDC hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format)
%ifdef USE_WIDECHAR_TEXTS
extern _DrawTextW@20
extern __imp__DrawTextW@20
%else
extern _DrawTextA@20
extern __imp__DrawTextA@20
%endif
; FillRect@12 int FillRect(HDC *hDC, const RECT *lprc, HBRUSH hbr)
extern _FillRect@12
extern __imp__FillRect@12
; --- constants ---
; DIB_RGB_COLORS #define DIB_RGB_COLORS 0 /* color table in RGBs */
; FW_BOLD #define FW_NORMAL 400
; #define FW_BOLD 700
; ANSI_CHARSET #define ANSI_CHARSET 0
; OUT_DEFAULT_PRECIS #define OUT_DEFAULT_PRECIS 0
; CLIP_DEFAULT_PRECIS #define CLIP_DEFAULT_PRECIS 0
; ANTIALIASED_QUALITY #define NONANTIALIASED_QUALITY 3
; #define DEFAULT_QUALITY 0
; DEFAULT_PITCH #define DEFAULT_PITCH 0
;
; --- other ---
; font name e.g. "Times New Roman"
%include "winconstants.inc"
%endif ; USE_TEXTS
section .code1 code align=1
; our main entry point is called "t"
global t
t:
main:
push 4
push DMSCREENSETTINGS
call [__imp__ChangeDisplaySettingsA@8]
push 0
push 0
push 0
push 0
push 0
push 0
push 0
push 0
push 0x91000000
push 0
push 0xC018 ; http://www.pouet.net/topic.php?which=9894
push 0
call [__imp__CreateWindowExA@48]
push eax
call [__imp__GetDC@4]
push eax
pop edi ; edi : HDC
; all functions we call must preserve the edi register now
push pfd
push pfd
push edi
call [__imp__ChoosePixelFormat@8]
push eax
push edi
call [__imp__SetPixelFormat@12]
push edi
call [__imp__wglCreateContext@4]
push eax
push edi
call [__imp__wglMakeCurrent@8]
push seireripointteri
push 1
push 0x00008b30
push glCreateShaderProgramv_string
call [__imp__wglGetProcAddress@4]
call eax
%ifdef USE_UNIFORMS
mov [gl_program], eax
%endif
push eax
push glUseProgram_string
call [__imp__wglGetProcAddress@4]
call eax
%ifdef USE_TEXTS
call InitTextDrawingStuff
%endif
; play music, running 4klang audio renderer in a separate thread
; call Play
; create a separate thread for 4klang to render its audio in the background
push 0
push 0
push rendered_audio_data + (AUDIO_DELAY * 4)
push __4klang_render@4
push 0
push 0
call [__imp__CreateThread@24]
%ifdef SLEEP_TO_LET_MUSIC_THREAD_GET_A_HEAD_START
; Wait/sleep for 200 milliseconds so that 4klang's renderer thread gets well on its way, before we start playback
push 200 ; if your music is too CPU heavy, try increasing this number
call [__imp__Sleep@4]
%endif
push 0
push 0
push 0
push pcmFormat
push -1
push hWaveOut
call [__imp__waveOutOpen@24]
push 32 ; sizeof(WaveHDR)
push WaveHDR
push DWORD [hWaveOut]
call [__imp__waveOutPrepareHeader@12]
push 32 ; sizeof(WaveHDR)
push WaveHDR
push DWORD [hWaveOut]
call [__imp__waveOutWrite@12] ; <--- audio starts now
; -------------- main program loop, repeat until we reach the ending time position, or the user presses Esc ----------- LOOP
luuppi:
; hide mouse pointer
push 0
call [__imp__ShowCursor@4]
; pump window message queue (or otherwise Windows will think that our program hung up)
push 1
push 0
push 0
push 0
push 0
call [__imp__PeekMessageA@20]
%ifdef FRAME_TO_TEXTURE
; --- copy previous frame to texture before running the shader ---
call copy_framebuffer_to_texture
%endif
call GetPosition ; <-- get the time to eax
; did we reach the end of the prod?
cmp eax, %[PROD_END_TIME]
jae loppu
%ifdef USE_TEXTS
push eax
%endif
; time is in eax
call set_time_in_EAX_to_shader
%ifdef USE_TEXTS
; pop eax
; check
call update_texts_time_on_STACK
pushad
call DrawTextBitmap
popad
%endif
%ifdef USE_RESOLUTION_UNIFORM
push glGetUniformLocation_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
push resolution_uniform_name
push dword [gl_program]
call eax
mov [resolution_uniform_loc], eax
; FAIL_ON_GL_ERROR glGetUniformLocation_string
push glUniform2f_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
push __float32__(%[RESOLUTION_Y].0)
push __float32__(%[RESOLUTION_X].0)
push dword [resolution_uniform_loc]
call eax
; FAIL_ON_GL_ERROR glUniform2f_string
%endif ; USE_RESOLUTION_UNIFORM
; draw one full-screen quad
call draw_full_screen_quad
; ________ IF TWO_PASS_RENDERING DRAW ONCE MORE, WITH TIME = 0 _______
%ifdef TWO_PASS_RENDERING
call copy_framebuffer_to_texture
%ifdef SECOND_PASS_NEGATIVE_TIME
call GetPosition ; <-- get the time to eax
neg eax
%else
xor eax, eax ; push 0; pop eax might be smaller
%endif
call set_time_in_EAX_to_shader
; draw another full-screen quad
call draw_full_screen_quad
; ----------------------- ^^^TWO-PASS RENDERING^^^-----------------------
%endif ; TWO_PASS_RENDERING
; ------------------------------------------- SWAP BUFFERS -------------------------------------
push edi
call [__imp__SwapBuffers@4]
; Esc pressed?
push 27 ; 0000001bH
call [__imp__GetAsyncKeyState@4]
test eax, eax
%ifdef USE_UNIFORMS
je luuppi
%else
je SHORT luuppi
%endif
loppu:
push 0
call [__imp__ExitProcess@4] ; <--- end program execution
section .cdennn
section .text
; the __imp__ versions refer to the corresponding import address table entries
extern __4klang_render@4
extern _CreateThread@24
extern __imp__CreateThread@24
%ifdef USE_SLEEP
extern _Sleep@4
extern __imp__Sleep@4
%endif
extern _waveOutOpen@24
extern __imp__waveOutOpen@24
extern _waveOutPrepareHeader@12
extern __imp__waveOutPrepareHeader@12
extern _waveOutWrite@12
extern __imp__waveOutWrite@12
extern _waveOutGetPosition@12
extern __imp__waveOutGetPosition@12
section .code2 code align=1
;global Play
;Play:
; ret
; ---- GetPosition returns the current audio playback position ----
section .code3 code align=1
global GetPosition
GetPosition:
push 12 ; sizeof MMTIME struct
push MMTime
push DWORD [hWaveOut]
call [__imp__waveOutGetPosition@12]
mov eax, [MMTime_sample]
ret
%ifdef USE_COPY_FRAMEBUFFER_TO_TEXTURE
section .cde231 code align=1
global copy_framebuffer_to_texture
copy_framebuffer_to_texture:
%ifdef MORE_THAN_ONE_TEXTURE
push glActiveTexture_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
push GL_TEXTURE0
call eax
; JUMP_ON_GL_ERROR .fail, glActiveTexture_string
; --- copy previous frame to texture before running the shader ---
push 0
push GL_TEXTURE_2D
call [__imp__glBindTexture@8]
; JUMP_ON_GL_ERROR .fail, glBindTexture_string
%endif ; MORE_THAN_ONE_TEXTURE
%ifdef USE_MIPMAP
push GL_LINEAR_MIPMAP_LINEAR
%else
push GL_LINEAR
%endif
push GL_TEXTURE_MIN_FILTER
push GL_TEXTURE_2D
call [__imp__glTexParameteri@12]
; JUMP_ON_GL_ERROR .fail, glTexParameteri_string
push 0 ; border
push RESOLUTION_Y ; height
push RESOLUTION_X ; width
push 0 ; y
push 0 ; x
push GL_RGBA8 ; internalformat
push 0 ; level, mipmap level-of-detail number
push GL_TEXTURE_2D ; target
call [__imp__glCopyTexImage2D@32]
; JUMP_ON_GL_ERROR .fail, glCopyTexImage2D_string
%ifdef USE_MIPMAP
push glGenerateMipmap_string
call [__imp__wglGetProcAddress@4]
push GL_TEXTURE_2D
call eax
%endif
ret
%endif
; set_time_in_EAX_to_shader(time), as parameter: eax = time
section .cde232 code align=1
set_time_in_EAX_to_shader:
%ifdef USE_TIME_UNIFORM
push eax
fild dword [esp] ; load the audio position to FPU stack (0) so we can divide it
%ifdef TIME_DIVIDER_IS_INTEGER
fidiv dword [time_divider]
%else
fdiv dword [time_divider]
%endif
fstp dword [esp] ; store from FPU stack to top of CPU stack, replacing it with the divided floating point time value
; on top of stack i.e. [esp] is now the SECOND parameter (pushed first in stdcall) to glUniform1f()
push glGetUniformLocation_string
call [__imp__wglGetProcAddress@4]
push time_uniform_name
push dword [gl_program]
call eax ; call glGetUniformLocation
; mov [time_uniform_loc], eax
push eax ; <-- FIRST parameter (pushed last) to glUniform1f()
; set the shader uniform variables
push glUniform1f_string
call [__imp__wglGetProcAddress@4]
; eax = pointer to glUniform1f() function
call eax ; call glUniform1f()
%else
; ---- NOT USE_TIME_UNIFORM ---
; green color is (time position >> 8), meaning the color value grows by 1/65536 every 256/44100 seconds (if we have 44100 Hz audio sample rate)
;shr eax, 8
sar eax, 8
push 0
push eax ; green color is (time position >> 8), meaning the color value grows by 1/65536 every 256/44100 seconds (if we have 44100 Hz audio sample rate)
push 0
call [__imp__glColor3s@12]
%endif ; (not) USE_TIME_UNIFORM
ret
section .cde233 code align=1
draw_full_screen_quad:
push -1
push -1
push 1
push 1
call [__imp__glRecti@16]
ret
%ifdef USE_TEXTS
section .data
%ifdef GEN_TEXTURES
texts_gl_texture_name: dd 0
%endif
hardcoded_font_name: db TEXT_FONT_NAME, 0
text_font_name: dd hardcoded_font_name
current_text_ptr: dd _string0
current_timing_ptr: dd text_string_timings
textsDC: dd 0
textsBitmapHandle: dd 0
textsBitmapBitsPtr: dd 0
textsFontHandle: dd 0
TextRectangle: ; we overlap this with BitmapInfo
dd 0
; , 0, TEXT_BITMAP_RESOLUTION_X, TEXT_BITMAP_RESOLUTION_Y
BitmapInfo: ; bmiHeader
dd 40 ; biSize, it doesn't seem to work if you give 0 in this field
BitmapInfo_biWidth: dd TEXT_BITMAP_RESOLUTION_X ; biWidth
BitmapInfo_biHeight: dd TEXT_BITMAP_RESOLUTION_Y ; biHeight
BitmapInfo_biPlanes: dw 1 ; biPlanes
dw 32 ; biBitCount
dd 0 ; biCompression
dd 0 ; biSizeImage
dd 0 ; biXPelsPerMeter
dd 0 ; biYPelsPerMeter
dd 0 ; biClrUsed
dd 0 ; biClrImportant
dd 0 ; bmiColors
texts_uniform_loc: dd 0
texts_uniform_name: db TEXTS_UNIFORM_NAME, 0
section .cdet33 code align=1
;update_texts_time_in_EAX:
update_texts_time_on_STACK:
; if current time >= current_text->time
; draw text to buffer
; move current_text pointer to next text
.seek_loop
mov eax, [current_timing_ptr]
mov ecx, dword [eax] ; get time value from the timings
cmp ecx, [esp+4]
ja .skip
; set current string pointer
mov ecx, [eax+TIMINGS_REC_STRING_PTR_FIELD_OFS]
mov [current_text_ptr], ecx
; move timing pointer to next timing rec
add eax, TIMINGS_REC_SIZE
mov [current_timing_ptr], eax
jmp .seek_loop
.skip:
ret
section .cde3133 code align=1
InitTextDrawingStuff:
%ifdef GEN_TEXTURES
push texts_gl_texture_name
push 1
call [__imp__glGenTextures@8]
%endif
push 0
call [__imp__CreateCompatibleDC@4]
mov [textsDC], eax
; test eax, eax
; jz .fail
%if TEXT_CHARACTER_EXTRA_SPACING > 0
push TEXT_CHARACTER_EXTRA_SPACING
push eax
call [__imp__SetTextCharacterExtra@8]
%endif
; CreateDIBSection@24
; HBITMAP CreateDIBSection(HDC hdc, CONST BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset)
push 0 ; offset
push 0 ; hSection
push textsBitmapBitsPtr ; ppvBits
push DIB_RGB_COLORS ; usage
push BitmapInfo ; BITMAPINFO *pbmi
push dword [textsDC] ; hdc
call [__imp__CreateDIBSection@24]
mov [textsBitmapHandle], eax
; test eax, eax
; jz .fail
mov dword [BitmapInfo], 0 ; clear the first field of BitmapInfo, so we can use it as part of the RECT structure
; CreateFontA@56 HFONT CreateFontA(int cHeight, int cWidth, int cEscapement, int cOrientation, int cWeight, DWORD bItalic, DWORD bUnderline,
; DWORD bStrikeOut, DWORD iCharSet, DWORD iOutPrecision, DWORD iClipPrecision, DWORD iQuality, DWORD iPitchAndFamily, LPCSTR pszFaceName)
push dword [text_font_name] ; font name
push 0 ; iPitchAndFamily
push ANTIALIASED_QUALITY ; iQuality
push CLIP_DEFAULT_PRECIS ; iClipPrecision
push OUT_DEFAULT_PRECIS ; iOutPrecision
push ANSI_CHARSET ; iCharSet
push TEXT_FONT_STRIKEOUT ; bStrikeOut
push TEXT_FONT_UNDERLINE ; bUnderline
push TEXT_FONT_ITALIC ; bItalic
push TEXT_FONT_WEIGHT ; cWeight FW_BOLD = 700
push TEXT_FONT_ORIENTATION ; cOrientation
push TEXT_FONT_ESCAPEMENT ; cEscapement
push TEXT_FONT_WIDTH ; cWidth
push -TEXT_FONT_SIZE ; cHeight
call [__imp__CreateFontA@56]
mov [textsFontHandle], eax
.fail:
ret
DrawTextBitmap:
; SelectObject@8 HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h)
push dword [textsBitmapHandle]
push dword [textsDC]
call [__imp__SelectObject@8]
push dword [textsFontHandle]
push dword [textsDC]
call [__imp__SelectObject@8]
; SetBkColor@8 COLORREF SetBkColor(HDC hdc, COLORREF color)
push 0x000000 ; black color
push dword [textsDC]
call [__imp__SetBkColor@8]
; SetTextColor@8 COLORREF SetTextColor(HDC hdc, COLORREF color)
push 0x00FFFFFF ; black color
push dword [textsDC]
call [__imp__SetTextColor@8]
; some stock object constants
WHITE_BRUSH equ 0
BLACK_BRUSH equ 4
DC_BRUSH equ 18
push BLACK_BRUSH
call [__imp__GetStockObject@4] ; wingdi.h / Gdi32.lib / Gdi32.dll
push eax ; HBRUSH hbr
push TextRectangle ; RECT *lprc
push dword [textsDC] ; HDC hDC
call [__imp__FillRect@12] ; winuser.h / User32.lib
; --- functions --- User32.Lib
; DrawText@20 int DrawText(HDC hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format)
push DT_CENTER ; format
push TextRectangle ; lprc
push -1 ; cchText, -1 means null-terminated
push dword [current_text_ptr] ; lpchText
push dword [textsDC]
%ifdef USE_WIDECHAR_TEXTS
call [__imp__DrawTextW@20]
%else
call [__imp__DrawTextA@20]
%endif
%ifdef MORE_THAN_ONE_TEXTURE
push glActiveTexture_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
; use texture unit 1 for texts, if there's more than one texture
push GL_TEXTURE1
call eax
;JUMP_ON_GL_ERROR .fail, glActiveTexture_string
%endif
; do we want to mipmap the texts too?
;%ifdef USE_MIPMAP
;push GL_LINEAR_MIPMAP_LINEAR
;%else
push GL_LINEAR
;%endif
push GL_TEXTURE_MIN_FILTER
push GL_TEXTURE_2D
call [__imp__glTexParameteri@12]
; JUMP_ON_GL_ERROR .fail, glTexParameteri_string
; "Texture names are unsigned integers with the value zero reserved to represent the default texture for each texture target."
%ifdef MORE_THAN_ONE_TEXTURE
%ifdef GEN_TEXTURES
push dword [texts_gl_texture_name]
%else
push 1
%endif
push GL_TEXTURE_2D
call [__imp__glBindTexture@8]
%endif ; MORE_THAN_ONE_TEXTURE
push dword [textsBitmapBitsPtr] ; pixels
push GL_UNSIGNED_BYTE ; type
push GL_RGBA ; format
push 0 ; border
push TEXT_BITMAP_RESOLUTION_Y ; height
push TEXT_BITMAP_RESOLUTION_X ; width
push GL_RGBA ; internal format
push 0 ; level of detail
push GL_TEXTURE_2D
call [__imp__glTexImage2D@36]
;glGenTextures(1, &texture);
;glActiveTexture(GL_TEXTURE1);
;glBindTexture(GL_TEXTURE_2D, texture); // activate first texture
; glTexImage2D( GL_TEXTURE_2D, 0 /* level of detail */ , GL_RGBA, TEXTDISPLAY_XRES/*width*/, TEXTDISPLAY_YRES/*height*/, 0/*border*/, GL_RGBA, GL_UNSIGNED_BYTE, TextBitmaps[textindex]);
;void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
; --- other ---
; font name e.g. "Times New Roman"
%ifdef USE_TEXTS_UNIFORM
push glGetUniformLocation_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
push texts_uniform_name
push dword [gl_program]
call eax
mov [texts_uniform_loc], eax
; JUMP_ON_GL_ERROR_EXT .fail, glGetUniformLocation_string, texts_uniform_name
push glGetUniformLocation_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
push glUniform1i_string
call [__imp__wglGetProcAddress@4]
; FAIL_ON_WINDOWS_ERROR wglGetProcAddress_string
%ifdef GEN_TEXTURES
push dword [texts_gl_texture_name]
%else
push 1
%endif
push dword [texts_uniform_loc]
call eax
; JUMP_ON_GL_ERROR .fail, glUniform1i_string
%endif ; USE_TEXTS_UNIFORM
ret
%endif ; USE_TEXTS
; end-of-file

13
final.config Normal file
View File

@ -0,0 +1,13 @@
# Compofiller Studio by Yzi
PARENT_CONFIG=minified.config
include $(PARENT_CONFIG)
# Override things that differ from the parent
# Visuals
RESOLUTION_X=1280
RESOLUTION_Y=720
CRINKLER_ORDERTRIES=4000
OUTPUT_EXE_NAME=release.exe

9
glconstants.inc Normal file
View File

@ -0,0 +1,9 @@
GL_TEXTURE_2D equ 0x0DE1
GL_TEXTURE_MIN_FILTER equ 0x2801
GL_LINEAR equ 0x2601
GL_TEXTURE0 equ 0x84C0
GL_TEXTURE1 equ 0x84C1
GL_RGBA8 equ 0x8058
GL_UNSIGNED_BYTE equ 0x1401
GL_RGBA equ 0x1908
GL_LINEAR_MIPMAP_LINEAR equ 0x2703

View File

@ -0,0 +1,66 @@
%if USE_TIME_UNIFORM > 0
%define USE_UNIFORMS
%else
%undef USE_TIME_UNIFORM
%endif
%if USE_RESOLUTION_UNIFORM > 0
%define USE_UNIFORMS
%else
%undef USE_RESOLUTION_UNIFORM
%endif
%if USE_TEXTS = 0
%undef USE_TEXTS
%endif
%if USE_WIDECHAR_TEXTS = 0
%undef USE_WIDECHAR_TEXTS
%endif
%if USE_TEXTS_UNIFORM > 0
%define USE_UNIFORMS
%define USE_TEXTURES
%else
%undef USE_TEXTS_UNIFORM
%endif
%if TWO_PASS_RENDERING > 0
%define USE_TEXTURES
%define USE_COPY_FRAMEBUFFER_TO_TEXTURE
%ifdef USE_TEXTS
%define MORE_THAN_ONE_TEXTURE
%endif
%else
%undef TWO_PASS_RENDERING
%endif
%if SECOND_PASS_NEGATIVE_TIME > 0
%else
%undef SECOND_PASS_NEGATIVE_TIME
%endif
%if FRAME_TO_TEXTURE > 0
%define USE_TEXTURES
%define USE_COPY_FRAMEBUFFER_TO_TEXTURE
%ifdef USE_TEXTS
%define MORE_THAN_ONE_TEXTURE
%endif
%else
%undef FRAME_TO_TEXTURE
%endif
%if USE_MIPMAP = 0
%undef USE_MIPMAP
%endif
%ifndef USE_TEXTURES
%undef USE_MIPMAP
%endif
; if there's more than one texture, we have to use uniforms to set the texture names to the samplers, using uniforms
%ifdef MORE_THAN_ONE_TEXTURE
%define USE_UNIFORMS
%define USE_TEXTS_UNIFORM
%endif

11
minified.config Normal file
View File

@ -0,0 +1,11 @@
# Compofiller Studio by Yzi
PARENT_CONFIG=base.config
include $(PARENT_CONFIG)
# Override things that differ from the parent
# Visuals
EXE_LINKER_PROGRAM=Crinkler
CRINKLER_ORDERTRIES=100

7
prod.nfo Normal file
View File

@ -0,0 +1,7 @@
*** Prod Name ***
By The Demo Group
INSERT SOMETHING HERE
made by accident
greetings to Heppo

314
shader.glsl Normal file
View File

@ -0,0 +1,314 @@
// Compofiller Studio by Yzi 2018
//
// Default template shader
// This shader program is executed in the GPU (or a CPU-based emulation) for
// every pixel (i.e. "fragment" in OpenGL jargon) of every frame.
// The "uniforms" are the same (i.e. uniform) for all pixels/fragments of the frame,
// and they come from the main program.
uniform float time;
uniform vec2 resolution;
// If you choose to save some bytes and not use either of these uniforms, you have to
// do some additional tricks.
// * time : if you uncheck "[ ] Use time uniform" checkbox, time is in gl_Color.y (green component)
// * resolution : if you uncheck "[ ] Use resolution uniform" checkbox, you'll have to hard-code the resolution manually
// The uniform-less version could look like this, 88200.0 being the time divider
//float time = gl_Color.y * 256.0 * (65536.0 / 88200.0);
//vec2 resolution = vec2(1280.0, 720.0);
// Uncomment this to use the texture-based features
uniform sampler2D texture_sampler;
// Uncomment this to use the texture-based features
uniform sampler2D texts;
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// Created by S. Guillitte 2015
float zoom=1.;
vec2 cmul( vec2 a, vec2 b ) { return vec2( a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x ); }
vec2 csqr( vec2 a ) { return vec2( a.x*a.x - a.y*a.y, 2.*a.x*a.y ); }
mat2 rot(float a) {
return mat2(cos(a),sin(a),-sin(a),cos(a));
}
vec2 iSphere( in vec3 ro, in vec3 rd, in vec4 sph )//from iq
{
vec3 oc = ro - sph.xyz;
float b = dot( oc, rd );
float c = dot( oc, oc ) - sph.w*sph.w;
float h = b*b - c;
if( h<0.0 ) return vec2(-1.0);
h = sqrt(h);
return vec2(-b-h, -b+h );
}
float map(in vec3 p) {
float res = 0.;
vec3 c = p;
for (int i = 0; i < 10; ++i) {
p =.7*abs(p)/dot(p,p) -.7;
p.yz= csqr(p.yz);
p=p.zxy;
res += exp(-19. * abs(dot(p,c)));
}
return res/2.;
}
vec3 raymarch( in vec3 ro, vec3 rd, vec2 tminmax )
{
float t = tminmax.x;
float dt = .02;
//float dt = .2 - .195*cos(iTime*.05);//animated
vec3 col= vec3(0.);
float c = 0.;
for( int i=0; i<64; i++ )
{
t+=dt*exp(-2.*c);
if(t>tminmax.y)break;
c = map(ro+t*rd);
col = .99*col+ .08*vec3(c*c, c, c*c*c);//green
//col = .99*col+ .08*vec3(c*c*c, c*c, c);//blue
}
return col;
}
void CoolSphere( out vec4 fragColor, in vec2 fragCoord )
{
float time = time;
vec2 q = fragCoord.xy / resolution.xy;
vec2 p = -1.0 + 2.0 * q;
p.x *= resolution.x/resolution.y;
vec2 m = vec2(0.);
m-=.5;
// camera
vec3 ro = zoom*vec3(4.);
ro.yz*=rot(m.y);
ro.xz*=rot(m.x+ 0.1*time);
vec3 ta = vec3( 0.0 , 0.0, 0.0 );
vec3 ww = normalize( ta - ro );
vec3 uu = normalize( cross(ww,vec3(0.0,1.0,0.0) ) );
vec3 vv = normalize( cross(uu,ww));
vec3 rd = normalize( p.x*uu + p.y*vv + 4.0*ww );
vec2 tmm = iSphere( ro, rd, vec4(0.,0.,0.,2.) );
// raymarch
vec3 col = raymarch(ro,rd,tmm);
if (tmm.x<0.)col = texture(texture_sampler, rd).rgb;
else {
vec3 nor=(ro+tmm.x*rd)/2.;
nor = reflect(rd, nor);
float fre = pow(.5+ clamp(dot(nor,rd),0.0,1.0), 3. )*1.3;
col += texture(texture_sampler, nor).rgb * fre;
}
// shade
col = .5 *(log(1.+col));
col = clamp(col,0.,1.);
fragColor = vec4( col, 1.0 );
}
float bar = time; // this is just a coding nicety to highlight that in some calculations we want musical time ... you wouldn't want to have this in a real prod's final version
// --- noise from procedural pseudo-Perlin (better but not so nice derivatives) ---------
// ( adapted from IQ )
float gTime = 0.;
float sdBox( vec3 p, vec3 b )
{
vec3 q = abs(p) - b;
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
float box(vec3 pos, float scale) {
pos *= scale;
float base = sdBox(pos, vec3(.4,.4,.1)) /1.5;
pos.xy *= 5.;
pos.y -= 3.5;
pos.xy *= rot(.75);
float result = -base;
return result;
}
float box_set(vec3 pos, float time) {
vec3 pos_origin = pos;
pos = pos_origin;
pos .y += sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box1 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos .y -=sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box2 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos .x +=sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box3 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos .x -=sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box4 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos.xy *= rot(.8);
float box5 = box(pos,.5) * 6.;
pos = pos_origin;
float box6 = box(pos,.5) * 6.;
float result = max(max(max(max(max(box1,box2),box3),box4),box5),box6);
return result;
}
float map(vec3 pos, float time) {
vec3 pos_origin = pos;
float box_set1 = box_set(pos, time);
return box_set1;
}
void mainImage2( out vec4 fragColor, in vec2 fragCoord ) {
vec2 p = (fragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y);
vec3 ro = vec3(0., -0.2 ,time * 4.);
vec3 ray = normalize(vec3(p, 1.5));
ray.xy = ray.xy * rot(sin(time * .03) * 5.);
ray.yz = ray.yz * rot(sin(time * .05) * .2);
float t = 0.1;
vec3 col = vec3(0.);
float ac = 0.0;
for (int i = 0; i < 99; i++){
vec3 pos = ro + ray * t;
pos = mod(pos-2., 4.) -2.;
gTime = time -float(i) * 0.01;
float d = map(pos, time);
d = max(abs(d), 0.01);
ac += exp(-d*23.);
t += d* 0.55;
}
col = vec3(ac * 0.02);
col +=vec3(0.,0.2 * abs(sin(time)),0.5 + sin(time) * 0.2);
fragColor = vec4(col ,1.0 - t * (0.02 + 0.02 * sin (time)));
}
float noise3( vec3 x ) {
vec3 p = floor(x),f = fract(x);
f = f*f*(3.-2.*f); // or smoothstep // to make derivative continuous at borders
#define hash3(p) fract(sin(1e3*dot(p,vec3(1,57,-13.7)))*4375.5453) // rand
return mix( mix(mix( hash3(p+vec3(0,0,0)), hash3(p+vec3(1,0,0)),f.x), // triilinear interp
mix( hash3(p+vec3(0,1,0)), hash3(p+vec3(1,1,0)),f.x),f.y),
mix(mix( hash3(p+vec3(0,0,1)), hash3(p+vec3(1,0,1)),f.x),
mix( hash3(p+vec3(0,1,1)), hash3(p+vec3(1,1,1)),f.x),f.y), f.z);
}
#define noise(x) (noise3(x)+noise3(x+11.5)) / 2. // pseudoperlin improvement from foxes idea
void mainImage3( out vec4 O, vec2 U ) // ------------ draw isovalues
{
vec2 R = resolution.xy;
float n = noise(vec3(U*8./R.y, .1*time)),
v = sin(6.28*10.*n),
t = time;
v = smoothstep(1.,0., .5*abs(v)/fwidth(v));
O = mix( exp(-33./R.y )* texture2D( texture_sampler, (U+vec2(1,sin(t)))/R), // .97
.5+.5*sin(12.*n+vec4(0,2.1,-2.1,0)),
v );
}
/* "Vortex" by @kishimisu (2024) - https://www.shadertoy.com/view/MX33Dr
It eventually leads somewhere...
[388 → 378 chars by @Xor]
*/
#define R mat2(cos(vec4(0,11,33,0)
void mainImage(out vec4 O, vec2 F) {
vec2 V = resolution;
vec3 o;
float r = time;
float t= .1;
float e,x;
for (O *= e; e++ < 40.;
o.y += t*t*.09,
o.z = mod(o.z + r, .2) - .1,
x = t*.06 - r*.2,
o.x = fract(
o.xy *= R+floor(((atan(o.y, o.x) - x) / .314) +0.5) * .314 + x))
).x - .8,
t += x = length(o)*.5 - .014,
O += (1. + cos(t*.5 + r + vec4(0,1,2,0)))
* (.3 + sin(3.*t + r*5.)/4.)
/ (8. + x*4e2)
)
o = t * normalize(vec3((F+F-V.xy)*R+r*.15)),V.y));
}
void main(void)
{
float abstime = abs(time);
vec3 l;
if (abstime < 10.0)
CoolSphere(gl_FragColor, gl_FragCoord.xy);
else if (abstime < 15.0)
{
mainImage2(gl_FragColor, gl_FragCoord.xy);
}
else if (abstime < 20.0)
{
mainImage(gl_FragColor, gl_FragCoord.xy);
}
else
{
mainImage3(gl_FragColor, gl_FragCoord.xy);
}
vec2 texttop = vec2(0., -.35), pt = (gl_FragCoord.xy / resolution) - texttop;
if (pt.y > 0.)
l = gl_FragColor + texture(texts, pt);
gl_FragColor = vec4(l * (1.0), 1.0);
}

16
shader_code.asm Normal file
View File

@ -0,0 +1,16 @@
; Compofiller Studio by Yzi 2017
;
; This asm file is for making a COFF object file from the GLSL shader code.
; C++ mangled name would be something like this:
;global ?shader_glsl@@3DA
;?shader_glsl@@3DA:
section .shader0 data align=1
global shader_glsl
shader_glsl:
incbin TEMP_PROCESSED_SHADER_FILE
db 0

71
timings_and_texts.inc Normal file
View File

@ -0,0 +1,71 @@
; timings_and_texts.inc
; Compofiller Studio project text strings and timings
section .textstr0 data
%ifdef USE_WIDECHAR_TEXTS
%define DEFINE_STRING dw
%else
%define DEFINE_STRING db
%endif
%define END_STRING , 0
%define SHADER_SOURCE_TEXT
; each timing entry is a bunch of dwords
%define DEFINE_TIMING dd
%ifndef TIME_DIVIDER_INT
error! TIME_DIVIDER_INT MUST BE DEFINED!!!
%endif
; Kludge Construction Kit: x and y are floating point values used by the IDE's timings and texts editor,
; and z is the final integer value that has x, y and TIME_DIVIDER_INT baked into it. :/ This is needed
; because NASM is apparently unable to do the calculation and float-to-int conversion at compile time.
%define TIMING_TIME(x,y,z) (z)
REC_TIMINGS_TIME_FIELD_SIZE equ 4
; alias is only used by the IDE, not actually assembled into any sort of data
%define TIMING_ALIAS(x)
%ifdef USE_CUSTOM_UNIFORM
%define TIMING_CUSTOM(x) , x
REC_TIMINGS_CUSTOM_FIELD_SIZE equ 4
%else
%define TIMING_CUSTOM(x)
REC_TIMINGS_CUSTOM_FIELD_SIZE equ 0
%endif
%define TIMING_STRING(x, y) , y
REC_TIMINGS_STRING_PTR_FIELD_SIZE equ 4
TIMINGS_REC_SIZE equ (REC_TIMINGS_TIME_FIELD_SIZE + REC_TIMINGS_CUSTOM_FIELD_SIZE + REC_TIMINGS_STRING_PTR_FIELD_SIZE)
TIMINGS_REC_STRING_PTR_FIELD_OFS equ (REC_TIMINGS_TIME_FIELD_SIZE + REC_TIMINGS_CUSTOM_FIELD_SIZE)
; Separating the timings and actual string data enables us to do things
section .textstr1 data
;______STRINGS_START______
_string0: DEFINE_STRING 'Hello World' END_STRING
_string1: DEFINE_STRING 'This is Scene1' END_STRING
_string2: DEFINE_STRING 70, 105, 114, 115, 116, 32, 100, 101, 109, 111, 13, 119, 101, 32, 101, 118, 101, 114, 32, 109, 97, 100, 101 END_STRING
_string3: DEFINE_STRING 'This is Scene2' END_STRING
_string4: DEFINE_STRING 83, 97, 121, 32, 104, 105, 32, 116, 111, 13, 77, 111, 109, 32, 102, 111, 114, 32, 109, 101 END_STRING
_string5: DEFINE_STRING 'Shout out to' END_STRING
_string6: DEFINE_STRING 'Puavohard' END_STRING
_string7: DEFINE_STRING 'Goodbye!' END_STRING
;______STRINGS_END______
section .textstr2 data
text_string_timings:
;______TIMINGS_START______
DEFINE_TIMING TIMING_TIME(0,0.00000,0) TIMING_ALIAS('START_TIME') TIMING_CUSTOM(0) TIMING_STRING(0,_string0) ; this is a comment
DEFINE_TIMING TIMING_TIME(1,0.00000,88200) TIMING_ALIAS('') TIMING_CUSTOM(0) TIMING_STRING(0,_string1) ; this is a comment
DEFINE_TIMING TIMING_TIME(2,0.50000,220500) TIMING_ALIAS('') TIMING_CUSTOM(0) TIMING_STRING(0,_string2) ; another comment
DEFINE_TIMING TIMING_TIME(10,0.00000,882000) TIMING_ALIAS('') TIMING_CUSTOM(0) TIMING_STRING(0,_string3) ; this is a komment
DEFINE_TIMING TIMING_TIME(12,0.00000,1058400) TIMING_ALIAS('') TIMING_CUSTOM(0) TIMING_STRING(0,_string4) ;
DEFINE_TIMING TIMING_TIME(15,0.00000,1323000) TIMING_ALIAS('') TIMING_CUSTOM(0) TIMING_STRING(0,_string5) ; abcd
DEFINE_TIMING TIMING_TIME(18,0.00000,1587600) TIMING_ALIAS('') TIMING_CUSTOM(0) TIMING_STRING(0,_string6) ; efgh
DEFINE_TIMING TIMING_TIME(20,0.00000,1764000) TIMING_ALIAS('END_TIME') TIMING_CUSTOM(0) TIMING_STRING(0,_string7) ; efgh
;______TIMINGS_END______
dd 0xFFFFFFFF ; end-of-time

18
winconstants.inc Normal file
View File

@ -0,0 +1,18 @@
DIB_RGB_COLORS equ 0
FW_NORMAL equ 400
FW_BOLD equ 700
ANSI_CHARSET equ 0
OUT_DEFAULT_PRECIS equ 0
CLIP_DEFAULT_PRECIS equ 0
ANTIALIASED_QUALITY equ 4
NONANTIALIASED_QUALITY equ 3
DEFAULT_QUALITY equ 0
DEFAULT_PITCH equ 0
DT_TOP equ 0
DT_LEFT equ 0
DT_CENTER equ 1
DT_RIGHT equ 2
DT_VCENTER equ 4
DT_BOTTOM equ 8
DT_WORDBREAK equ 16