Page 1 of 1
Change the active video memory?
Posted: 10 May 2011, 16:11
by miningmarsh
Is it possible to change the location of the video memory? For example – on the ti89 calculator, a pointer points to the beginning to the video memory, and by changing that pointer, the screen would be updated to reflect the new video memory. Is this possible in nxc?
I have been working on getting grayscale on the nxt, but I have not been able to sync any drawing operations with the 10 Hz refresh rate. I think it would be a lot easier if I could just write to different sections of memory, and just change the active screen area every 10 milliseconds. I am aware that this is next to useless because nxc has no pointer support (or it does and I’m just an idiot).
Sorry if this was a stupid question.
Re: Change the active video memory?
Posted: 10 May 2011, 18:33
by mattallen37
That is basically another way of saying what I asked for yesterday
I can see now that I am not the only one that wants this concept.
One thing though, 10 Hz would be every 100ms, not 10ms.
Re: Change the active video memory?
Posted: 10 May 2011, 18:48
by miningmarsh
Stupid I, I always have to change my programs because I keep perceiving milliseconds as 1/100 of a second. I saw your thread, but I think we can probably get much better quality if we can implement this method. In fact a year ago, before nxtasy went down, I posted a similar request to this, except I asked about a specific function I believed could accomplish this (forgot the function, though).
Re: Change the active video memory?
Posted: 10 May 2011, 18:54
by mattallen37
Well, don't feel too bad... in NQC, 10 WOULD be 1/10 of a second. The RCX uses 100th's of a second. Perhaps you get them mixed up (I know that I still do, only the other way around).
I tried for a few minutes the other day to implement this as a custom function, but only with text (no graphics). I got hung up on parsing the string into an array of chars, but I know of another thing to try now... Although this still wouldn't help for graphics, it could help for text.
Re: Change the active video memory?
Posted: 11 May 2011, 02:14
by muntoo
Try
this. I use it in my
ScribblePad, which I must blog sometime.
If you look around, there
may be stuff with
addr()
in it. Replace it with
addressOf()
.
I'll see if I can find the "tutorial" in the waybackmachine...
-----
I'm pretty sure you
can get the offset of the display. (A "pointer" to it.) Then you use
IOMapWriteById()
or something.
You may wish to look at the large block comments in SCR_File_Lib; they explain exactly how the display memory is organised.
-----
Fun fact: Did you know there are
two buffers? Popup memory and Display memory. You can switch between them "instantly", and read/write to either of them. Look around the API for popup memory, and you'll find it's inverse (display memory), too.
-----
Try this:
Code: Select all
byte dat[];
ArrayInit(dat, 0x00, 8*100);
GetDisplayModuleBytes(DisplayOffsetNormal(0,0), 8*100, dat);
There's lots of different ways to do this (IIRC), so you should try them out and test 'em for speed before you decide upon the right one. And post your findings, 'cause I'm interested, too.
Here's a bunch of
Display module IOMAP offsets. (There's one for
each module!)
And you may also be interested in the
Command Module Constants.
-----
To enlighten you, we
do have "pseudo-pointers":
Check out
this amazing example I just discovered.
Some of the memory/pointer stuff is hidden in the
cstring API.
-----
What I was once looking for was a way to
change the pointer to the display memory... if such a thing
can exist.
Re: Change the active video memory?
Posted: 11 May 2011, 02:43
by muntoo
miningmarsh wrote:Stupid I, I always have to change my programs because I keep perceiving milliseconds as 1/100 of a second.
Get used to it.
Milliseconds is sort of a standard now.
miningmarsh wrote:In fact a year ago, before nxtasy went down, I posted a similar request to this, except I asked about a specific function I believed could accomplish this (forgot the function, though).
Maybe look around the "
waybackmachine"?
Re: Change the active video memory?
Posted: 11 May 2011, 14:27
by miningmarsh
muntoo wrote:Try
this. I use it in my
ScribblePad, which I must blog sometime.
I was looking through the source and found the function I was looking for,
SetDisplayDisplay. The documentation made it seem like this was the pointer to the video memory. Unfortunately, passing the address of an empty array of bytes had no effect (I had expected it to blank the screen if the video memory was properly rerouted).
muntoo wrote:Fun fact: Did you know there are two buffers? Popup memory and Display memory. You can switch between them "instantly", and read/write to either of them. Look around the API for popup memory, and you'll find it's inverse (display memory), too.
I was aware of this, however since there was no real support for the popup memory, and I did not feel like writing any libraries, I looked for other ways. I was also worried about the OS messing with the popup memory (such as using it for the low battery message).
muntoo wrote:What I was once looking for was a way to change the pointer to the display memory... if such a thing can exist.
This is what I am trying to do, and the biggest advantage I see of this is that by just editing a pointer to the display memory, we can use the regular display memory as one of the two buffers, meaning we will only use half the memory of using two different arrays. This is what I was hoping SetDisplayDisplay would do.
muntoo wrote:
Try this:
Code: Select all
byte dat[];
ArrayInit(dat, 0x00, 8*100);
GetDisplayModuleBytes(DisplayOffsetNormal(0,0), 8*100, dat);
There's lots of different ways to do this (IIRC), so you should try them out and test 'em for speed before you decide upon the right one. And post your findings, 'cause I'm interested, too.
This just crashes every time I run it.
muntoo wrote:To enlighten you, we do have "pseudo-pointers":
Check out this amazing example I just discovered.
Some of the memory/pointer stuff is hidden in the cstring API.
This is one of the single thing I wanted from nxc( type casting, and this). Thank you so much for sharing this.