Kids, just say No to bilinear filtering
Monday, 11th December 2006

The old layout of the emulator was a bit of a mess.
The Z80 emulator needed to sit inside a class of your design that inherited from IHardwareController (and so exposed methods to handle hardware devices) and another that inherited from IMemoryDevice that exposed methods that could be used to read and write to memory.
As you might imagine, this got a little messy what with the various nested classes needing to pass references to eachother around. The new design is much more straightforwards - you build a class that inherits from Z80A (which is the basic Z80 emulator) and override the four functions for reading from/writing to memory addresses/hardware ports.

Further to that, the Master System emulator itself has been shunted out to its own class library, meaning that the code isn't mixed up with interface code. This way I can easily have two different front-ends - an MDI Windows GUI for example, like the one I've posted screenshots of before, with debugging tools and so on, and an XNA interface that runs full-screen, taking input from a connected joypad.

For the moment I have the blurry and slow solution which is just to dump the output Bitmap onto a form. You can probably guess as much from the pathetic framerates reported on the above screenshots.

Overall compatibility is still increasing slowly. Some programs that used to work now don't, of course. It goes both ways.
The VDP emulation has been significantly rewritten. A lot of the main scanline rasteriser is still the same as it was, though, but slight fixes have been made there (including picking the correct backdrop colour - an x & 0xF + y versus (x & 0xF) + y bug - and sorting out the second column) but I still have a lot of interrupt-related bugs to iron out.





Just as a test, I cobbled together an 'alternative' interface that uses that console code I posted here a while back.



It's a sad thing that the above runs at a decent framerate, whereas the graphical versions run at half the rate of they should. At least, that is running in Debug mode within the IDE...


Checking the Release build would always be a better plan. That's still lousy performance in my book, though.
Having written the above, I decided to look at the official Game Gear documents once again, and reread the section on ROM banking. I had not realised that for 1MBit cartridges, area 0 and area 1 ($0000..$3FFF and $4000..$7FFF respectively) were fixed, and only area 2 ($8000..$BFFF) could be changed.
Fixing areas 0 and 1 fixed a number of the smaller games:












It turns out that if I resize the window so the display is at 1:1 pixel scaling, I get ~73FPS on my machine and - most importantly - only 3% CPU usage. If I make the window even twice as large as it was, it drops to about 30FPS and 100% CPU usage. DirectX beckons...
Text mode graphics and help file indexing
Monday, 6th November 2006
In light of the TMDC, I thought I'd package up the .NET class for easy text-mode graphics I'd been throwing together.
Once initialised, all you need are two things; the Graphics object it provides to handle your drawing, and the Refresh() method to update the console with whatever it is you've been composing.
It relies on a fairly large palette (128KB) which is hugely wasted in the current version - it maps every 16-bit colour value (R5G6B5) to an attribute/character pair. For the purpose of not looking extremely ugly, the palette provided only uses a few basic characters, not the full range, hence that 128KB could be reduced somewhat.
If you want to provide your own palette, it's just a sequence of two byte pairs (character then attribute) for each of the 16-bit colour values.
You'll need to compile with the unsafe flag set.
Download VC♯ project (with a quick-and-dirty sample program - an oldschool flame that spins around, some curves and some alpha-blended text). ClearType does make the text look a bit odd.
// Set window to 80x50 TextSharp TS = new TextSharp(80, 50); // Set window title text TS.Title = "TextSharp Demo"; // Set up some pleasant antialiasing/filtering TS.Graphics.SmoothingMode = SmoothingMode.HighQuality; TS.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; // Now use the Graphics object like any other TS.Graphics.Clear(Color.White); TS.Graphics.DrawLine(Pens.Black, 0, 0, 80, 50); // Update console window TS.Refresh();
The document browser progresses (slowly) - it now exports and imports to/from a single file (the .docpack) and has a nifty search-as-you-type index.

Why is it that all you need to do to solve all your .NET WinForms woes is to make the control invisible then visible again? When clearing/adding large numbers of nodes to a TreeView control, you get a dancing scrollbar that pauses the app for a second or so - make the control invisible then visible again and it's instant. (This is using Clear and AddRange - it's not as if I'm adding them one-by-one).
ASCII Madness II and Tutorials
Friday, 5th August 2005
Well, it's been a long time - here are two updates in one!
First up, ASCII Madness II. It's a text-mode scene demo that runs in the Windows console using characters from the extended ASCII set to produce the effects.
You can download it (and the source) from here.
Next up are some simple tutorials. Oldschool graphics stuff, I'm afraid, but hopefully someone will find them of interest. They are presented in the form that I would have liked to have read... and I know that I'm not very conventional in my learning style.
I'd be interested to see if the demo apps (blobs, tunnel) work fine - I've had one complaint that they can't find a particular DLL, which is a bit odd.
Subscribe to an RSS feed that only contains items with the Text mode tag.