don't click here

Sonic CD Quirks/Deconstruction

Discussion in 'Engineering & Reverse Engineering' started by Devon, Jul 11, 2022.

  1. Chimes

    Chimes

    The One SSG-EG Maniac Member
    1,067
    740
    93
    Sliding tiles... Actually, what *would* the bandwidth of that be? Because I've always had a nagging concern that shifting the tiles isn't as set-and-forget as I think it might be (unless the Sega CD allows you to freely use the hardware-rendered tiles in any way like shifting them on the fly to compensate while the MCD is scaling them more slowly). Do you have to keep track of the tiles' positions, or can one wire in a "global" position for the object itself
     
  2. Cooljerk

    Cooljerk

    Professional Electromancer Oldbie
    5,183
    820
    93
    The problem of scaling downward is that you need to selectively hide rows or columns of pixels to achieve this. Sliding tiles is handled by the Genesis. You construct a sprite on the genesis made up of multiple smaller sprites, and slide them over each other to simulate removing columns/rows of pixels. Because the sprites overlap, and are drawn in order, one sprite tile will hide rows/columns from another as they move, achieving the selective removal needed. The UFO tiles would already be in the Genesis VRAM after load, so would wouldn't have to constantly copy them over from the Sega CD's visible buffer.

    qisha-smooth-scaling.gif

    As for how the Sega CD handles images, the ASIC works like a framebuffer that can be blitted to, like stamps. You create an image on the sega CD framebuffer, the ASIC turns it into tiles, then puts it into work ram. Typically the Sega CD is seen as two 128kb "carts" that get swapped in and out. The Sega CD can see and write to one, while the Sega Genesis can see and read from the other, and they flip when needed. To transfer tiles to the Genesis, the Sega CD ASIC creates the tiles, puts them into it's "cart," then the Sega Genesis swaps the "cart," and copies the tiles from the "cart" into VRAM, and renders everything itself. If it's a big scaled floor like in Sonic CD, that's many tiles being copied. But stuff like the UFOs and whatnot are just normal Sega Genesis sprites, using tiles already copied to VRAM. The Sega CD itself has no ability to actually draw anything to screen, it's all handled by the Genesis hardware. In graphics terms, you'd say the Sega CD was working with BOBs (Blitter Objects), not sprites.
     
    Last edited: May 29, 2025
    • Informative Informative x 1
    • List
  3. Devon

    Devon

    pfp by @litchui on Twitter Tech Member
    1,580
    1,958
    93
    your mom
    What you are describing is the 1M/1M mode of Word RAM, which actually can't do the hardware scaling/rotation type of rendering that the special stages do. That is exclusive to 2M mode, where either the Genesis or Sega CD have access to the entire 256 KiB of Word RAM at one time, due to the amount of memory space needed to hold the source image (stamps + stamp map), output render buffer, and trace vector, which describes to the ASIC how the rendering is done. In 1M/1M mode, what you can do instead is an easier form of software rendering in Word RAM. Basically, on the Sega CD side, a mirror of its assigned Word RAM bank is made that splits each 4 bit nibble (pixel) into separate bytes, which makes it easier to do software rendering, as opposed to having to directly deal with the 2 pixels per byte format. On the Genesis side, a mirrors of its assigned Word RAM bank is made that rearranges Word RAM into tiles that are to be uploaded into VRAM.

    With the special stages, since you can't just do that easy Word RAM double buffering thing with the split banks, what is done instead is that after a frame is rendered, it is copied into the Genesis' work RAM, which is then transferred into VRAM over the span of 3 video frames (via split DMA jobs during V-BLANK), while the Sega CD is told to start rendering the next frame. On top of the amount of space needed to hold the rotated and scaled floor graphics being a potential problem (+ the extra work needed to upload it all into VRAM), there's also the fact that the sprites use different palette lines, which obviously causes a major conflict, since the ASIC was only really designed to render an image for a single palette line (at least without having to do complicated tricks on the rendered image's tilemap). Basically, 1 palette line is assigned for the floor, which is rendered by the ASIC, 1 palette line for the background, and 2 palette lines for the sprites. If you want to somehow get sprites to be rendered on top of the floor, the easiest method would have to involve somehow getting all the different assets to share the same palette line, which... lol good luck.

    The ASIC could be programmed to render the sprites separately, but you would first need to optimize the tile output to fit sprites better (while the tile output is column ordered like sprites expect, it's still more optimal for tilemaps, because tile outputs taller than 4 tiles will not work), and also would need to reprogram how the ASIC is interfaced to actually handle more than 1 render job at a time (you can use the graphics interrupt on the Sega CD side to automatically manage multiple render jobs in a queue of sorts), and of course add more work on the Genesis side in uploading the rendered sprites into VRAM.
     
    Last edited: May 29, 2025
    • Useful Useful x 3
    • Informative Informative x 1
    • List
  4. Cooljerk

    Cooljerk

    Professional Electromancer Oldbie
    5,183
    820
    93
    Good to knowl, but the sliding tiles method of smoothing out the UFO scaling should still be possible, right? It'd be the same number of tiles needed to hold the different UFO sizes anyways. The earlier Balloon UFO sprites were more of a solid color, so they could fit the palette line better, no? EDIT: Slightly less, the final UFOs use 27 colors, the 510 beta uses 22. Makes you wonder how many colors this used:

    3.png
     
    Last edited: May 29, 2025
  5. Devon

    Devon

    pfp by @litchui on Twitter Tech Member
    1,580
    1,958
    93
    your mom
    Considering that UFOs are still just Genesis sprites that the ASIC has nothing to do with, then yeah, it's totally possible. My only main concern is sprite count, because you'd need to use separate sprites for each individual tile in order to do the sliding in the first place, and the sprite limitation is even more limited than normal, due to the use of H32 mode (256px wide resolution) to make the floor rendering easier to handle (easier to double buffer in VRAM and also takes less memory/tiles due to the smaller horizontal resolution). As a result, the max number of sprites is decreased from 80 to 64, with a maximum of 16 sprites per scanline instead of 20 (and also a maximum of 256 sprite pixels per scanline instead of 320).
    The less colors to deal with, the better, but I'd imagine that it would still be a challenge, especially with the extra workload and memory needed for the ASIC render and VRAM upload for this to properly be handled.
     
    Last edited: May 29, 2025
  6. I think it was because they went for such a big display window and when the Mega CD used the flat mode 7 style floor, it never moved well IMO be that on Wildy Woody or Sonic CD.
    Better if Sonic CD went the Batman Returns and Cliffhanger style for 3D sections

    For me, the most impressive use of the ASIC chip in Sonic CD was the cloud cheat on the title screen and the D.A Garden bonus for finishing the game





    Wild Wood 3D bonus stage did have ace music, very much like Sonic CD bonus stage music mind
     
  7. Cooljerk

    Cooljerk

    Professional Electromancer Oldbie
    5,183
    820
    93
    Ever checked out Night Striker on the Sega CD? That's pretty much exactly what I want out of a Sega CD game, it looks like a Super Scalar arcade game. What is really nuts is comparing it to the Sega Saturn version, and the Sega CD version not being that far off. It's one of those games that shows that the Sega CD really was a significant upgrade to the Genesis:

     
  8. I couldn't agree more, it was remarkable how close the Mega CD version is and how it included so much from the Arcade, just a shame it was so blocky

    Though I think John O'Brien got the best out of the ASIC chip and really showed what it could do. Both his games felt like state of the art SEGA Coinup scalers