Sunday, December 3, 2017

Now full time!

I am now in a unique position where I can now work on this project full time and give it 100% of my attention. Progress is being made, but it's interesting to see various limitations and strengths of Allegro and Nermal as I try wrap one around the other. I ran into a rather nasty issue when Nermal made an intresting assumption about computers that isn't true nowadays.

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.

Nermal assumes that you can read and write to video memory. It likes to be able to swap out what's there arbitrarily. This had me stuck for a bit, but I got around it by creating a "virtual screen". Now, if my virtual screen is touched in any way, there is a trigger that immediately mirrors the changes on the actual screen.

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