Sega Virtua Processor/Virtua Racing Research

Discussion in 'Engineering & Reverse Engineering' started by Ralakimus, Nov 12, 2018.

  1. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    So, I pretty much have a good grasp on how exactly Virtua Racing handles the generated tiles from the SVP. Normally, a Genesis game would keep itself in sync with VSync, and then do all the major graphics transfers during VBlank. However, because the number of tiles generated by the SVP is so large, even with display disabled and with DMA, it would take too long to transfer all of them to VRAM without some issues. So, here's what Virtua Racing does:

    The game doesn't (always) sync itself with VSync, but rather it utilized the H-INT and a counter. Every 8 scanlines, a counter (whose base value is 0x1B) is decremented, and once that counter has run out, it resets the counter (V-INT also resets the counter), it then starts doing all the major graphics transfers. Notice that 0x1B * 8 = 216, 8 pixels less than the typical 224 vertical resolution. What the game is doing here is it's making it so that it starts the updates earlier than normal, and also ends before where the graphics start displaying. Of course, with that in mind, it purposely has top and bottom borders, so the game isn't full screen. The H-INT routine also uses a flag in which when clear, it won't run the updates at all. I'll mention it later down below.

    [​IMG]

    And also here's how a general game loop works:

    • Wait until the H-INT counter is set to 0x1A
    • Once that condition is met, run one of the following routines
      • Frame initializationn
      • Render setup (part 1)
      • Render setup (part 2)
      • Render setup (part 3) and game execution
      • Frame lag
    • Set to allow updates to run during H-INT and wait for updates to happen
    • Loop
    The "frame initialization" tells the SVP to start generating tiles and also tells the H-INT to do game mode specific general updates.
    The "render setup" is split up into 3 parts as you can see. Here's what the H-INT does for each part:

    • Part 1 transfers the first 0x26C0 bytes of generated tile data from the tile buffer via DMA, and also sets the background's HScroll.
    • Part 2 transfers the next 0x1280 bytes from the tile buffer, and if a flag is set, it'll transfer the palette data to CRAM, and then also transfer HScroll data for a scroll by scanline setup (used in the 2P mode to scroll the backgrounds in each screen independently)
    • Part 3 transfers the final 0x26C0 bytes from the tile buffer, and sets the VScroll value, depending on which tile buffer is being used.
    The "frame lag" only happens when the SVP isn't fully completed with generating tile data. Typically, it'll just tell the H-INT to do the same updates as in "frame initialization".

    In the end, it's possible that the SVP is capable of producing graphics real quickly, and that the reason the framerate is limited the way it is is due to tile transfer speed limitations, but don't take my word for it.

    [​IMG]

    And may I ask, where the tidbit on information on Sega Retro that says that the SVP performs lighting calculations and texture mapping came from? AFAIK, the SVP don't support these at ALL.
     
    Last edited: Oct 21, 2019
    • Informative Informative x 3
    • Like Like x 1
    • List
  2. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,140
    101
    43
    Formerly Sonic the Fighters
    Holy SHIT my mind is blown!
     
  3. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    Just an FYI for that screenshot, I made a simple converter that converts SVP models to OBJ... with a material file that has every possible color combination from the palette lol. Gonna eventually make a simple OBJ to SVP converter so I can create custom models.

    EDIT: Actually...
    [​IMG] [​IMG]
     
    Last edited: Oct 22, 2019
    • Like Like x 2
    • Useful Useful x 1
    • List
  4. Overlord

    Overlord

    Aros gartref, diogelu'r GIG, achub bywydau Moderator
    17,875
    158
    43
    Berkshire, England
    Learning Cymraeg
    That's really really cool.
     
  5. JaviTaiyou

    JaviTaiyou

    Member
    3
    0
    1
    This is superb work, congratulations!!
     
  6. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    [​IMG]
    [​IMG]

    :)
     
    Last edited: Oct 24, 2019
    • Informative Informative x 2
    • List
  7. Aesculapius Piranha

    Aesculapius Piranha

    つづく Oldbie
    4,285
    29
    28
    Unknown
    Diva
    Who needs trees when you have monkey heads?
     
  8. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    I ripped all the models I could find in Virtua Racing and converted them into OBJ format. I also provided the original SVP format files as well.

    Download

    I still need to figure out how to handle palettes for exporting before I release this add-on for Blender at all. If anyone here has any ideas at all, please shoot em towards me. The way I currently have it set up for importing is that it creates a material for every possible color combination from a palette. This wouldn't be so bad if it weren't for the fact that each face is assigned 2 colors from the palette, so with this setup, it's super counter intuitive and hackish.
     
    Last edited: Apr 18, 2020
    • Like Like x 4
    • Useful Useful x 1
    • List
  9. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    upload_2020-4-17_23-1-55.png

    Getting something figured out...
     
  10. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    Yeah, I know, the 3rd bump in a row, but things are really looking up now.

    upload_2020-4-20_5-0-55.png
    upload_2020-4-20_7-26-52.png

    I may be able to release this soon!
     
    Last edited: Apr 20, 2020
  11. LForoni

    LForoni

    Member
    2
    0
    1
    Your work is amazing.
    Truly inspire me to try something.

    Sometime ago I tried to recreate the beginner track by hand, and failed spectacularly.
    Can't wait to see more.
     
  12. Ralakimus

    Ralakimus

    pretty much a dead account Tech Member
    557
    158
    43
    I wouldn't expect to see much more in the near future. I have other crap to work on + IRL stuff getting in the way. I would've gotten the plugin finished a good while ago, but shit happened.