You can't read or write directly to video memory anymore. :(
Back in the day, if you wanted to put a dot on the screen, you just put a byte in the video memory area. On the next vsync, the graphics chip would scan the memory and put your byte on the screen in the appropriate spot as a dot. On the reverse, of you wanted to know if a dot was on the screen, you would just look at video memory, and if the byte was looking for was there, then that meant the dot on the screen was there.
As Video memory was just like "normal" memory, there was nothing stopping you from copying chunks of ram in and out of the video section. That's how animation worked. You would draw in "normal" memory and then, when you wanted to show your screen, you would block copy the whole chunk into video ram. BAM! Instant picture.
PCs nowadays run in something called "protected mode" This means the operating system controls what memory you have and what you can do with it. If you try and access memory that isn't yours, thee OS will catch that exception, and then (normally) shut down your program. It doesn't give you the pointer back, pat you on the head, and ask you to be more careful next time. The default behavior is to terminate with extreme prejudice.
In Windows, video memory is an absolute no-no to touch. Allegro, however, goes though the proper channels and gives me a reasonable facsimile of video memory to play with. It's called an ALLEGRO_DISPLAY object. It's not real video memory, but close enough that Allegro can work behind the scenes to display what I want.
One caveat;
The Display object is write only. You put what you want on the canvas, push a button, and it goes on the screen in a little window. If you want to alter what is on the screen, you have to send it another drawing. If you try and read the screen, then *CRASH* Windows will shut down my naughty program.

Later on I discovered that I can't Cut/Paste video data to the same canvas either. That's my current hill I'm battling on.
However, my poorly converted GIF shows that there is progress being made....(And then crashes to a white screen)
No comments:
Post a Comment