From 41e4a81057c4692e5aaa7a5246090088f5a9c4c6 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Sat, 23 Aug 2025 10:52:55 +0300 Subject: [PATCH] alnyan/yggdrasil: add yggdrasil integration --- doomgeneric/Makefile.yggdrasil | 74 ++ doomgeneric/doomgeneric-yggdrasil/.gitignore | 2 + doomgeneric/doomgeneric-yggdrasil/Cargo.lock | 672 +++++++++++++++++++ doomgeneric/doomgeneric-yggdrasil/Cargo.toml | 14 + doomgeneric/doomgeneric-yggdrasil/src/lib.rs | 142 ++++ doomgeneric/doomgeneric.h | 4 +- doomgeneric/doomgeneric_yggdrasil.c | 152 +++++ doomgeneric/doomtype.h | 19 +- doomgeneric/hu_stuff.c | 32 +- doomgeneric/i_system.c | 14 +- doomgeneric/r_data.c | 152 ++--- doomgeneric/r_things.c | 216 +++--- doomgeneric/wi_stuff.c | 116 ++-- 13 files changed, 1334 insertions(+), 275 deletions(-) create mode 100644 doomgeneric/Makefile.yggdrasil create mode 100644 doomgeneric/doomgeneric-yggdrasil/.gitignore create mode 100644 doomgeneric/doomgeneric-yggdrasil/Cargo.lock create mode 100644 doomgeneric/doomgeneric-yggdrasil/Cargo.toml create mode 100644 doomgeneric/doomgeneric-yggdrasil/src/lib.rs create mode 100644 doomgeneric/doomgeneric_yggdrasil.c diff --git a/doomgeneric/Makefile.yggdrasil b/doomgeneric/Makefile.yggdrasil new file mode 100644 index 0000000..e339e3a --- /dev/null +++ b/doomgeneric/Makefile.yggdrasil @@ -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) + diff --git a/doomgeneric/doomgeneric-yggdrasil/.gitignore b/doomgeneric/doomgeneric-yggdrasil/.gitignore new file mode 100644 index 0000000..626d987 --- /dev/null +++ b/doomgeneric/doomgeneric-yggdrasil/.gitignore @@ -0,0 +1,2 @@ +/target +/yggdrasil-root \ No newline at end of file diff --git a/doomgeneric/doomgeneric-yggdrasil/Cargo.lock b/doomgeneric/doomgeneric-yggdrasil/Cargo.lock new file mode 100644 index 0000000..2dcfdac --- /dev/null +++ b/doomgeneric/doomgeneric-yggdrasil/Cargo.lock @@ -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", +] diff --git a/doomgeneric/doomgeneric-yggdrasil/Cargo.toml b/doomgeneric/doomgeneric-yggdrasil/Cargo.toml new file mode 100644 index 0000000..3fc56cc --- /dev/null +++ b/doomgeneric/doomgeneric-yggdrasil/Cargo.toml @@ -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" diff --git a/doomgeneric/doomgeneric-yggdrasil/src/lib.rs b/doomgeneric/doomgeneric-yggdrasil/src/lib.rs new file mode 100644 index 0000000..7308977 --- /dev/null +++ b/doomgeneric/doomgeneric-yggdrasil/src/lib.rs @@ -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 = None; +static mut HANDLE_KEY_EVENT: Option = 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(); +} diff --git a/doomgeneric/doomgeneric.h b/doomgeneric/doomgeneric.h index 0fbbd2b..b3d442f 100644 --- a/doomgeneric/doomgeneric.h +++ b/doomgeneric/doomgeneric.h @@ -5,11 +5,11 @@ #include #ifndef DOOMGENERIC_RESX -#define DOOMGENERIC_RESX 640 +#define DOOMGENERIC_RESX (640 * 2) #endif // DOOMGENERIC_RESX #ifndef DOOMGENERIC_RESY -#define DOOMGENERIC_RESY 400 +#define DOOMGENERIC_RESY (400 * 2) #endif // DOOMGENERIC_RESY diff --git a/doomgeneric/doomgeneric_yggdrasil.c b/doomgeneric/doomgeneric_yggdrasil.c new file mode 100644 index 0000000..7fbc939 --- /dev/null +++ b/doomgeneric/doomgeneric_yggdrasil.c @@ -0,0 +1,152 @@ +#include +#include +#include + +#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; +} diff --git a/doomgeneric/doomtype.h b/doomgeneric/doomtype.h index a225c64..1bc0686 100644 --- a/doomgeneric/doomtype.h +++ b/doomgeneric/doomtype.h @@ -15,7 +15,7 @@ // DESCRIPTION: // Simple basic typedefs, isolated here to make it easier // separating modules. -// +// #ifndef __DOOMTYPE__ @@ -38,7 +38,7 @@ // -// The packed attribute forces structures to be packed into the minimum +// The packed attribute forces structures to be packed into the minimum // space necessary. If this is not done, the compiler may align structure // fields differently to optimize memory access, inflating the overall // structure size. It is important to use the packed attribute on certain @@ -52,17 +52,17 @@ #define PACKEDATTR #endif -// C99 integer types; with gcc we just use this. Other compilers +// C99 integer types; with gcc we just use this. Other compilers // should add conditional statements that define the C99 types. // What is really wanted here is stdint.h; however, some old versions -// of Solaris don't have stdint.h and only have inttypes.h (the -// pre-standardisation version). inttypes.h is also in the C99 -// standard and defined to include stdint.h, so include this. +// of Solaris don't have stdint.h and only have inttypes.h (the +// pre-standardisation version). inttypes.h is also in the C99 +// standard and defined to include stdint.h, so include this. #include -#ifdef __cplusplus +#if defined(__cplusplus) // Use builtin bool type with C++. @@ -70,7 +70,10 @@ typedef bool boolean; #else -typedef enum +#undef false +#undef true + +typedef enum { false = 0, true = 1, diff --git a/doomgeneric/hu_stuff.c b/doomgeneric/hu_stuff.c index b63cac7..55697fa 100644 --- a/doomgeneric/hu_stuff.c +++ b/doomgeneric/hu_stuff.c @@ -184,7 +184,7 @@ char *mapnames_commercial[] = HUSTR_9, HUSTR_10, HUSTR_11, - + HUSTR_12, HUSTR_13, HUSTR_14, @@ -194,7 +194,7 @@ char *mapnames_commercial[] = HUSTR_18, HUSTR_19, HUSTR_20, - + HUSTR_21, HUSTR_22, HUSTR_23, @@ -221,7 +221,7 @@ char *mapnames_commercial[] = PHUSTR_9, PHUSTR_10, PHUSTR_11, - + PHUSTR_12, PHUSTR_13, PHUSTR_14, @@ -231,7 +231,7 @@ char *mapnames_commercial[] = PHUSTR_18, PHUSTR_19, PHUSTR_20, - + PHUSTR_21, PHUSTR_22, PHUSTR_23, @@ -244,7 +244,7 @@ char *mapnames_commercial[] = PHUSTR_30, PHUSTR_31, PHUSTR_32, - + // TNT WAD map names. THUSTR_1, @@ -258,7 +258,7 @@ char *mapnames_commercial[] = THUSTR_9, THUSTR_10, THUSTR_11, - + THUSTR_12, THUSTR_13, THUSTR_14, @@ -268,7 +268,7 @@ char *mapnames_commercial[] = THUSTR_18, THUSTR_19, THUSTR_20, - + THUSTR_21, THUSTR_22, THUSTR_23, @@ -294,7 +294,7 @@ void HU_Init(void) j = HU_FONTSTART; for (i=0;i %d", ev->data1, c); // plr->message = buf; } diff --git a/doomgeneric/i_system.c b/doomgeneric/i_system.c index 65ab39d..7dbd3c1 100644 --- a/doomgeneric/i_system.c +++ b/doomgeneric/i_system.c @@ -157,7 +157,7 @@ byte *I_ZoneBase (int *size) zonemem = AutoAllocMemory(size, default_ram, min_ram); - printf("zone memory: %p, %x allocated for zone\n", + printf("zone memory: %p, %x allocated for zone\n", zonemem, *size); return zonemem; @@ -191,7 +191,7 @@ void I_PrintStartupBanner(char *gamedescription) I_PrintDivider(); I_PrintBanner(gamedescription); I_PrintDivider(); - + printf( " " PACKAGE_NAME " is free software, covered by the GNU General Public\n" " License. There is NO warranty; not even for MERCHANTABILITY or FITNESS\n" @@ -201,7 +201,7 @@ void I_PrintStartupBanner(char *gamedescription) I_PrintDivider(); } -// +// // I_ConsoleStdout // // Returns true if stdout is a real console, false if it is a file @@ -248,8 +248,8 @@ void I_Quit (void) atexit_listentry_t *entry; // Run through all exit functions - - entry = exit_funcs; + + entry = exit_funcs; while (entry != NULL) { @@ -264,7 +264,7 @@ void I_Quit (void) #endif } -#if !defined(_WIN32) && !defined(__MACOSX__) && !defined(__DJGPP__) +#if !defined(_WIN32) && !defined(__MACOSX__) && !defined(__DJGPP__) && !defined(__yggdrasil__) #define ZENITY_BINARY "/usr/bin/zenity" // returns non-zero if zenity is available @@ -448,7 +448,7 @@ void I_Error (char *error, ...) message, NULL); } -#elif defined(__DJGPP__) +#elif defined(__DJGPP__) || defined(__yggdrasil__) { printf("%s\n", msgbuf); exit(-1); diff --git a/doomgeneric/r_data.c b/doomgeneric/r_data.c index 2d4b65b..6f12a7b 100644 --- a/doomgeneric/r_data.c +++ b/doomgeneric/r_data.c @@ -44,7 +44,7 @@ // is stored in vertical runs of opaque pixels (posts). // A column is composed of zero or more posts, // a patch or sprite is composed of zero or more columns. -// +// @@ -74,7 +74,7 @@ typedef struct typedef struct { char name[8]; - int masked; + int masked; short width; short height; int obsolete; @@ -91,7 +91,7 @@ typedef struct // Block origin (allways UL), // which has allready accounted // for the internal origin of the patch. - short originx; + short originx; short originy; int patch; } texpatch_t; @@ -106,7 +106,7 @@ typedef struct texture_s texture_t; struct texture_s { // Keep name for switch changing, etc. - char name[8]; + char name[8]; short width; short height; @@ -117,11 +117,11 @@ struct texture_s // Next in hash table chain texture_t *next; - + // All the patches[patchcount] // are drawn back to front into the cached texture. short patchcount; - texpatch_t patches[1]; + texpatch_t patches[1]; }; @@ -145,7 +145,7 @@ texture_t** textures_hashtable; int* texturewidthmask; // needed for texture pegging -fixed_t* textureheight; +fixed_t* textureheight; int* texturecompositesize; short** texturecolumnlump; unsigned short** texturecolumnofs; @@ -156,7 +156,7 @@ int* flattranslation; int* texturetranslation; // needed for pre rendering -fixed_t* spritewidth; +fixed_t* spritewidth; fixed_t* spriteoffset; fixed_t* spritetopoffset; @@ -210,8 +210,8 @@ R_DrawColumnInCache if (count > 0) memcpy (cache + position, source, count); - - patch = (column_t *)( (byte *)patch + patch->length + 4); + + patch = (column_t *)( (byte *)patch + patch->length + 4); } } @@ -227,7 +227,7 @@ void R_GenerateComposite (int texnum) { byte* block; texture_t* texture; - texpatch_t* patch; + texpatch_t* patch; patch_t* realpatch; int x; int x1; @@ -236,19 +236,19 @@ void R_GenerateComposite (int texnum) column_t* patchcol; short* collump; unsigned short* colofs; - + texture = textures[texnum]; block = Z_Malloc (texturecompositesize[texnum], - PU_STATIC, - &texturecomposite[texnum]); + PU_STATIC, + &texturecomposite[texnum]); collump = texturecolumnlump[texnum]; colofs = texturecolumnofs[texnum]; - + // Composite the columns together. patch = texture->patches; - + for (i=0 , patch = texture->patches; ipatchcount; i++, patch++) @@ -261,7 +261,7 @@ void R_GenerateComposite (int texnum) x = 0; else x = x1; - + if (x2 > texture->width) x2 = texture->width; @@ -270,7 +270,7 @@ void R_GenerateComposite (int texnum) // Column does not have multiple patches? if (collump[x] >= 0) continue; - + patchcol = (column_t *)((byte *)realpatch + LONG(realpatch->columnofs[x-x1])); R_DrawColumnInCache (patchcol, @@ -278,7 +278,7 @@ void R_GenerateComposite (int texnum) patch->originy, texture->height); } - + } // Now that the texture has been built in column cache, @@ -295,7 +295,7 @@ void R_GenerateLookup (int texnum) { texture_t* texture; byte* patchcount; // patchcount[texture->width] - texpatch_t* patch; + texpatch_t* patch; patch_t* realpatch; int x; int x1; @@ -303,16 +303,16 @@ void R_GenerateLookup (int texnum) int i; short* collump; unsigned short* colofs; - + texture = textures[texnum]; // Composited texture not created yet. texturecomposite[texnum] = 0; - + texturecompositesize[texnum] = 0; collump = texturecolumnlump[texnum]; colofs = texturecolumnofs[texnum]; - + // Now count the number of columns // that are covered by more than one patch. // Fill in the lump / offset, so columns @@ -328,7 +328,7 @@ void R_GenerateLookup (int texnum) realpatch = W_CacheLumpNum (patch->patch, PU_CACHE); x1 = patch->originx; x2 = x1 + SHORT(realpatch->width); - + if (x1 < 0) x = 0; else @@ -343,7 +343,7 @@ void R_GenerateLookup (int texnum) colofs[x] = LONG(realpatch->columnofs[x-x1])+3; } } - + for (x=0 ; xwidth ; x++) { if (!patchcount[x]) @@ -353,19 +353,19 @@ void R_GenerateLookup (int texnum) return; } // I_Error ("R_GenerateLookup: column without a patch"); - + if (patchcount[x] > 1) { // Use the cached block. - collump[x] = -1; + collump[x] = -1; colofs[x] = texturecompositesize[texnum]; - + if (texturecompositesize[texnum] > 0x10000-texture->height) { I_Error ("R_GenerateLookup: texture %i is >64k", texnum); } - + texturecompositesize[texnum] += texture->height; } } @@ -386,11 +386,11 @@ R_GetColumn { int lump; int ofs; - + col &= texturewidthmask[tex]; lump = texturecolumnlump[tex][col]; ofs = texturecolumnofs[tex][col]; - + if (lump > 0) return (byte *)W_CacheLumpNum(lump,PU_CACHE)+ofs; @@ -407,7 +407,7 @@ static void GenerateTextureHashTable(void) int i; int key; - textures_hashtable + textures_hashtable = Z_Malloc(sizeof(texture_t *) * numtextures, PU_STATIC, 0); memset(textures_hashtable, 0, sizeof(texture_t *) * numtextures); @@ -461,13 +461,13 @@ void R_InitTextures (void) int* maptex; int* maptex2; int* maptex1; - + char name[9]; char* names; char* name_p; - + int* patchlookup; - + int totalwidth; int nummappatches; int offset; @@ -477,12 +477,12 @@ void R_InitTextures (void) int numtextures2; int* directory; - + int temp1; int temp2; int temp3; - + // Load the patch names from pnames.lmp. name[8] = 0; names = W_CacheLumpName (DEH_String("PNAMES"), PU_STATIC); @@ -504,7 +504,7 @@ void R_InitTextures (void) numtextures1 = LONG(*maptex); maxoff = W_LumpLength (W_GetNumForName (DEH_String("TEXTURE1"))); directory = maptex+1; - + if (W_CheckNumForName (DEH_String("TEXTURE2")) != -1) { maptex2 = W_CacheLumpName (DEH_String("TEXTURE2"), PU_STATIC); @@ -518,7 +518,7 @@ void R_InitTextures (void) maxoff2 = 0; } numtextures = numtextures1 + numtextures2; - + textures = Z_Malloc (numtextures * sizeof(*textures), PU_STATIC, 0); texturecolumnlump = Z_Malloc (numtextures * sizeof(*texturecolumnlump), PU_STATIC, 0); texturecolumnofs = Z_Malloc (numtextures * sizeof(*texturecolumnofs), PU_STATIC, 0); @@ -528,7 +528,7 @@ void R_InitTextures (void) textureheight = Z_Malloc (numtextures * sizeof(*textureheight), PU_STATIC, 0); totalwidth = 0; - + // Really complex printing shit... temp1 = W_GetNumForName (DEH_String("S_START")); // P_??????? temp2 = W_GetNumForName (DEH_String("S_END")) - 1; @@ -547,7 +547,7 @@ void R_InitTextures (void) for (i = 0; i < temp3 + 10; i++) printf("\b"); } - + for (i=0 ; i maxoff) I_Error ("R_InitTextures: bad texture directory"); - + mtexture = (maptexture_t *) ( (byte *)maptex + offset); texture = textures[i] = Z_Malloc (sizeof(texture_t) + sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC, 0); - + texture->width = SHORT(mtexture->width); texture->height = SHORT(mtexture->height); texture->patchcount = SHORT(mtexture->patchcount); - + memcpy (texture->name, mtexture->name, sizeof(texture->name)); mpatch = &mtexture->patches[0]; patch = &texture->patches[0]; @@ -591,7 +591,7 @@ void R_InitTextures (void) I_Error ("R_InitTextures: Missing patch in texture %s", texture->name); } - } + } texturecolumnlump[i] = Z_Malloc (texture->width*sizeof(**texturecolumnlump), PU_STATIC,0); texturecolumnofs[i] = Z_Malloc (texture->width*sizeof(**texturecolumnofs), PU_STATIC,0); @@ -601,7 +601,7 @@ void R_InitTextures (void) texturewidthmask[i] = j-1; textureheight[i] = texture->height<width; } @@ -610,15 +610,15 @@ void R_InitTextures (void) W_ReleaseLumpName(DEH_String("TEXTURE1")); if (maptex2) W_ReleaseLumpName(DEH_String("TEXTURE2")); - - // Precalculate whatever possible. + + // Precalculate whatever possible. for (i=0 ; iname, name, 8) ) @@ -761,7 +761,7 @@ int R_CheckTextureNumForName (char *name) texture = texture->next; } - + return -1; } @@ -775,7 +775,7 @@ int R_CheckTextureNumForName (char *name) int R_TextureNumForName (char* name) { int i; - + i = R_CheckTextureNumForName (name); if (i==-1) @@ -807,24 +807,24 @@ void R_PrecacheLevel (void) int j; int k; int lump; - + texture_t* texture; thinker_t* th; spriteframe_t* sf; - if (demoplayback) + // if (demoplayback) return; - + // Precache flats. flatpresent = Z_Malloc(numflats, PU_STATIC, NULL); - memset (flatpresent,0,numflats); + memset (flatpresent,0,numflats); for (i=0 ; ipatchcount ; j++) { lump = texture->patches[j].patch; @@ -875,17 +875,17 @@ void R_PrecacheLevel (void) } Z_Free(texturepresent); - + // Precache sprites. spritepresent = Z_Malloc(numsprites, PU_STATIC, NULL); memset (spritepresent,0, numsprites); - + for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acp1 == (actionf_p1)P_MobjThinker) spritepresent[((mobj_t *)th)->sprite] = 1; } - + spritememory = 0; for (i=0 ; i= 29 || rotation > 8) I_Error("R_InstallSpriteLump: " "Bad frame characters in lump %i", lump); - + if ((int)frame > maxframe) maxframe = frame; - + if (rotation == 0) { // the lump should be used for all rotations @@ -122,7 +122,7 @@ R_InstallSpriteLump if (sprtemp[frame].rotate == true) I_Error ("R_InitSprites: Sprite %s frame %c has rotations " "and a rot=0 lump", spritename, 'A'+frame); - + sprtemp[frame].rotate = false; for (r=0 ; r<8 ; r++) { @@ -131,21 +131,21 @@ R_InstallSpriteLump } return; } - + // the lump is only used for one rotation if (sprtemp[frame].rotate == false) I_Error ("R_InitSprites: Sprite %s frame %c has rotations " "and a rot=0 lump", spritename, 'A'+frame); - + sprtemp[frame].rotate = true; // make 0 based - rotation--; + rotation--; if (sprtemp[frame].lump[rotation] != -1) I_Error ("R_InitSprites: Sprite %s : %c : %c " "has two lumps mapped to it", spritename, 'A'+frame, '1'+rotation); - + sprtemp[frame].lump[rotation] = lump - firstspritelump; sprtemp[frame].flip[rotation] = (byte)flipped; } @@ -159,7 +159,7 @@ R_InstallSpriteLump // (4 chars exactly) to be used. // Builds the sprite rotation matrixes to account // for horizontally flipped sprites. -// Will report an error if the lumps are inconsistant. +// Will report an error if the lumps are inconsistant. // Only called at startup. // // Sprite lump names are 4 characters for the actor, @@ -168,8 +168,8 @@ R_InstallSpriteLump // letter/number appended. // The rotation character can be 0 to signify no rotations. // -void R_InitSpriteDefs (char** namelist) -{ +void R_InitSpriteDefs (char** namelist) +{ char** check; int i; int l; @@ -178,22 +178,22 @@ void R_InitSpriteDefs (char** namelist) int start; int end; int patched; - + // count the number of sprite names check = namelist; while (*check != NULL) check++; numsprites = check-namelist; - + if (!numsprites) return; - + sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); - + start = firstspritelump-1; end = lastspritelump+1; - + // scan all the lump names for each of the names, // noting the highest frame letter. // Just compare 4 characters as ints @@ -201,9 +201,9 @@ void R_InitSpriteDefs (char** namelist) { spritename = DEH_String(namelist[i]); memset (sprtemp,-1, sizeof(sprtemp)); - + maxframe = -1; - + // scan the lumps, // filling in the frames for whatever is found for (l=start+1 ; ltopdelta != 0xff ; ) + + for ( ; column->topdelta != 0xff ; ) { // calculate unclipped screen coordinates // for post @@ -357,7 +357,7 @@ void R_DrawMaskedColumn (column_t* column) dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS; - + if (dc_yh >= mfloorclip[dc_x]) dc_yh = mfloorclip[dc_x]-1; if (dc_yl <= mceilingclip[dc_x]) @@ -371,11 +371,11 @@ void R_DrawMaskedColumn (column_t* column) // Drawn by either R_DrawColumn // or (SHADOW) R_DrawFuzzColumn. - colfunc (); + colfunc (); } column = (column_t *)( (byte *)column + column->length + 4); } - + dc_texturemid = basetexturemid; } @@ -395,12 +395,12 @@ R_DrawVisSprite int texturecolumn; fixed_t frac; patch_t* patch; - - + + patch = W_CacheLumpNum (vis->patch+firstspritelump, PU_CACHE); dc_colormap = vis->colormap; - + if (!dc_colormap) { // NULL colormap = shadow draw @@ -412,13 +412,13 @@ R_DrawVisSprite dc_translation = translationtables - 256 + ( (vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8) ); } - + dc_iscale = abs(vis->xiscale)>>detailshift; dc_texturemid = vis->texturemid; frac = vis->startfrac; spryscale = vis->scale; sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); - + for (dc_x=vis->x1 ; dc_x<=vis->x2 ; dc_x++, frac += vis->xiscale) { texturecolumn = frac>>FRACBITS; @@ -445,55 +445,55 @@ void R_ProjectSprite (mobj_t* thing) { fixed_t tr_x; fixed_t tr_y; - + fixed_t gxt; fixed_t gyt; - + fixed_t tx; fixed_t tz; fixed_t xscale; - + int x1; int x2; spritedef_t* sprdef; spriteframe_t* sprframe; int lump; - + unsigned rot; boolean flip; - + int index; vissprite_t* vis; - + angle_t ang; fixed_t iscale; - + // transform the origin point tr_x = thing->x - viewx; tr_y = thing->y - viewy; - - gxt = FixedMul(tr_x,viewcos); + + gxt = FixedMul(tr_x,viewcos); gyt = -FixedMul(tr_y,viewsin); - - tz = gxt-gyt; + + tz = gxt-gyt; // thing is behind view plane? if (tz < MINZ) return; - + xscale = FixedDiv(projection, tz); - - gxt = -FixedMul(tr_x,viewsin); - gyt = FixedMul(tr_y,viewcos); - tx = -(gyt+gxt); + + gxt = -FixedMul(tr_x,viewsin); + gyt = FixedMul(tr_y,viewcos); + tx = -(gyt+gxt); // too far off the side? if (abs(tx)>(tz<<2)) return; - + // decide which patch to use for sprite relative to player #ifdef RANGECHECK if ((unsigned int) thing->sprite >= (unsigned int) numsprites) @@ -522,22 +522,22 @@ void R_ProjectSprite (mobj_t* thing) lump = sprframe->lump[0]; flip = (boolean)sprframe->flip[0]; } - + // calculate edges of the shape - tx -= spriteoffset[lump]; + tx -= spriteoffset[lump]; x1 = (centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS; // off the right side? if (x1 > viewwidth) return; - + tx += spritewidth[lump]; x2 = ((centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS) - 1; // off the left side if (x2 < 0) return; - + // store information in a vissprite vis = R_NewVisSprite (); vis->mobjflags = thing->flags; @@ -548,7 +548,7 @@ void R_ProjectSprite (mobj_t* thing) vis->gzt = thing->z + spritetopoffset[lump]; vis->texturemid = vis->gzt - viewz; vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; iscale = FixedDiv (FRACUNIT, xscale); if (flip) @@ -565,7 +565,7 @@ void R_ProjectSprite (mobj_t* thing) if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1); vis->patch = lump; - + // get light level if (thing->flags & MF_SHADOW) { @@ -582,17 +582,17 @@ void R_ProjectSprite (mobj_t* thing) // full bright vis->colormap = colormaps; } - + else { // diminished light index = xscale>>(LIGHTSCALESHIFT-detailshift); - if (index >= MAXLIGHTSCALE) + if (index >= MAXLIGHTSCALE) index = MAXLIGHTSCALE-1; vis->colormap = spritelights[index]; - } + } } @@ -612,14 +612,14 @@ void R_AddSprites (sector_t* sec) // subsectors during BSP building. // Thus we check whether its already added. if (sec->validcount == validcount) - return; + return; // Well, now it will be done. sec->validcount = validcount; - + lightnum = (sec->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (lightnum < 0) + if (lightnum < 0) spritelights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) spritelights = scalelight[LIGHTLEVELS-1]; @@ -646,7 +646,7 @@ void R_DrawPSprite (pspdef_t* psp) boolean flip; vissprite_t* vis; vissprite_t avis; - + // decide which patch to use #ifdef RANGECHECK if ( (unsigned)psp->state->sprite >= (unsigned int) numsprites) @@ -663,16 +663,16 @@ void R_DrawPSprite (pspdef_t* psp) lump = sprframe->lump[0]; flip = (boolean)sprframe->flip[0]; - + // calculate edges of the shape tx = psp->sx-160*FRACUNIT; - - tx -= spriteoffset[lump]; + + tx -= spriteoffset[lump]; x1 = (centerxfrac + FixedMul (tx,pspritescale) ) >>FRACBITS; // off the right side if (x1 > viewwidth) - return; + return; tx += spritewidth[lump]; x2 = ((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1; @@ -680,15 +680,15 @@ void R_DrawPSprite (pspdef_t* psp) // off the left side if (x2 < 0) return; - + // store information in a vissprite vis = &avis; vis->mobjflags = 0; vis->texturemid = (BASEYCENTER<sy-spritetopoffset[lump]); vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; vis->scale = pspritescale<xiscale = -pspriteiscale; @@ -699,7 +699,7 @@ void R_DrawPSprite (pspdef_t* psp) vis->xiscale = pspriteiscale; vis->startfrac = 0; } - + if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1); @@ -726,7 +726,7 @@ void R_DrawPSprite (pspdef_t* psp) // local light vis->colormap = spritelights[MAXLIGHTSCALE-1]; } - + R_DrawVisSprite (vis, vis->x1, vis->x2); } @@ -740,23 +740,23 @@ void R_DrawPlayerSprites (void) int i; int lightnum; pspdef_t* psp; - + // get light level lightnum = - (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) + (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) +extralight; - if (lightnum < 0) + if (lightnum < 0) spritelights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) spritelights = scalelight[LIGHTLEVELS-1]; else spritelights = scalelight[lightnum]; - + // clip to screen bounds mfloorclip = screenheightarray; mceilingclip = negonearray; - + // add all active psprites for (i=0, psp=viewplayer->psprites; inext = ds+1; ds->prev = ds-1; } - + vissprites[0].prev = &unsorted; unsorted.next = &vissprites[0]; (vissprite_p-1)->next = &unsorted; unsorted.prev = vissprite_p-1; - + // pull the vissprites out by scale vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; @@ -843,10 +843,10 @@ void R_DrawSprite (vissprite_t* spr) fixed_t scale; fixed_t lowscale; int silhouette; - + for (x = spr->x1 ; x<=spr->x2 ; x++) clipbot[x] = cliptop[x] = -2; - + // Scan drawsegs from end to start for obscuring segs. // The first drawseg that has a greater scale // is the clip seg. @@ -861,7 +861,7 @@ void R_DrawSprite (vissprite_t* spr) // does not cover sprite continue; } - + r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; @@ -875,28 +875,28 @@ void R_DrawSprite (vissprite_t* spr) lowscale = ds->scale1; scale = ds->scale2; } - + if (scale < spr->scale || ( lowscale < spr->scale && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline) ) ) { // masked mid texture? - if (ds->maskedtexturecol) + if (ds->maskedtexturecol) R_RenderMaskedSegRange (ds, r1, r2); // seg is behind sprite - continue; + continue; } - + // clip this piece of the sprite silhouette = ds->silhouette; - + if (spr->gz >= ds->bsilheight) silhouette &= ~SIL_BOTTOM; if (spr->gzt <= ds->tsilheight) silhouette &= ~SIL_TOP; - + if (silhouette == 1) { // bottom sil @@ -922,21 +922,21 @@ void R_DrawSprite (vissprite_t* spr) cliptop[x] = ds->sprtopclip[x]; } } - + } - + // all clipping has been performed, so draw the sprite // check for unclipped columns for (x = spr->x1 ; x<=spr->x2 ; x++) { - if (clipbot[x] == -2) + if (clipbot[x] == -2) clipbot[x] = viewheight; if (cliptop[x] == -2) cliptop[x] = -1; } - + mfloorclip = clipbot; mceilingclip = cliptop; R_DrawVisSprite (spr, spr->x1, spr->x2); @@ -952,7 +952,7 @@ void R_DrawMasked (void) { vissprite_t* spr; drawseg_t* ds; - + R_SortVisSprites (); if (vissprite_p > vissprites) @@ -962,19 +962,19 @@ void R_DrawMasked (void) spr != &vsprsortedhead ; spr=spr->next) { - + R_DrawSprite (spr); } } - + // render any remaining masked mid textures for (ds=ds_p-1 ; ds >= drawsegs ; ds--) if (ds->maskedtexturecol) R_RenderMaskedSegRange (ds, ds->x1, ds->x2); - + // draw the psprites on top of everything // but does not draw on side views - if (!viewangleoffset) + if (!viewangleoffset) R_DrawPlayerSprites (); } diff --git a/doomgeneric/wi_stuff.c b/doomgeneric/wi_stuff.c index ddb9a66..fdaba60 100644 --- a/doomgeneric/wi_stuff.c +++ b/doomgeneric/wi_stuff.c @@ -63,11 +63,11 @@ // in tics -//U #define PAUSELEN (TICRATE*2) +//U #define PAUSELEN (TICRATE*2) //U #define SCORESTEP 100 //U #define ANIMPERIOD 32 // pixel distance from "(YOU)" to "PLAYER N" -//U #define STARDIST 10 +//U #define STARDIST 10 //U #define WK 1 @@ -118,7 +118,7 @@ typedef struct { int x; int y; - + } point_t; @@ -147,10 +147,10 @@ typedef struct // ALWAYS: n/a, // RANDOM: random base period, // LEVEL: n/a - int data2; + int data2; // actual graphics for frames of animations - patch_t* p[3]; + patch_t* p[3]; // following must be initialized to zero before use! @@ -162,9 +162,9 @@ typedef struct // next frame number to animate int ctr; - + // used by RANDOM and LEVEL when animating - int state; + int state; } anim_t; @@ -288,8 +288,8 @@ static anim_t *anims[NUMEPISODES] = #define SP_KILLS 0 #define SP_ITEMS 2 #define SP_SECRET 4 -#define SP_FRAGS 6 -#define SP_TIME 8 +#define SP_FRAGS 6 +#define SP_TIME 8 #define SP_PAR ST_TIME #define SP_PAUSE 1 @@ -314,13 +314,13 @@ static wbstartstruct_t* wbs; static wbplayerstruct_t* plrs; // wbs->plyr[] // used for general timing -static int cnt; +static int cnt; // used for timing of background animation static int bcnt; // signals to refresh everything for one frame -static int firstrefresh; +static int firstrefresh; static int cnt_kills[MAXPLAYERS]; static int cnt_items[MAXPLAYERS]; @@ -330,7 +330,7 @@ static int cnt_par; static int cnt_pause; // # of commercial levels -static int NUMCMAPS; +static int NUMCMAPS; // @@ -338,7 +338,7 @@ static int NUMCMAPS; // // You Are Here graphic -static patch_t* yah[3] = { NULL, NULL, NULL }; +static patch_t* yah[3] = { NULL, NULL, NULL }; // splat static patch_t* splat[2] = { NULL, NULL }; @@ -357,7 +357,7 @@ static patch_t* wiminus; static patch_t* finished; // "Entering" graphic -static patch_t* entering; +static patch_t* entering; // "secret" static patch_t* sp_secret; @@ -375,7 +375,7 @@ static patch_t* sucks; // "killers", "victims" static patch_t* killers; -static patch_t* victims; +static patch_t* victims; // "Total", your face, your dead face static patch_t* total; @@ -419,7 +419,7 @@ void WI_drawLF(void) if (gamemode != commercial || wbs->last < NUMCMAPS) { - // draw + // draw V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2, y, lnames[wbs->last]); @@ -439,7 +439,7 @@ void WI_drawLF(void) // bits of memory at this point, but let's try to be accurate // anyway. This deliberately triggers a V_DrawPatch error. - patch_t tmp = { SCREENWIDTH, SCREENHEIGHT, 1, 1, + patch_t tmp = { SCREENWIDTH, SCREENHEIGHT, 1, 1, { 0, 0, 0, 0, 0, 0, 0, 0 } }; V_DrawPatch(0, y, &tmp); @@ -462,7 +462,7 @@ void WI_drawEL(void) y += (5*SHORT(lnames[wbs->next]->height))/4; V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2, - y, + y, lnames[wbs->next]); } @@ -510,7 +510,7 @@ WI_drawOnLnode else { // DEBUG - printf("Could not place patch on level %d", n+1); + printf("Could not place patch on level %d", n+1); } } @@ -578,7 +578,7 @@ void WI_updateAnimatedBack(void) } else a->nexttic = bcnt + a->period; break; - + case ANIM_LEVEL: // gawd-awful hack for level anims if (!(state == StatCount && i == 7) @@ -726,13 +726,13 @@ WI_drawTime // draw if (div==60 || t / div) V_DrawPatch(x, y, colon); - + } while (t / div); } else { // "sucks" - V_DrawPatch(x - SHORT(sucks->width), y, sucks); + V_DrawPatch(x - SHORT(sucks->width), y, sucks); } } @@ -756,7 +756,7 @@ void WI_updateNoState(void) { if (!--cnt) { - // Don't call WI_End yet. G_WorldDone doesnt immediately + // Don't call WI_End yet. G_WorldDone doesnt immediately // change gamestate, so WI_Drawer is still going to get // run until that happens. If we do that after WI_End // (which unloads all the graphics), we're in trouble. @@ -797,7 +797,7 @@ void WI_drawShowNextLoc(void) WI_slamBackground(); // draw animated background - WI_drawAnimatedBack(); + WI_drawAnimatedBack(); if ( gamemode != commercial) { @@ -806,7 +806,7 @@ void WI_drawShowNextLoc(void) WI_drawEL(); return; } - + last = (wbs->last == 8) ? wbs->next - 1 : wbs->last; // draw a splat on taken cities. @@ -819,13 +819,13 @@ void WI_drawShowNextLoc(void) // draw flashing ptr if (snl_pointeron) - WI_drawOnLnode(wbs->next, yah); + WI_drawOnLnode(wbs->next, yah); } // draws which level you are entering.. if ( (gamemode != commercial) || wbs->next != 30) - WI_drawEL(); + WI_drawEL(); } @@ -839,7 +839,7 @@ int WI_fragSum(int playernum) { int i; int frags = 0; - + for (i=0 ; i 99) dm_totals[i] = 99; - + if (dm_totals[i] < -99) dm_totals[i] = -99; } - + } if (!stillticking) { @@ -1008,16 +1008,16 @@ void WI_drawDeathmatchStats(void) int w; WI_slamBackground(); - + // draw animated background - WI_drawAnimatedBack(); + WI_drawAnimatedBack(); WI_drawLF(); // draw stat titles (top line) V_DrawPatch(DM_TOTALSX-SHORT(total->width)/2, DM_MATRIXY-WI_SPACINGY+10, total); - + V_DrawPatch(DM_KILLERSX, DM_KILLERSY, killers); V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, victims); @@ -1032,7 +1032,7 @@ void WI_drawDeathmatchStats(void) V_DrawPatch(x-SHORT(p[i]->width)/2, DM_MATRIXY - WI_SPACINGY, p[i]); - + V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, p[i]); @@ -1119,7 +1119,7 @@ void WI_updateNetgameStats(void) int i; int fsum; - + boolean stillticking; WI_updateAnimatedBack(); @@ -1163,7 +1163,7 @@ void WI_updateNetgameStats(void) else stillticking = true; } - + if (!stillticking) { S_StartSound(0, sfx_barexp); @@ -1213,7 +1213,7 @@ void WI_updateNetgameStats(void) else stillticking = true; } - + if (!stillticking) { S_StartSound(0, sfx_barexp); @@ -1239,7 +1239,7 @@ void WI_updateNetgameStats(void) else stillticking = true; } - + if (!stillticking) { S_StartSound(0, sfx_pldeth); @@ -1277,9 +1277,9 @@ void WI_drawNetgameStats(void) int pwidth = SHORT(percent->width); WI_slamBackground(); - + // draw animated background - WI_drawAnimatedBack(); + WI_drawAnimatedBack(); WI_drawLF(); @@ -1292,7 +1292,7 @@ void WI_drawNetgameStats(void) V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width), NG_STATSY, secret); - + if (dofrags) V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width), NG_STATSY, frags); @@ -1447,7 +1447,7 @@ void WI_updateStats(void) void WI_drawStats(void) { // line height - int lh; + int lh; lh = (3*SHORT(num[0]->height))/2; @@ -1455,7 +1455,7 @@ void WI_drawStats(void) // draw animated background WI_drawAnimatedBack(); - + WI_drawLF(); V_DrawPatch(SP_STATSX, SP_STATSY, kills); @@ -1514,7 +1514,7 @@ void WI_checkForAccelerate(void) void WI_Ticker(void) { // counter for general background animation - bcnt++; + bcnt++; if (bcnt == 1) { @@ -1522,7 +1522,7 @@ void WI_Ticker(void) if ( gamemode == commercial ) S_ChangeMusic(mus_dm2int, true); else - S_ChangeMusic(mus_inter, true); + S_ChangeMusic(mus_inter, true); } WI_checkForAccelerate(); @@ -1534,11 +1534,11 @@ void WI_Ticker(void) else if (netgame) WI_updateNetgameStats(); else WI_updateStats(); break; - + case ShowNextLoc: WI_updateShowNextLoc(); break; - + case NoState: WI_updateNoState(); break; @@ -1593,7 +1593,7 @@ static void WI_loadUnloadData(load_callback_t callback) if (wbs->epsd != 1 || j != 8) { // 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]); } else @@ -1744,7 +1744,7 @@ void WI_unloadData(void) // We do not free these lumps as they are shared with the status // bar code. - + // W_ReleaseLumpName("STFST01"); // W_ReleaseLumpName("STFDEAD0"); } @@ -1761,11 +1761,11 @@ void WI_Drawer (void) else WI_drawStats(); break; - + case ShowNextLoc: WI_drawShowNextLoc(); break; - + case NoState: WI_drawNoState(); break;