FPGA Genesis with Sound

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

OzOnE
Interested
Posts: 23
Joined: Wed Dec 04, 2013 3:49 pm

Post by OzOnE » Tue Dec 10, 2013 2:32 am

No problem at all. :)

It's been good to use my brain and try to work it out.

Not done yet though, looks like the scroll values will need changing too?

Just compiling and trying the sprite address as well, but I'm not sure quite how the sprite engine works yet. I've added the interlace stuff like this...

Code: Select all

	if IM2 = '0' then SP1_VRAM_ADDR <= (SATB & "00000000") + (OBJ_CUR & "00");
	else SP1_VRAM_ADDR <= (SATB(5 downto 0) & "000000000") + (OBJ_CUR & "00");
	end if;
SATB is normally 7-bits (6 downto 0), so I'm taking a long shot here that this is the correct place to try. :?

I kind of like the trial-and-error / shotgun approach at times, but it takes around 5 minutes to recompile on this aging Q6600 @ 2.4GHz.

New Core i5 3.4GHz with GTX 670 is sat in the corner, but I can't bring myself to install a load of electronics junk on it - it's meant to be my Oculus Rift / gaming machine, but I hardly have time to ever play any games. lol

Oh, compile nearly done....

I also changed the "IM" bit back to "IM2", since 8x16 stuff should only be done in double-res mode apparently.

Nope, that didn't fix the sprites. lol

Hmmm, food time I think, then I can look through the code a few (hundred) more times.

OzOnE.

OzOnE
Interested
Posts: 23
Joined: Wed Dec 04, 2013 3:49 pm

Post by OzOnE » Wed Dec 11, 2013 11:14 pm

I spoke too soon with the results of the last code change.
Looks like the scroll values are still messed up or something?

The nametable addresses look like they're wrapping as well, as if I need to divide some values by two (limit the scroll range, due to using half the screen height?

The lower half of the screen is clearly broken too, as I'm not changing to the correct values at the half-way point.

This is a screenshot of the very start of the intro demo (sprites still missing)...

Image

You can see that even the player one background is slightly too high.
When the players move further through the course, the vertical scrolling gets even more out of whack (like it needs to be divided by 2).

I realize that modifying Grégory's code wasn't going to be easy for someone as inexperienced as me, but I was wondering if anyone has seen similar graphics issues to this who might want to lend a hand to fix it?

This is only for the double-res interlaced mode though, so only affects a few games to be fair.

You can see the effect a bit better on this photo...

Image

Looks like I need to half the VSCROLL value for the top half, then halve the VSCROLL value again after the mid point?

I underestimated quite how many code changes would be needed.
If you look at the current MAME source, you'll see what I mean by searching for megadrive_imode ...

http://mamedev.org/source/src/mame/mach ... vdp.c.html

OzOnE

OzOnE
Interested
Posts: 23
Joined: Wed Dec 04, 2013 3:49 pm

Post by OzOnE » Wed Dec 11, 2013 11:53 pm

Ahhaaaaa.... fixed the backgrounds!! :D

Funny how a fresh look at things can often help...

Code: Select all

	when BGAC_CALC_Y =>
		BGA_COLINFO_WE_A <= '0';
		if WIN_H = '1' or WIN_V = '1' then
			BGA_Y <= "00" & Y;					
		else
			if BGA_POS(9) = '1' then
				BGA_Y <= (VSRAM(0)(9 downto 0) + Y) and (VSIZE & "11111111");
			else
				if VSCR = '1' then	-- 2-cell V-scroll...
					if IM2 = '0' then BGA_Y <= (VSRAM( CONV_INTEGER(BGA_POS(8 downto 4) & "0") )(9 downto 0) + Y) and (VSIZE & "11111111");
					else BGA_Y <= (VSRAM( CONV_INTEGER(BGA_POS(8 downto 4) & "0") )(9 downto 0) + Y) and (VSIZE & "11111111");
					end if;
				else						-- Full V-scroll...
					if IM2 = '0' then BGA_Y <= (VSRAM(0)(9 downto 0) + Y) and (VSIZE & "11111111");
					else BGA_Y <= '0' & (VSRAM(0)(8 downto 1) + Y) and (VSIZE & "11111111"); -- todo (OzOnE)
					end if;
				end if;
			end if;
		end if;
I just shifted the bits right for the Full V-Scroll value, and stuffed the MSB with an extra zero.

Did the same for background B, and the Sonic 2 two-player mode backgrounds look fine now. :)

Just need to figure out how to fix the sprites now.

(didn't need to "change the values at the half-way point" after all - that was just something I read from Nemesis on another thread about the 68K coding side of things)

OzOnE.

EDIT: The only minor glitch is that you can see the tiles being updated along the left-hand side of the screen. I'm not too bothered about that atm.

OzOnE
Interested
Posts: 23
Joined: Wed Dec 04, 2013 3:49 pm

Post by OzOnE » Thu Dec 12, 2013 3:49 am

Now, that's much better isn't it. :)

Image

I see now that the Sonic 2 character sprites are still written to the same place in VRAM in double-res mode (around 0xF000), but they are also now two tiles high.

(I used Exodus to have a peek at the memory - such a useful tool, Nemesis).

So, I think I need to modify the pattern index pointers in the sprite attrib tables, then change some of the X/Y offset stuff?

Just talking to the mdwiki guys atm.
Lots of interesting techy talks going on. :)

OzOnE.

Post Reply