diff --git a/src/d_main/mod.rs b/src/d_main/mod.rs index a38d938..fb6cf80 100644 --- a/src/d_main/mod.rs +++ b/src/d_main/mod.rs @@ -10,6 +10,7 @@ use crate::m_argv::M_GetOptionalArgumentValueByArgument; use crate::m_argv::PARM_NOT_FOUND; use crate::m_misc::M_LoadDefaults; +use crate::v_video::V_Init; use crate::w_wad::{W_CheckNumForName, W_InitMultipleFiles}; use crate::doomdef::{ @@ -400,18 +401,17 @@ pub fn D_DoomMain() { } } - // TODO: Implement subsytem inits - /* + println!("V_Init: allocate screens."); V_Init(); - */ + println!("M_LoadDefaults: Load system defaults."); M_LoadDefaults(); - /* - println!("Z_init: Init zone memory allocation daemon."); - Z_Init(); + /* TODO: Implement subsytem inits + println!("Z_init: Init zone memory allocation daemon."); + Z_Init(); */ println!("W_Init: Init WADfiles"); W_InitMultipleFiles(DOOMGLOBALS::with_ref(|g| g.wadfiles.clone())); // we are loading so how cares about a borrow diff --git a/src/doomdef.rs b/src/doomdef/mod.rs similarity index 80% rename from src/doomdef.rs rename to src/doomdef/mod.rs index 62c8ae0..185d886 100644 --- a/src/doomdef.rs +++ b/src/doomdef/mod.rs @@ -1,7 +1,35 @@ use std::cell::RefCell; +/// DOOM version pub const VERSION:i32 = 110; -pub const D_DEVSTR: &str = "Development mode ON."; + +/// BASE_WIDTH +/// For resize of screen, at start of game. +/// It will not work dynamically, see visplanes. TODO: Investigate what this means. +pub const BASE_WIDTH: i32 = 320; + +/// Screen scale multiplier? +/// Original source comment: +/// It is educational but futile to change this +/// scaling e.g. to 2. Drawing of status bar, +/// menues etc. is tied to the scale implied +/// by the graphics. +pub const SCREEN_MUL: i32 = 1; + +/// Inverse of the aspect ratio +pub const INV_ASPECT_RATIO: f32 = 0.625; // 0.75, ideally according to the original source + +/// SCREENWIDTH +/// = SCREEN_MUL*BASE_WIDTH //320 +pub const SCREENWIDTH: i32 = 320; + +/// SCREENHEIGHT +/// (int)(SCREEN_MUL*BASE_WIDTH*INV_ASPECT_RATIO) //200 +pub const SCREENHEIGHT:i32 = 200; + + +/// The maximum number of players, multiplayer/networking. +pub const MAXPLAYERS: i32 = 4; /// The number of state updates (ticks) to be done per second pub const TICRATE: i32 = 35; diff --git a/src/doomtype/mod.rs b/src/doomtype/mod.rs new file mode 100644 index 0000000..367cb12 --- /dev/null +++ b/src/doomtype/mod.rs @@ -0,0 +1,10 @@ +const MAXCHAR: i8 = i8::MAX; +const MAXSHORT: i16 = i16::MAX; +const MAXINT: i32 = i32::MAX; +const MAXLONG: i32 = i32::MAX; + +// Minimum values +const MINCHAR: i8 = i8::MIN; +const MINSHORT: i16 = i16::MIN; +const MININT: i32 = i32::MIN; +const MINLONG: i32 = i32::MIN; \ No newline at end of file diff --git a/src/m_misc/mod.rs b/src/m_misc/mod.rs index 8e8582d..e6a08ef 100644 --- a/src/m_misc/mod.rs +++ b/src/m_misc/mod.rs @@ -1,20 +1,10 @@ use std::ptr::addr_of_mut; use crate::d_strings; +use crate::doomtype; use crate::hu_stuff::get_chat_macro_ptr; use crate::m_argv::{M_CheckParm, M_GetOptionalArgumentValueByArgument, PARM_NOT_FOUND}; -const MAXCHAR: i8 = i8::MAX; -const MAXSHORT: i16 = i16::MAX; -const MAXINT: i32 = i32::MAX; -const MAXLONG: i32 = i32::MAX; - -// Minimum values -const MINCHAR: i8 = i8::MIN; -const MINSHORT: i16 = i16::MIN; -const MININT: i32 = i32::MIN; -const MINLONG: i32 = i32::MIN; - // static mut variable stuff @@ -280,7 +270,6 @@ pub fn M_WriteFile(name: &str, source: std::fs::File, length: i64) { } #[allow(non_snake_case)] - pub fn M_ReadFile(name: &str, buffer: Vec) { } diff --git a/src/main.rs b/src/main.rs index 6edb62b..1b18085 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,11 @@ mod d_main; mod d_strings; mod doomdef; +mod doomtype; mod hu_stuff; mod m_argv; mod m_misc; +mod v_video; mod w_wad; mod math; diff --git a/src/v_video/mod.rs b/src/v_video/mod.rs new file mode 100644 index 0000000..372b305 --- /dev/null +++ b/src/v_video/mod.rs @@ -0,0 +1,43 @@ +use crate::doomdef::{SCREENHEIGHT, SCREENWIDTH}; +use crate::doomtype; + +pub const CENTERY: i32 = SCREENHEIGHT / 2; + +// static var stuff +#[allow(non_upper_case_globals)] +static mut screens: [[u8; (SCREENWIDTH*SCREENHEIGHT) as usize]; 5] = [[0u8; (SCREENWIDTH*SCREENHEIGHT) as usize]; 5]; + + +#[allow(non_snake_case)] +pub fn V_Init() { + // Do nothing :) + // the memory is already allocated +} + +#[allow(non_snake_case)] +pub fn V_CopyRect(srcx: i32, srcy: i32, srcscrn: i32, width: i32, height: i32, destx: i32, desty: i32, destscrn: i32) { + +} + +/* +TODO: Implement "r_data" +#[allow(non_snake_case)] +pub fn V_DrawPatch(x: i32, y: i32, scrn: i32, patch: Vec) { + +} + +#[allow(non_snake_case)] +pub fn V_DrawPatchDirect(x: i32, y: i32, scrn: i32, patch: Vec) { + +} +*/ + +#[allow(non_snake_case)] +pub fn V_GetBlock(x: i32, y: i32, scrn: i32, width: i32, height: i32, dest: Vec) { + +} + +#[allow(non_snake_case)] +pub fn V_MarkRect(x: i32, y: i32, width: i32, height: i32) { + +}