sim86_memory.h (1064B)
1 /* ======================================================================== 2 3 (C) Copyright 2023 by Molly Rocket, Inc., All Rights Reserved. 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Please see https://computerenhance.com for more information 10 11 ======================================================================== */ 12 13 struct memory 14 { 15 u8 Bytes[1024*1024]; 16 }; 17 #define MEMORY_ACCESS_MASK 0xfffff 18 static_assert((ArrayCount(memory::Bytes) - 1) == MEMORY_ACCESS_MASK, "Memory size doesn't match access mask"); 19 20 struct segmented_access 21 { 22 u16 SegmentBase; 23 u16 SegmentOffset; 24 }; 25 26 static u32 GetAbsoluteAddressOf(u16 SegmentBase, u16 SegmentOffset, u16 AdditionalOffset = 0); 27 static u32 GetAbsoluteAddressOf(segmented_access Access, u16 AdditionalOffset = 0); 28 29 static u8 ReadMemory(memory *Memory, u32 AbsoluteAddress); 30 31 static u32 LoadMemoryFromFile(char *FileName, memory *Memory, u32 AtOffset);