From f465587d7ed376fac32d0164f38d111b609f23b6 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Sun, 15 Oct 2023 10:47:07 +0100 Subject: [PATCH] Started work on remake. This includes support for building a separate iso with a new executable built exclusively from a rust. The remake will not be binary perfect, and instead will be focused on replicating the base game in a high-level language with the intent of being easily moddable. The current iso will not be removed. Instead it will live alongside the remake. --- .vscode/settings.json | 2 + dw2003-remake.xml | 2617 ++++++++++++++++++++++++++++++++ remake-rust/.cargo/config.toml | 8 + remake-rust/.gitignore | 2 + remake-rust/Cargo.lock | 16 + remake-rust/Cargo.toml | 10 + remake-rust/dw2003/Cargo.toml | 8 + remake-rust/dw2003/src/main.rs | 22 + zbuild.yaml | 75 +- 9 files changed, 2739 insertions(+), 21 deletions(-) create mode 100644 dw2003-remake.xml create mode 100644 remake-rust/.cargo/config.toml create mode 100644 remake-rust/.gitignore create mode 100644 remake-rust/Cargo.lock create mode 100644 remake-rust/Cargo.toml create mode 100644 remake-rust/dw2003/Cargo.toml create mode 100644 remake-rust/dw2003/src/main.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index 73bd9641c..b39dd58f5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,6 +23,7 @@ "Digitamamon", "Dinohumon", "divu", + "dprintln", "EVOS", "ExVeemon", "Fullwidth", @@ -100,6 +101,7 @@ "Taomon", "thiserror", "tims", + "vblank", "Veemon", "WarGreymon", "WarGrowlmon" diff --git a/dw2003-remake.xml b/dw2003-remake.xml new file mode 100644 index 000000000..b584e7328 --- /dev/null +++ b/dw2003-remake.xml @@ -0,0 +1,2617 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/remake-rust/.cargo/config.toml b/remake-rust/.cargo/config.toml new file mode 100644 index 000000000..e29c6c02a --- /dev/null +++ b/remake-rust/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +dep-info-basedir = ".." +target = "mipsel-sony-psx" +rustflags = ["-Clink-arg=-Tpsexe.ld", "-Clink-arg=--oformat=binary"] + +[unstable] +build-std = ["core"] +build-std-features = ["compiler-builtins-mem"] diff --git a/remake-rust/.gitignore b/remake-rust/.gitignore new file mode 100644 index 000000000..c1f762362 --- /dev/null +++ b/remake-rust/.gitignore @@ -0,0 +1,2 @@ +# Rust output +target/ diff --git a/remake-rust/Cargo.lock b/remake-rust/Cargo.lock new file mode 100644 index 000000000..fe9eeafa7 --- /dev/null +++ b/remake-rust/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "dw2003" +version = "0.1.0" +dependencies = [ + "psx", +] + +[[package]] +name = "psx" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47204f4a0c027798cd54dfa8ae34a3ce0d9fa0e2f59de7403f0c0a5e404e3198" diff --git a/remake-rust/Cargo.toml b/remake-rust/Cargo.toml new file mode 100644 index 000000000..05d80e7d6 --- /dev/null +++ b/remake-rust/Cargo.toml @@ -0,0 +1,10 @@ +[workspace] + +resolver = "2" + +members = ["dw2003"] + +[workspace.dependencies] + +# Workspace +dw2003 = { path = "dw2003" } diff --git a/remake-rust/dw2003/Cargo.toml b/remake-rust/dw2003/Cargo.toml new file mode 100644 index 000000000..1c862d4ad --- /dev/null +++ b/remake-rust/dw2003/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "dw2003" +version = "0.1.0" +edition = "2021" + +[dependencies] + +psx = "0.1.6" diff --git a/remake-rust/dw2003/src/main.rs b/remake-rust/dw2003/src/main.rs new file mode 100644 index 000000000..3567d9899 --- /dev/null +++ b/remake-rust/dw2003/src/main.rs @@ -0,0 +1,22 @@ +#![no_std] +#![no_main] + +use psx::{dprintln, Framebuffer}; + +#[no_mangle] +fn main() { + let buf0 = (0, 0); + let buf1 = (0, 240); + let res = (320, 240); + let txt_offset = (0, 8); + let mut fb = Framebuffer::new(buf0, buf1, res, None).unwrap(); + let font = fb.load_default_font(); + let mut txt = font.new_text_box(txt_offset, res); + loop { + txt.reset(); + dprintln!(txt, "Hello, world!"); + fb.draw_sync(); + fb.wait_vblank(); + fb.swap(); + } +} diff --git a/zbuild.yaml b/zbuild.yaml index 83e8aa53b..cd8f776e9 100644 --- a/zbuild.yaml +++ b/zbuild.yaml @@ -17,6 +17,7 @@ alias: truncate : truncate # truncate (GNU coreutils) 9.3 python3 : python3 # Python 3.11.3 yq : yq # yq 3.2.2 + cargo-psx: cargo-psx # cargo-psx-0.1.3 # Other tools generate_psx_iso_deps : tools/generate_psx_iso_deps.py @@ -43,20 +44,21 @@ alias: # Directories build_dir : build - build_rust_tool_dir: $(build_dir)/tools - build_misc_dir : $(build_dir)/misc - build_psx_iso_dir : $(build_dir)/iso - build_asm_dir : $(build_dir)/asm - build_elf_dir : $(build_dir)/elf - build_psexe_dir : $(build_dir)/psexe - build_rust_dir : $(build_dir)/rust - build_raw_exe_dir : $(build_dir)/raw_exe - build_lang_file_dir: $(build_dir)/lang_file - build_pack_dir : $(build_dir)/pack - build_tim_dir : $(build_dir)/tim - build_map_dir : $(build_dir)/map - build_map_tile_dir : $(build_dir)/map-tile - build_rlen_dir : $(build_dir)/rlen + build_rust_tool_dir : $(build_dir)/tools + build_misc_dir : $(build_dir)/misc + build_psx_iso_dir : $(build_dir)/iso + build_asm_dir : $(build_dir)/asm + build_elf_dir : $(build_dir)/elf + build_psexe_dir : $(build_dir)/psexe + build_rust_dir : $(build_dir)/rust + build_raw_exe_dir : $(build_dir)/raw_exe + build_lang_file_dir : $(build_dir)/lang_file + build_pack_dir : $(build_dir)/pack + build_tim_dir : $(build_dir)/tim + build_map_dir : $(build_dir)/map + build_map_tile_dir : $(build_dir)/map-tile + build_rlen_dir : $(build_dir)/rlen + build_remake_psexe_dir: $(build_dir)/remake-psexe # Licenses license_psx_iso : licenses/psx-bin.dat @@ -77,13 +79,14 @@ alias: rust_tool_src : tools/^(name) # Psx iso - dw2003_psx_iso: $(build_psx_iso_dir)/dw2003.bin - dw3_psx_iso : $(build_psx_iso_dir)/dw3.bin - psx_iso : $(build_psx_iso_dir)/^(path).bin - psx_iso_cue : $(build_psx_iso_dir)/^(path).cue - psx_iso_lba : $(build_psx_iso_dir)/^(path).lba - psx_iso_deps : $(build_psx_iso_dir)/^(path).d - psx_iso_xml : ^(path).xml + dw2003_psx_iso : $(build_psx_iso_dir)/dw2003.bin + dw2003_remake_psx_iso: $(build_psx_iso_dir)/dw2003-remake.bin + dw3_psx_iso : $(build_psx_iso_dir)/dw3.bin + psx_iso : $(build_psx_iso_dir)/^(path).bin + psx_iso_cue : $(build_psx_iso_dir)/^(path).cue + psx_iso_lba : $(build_psx_iso_dir)/^(path).lba + psx_iso_deps : $(build_psx_iso_dir)/^(path).d + psx_iso_xml : ^(path).xml # Assembly asm_obj : $(build_asm_dir)/^(path).o @@ -101,6 +104,10 @@ alias: psexe_deps: $(build_psexe_dir)/^(path).d psexe_yaml: psexe/^(path).yaml + # Psexe remake + remake_psexe : $(build_remake_psexe_dir)/^(name).exe + remake_psexe_deps: $(build_remake_psexe_dir)/^(name).d + # Raw exe raw_exe : $(build_raw_exe_dir)/^(path).bin raw_exe_deps: $(build_raw_exe_dir)/^(path).d @@ -145,6 +152,7 @@ alias: default: - $(dw3_psx_iso) - $(dw2003_psx_iso) + - $(dw2003_remake_psx_iso) rules: # Compare @@ -584,3 +592,28 @@ rules: - -e - 's,rust/$(build_target_dir)/lib^(name).a,$(build_rust_dir)/^(name).a,g' - $(rust_lib_deps) + + # psexe (remake) + remake_psexe: + alias: + build_target_dir: target/mipsel-sony-psx/release + out: + - $(remake_psexe) + - deps_file: $(remake_psexe_deps) + deps: + - static: $(remake_psexe::dir_name)/ + exec: + # Build the crate + - cwd: remake-rust/ + args: + - $(cargo-psx) + - build + - [$(cp), remake-rust/$(build_target_dir)/^(name).exe, $(remake_psexe)] + + # Then copy the dependency file and adjust the references + - [$(cp), remake-rust/$(build_target_dir)/^(name).d, $(remake_psexe_deps)] + - - sed + - -i + - -e + - 's,remake-rust/$(build_target_dir)/^(name).exe,$(build_remake_psexe_dir)/^(name).exe,g' + - $(remake_psexe_deps)