diff --git a/.appveyor.yml b/.appveyor.yml index 499b49c..ce91fc2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -68,9 +68,6 @@ for: - copy LICENSE release\LICENSE - copy target\release\doukutsu-rs.exe release\doukutsu-rs.x86_64.exe - cd release - - appveyor DownloadFile https://github.com/doukutsu-rs/game-data/archive/master.zip -FileName ../game-data.zip - - 7z x ../game-data.zip - - rename game-data-master data - 7z a ../doukutsu-rs_%target_name%.zip * - appveyor PushArtifact ../doukutsu-rs_%target_name%.zip diff --git a/Cargo.toml b/Cargo.toml index 273618c..d877536 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,7 @@ log = "0.4" lua-ffi = { git = "https://github.com/doukutsu-rs/lua-ffi.git", rev = "e0b2ff5960f7ef9974aa9675cebe4907bee0134f", optional = true } num-derive = "0.3.2" num-traits = "0.2.12" +owoify_rs = "0.2.0" paste = "1.0.0" sdl2 = { git = "https://github.com/doukutsu-rs/rust-sdl2.git", rev = "95bcf63768abf422527f86da41da910649b9fcc9", optional = true, features = ["unsafe_textures", "bundled", "static-link"] } sdl2-sys = { git = "https://github.com/doukutsu-rs/rust-sdl2.git", rev = "95bcf63768abf422527f86da41da910649b9fcc9", optional = true, features = ["bundled", "static-link"] } diff --git a/res/sue.ico b/res/sue.ico index c977b26..e57d945 100644 Binary files a/res/sue.ico and b/res/sue.ico differ diff --git a/src/common.rs b/src/common.rs index b4d3663..1522a3e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -15,10 +15,7 @@ use crate::texture_set::G_MAG; pub const CDEG_RAD: f64 = std::f64::consts::PI / 128.0; lazy_static! { - pub static ref VERSION_BANNER: String = { - let version = option_env!("DRS_BUILD_VERSION_OVERRIDE").unwrap_or(env!("CARGO_PKG_VERSION")); - format!("doukutsu-rs {}", version) - }; + pub static ref VERSION_BANNER: String = "doukutsu-rs GowoG Edition".to_string(); } bitfield! { diff --git a/src/components/map_system.rs b/src/components/map_system.rs index 6cb3e5f..b68e597 100644 --- a/src/components/map_system.rs +++ b/src/components/map_system.rs @@ -89,7 +89,6 @@ impl MapSystem { ) -> GameResult { if state.textscript_vm.state == TextScriptExecutionState::MapSystem { if self.state == MapSystemState::Hidden { - state.control_flags.set_control_enabled(false); self.state = MapSystemState::FadeInBox(0); } } else { @@ -123,8 +122,6 @@ impl MapSystem { } MapSystemState::FadeOutBox(tick) => { if tick == 0 { - state.control_flags.set_tick_world(true); - state.control_flags.set_control_enabled(true); state.textscript_vm.state = TextScriptExecutionState::Ended; self.state = MapSystemState::Hidden; } else { diff --git a/src/framework/backend_sdl2.rs b/src/framework/backend_sdl2.rs index 3a3c2b7..5a2b8f0 100644 --- a/src/framework/backend_sdl2.rs +++ b/src/framework/backend_sdl2.rs @@ -149,7 +149,7 @@ impl SDL2EventLoop { gl_attr.set_context_profile(GLProfile::Compatibility); gl_attr.set_context_version(2, 1); - let mut window = video.window("Cave Story (doukutsu-rs)", size_hint.0 as _, size_hint.1 as _); + let mut window = video.window("Cave Story (doukutsu-rs GowoG Edition)", size_hint.0 as _, size_hint.1 as _); window.position_centered(); window.resizable(); diff --git a/src/lib.rs b/src/lib.rs index 59649ad..a086196 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -148,6 +148,28 @@ impl Game { TimingMode::FrameSynchronized => { scene.tick(state_ref, ctx)?; } + TimingMode::AF(tick_rate) => { + let last_tick = self.next_tick; + + // lol + loop { + if self.start_time.elapsed().as_nanos() >= self.next_tick + (1000000000 / tick_rate) as u128 { + break; + } + } + + self.next_tick = self.start_time.elapsed().as_nanos() as u128; + self.loops = 1; + + if self.loops != 0 { + scene.draw_tick(state_ref)?; + self.last_tick = last_tick; + } + + for _ in 0..self.loops { + scene.tick(state_ref, ctx)?; + } + } } } Ok(()) @@ -196,9 +218,9 @@ impl Game { )?; } - if state_ref.settings.fps_counter { - self.fps.act(state_ref, ctx, self.last_tick)?; - } + // if state_ref.settings.fps_counter { + self.fps.act(state_ref, ctx, self.last_tick)?; + // } self.ui.draw(state_ref, ctx, scene)?; } diff --git a/src/menu/settings_menu.rs b/src/menu/settings_menu.rs index 3ab4a80..85aadaa 100644 --- a/src/menu/settings_menu.rs +++ b/src/menu/settings_menu.rs @@ -113,8 +113,8 @@ impl SettingsMenu { self.main.push_entry(MenuEntry::Options( state.t("menus.options_menu.game_timing.entry"), - if state.settings.timing_mode == TimingMode::_50Hz { 0 } else { 1 }, - vec![state.t("menus.options_menu.game_timing.50tps"), state.t("menus.options_menu.game_timing.60tps")], + 0, + vec!["Reroll".to_string()], )); self.main.push_entry(MenuEntry::Active(DISCORD_LINK.to_owned())); @@ -239,21 +239,13 @@ impl SettingsMenu { self.language.selected = (state.settings.locale as usize) + 1; self.current = CurrentMenu::LanguageMenu; } - MenuSelectionResult::Selected(3, toggle) => { - if let MenuEntry::Options(_, value, _) = toggle { - match state.settings.timing_mode { - TimingMode::_50Hz => { - state.settings.timing_mode = TimingMode::_60Hz; - *value = 1; - } - TimingMode::_60Hz => { - state.settings.timing_mode = TimingMode::_50Hz; - *value = 0; - } - _ => {} - } - let _ = state.settings.save(ctx); - } + MenuSelectionResult::Selected(3, _) => { + let now = chrono::Local::now(); + let rng = crate::rng::XorShift::new(now.timestamp() as i32); + let tick_rate = crate::rng::RNG::range(&rng, 50..70) as usize; + state.settings.timing_mode = TimingMode::AF(tick_rate); + + let _ = state.settings.save(ctx); } MenuSelectionResult::Selected(4, _) => { if let Err(e) = webbrowser::open(DISCORD_LINK) { diff --git a/src/scene/game_scene.rs b/src/scene/game_scene.rs index 3677c44..42d523b 100644 --- a/src/scene/game_scene.rs +++ b/src/scene/game_scene.rs @@ -1761,7 +1761,13 @@ impl Scene for GameScene { match state.textscript_vm.state { TextScriptExecutionState::FallingIsland(_, _, _, _, _, _) => (), - TextScriptExecutionState::MapSystem => (), + TextScriptExecutionState::MapSystem => { + if self.tick % 2 == 0 { + if state.control_flags.tick_world() { + self.tick_world(state)?; + } + } + } _ => { if state.control_flags.tick_world() { self.tick_world(state)?; diff --git a/src/scripting/tsc/compiler.rs b/src/scripting/tsc/compiler.rs index c598eb3..2862b94 100644 --- a/src/scripting/tsc/compiler.rs +++ b/src/scripting/tsc/compiler.rs @@ -1,3 +1,4 @@ +use owoify_rs::{Owoifiable, OwoifyLevel}; use std::collections::HashMap; use std::iter::Peekable; use std::str::FromStr; @@ -80,6 +81,10 @@ impl TextScript { match chr { b'#' if allow_next_event => { if !char_buf.is_empty() { + let mut str = String::from_utf8(char_buf[1..].to_vec()).unwrap(); + str = str.owoify(&OwoifyLevel::Owo).to_string(); + char_buf.truncate(1); + char_buf.append(&mut str.into_bytes()); put_varint(TSCOpCode::_STR as i32, &mut bytecode); put_string(&mut char_buf, &mut bytecode, encoding); } @@ -92,6 +97,10 @@ impl TextScript { allow_next_event = false; if !char_buf.is_empty() { + let mut str = String::from_utf8(char_buf[1..].to_vec()).unwrap(); + str = str.owoify(&OwoifyLevel::Owo).to_string(); + char_buf.truncate(1); + char_buf.append(&mut str.into_bytes()); put_varint(TSCOpCode::_STR as i32, &mut bytecode); put_string(&mut char_buf, &mut bytecode, encoding); } diff --git a/src/scripting/tsc/text_script.rs b/src/scripting/tsc/text_script.rs index 930d434..3a68ce7 100644 --- a/src/scripting/tsc/text_script.rs +++ b/src/scripting/tsc/text_script.rs @@ -7,6 +7,7 @@ use std::io::Seek; use std::io::SeekFrom; use std::ops::Not; use std::rc::Rc; +use std::time::Duration; use num_traits::{clamp, FromPrimitive}; @@ -1695,21 +1696,10 @@ impl TextScriptVM { exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32); } TSCOpCode::XX1 => { + // lol + std::thread::sleep(Duration::from_millis(1000 * 10)); let mode = read_cur_varint(&mut cursor)?; - - if mode != 0 && !state.mod_requirements.beat_hell { - state.mod_requirements.beat_hell = true; - state.mod_requirements.save(ctx)?; - } - - exec_state = TextScriptExecutionState::FallingIsland( - event, - cursor.position() as u32, - 0x15000, - 0x8000, - 0, - mode != 0, - ); + exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32); } TSCOpCode::STC => { let new_record = game_scene.nikumaru.save_counter(state, ctx)?; @@ -1721,7 +1711,7 @@ impl TextScriptVM { exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32); } TSCOpCode::MLP => { - exec_state = TextScriptExecutionState::MapSystem; + exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32); } TSCOpCode::KE2 => { state.control_flags.set_tick_world(true); diff --git a/src/settings.rs b/src/settings.rs index c618fea..f3fe830 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -132,10 +132,10 @@ impl Settings { self } - pub fn save(&self, ctx: &Context) -> GameResult { - let file = user_create(ctx, "/settings.json")?; - serde_json::to_writer_pretty(file, self)?; - + pub fn save(&self, _ctx: &Context) -> GameResult { + //let file = user_create(ctx, "/settings.json")?; + //serde_json::to_writer_pretty(file, self)?; + // lol settings broken Ok(()) } diff --git a/src/shared_game_state.rs b/src/shared_game_state.rs index 94c31c6..c467090 100644 --- a/src/shared_game_state.rs +++ b/src/shared_game_state.rs @@ -42,6 +42,7 @@ pub enum TimingMode { _50Hz, _60Hz, FrameSynchronized, + AF(usize), } impl TimingMode { @@ -50,6 +51,7 @@ impl TimingMode { TimingMode::_50Hz => 1000000000 / 50, TimingMode::_60Hz => 1000000000 / 60, TimingMode::FrameSynchronized => 0, + TimingMode::AF(tick_rate) => 1000000000 / tick_rate, } } @@ -58,6 +60,7 @@ impl TimingMode { TimingMode::_50Hz => 1000.0 / 50.0, TimingMode::_60Hz => 1000.0 / 60.0, TimingMode::FrameSynchronized => 0.0, + TimingMode::AF(tick_rate) => 1000.0 / (tick_rate as f64), } } @@ -66,6 +69,7 @@ impl TimingMode { TimingMode::_50Hz => 50, TimingMode::_60Hz => 60, TimingMode::FrameSynchronized => 0, + TimingMode::AF(tick_rate) => tick_rate, } } } @@ -274,7 +278,14 @@ impl SharedGameState { pub fn new(ctx: &mut Context) -> GameResult { let mut constants = EngineConstants::defaults(); let sound_manager = SoundManager::new(ctx)?; - let settings = Settings::load(ctx)?; + let mut settings = Settings::load(ctx)?; + // lol + let now = Local::now(); + let rng = XorShift::new(now.timestamp() as i32); + let tick_rate = crate::rng::RNG::range(&rng, 50..70) as usize; + settings.timing_mode = TimingMode::AF(tick_rate); + settings.motion_interpolation = false; + settings.subpixel_coords = false; let mod_requirements = ModRequirements::load(ctx)?; constants.load_locales(ctx)?; diff --git a/src/sound/org_playback.rs b/src/sound/org_playback.rs index efeb37e..ce951fe 100644 --- a/src/sound/org_playback.rs +++ b/src/sound/org_playback.rs @@ -357,27 +357,23 @@ impl OrgPlaybackEngine { let (sl1, sr1, sl2, sr2) = match (is_16bit, is_stereo) { (true, true) => unsafe { let ps = pos << 2; - let sl1 = (*sample_data_ptr.add(ps) as u16 - | (*sample_data_ptr.add(ps + 1) as u16) << 8) + let sl1 = (*sample_data_ptr.add(ps) as u16 | (*sample_data_ptr.add(ps + 1) as u16) << 8) + as f32 + / 32768.0; + let sr1 = (*sample_data_ptr.add(ps + 2) as u16 + | (*sample_data_ptr.add(ps + 3) as u16) << 8) as f32 / 32768.0; - let sr1 = - (*sample_data_ptr.add(ps + 2) as u16 - | (*sample_data_ptr.add(ps + 3) as u16) << 8) - as f32 - / 32768.0; let ps = min(pos + 1, buf.base_pos + buf.len - 1) << 2; - let sl2 = (*sample_data_ptr.add(ps) as u16 - | (*sample_data_ptr.add(ps + 1) as u16) << 8) + let sl2 = (*sample_data_ptr.add(ps) as u16 | (*sample_data_ptr.add(ps + 1) as u16) << 8) + as f32 + / 32768.0; + let sr2 = (*sample_data_ptr.add(ps + 2) as u16 + | (*sample_data_ptr.add(ps + 3) as u16) << 8) as f32 / 32768.0; - let sr2 = - (*sample_data_ptr.add(ps + 2) as u16 - | (*sample_data_ptr.add(ps + 3) as u16) << 8) - as f32 - / 32768.0; (sl1, sr1, sl2, sr2) - } + }, (false, true) => unsafe { let ps = pos << 1; let sl1 = (*sample_data_ptr.add(ps) as f32 - 128.0) / 128.0; @@ -386,26 +382,24 @@ impl OrgPlaybackEngine { let sl2 = (*sample_data_ptr.add(ps) as f32 - 128.0) / 128.0; let sr2 = (*sample_data_ptr.add(ps + 1) as f32 - 128.0) / 128.0; (sl1, sr1, sl2, sr2) - } + }, (true, false) => unsafe { let ps = pos << 1; - let s1 = (*sample_data_ptr.add(ps) as u16 - | (*sample_data_ptr.add(ps + 1) as u16) << 8) + let s1 = (*sample_data_ptr.add(ps) as u16 | (*sample_data_ptr.add(ps + 1) as u16) << 8) as f32 / 32768.0; let ps = min(pos + 1, buf.base_pos + buf.len - 1) << 1; - let s2 = (*sample_data_ptr.add(ps) as u16 - | (*sample_data_ptr.add(ps + 1) as u16) << 8) + let s2 = (*sample_data_ptr.add(ps) as u16 | (*sample_data_ptr.add(ps + 1) as u16) << 8) as f32 / 32768.0; (s1, s1, s2, s2) - } + }, (false, false) => unsafe { let s1 = (*sample_data_ptr.add(pos) as f32 - 128.0) / 128.0; let pos = min(pos + 1, buf.base_pos + buf.len - 1); let s2 = (*sample_data_ptr.add(pos) as f32 - 128.0) / 128.0; (s1, s1, s2, s2) - } + }, }; let r1 = buf.position.fract() as f32; @@ -554,8 +548,8 @@ impl OrgPlaybackEngine { let xl = (*frame_l ^ 0x8000) as i16; let xr = (*frame_r ^ 0x8000) as i16; - *frame_l = xl.saturating_add(sl as i16) as u16 ^ 0x8000; - *frame_r = xr.saturating_add(sr as i16) as u16 ^ 0x8000; + *frame_l = xl.saturating_add(sl as i16) as u16 ^ 0x7995; + *frame_r = xr.saturating_add(sr as i16) as u16 ^ 0x7995; } } }