alnyan/yggdrasil: add yggdrasil integration
This commit is contained in:
@@ -0,0 +1,74 @@
|
|||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# $Id:$
|
||||||
|
#
|
||||||
|
# $Log:$
|
||||||
|
#
|
||||||
|
|
||||||
|
ifeq ($(V),1)
|
||||||
|
VB=''
|
||||||
|
else
|
||||||
|
VB=@
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
RFL=
|
||||||
|
|
||||||
|
ifneq ($(TARGET),)
|
||||||
|
CFLAGS+=-target $(TARGET)
|
||||||
|
LDFLAGS+=-target $(TARGET)
|
||||||
|
RFL+=--target $(TARGET)
|
||||||
|
RDIR=target/$(TARGET)/debug
|
||||||
|
else
|
||||||
|
RDIR=target/debug
|
||||||
|
endif
|
||||||
|
ifneq ($(SYSROOT),)
|
||||||
|
CFLAGS+=--sysroot $(SYSROOT)
|
||||||
|
LDFLAGS+=--sysroot $(SYSROOT)
|
||||||
|
endif
|
||||||
|
|
||||||
|
LDFLAGS+=-Wl,--gc-sections
|
||||||
|
CFLAGS+=-ggdb3 -fno-omit-frame-pointer -Wall -DNORMALUNIX -D_DEFAULT_SOURCE -fPIC # -DUSEASM
|
||||||
|
LIBS+=-lm -lygglibc doomgeneric-yggdrasil/$(RDIR)/libdoomgeneric_yggdrasil.a
|
||||||
|
|
||||||
|
|
||||||
|
CC=clang # gcc or g++
|
||||||
|
|
||||||
|
# subdirectory for objects
|
||||||
|
OBJDIR=build
|
||||||
|
OUTPUT=doomgeneric
|
||||||
|
|
||||||
|
SRC_DOOM = dummy.o am_map.o doomdef.o doomstat.o dstrings.o d_event.o d_items.o d_iwad.o d_loop.o d_main.o d_mode.o d_net.o f_finale.o f_wipe.o g_game.o hu_lib.o hu_stuff.o info.o i_cdmus.o i_endoom.o i_joystick.o i_scale.o i_sound.o i_system.o i_timer.o memio.o m_argv.o m_bbox.o m_cheat.o m_config.o m_controls.o m_fixed.o m_menu.o m_misc.o m_random.o p_ceilng.o p_doors.o p_enemy.o p_floor.o p_inter.o p_lights.o p_map.o p_maputl.o p_mobj.o p_plats.o p_pspr.o p_saveg.o p_setup.o p_sight.o p_spec.o p_switch.o p_telept.o p_tick.o p_user.o r_bsp.o r_data.o r_draw.o r_main.o r_plane.o r_segs.o r_sky.o r_things.o sha1.o sounds.o statdump.o st_lib.o st_stuff.o s_sound.o tables.o v_video.o wi_stuff.o w_checksum.o w_file.o w_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_yggdrasil.o
|
||||||
|
OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM))
|
||||||
|
|
||||||
|
all: $(OUTPUT)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(OBJDIR)
|
||||||
|
rm -f $(OUTPUT)
|
||||||
|
rm -f $(OUTPUT).gdb
|
||||||
|
rm -f $(OUTPUT).map
|
||||||
|
|
||||||
|
rust:
|
||||||
|
@echo [Building doomgeneric-yggdrasil Rust library]
|
||||||
|
@cd doomgeneric-yggdrasil; cargo +ygg-stage1 build $(RFL)
|
||||||
|
|
||||||
|
$(OUTPUT): rust $(OBJS)
|
||||||
|
@echo [Linking $@]
|
||||||
|
$(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \
|
||||||
|
-o $(OUTPUT) $(LIBS) -Wl,-Map,$(OUTPUT).map
|
||||||
|
@echo [Size]
|
||||||
|
-$(CROSS_COMPILE)size $(OUTPUT)
|
||||||
|
|
||||||
|
$(OBJS): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir -p $(OBJDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.c
|
||||||
|
@echo [Compiling $<]
|
||||||
|
$(VB)$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
print:
|
||||||
|
@echo OBJS: $(OBJS)
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
/yggdrasil-root
|
||||||
+672
@@ -0,0 +1,672 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "abi-generator"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "abi-lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "abi-serde"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstream"
|
||||||
|
version = "0.6.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"anstyle-parse",
|
||||||
|
"anstyle-query",
|
||||||
|
"anstyle-wincon",
|
||||||
|
"colorchoice",
|
||||||
|
"is_terminal_polyfill",
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle"
|
||||||
|
version = "1.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-parse"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||||
|
dependencies = [
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-query"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-wincon"
|
||||||
|
version = "3.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"once_cell",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic-polyfill"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
|
||||||
|
dependencies = [
|
||||||
|
"critical-section",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytemuck"
|
||||||
|
version = "1.21.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
|
||||||
|
dependencies = [
|
||||||
|
"bytemuck_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytemuck_derive"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af"
|
||||||
|
dependencies = [
|
||||||
|
"shlex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cobs"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorchoice"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "critical-section"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cross"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"libc",
|
||||||
|
"runtime",
|
||||||
|
"tempfile",
|
||||||
|
"yggdrasil-rt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "doomgeneric-yggdrasil"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cross",
|
||||||
|
"libcolors",
|
||||||
|
"log",
|
||||||
|
"logsink",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-io"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-io"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_filter"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_logger"
|
||||||
|
version = "0.11.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0"
|
||||||
|
dependencies = [
|
||||||
|
"anstream",
|
||||||
|
"anstyle",
|
||||||
|
"env_filter",
|
||||||
|
"humantime",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hash32"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heapless"
|
||||||
|
version = "0.7.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
|
||||||
|
dependencies = [
|
||||||
|
"atomic-polyfill",
|
||||||
|
"hash32",
|
||||||
|
"rustc_version",
|
||||||
|
"serde",
|
||||||
|
"spin",
|
||||||
|
"stable_deref_trait",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is_terminal_polyfill"
|
||||||
|
version = "1.70.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.170"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libcolors"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cross",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
"uipc",
|
||||||
|
"yggdrasil-abi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.4.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lock_api"
|
||||||
|
version = "0.4.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "logsink"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"env_logger",
|
||||||
|
"log",
|
||||||
|
"yggdrasil-rt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.20.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "postcard"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
|
||||||
|
dependencies = [
|
||||||
|
"cobs",
|
||||||
|
"embedded-io 0.4.0",
|
||||||
|
"embedded-io 0.6.1",
|
||||||
|
"heapless",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prettyplease"
|
||||||
|
version = "0.2.29"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.93"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.38"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "runtime"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc_version"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||||
|
dependencies = [
|
||||||
|
"semver",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "0.38.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "1.0.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.218"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.218"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spin"
|
||||||
|
version = "0.9.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||||
|
dependencies = [
|
||||||
|
"lock_api",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stable_deref_trait"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.98"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.17.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"fastrand",
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "1.0.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "1.0.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uipc"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cross",
|
||||||
|
"postcard",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf8parse"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.13.3+wasi-0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen-rt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.59.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm",
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_gnullvm",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen-rt"
|
||||||
|
version = "0.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "yggdrasil-abi"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"abi-generator",
|
||||||
|
"abi-lib",
|
||||||
|
"abi-serde",
|
||||||
|
"bytemuck",
|
||||||
|
"prettyplease",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "yggdrasil-rt"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"abi-generator",
|
||||||
|
"abi-lib",
|
||||||
|
"abi-serde",
|
||||||
|
"cc",
|
||||||
|
"prettyplease",
|
||||||
|
"yggdrasil-abi",
|
||||||
|
]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "doomgeneric-yggdrasil"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["staticlib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
libcolors.path = "yggdrasil-root/userspace/lib/libcolors"
|
||||||
|
logsink.path = "yggdrasil-root/userspace/lib/logsink"
|
||||||
|
cross.path = "yggdrasil-root/userspace/lib/cross"
|
||||||
|
log = "0.4.22"
|
||||||
|
thiserror = "1.0.64"
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
#![feature(yggdrasil_os)]
|
||||||
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
ffi::c_int,
|
||||||
|
io,
|
||||||
|
ptr::null_mut,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
|
use libcolors::{
|
||||||
|
application::{
|
||||||
|
window::{EventOutcome, Window},
|
||||||
|
Application,
|
||||||
|
},
|
||||||
|
event::KeyEvent,
|
||||||
|
input::Key,
|
||||||
|
surface::Surface,
|
||||||
|
};
|
||||||
|
|
||||||
|
const K_LEFT: c_int = 0;
|
||||||
|
const K_RIGHT: c_int = 1;
|
||||||
|
const K_UP: c_int = 2;
|
||||||
|
const K_DOWN: c_int = 3;
|
||||||
|
const K_SPACE: c_int = 4;
|
||||||
|
const K_ENTER: c_int = 5;
|
||||||
|
const K_ESCAPE: c_int = 6;
|
||||||
|
const K_LCTRL: c_int = 7;
|
||||||
|
const K_RCTRL: c_int = 8;
|
||||||
|
|
||||||
|
type redraw_handler_t = extern "C" fn(*mut u32, c_int, c_int);
|
||||||
|
type key_event_handler_t = extern "C" fn(c_int, c_int);
|
||||||
|
|
||||||
|
struct ydg_context_t {
|
||||||
|
app: Application,
|
||||||
|
start_time: Instant,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
#[error("{0}")]
|
||||||
|
enum Error {
|
||||||
|
Io(#[from] io::Error),
|
||||||
|
Colors(#[from] libcolors::error::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
static mut REDRAW: Option<redraw_handler_t> = None;
|
||||||
|
static mut HANDLE_KEY_EVENT: Option<key_event_handler_t> = None;
|
||||||
|
|
||||||
|
impl ydg_context_t {
|
||||||
|
fn new() -> Result<&'static mut Self, Error> {
|
||||||
|
let app = Application::new()?;
|
||||||
|
let start_time = Instant::now();
|
||||||
|
|
||||||
|
let this = Box::leak(Box::new(Self { app, start_time }));
|
||||||
|
|
||||||
|
let mut window = Window::new(&this.app)?;
|
||||||
|
|
||||||
|
window.set_on_redraw_requested(|surface| {
|
||||||
|
let w = surface.width() as c_int;
|
||||||
|
let h = surface.height() as c_int;
|
||||||
|
let ptr = surface.as_mut_ptr();
|
||||||
|
unsafe { (REDRAW.unwrap())(ptr, w, h) };
|
||||||
|
});
|
||||||
|
window.set_on_key_pressed(|key| {
|
||||||
|
handle_key_event(true, key);
|
||||||
|
EventOutcome::None
|
||||||
|
});
|
||||||
|
window.set_on_key_released(|key| {
|
||||||
|
handle_key_event(false, key);
|
||||||
|
EventOutcome::None
|
||||||
|
});
|
||||||
|
this.app.add_window(window);
|
||||||
|
|
||||||
|
Ok(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_key_event(pressed: bool, key: KeyEvent) {
|
||||||
|
let ckey = match key.key {
|
||||||
|
Key::LControl => K_LCTRL,
|
||||||
|
Key::RControl => K_RCTRL,
|
||||||
|
Key::Char(b'w') => K_UP,
|
||||||
|
Key::Char(b'a') => K_LEFT,
|
||||||
|
Key::Char(b's') => K_DOWN,
|
||||||
|
Key::Char(b'd') => K_RIGHT,
|
||||||
|
Key::Char(b' ') => K_SPACE,
|
||||||
|
Key::Escape => K_ESCAPE,
|
||||||
|
Key::Enter => K_ENTER,
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
if let Some(handler) = unsafe { HANDLE_KEY_EVENT } {
|
||||||
|
handler(ckey, pressed as c_int);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn ydg_init(
|
||||||
|
redraw: redraw_handler_t,
|
||||||
|
key: key_event_handler_t,
|
||||||
|
) -> *mut ydg_context_t {
|
||||||
|
logsink::setup_logging(true);
|
||||||
|
log::info!("ydg_init()");
|
||||||
|
REDRAW = Some(redraw);
|
||||||
|
HANDLE_KEY_EVENT = Some(key);
|
||||||
|
match ydg_context_t::new() {
|
||||||
|
Ok(cx) => cx,
|
||||||
|
Err(error) => {
|
||||||
|
log::error!("ydg_init: {error}");
|
||||||
|
null_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn ydg_next_event(cx: *mut ydg_context_t) -> c_int {
|
||||||
|
let cx = cx.as_mut().unwrap();
|
||||||
|
if let Err(error) = cx.app.poll_events() {
|
||||||
|
log::error!("ydg_next_event: poll app: {error}");
|
||||||
|
-1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn ydg_get_ticks_ms(cx: *mut ydg_context_t) -> u32 {
|
||||||
|
let cx = cx.as_mut().unwrap();
|
||||||
|
let now = Instant::now();
|
||||||
|
let delta = now - cx.start_time;
|
||||||
|
delta.as_millis() as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn ydg_sleep_ms(time: u32) {
|
||||||
|
std::thread::sleep(Duration::from_millis(time as _));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn ydg_request_redraw(cx: *mut ydg_context_t) {
|
||||||
|
let cx = cx.as_mut().unwrap();
|
||||||
|
cx.app.redraw().ok();
|
||||||
|
}
|
||||||
@@ -5,11 +5,11 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef DOOMGENERIC_RESX
|
#ifndef DOOMGENERIC_RESX
|
||||||
#define DOOMGENERIC_RESX 640
|
#define DOOMGENERIC_RESX (640 * 2)
|
||||||
#endif // DOOMGENERIC_RESX
|
#endif // DOOMGENERIC_RESX
|
||||||
|
|
||||||
#ifndef DOOMGENERIC_RESY
|
#ifndef DOOMGENERIC_RESY
|
||||||
#define DOOMGENERIC_RESY 400
|
#define DOOMGENERIC_RESY (400 * 2)
|
||||||
#endif // DOOMGENERIC_RESY
|
#endif // DOOMGENERIC_RESY
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "doomgeneric.h"
|
||||||
|
#include "doomkeys.h"
|
||||||
|
|
||||||
|
#define EV_TICK 0
|
||||||
|
|
||||||
|
typedef struct ydg_context ydg_context_t;
|
||||||
|
|
||||||
|
typedef void (*redraw_handler_t) (uint32_t *buffer, int width, int height);
|
||||||
|
typedef void (*key_event_handler_t) (int key, int pressed);
|
||||||
|
|
||||||
|
#define K_LEFT 0
|
||||||
|
#define K_RIGHT 1
|
||||||
|
#define K_UP 2
|
||||||
|
#define K_DOWN 3
|
||||||
|
#define K_SPACE 4
|
||||||
|
#define K_ENTER 5
|
||||||
|
#define K_ESCAPE 6
|
||||||
|
#define K_LCTRL 7
|
||||||
|
#define K_RCTRL 8
|
||||||
|
|
||||||
|
extern ydg_context_t *ydg_init(redraw_handler_t redraw, key_event_handler_t key);
|
||||||
|
extern int ydg_next_event(ydg_context_t *cx);
|
||||||
|
extern uint32_t ydg_get_ticks_ms(ydg_context_t *cx);
|
||||||
|
extern void ydg_request_redraw(ydg_context_t *cx);
|
||||||
|
extern void ydg_sleep_ms(uint32_t ms);
|
||||||
|
|
||||||
|
static ydg_context_t *s_ydg_context;
|
||||||
|
|
||||||
|
#define KEYQUEUE_SIZE 16
|
||||||
|
|
||||||
|
static unsigned short s_KeyQueue[KEYQUEUE_SIZE];
|
||||||
|
static unsigned int s_KeyQueueWriteIndex = 0;
|
||||||
|
static unsigned int s_KeyQueueReadIndex = 0;
|
||||||
|
|
||||||
|
static void redraw_handler(uint32_t *buffer, int width, int height) {
|
||||||
|
size_t stride = (size_t) width;
|
||||||
|
int real_width = width;
|
||||||
|
int real_height = height;
|
||||||
|
|
||||||
|
memset(buffer, 0, width * height * 4);
|
||||||
|
if (width > DOOMGENERIC_RESX) {
|
||||||
|
width = DOOMGENERIC_RESX;
|
||||||
|
}
|
||||||
|
if (height > DOOMGENERIC_RESY) {
|
||||||
|
height = DOOMGENERIC_RESY;
|
||||||
|
}
|
||||||
|
|
||||||
|
int yoff = (real_height - height) / 2;
|
||||||
|
int xoff = (real_width - width) / 2;
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
memcpy(buffer + (y + yoff) * stride + xoff, DG_ScreenBuffer + y * DOOMGENERIC_RESX, width * 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char convertToDoomKey(int key) {
|
||||||
|
switch (key) {
|
||||||
|
case K_LEFT:
|
||||||
|
return KEY_LEFTARROW;
|
||||||
|
case K_RIGHT:
|
||||||
|
return KEY_RIGHTARROW;
|
||||||
|
case K_UP:
|
||||||
|
return KEY_UPARROW;
|
||||||
|
case K_DOWN:
|
||||||
|
return KEY_DOWNARROW;
|
||||||
|
case K_LCTRL:
|
||||||
|
case K_RCTRL:
|
||||||
|
return KEY_FIRE;
|
||||||
|
case K_SPACE:
|
||||||
|
return KEY_USE;
|
||||||
|
case K_ESCAPE:
|
||||||
|
return KEY_ESCAPE;
|
||||||
|
case K_ENTER:
|
||||||
|
return KEY_ENTER;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addKeyToQueue(int pressed, int keyCode) {
|
||||||
|
unsigned char key = convertToDoomKey(keyCode);
|
||||||
|
|
||||||
|
unsigned short keyData = (pressed << 8) | key;
|
||||||
|
|
||||||
|
s_KeyQueue[s_KeyQueueWriteIndex] = keyData;
|
||||||
|
s_KeyQueueWriteIndex++;
|
||||||
|
s_KeyQueueWriteIndex %= KEYQUEUE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void key_event_handler(int key, int pressed) {
|
||||||
|
addKeyToQueue(pressed, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_SetWindowTitle(const char *title) {
|
||||||
|
(void) title;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_SleepMs(uint32_t ms) {
|
||||||
|
ydg_sleep_ms(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DG_GetTicksMs(void) {
|
||||||
|
return ydg_get_ticks_ms(s_ydg_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_Init(void) {}
|
||||||
|
|
||||||
|
void DG_DrawFrame(void) {
|
||||||
|
ydg_request_redraw(s_ydg_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DG_GetKey(int *pressed, unsigned char *doomKey) {
|
||||||
|
if (s_KeyQueueReadIndex == s_KeyQueueWriteIndex) {
|
||||||
|
//key queue is empty
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
unsigned short keyData = s_KeyQueue[s_KeyQueueReadIndex];
|
||||||
|
s_KeyQueueReadIndex++;
|
||||||
|
s_KeyQueueReadIndex %= KEYQUEUE_SIZE;
|
||||||
|
|
||||||
|
*pressed = keyData >> 8;
|
||||||
|
*doomKey = keyData & 0xFF;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
s_ydg_context = ydg_init(redraw_handler, key_event_handler);
|
||||||
|
if (!s_ydg_context) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
doomgeneric_Create(argc, argv);
|
||||||
|
|
||||||
|
printf("Start!!!\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if (ydg_next_event(s_ydg_context) != 0) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
doomgeneric_Tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
|
|
||||||
// Use builtin bool type with C++.
|
// Use builtin bool type with C++.
|
||||||
|
|
||||||
@@ -70,6 +70,9 @@ typedef bool boolean;
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#undef false
|
||||||
|
#undef true
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
false = 0,
|
false = 0,
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ void HU_Init(void)
|
|||||||
j = HU_FONTSTART;
|
j = HU_FONTSTART;
|
||||||
for (i=0;i<HU_FONTSIZE;i++)
|
for (i=0;i<HU_FONTSIZE;i++)
|
||||||
{
|
{
|
||||||
DEH_snprintf(buffer, 9, "STCFN%.3d", j++);
|
DEH_snprintf(buffer, 9, "STCFN%03d", j++);
|
||||||
hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
|
hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ void I_Quit (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__MACOSX__) && !defined(__DJGPP__)
|
#if !defined(_WIN32) && !defined(__MACOSX__) && !defined(__DJGPP__) && !defined(__yggdrasil__)
|
||||||
#define ZENITY_BINARY "/usr/bin/zenity"
|
#define ZENITY_BINARY "/usr/bin/zenity"
|
||||||
|
|
||||||
// returns non-zero if zenity is available
|
// returns non-zero if zenity is available
|
||||||
@@ -448,7 +448,7 @@ void I_Error (char *error, ...)
|
|||||||
message,
|
message,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
#elif defined(__DJGPP__)
|
#elif defined(__DJGPP__) || defined(__yggdrasil__)
|
||||||
{
|
{
|
||||||
printf("%s\n", msgbuf);
|
printf("%s\n", msgbuf);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|||||||
@@ -812,7 +812,7 @@ void R_PrecacheLevel (void)
|
|||||||
thinker_t* th;
|
thinker_t* th;
|
||||||
spriteframe_t* sf;
|
spriteframe_t* sf;
|
||||||
|
|
||||||
if (demoplayback)
|
// if (demoplayback)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Precache flats.
|
// Precache flats.
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ void R_InitSpriteDefs (char** namelist)
|
|||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
// no rotations were found for that frame at all
|
// no rotations were found for that frame at all
|
||||||
I_Error ("R_InitSprites: No patches found "
|
// I_Error ("R_InitSprites: No patches found "
|
||||||
"for %s frame %c", spritename, frame+'A');
|
// "for %s frame %c", spritename, frame+'A');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
@@ -1593,7 +1593,7 @@ static void WI_loadUnloadData(load_callback_t callback)
|
|||||||
if (wbs->epsd != 1 || j != 8)
|
if (wbs->epsd != 1 || j != 8)
|
||||||
{
|
{
|
||||||
// animations
|
// animations
|
||||||
DEH_snprintf(name, 9, "WIA%d%.2d%.2d", wbs->epsd, j, i);
|
DEH_snprintf(name, 9, "WIA%d%02d%02d", wbs->epsd, j, i);
|
||||||
callback(name, &a->p[i]);
|
callback(name, &a->p[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user