Quote:
Update: I have it displaying sprites almost correctly.
I fixed a bug which was causing massive graphics corruption (because the emulator byte-swaps the whole of VRAM, every 2 pixels were flipped, so instead of 1,2,3,4 I was getting 3,4,1,2), now that patterns are all being drawn perfectly. It's just that multi-cell sprites which are made of more than one tile are borked.
So that means 8x8 sprites are displayed perfectly, but anything else isn't. It can draw a wide sprite if the sprite isn't flipped (and I think I know how to fix that one), but trying to draw sprites more than 1 cell high results in a garbled mess. Obviously there's a bit of a gap between my understanding of the VDP and the way it actually works. The documentation I have is a little sparse when it comes to the way things are actually rendered, and the Genesis Plus software renderer isn't a lot of help.
I tried using the PVR's texture flip bits to emulate the tile flipping, but I couldn't get that to work, so it's just futzing around with the texture coordinates at the moment. Somewhat inelegant, but it works.
Aside from that, I need to start using the punch-through display list so we can start getting some transparency, and it's rendering the sprites in the wrong order (thinking of OpenGL, I thought that higher Z coordinates meant further away, when they're the opposite way around on the Dreamcast. D'oh!)
Edit: Just dropped the screen resolution back to 320x240 (was using 640x480 for some debug info which I no longer need), and the graphic corruption is still there. Now it's swapping every alternate pixel, but the distortion wasn't bad enough to notice on 640x480.
Other than that, sprites now work 99% correctly. Figured out the multi-cell sprite thing (I was drawing width first, should have been drawing height first) and the flipping stuff. Woohoo!
Edit 2: Fixed the GFX corruption. Apparently the DC and Genesis pack their colour values into one byte in the opposite order. Now sprites are almost perfect (for now). I tried to use the Punch-through display list, but it crashed on me. Bugger.
---
There's only one (major) problem with the sprites at the moment. For whatever reason, some of the sprites look completely screwed up. Basically, they look as if they're displaying the wrong graphics. However, even if it's displaying the wrong graphics every single frame and you pause it, it suddenly fixes itself. So that probably means it's an issue with the tile cache code. It's probably because of deferred rendering - I think I'm uploading textures for frame X when the PVR is still rendering frame X-1, so the frame gets bits of the graphics from the next frame...
---
I'm going to let you guys play with this thing as soon as I've fixed one bug related to horizontal scrolling (and me not having a bloody clue how horizontal scrolling works, or what the hell Charles MacDonald was doing in Genesis Plus - both have been causing a lot of problems). Basically, the tile offset into the name table is scrolling the wrong way, but the pixel offset onto the screen is scrolling correctly.
Aside from that, it works, and it's a hair's breadth from being full speed (every few frames it just passes over the 16.6ms boundary and takes two frames instead of one). Compatability is utter crap at the moment, and there are a lot of graphics glitches on every game I've tested on, but it works!
(Thirty minutes later)
Fixed. [...] If anyone wants to try to fix a few of the more glaringly obvious bugs [...] please feel free. The fact that the rendering code ignores virtually every single register used to control the display is a major problem (stuff like the display enable bit, background colour, vertical scroll mode, that kind of thing), it doesn't handle 32-cell display modes properly (draws them as if they were 40-cell), column-based vertical scrolling doesn't work, shadow/hilight doesn't work, theres some weird graphics glitches on the sprites, it's a bit slow, and it draws garbage outside the borders of the display.
I'd like to thank all of you that are involved with Genesis / Mega Drive emulation on DC, especially Stef and BlackAura for their outstanding achievments.