PDA

Click to See Complete Forum and Search --> : Direct Memory Addressing


Jimbob42
Jun 25th, 2000, 02:31 PM
This may seem simple, but would anyone be able to tell me how to write directly to memory in c (not c++), namely for SVGA graphics? Qbasic has it's "poke" and "peek" functions but I can't seem to find the equivalent in c.

parksie
Jun 26th, 2000, 01:42 AM
to write directly to a specific memory location in c, you need something like the following code. DON'T RUN THIS!!!!! IT WILL SERIOUSLY KILL YOUR COMPUTER!!!!!!

sorry.


#include <stdio.h>
#include <stdlib.h>

void main() {
char* pcMyVariable;
char* pcMyString = "Here is a string";

pcMyVariable = 0x6552; // random memory address
strcpy(pcMyVariable, pcMyString);
}


obviously, you set the memory address to whatever is needed - if you need to write to video memory, there are ways to find the base address. i assume that you know how to set up the screen mode, and just need to write something. anyway, all you do is set the pointer to your memory location and write away. and then your program dies because you messed up (it happens to me a lot!).

Jimbob42
Jun 26th, 2000, 07:16 PM
That sounds cool, but unfortunately I am still stuck in the c data segment. I don't suppose c supports segment overrides (or perhaps a way to trick it like a far external char in video segment 0xA000) ?

parksie
Jun 27th, 2000, 12:10 AM
make it a big enough address that it wraps round...there is a method floating round the Internet somewhere, but I
a) have never used it
b) never intend to use it
c) don't understand it
So I think you can see my problem.
Let's try something:

DOES ANYONE OUT THERE KNOW HOW TO GET AT VIDEO MEMORY FROM DOS!!!!!!!

Now to wait for the punters to 'flood in'...