Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

RAM & timer

Started by Deliverance Jul 10, 2006 at 3:36 PM 0 replies 800+ views
Original Post
Deliverance
Deliverance
Hi there! I have a question regarding the way the RAM memory is being handled and layed out. Here's what I want to do: I want to get a pointer (int, byte, etc) that points to a memory location that starts at a give address (let's say 1025 for example) Does that mean I'll actually get a pointer to the 1025's byte in the RAM?! First of all how can I accomplish this and second of all am I wrong here with something, because it's rather weird to me. I wanted to do this becasue in Pascal I can declare something like this var time:integer absolute $0:$46c; where time represents the timer (updated at every 0.055secs) How can I accomplish the same thing in C/C++. I don't want to use GetTickCount nor the performance timer, I basically want to know how to translate this line of code var time:integer absolute $0:$46c; into a C++ line of code.
SiCrane
SiCrane
You can use reinterpret_cast<> to cast an integer as an address to a pointer type in C++. However, that probably won't give you a pointer to that element in physical memory. It will give you a pointer into virtual memory. If it is possible on your operating system to obtain a pointer to physical memory, then you would have to consult them documentation for your operating system. As such, chances are that you won't be able to translate your timer code into C++ if you are trying to run it on a modern operating system. Compilers for DOS will generally tell you how to declare segment:offset memory addresses in their documentation.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.