As some people around here may know, I'm a 2D-isometric game enthusiast. For me, the dream games that I'd like to recreate are isometric classics like Starcraft, Age of Empires, and Diablo.
For the past year or so I've been teaching myself a lot of the basics that go into a game like this, including tile-scrolling and A* pathfinding, among others. But recently I'd hit a wall. The laptop that I use for game development only has 8 megs of VRAM, and at 16 bit display mode, I could get no more than 6 screens of graphics into my game in 800x600 mode. Changing to 640x480 only improved these numbers slightly. (You can actually overload graphics beyond your VRAM limits, but the extra graphics go into RAM, where they are drawn to screen very slowly).
I was, needless to say, frustrated. How was it that these classic games worked fine on my laptop, but I couldn't even come close in Blitz?
So I started doing a bit of research and came up with some nuggets that I thought my fellow Blitzers might be interested in. Here they are:
(1) 8 bit Mode: The first thing I discovered was that all 3 of the games I mentioned were rendered in 8 bit graphics (256 color) mode, using palettes (so you can pick which 256 colors you want). This isn't possible in Blitz, where the lowest display mode is 16 bit. Using 8 bit display mode allows you to get more than twice as many graphics into VRAM as 16 bit because the frontbuffer and backbuffer are also only 8 bit. Using 8 bit mode, I could load 14 screens worth of graphics into memory rather than just 6. This prompted me to learn C++ and Dx, and to create the Extended 2D dll that I've recently posted in the Blitzcoder showcase.
http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=turtle177605192003023744&comments=no
Was this the answer? Well, not totally. Turns out that 8 bit mode alone wasn't good enough to get a comparable amount of graphics into the game. What was going on here? So I recently had a discussion with a guy who used to work for Ensemble Studios who knew a bit about this, and come up with this ...
(2) RAM Blitting: Turns out, Starcraft barely used *any* VRAM at all. The game only used about 1 meg of VRAM -- enough to have just a front and backbuffer. All of the other graphics (by my estimate, about 10-15 megs of 8-bit images) were loaded into RAM where they were used to compose the on-screen scene. That was then blitted to the backbuffer in a RAM-VRAM blit. I've since added the ability to load images to RAM in my dll. It's also now possible in B+ and (for textures) B3D.
The downside is that RAM-VRAM blitting is *slow*. Starcraft got around this in a few ways, including:
- because it was 8 bit, the time it takes to do a RAM-VRAM blit is much lower (it takes about half the time of doing the same thing in 16 bit).
- they only updated the map portion of a 640x480 screen (the upper 2/3) on a regular basis, which reduced their requirements even further.
- lower fps were not as apparent, because the units moved relatively slowly. The mouse may have been implemented separately as a DirectX "overlay", so its position could be updated more frequently than the rest of the screen, thus disguising the lower fps.
- because the screen was composed in RAM, not VRAM, alpha-blending was fast because there were no VRAM-reads (which are *really* slow). They used a 256x256 lookup table to implement fast alpha blending in paletted mode. This alpha blending method is important, because you can't otherwise implement alpha-blending very quickly using Direct Draw and VRAM surfaces. Today, hardware supported alpha-blending is available using 3D technology, but they were doing it back in 1998 with 2D technology and DirectX 2 (!).
Some of what these folks did is now doable in Blitz. The 8 bit stuff is not supported by Blitz, but you can get this through my dll. Personally, I'm focusing on developing 2 separate blitting modes for my game, one using the 8 bit dll that will be used on older platforms, and the other using 3D-enabled, native Blitz when the user's computer is good enough to handle it.
I hope somebody out there finds this interesting. If anybody has any additions/corrections, I'd be curious to hear your feedback.
For the past year or so I've been teaching myself a lot of the basics that go into a game like this, including tile-scrolling and A* pathfinding, among others. But recently I'd hit a wall. The laptop that I use for game development only has 8 megs of VRAM, and at 16 bit display mode, I could get no more than 6 screens of graphics into my game in 800x600 mode. Changing to 640x480 only improved these numbers slightly. (You can actually overload graphics beyond your VRAM limits, but the extra graphics go into RAM, where they are drawn to screen very slowly).
I was, needless to say, frustrated. How was it that these classic games worked fine on my laptop, but I couldn't even come close in Blitz?
So I started doing a bit of research and came up with some nuggets that I thought my fellow Blitzers might be interested in. Here they are:
(1) 8 bit Mode: The first thing I discovered was that all 3 of the games I mentioned were rendered in 8 bit graphics (256 color) mode, using palettes (so you can pick which 256 colors you want). This isn't possible in Blitz, where the lowest display mode is 16 bit. Using 8 bit display mode allows you to get more than twice as many graphics into VRAM as 16 bit because the frontbuffer and backbuffer are also only 8 bit. Using 8 bit mode, I could load 14 screens worth of graphics into memory rather than just 6. This prompted me to learn C++ and Dx, and to create the Extended 2D dll that I've recently posted in the Blitzcoder showcase.
http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=turtle177605192003023744&comments=no
Was this the answer? Well, not totally. Turns out that 8 bit mode alone wasn't good enough to get a comparable amount of graphics into the game. What was going on here? So I recently had a discussion with a guy who used to work for Ensemble Studios who knew a bit about this, and come up with this ...
(2) RAM Blitting: Turns out, Starcraft barely used *any* VRAM at all. The game only used about 1 meg of VRAM -- enough to have just a front and backbuffer. All of the other graphics (by my estimate, about 10-15 megs of 8-bit images) were loaded into RAM where they were used to compose the on-screen scene. That was then blitted to the backbuffer in a RAM-VRAM blit. I've since added the ability to load images to RAM in my dll. It's also now possible in B+ and (for textures) B3D.
The downside is that RAM-VRAM blitting is *slow*. Starcraft got around this in a few ways, including:
- because it was 8 bit, the time it takes to do a RAM-VRAM blit is much lower (it takes about half the time of doing the same thing in 16 bit).
- they only updated the map portion of a 640x480 screen (the upper 2/3) on a regular basis, which reduced their requirements even further.
- lower fps were not as apparent, because the units moved relatively slowly. The mouse may have been implemented separately as a DirectX "overlay", so its position could be updated more frequently than the rest of the screen, thus disguising the lower fps.
- because the screen was composed in RAM, not VRAM, alpha-blending was fast because there were no VRAM-reads (which are *really* slow). They used a 256x256 lookup table to implement fast alpha blending in paletted mode. This alpha blending method is important, because you can't otherwise implement alpha-blending very quickly using Direct Draw and VRAM surfaces. Today, hardware supported alpha-blending is available using 3D technology, but they were doing it back in 1998 with 2D technology and DirectX 2 (!).
Some of what these folks did is now doable in Blitz. The 8 bit stuff is not supported by Blitz, but you can get this through my dll. Personally, I'm focusing on developing 2 separate blitting modes for my game, one using the 8 bit dll that will be used on older platforms, and the other using 3D-enabled, native Blitz when the user's computer is good enough to handle it.
I hope somebody out there finds this interesting. If anybody has any additions/corrections, I'd be curious to hear your feedback.