Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Mixing Video Modes. Mostly on Mega Drive

Reply to topic
Author Message
  • Joined: 17 Sep 2013
  • Posts: 128
  • Location: Gravataí, RS, Brazil
Reply with quote
Mixing Video Modes. Mostly on Mega Drive
Post Posted: Mon Mar 28, 2022 2:42 am
Last edited by gvx32 on Thu Jun 30, 2022 2:28 am; edited 2 times in total
This project was suposed to be my entry in this year competition. But thinking about it, doesn't seem like competition material, it's just some techincal notes, and two ROMs.

My Idea here was to expand on this concept: https://www.smspower.org/forums/14977-LegacyModeScrolling#81253

I always thought that, utilizing the legacy modes for a locked "window" of any sort was the obvious choice, expecially for a HUD. Not only you get the locked scroll that you need, but there are some other advantages:
They utilize less VRAM, so, this means more memory for graphics of the game itself.
Since they use less memory, it's faster to update then, so, more time in vBlank to update the game's graphics.

They also come with a great disadvantage: breaking compatibility with the Mega Drive.

Anyway, so far, nothing new, so let's talk about the two roms.
VdpMapper is a collection of diferent ways two create HUDs using other video modes from Mode 4. Press left or right to change the HUD showing, and 1 or 2 to see how they utilize VRAM and also, what changes need to be made to the VDP regs and also in witch lines. This rom will have different huds, depending on the Hardware (SMS1, SMS2 or MegaDrive especially)

DemoStatusBar is just for the MegaDrive. All the test cases are possible here, you can change the line in witch the VDP changes from Mode 4 to 5 and vice versa, and change the scroll positions.

Here are a few things that were new for me when I tested:
Mixing modes with diferent resolutions can be done, but the screen must start and end in the same resolution, so in the Castlevania mode, the screen will start drawing in Mode4 with extended resolution, change to Mode 0 in the first line, and than, change back to Mode 4 extraRes. This will force the Mode 0 area to be shifted upwards, and not skip the first 16 lines of screen like a regular 192 resolution mode would do.

Text Mode: this is actually really cool, while in text mode , you can access the VDP much faster that in the other modes, its possible to send bytes to the VDP at least as fast as one byte per 11 cpu cycles. Thats right, in pratice, in Text Mode, you are as free to access the VDP as if the VDP was disabled, Check the small animation in the Ninja Gainden HUD. Check the function ninjaGraphics.animRyuHead on TextMode.asm for that.

As for the MegaDrive. Since it's not compatible with the legacy modes, the obvious choice at first is to use Mode 5. You can use all the 64k of VRAM in it, so, just put the Mode5 stuff in the higher 48k and all the VRAM you saved in the regular SMS is preserved. Also, since in the Genesis you already have pretty much free access to the VDP already, you can preserve the advantage gain by using Text mode in SMS.

There are two problems here:
First, the signal generated in Mode 5,256 pixels wide, is slightly different than Mode 4. There is a distortion when changing between the modes, and forget about 320 wide resolution, it will completely mess the screen.
Second, The VDP maps VRAM diferently in Mode5, so, do not update the screen during that (aside from the Mode5 itself).

So Lets see what is possible on the Mega Drive in SMS mode (things that were new to me when I tested):

Changing vertical scroll position midframe in Mode 4: By switching to Mode 5 and back to Mode 4 in the next line, the vertical scroll position used until further update will be from the Vertical Scroll Table.

Extra resolution in Mode 4: Switching to Mode 5 prior to Line 192 and back to Mode 5 before Line 224 will make the Vdp forget to stop drawing, and the screen will be filled with Mode 4. The vertical scroll position in the outside areas is taken from the Vertical Scroll Table as well, but it behaves a little diferently from the regular screen. Check DemoStatusBar for details. Also, there will be no vBlank interrupts this way, you will have to rely on Line Interrupts to manage the vBlank here.

DMA in SMS mode: this contradicts some documentation I read before, but DMA is avaliable in SMS mode, VRAM to VRAM only. But its still pretty usefull.

Using 128k Mode to access Mode 4 memory: 128K mode is normally useless in the MegaDrive, but it can be usefull to edit Mode 4 stuff while in Mode 5. The Vram memory mapping is very similar, just shifted one bit to the left. So, all even bytes are mapped the their exacty positions as they would be in Mode 4. So, when accessing the Mode 4 information this way, just set the Vdp Adress to the same as you would normally, but shifted one bit left, and set the Auto-Increment Register to 2. That way you can use Mode 4 while in Mode 5. You can even DMA to Mode 4 this way, check the "spriteTable" function in Mode4Graphics.asm in DemoStatusBar. It copies 256 bytes in about 5 to 6 lines.

Another maybe usefull info: Bit 6 of Reg Misc 3 seens to block further updates to the Vdp Regs.
Roms.zip (60.1 KB)
Roms.zip
VdpMapper Correct.zip (9.73 KB)
Correction of the system test

  View user's profile Send private message
  • Joined: 17 Sep 2013
  • Posts: 128
  • Location: Gravataí, RS, Brazil
Reply with quote
Post Posted: Mon Mar 28, 2022 2:46 am
TR;DR:

Text Mode allows for fast access to the VDP
A lot of cool stuff for Genesis running on SMS mode.

Also, the bits about 128k mode I found here: https://plutiedev.com/mirror/kabuto-hardware-notes
The trick to extend the resolution is also there, just not for Mode 4.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!