don't click here

Splitscreen and Water Question

Discussion in 'General Sonic Discussion' started by Vague Rant, May 16, 2003.

  1. Vague Rant

    Vague Rant

    Deceptively cute Oldbie
    Hey all. I was just wondering, what is it about water levels that makes them unable to be played in splitscreen? I can guess that the water system would screw up (players ending up underwater when they're not supposed to be), but I was just wondering if it's really anything so serious. Would a save state hack get you into a water stage in splitscreen? How about if you hacked a save state to play in splitscreen and removed the water, too? Would that work? Thanks.

    [EDIT]Hey, I'm Alpha Prime! I sound like a Transformer, now![/EDIT]
     
  2. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    I don't know if water can be removed, but here's the principle on how water works.

    There's a palette of 64 colors total that the Genesis may ever use at any given time. There are no natural transluency effects built in to the graphics processor, and it's be far too slow to hack something like that in software.

    So how was the water effect accomplished?

    Leaving out interlaced modes and more intricate facets on the matter, the screen is redrawn via the CRT gun, effectively an electronic beam that sweeps the area of the screen from the upper-left to the lower-right, follwing horizontal lines. At the end of every horizontal line, the gun seeks back to the left side of the next line and continues to draw until it reaches the the lower-right, where it returns to the starting position. This is called "vertical blank". "Horizontal blank" would be when it reaches the end of one horizontal line and goes to the next one.

    So anyway, you set up an interrupt process (that is, something that can be called by the CPU to halt all other processes and be handled immediately and quickly) that waits for a particular row on the vertical scan period, probably on the horizontal blank interrupt of the Genesis. When it reaches a certain line (which will change depending on your Y location within the level), it will suddenly change from the normal level 64 color palette to an alternate "water" palette for the level. This hardware hack will enable a virtual 128 colors, 64 above the water line, and 64 below. The palette is reset on the vertical blank interrupt to the normal colors so when the scangun begins again the palette is correct for above the water line.

    [​IMG]


    Now, the Genesis hardware also has no natural support for scaling. So the 2-Player split screen required a different sort of hack. I don't fully understand how this one works, but it pretty much is a hack that prevents either even or odd horizontal lines from being drawn, skipping over them and basically drawing the screen twice with only have the lines.

    To answer your question, what can basically be assumed is that either one of two conditions occur:

    A) The hack to cut the scanlines (which is again done by horizontal blank monitoring) somehow prohibits the scanline position monitoring hack. (Not always an even/odd line?)

    B) It's too much load for the system! If you slow the Genesis down extremely in a water area where the water line is visible, you will often notice a "flicker" of the water temporarily engulfing the whole screen. This is due to the processor load making the system run too slowly to be able to set the palette quickly to the state required.

    EDIT: Updated image links. This is a good post. :P
     
  3. Vague Rant

    Vague Rant

    Deceptively cute Oldbie
    You're officially the smartest person I know. And you make sense, too. Anyway, I downloaded a save state from Sonic 2 Final a while back, I think it was from someone around here, but I can't be sure. Anyway, I'm putting it up on my site now... Done. You can get it here. Stupid geocities. Right-click and pick Save Target As... if it doesn't't work. Of course, it's a hack, and it said so on the site, and yes, it's rather screwy, but quit complaining. The reason I'm mentioning it is that the water isn't here. While this could just be a side effect of the hack, or the fact that it's being loaded over a deleted Hidden Palace Zone's data, but I just thought I should point it out. If there's a good reason why the water is gone, perhaps it could be done in S2B, and therefore loaded in splitscreen. Is it possible? Sorry if I'm beating a dead horse, it just has me intrigued (that and I want to play HPZ with my brother ;))
     
  4. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    Thanks :D

    *gets savestate*
    Yowch! Actually, if you run that in Gens, you'll find you goofed up something rather harshly. :P One of the music patches is bent out of shape, and there's this horrible flickering which I suppose is malfunctioning water. ;)

    Although you may not be too far off on your idea; manually replacing the level data, palette, and music index in a savestate really ought to do the trick to get you into 2Player Hidden Palace... at least theoretically. The only thing major thing is, I never figured out how to copy floor solid data correctly, so I always ended up with floors that had bad solids. :/

    If water is the only thing stopping the 2Player mechanism from loading HPZ, then really wouldn't Esrael's Sonic 2 Delta hack (for the final version) plus another hacking guide (assuming they document level properties like water) be all we need?
     
  5. LocalH

    LocalH

    roxoring your soxors Tech Member
    2P mode isn't a hack. The Genesis has two interlace modes, one that's more akin to a line-doubler, and the other gives a true resolution increase. However, tiles in the 2nd interlace mode are 8x16 rather than 8x8, so mappings are different, among other things. I'm thinking that running two player objects probably precluded the use of water simply due to lack of CPU time.

    The interlacing that the Genesis does is identical to the interlacing you see every day on NTSC/PAL, and is done in hardware. To the software, interlace mode 2 is just a 320x448 screen instead of 320x224.
     
  6. LocalH

    LocalH

    roxoring your soxors Tech Member
    Also, some other ruminations I recently had on how 2P might be implemented, and thus may explain why 2P water doesn't work. Keep in mind I am not referencing this to the actual code, and am merely speculating based on my observations of the screen layout in 2P.

    There are two playfields onscreen in interlace 2. If you look at the game while it's running in 2P mode, you'll notice there are a few blank rows of pixels inbetween the two playfields - I would presume this is where the game sets up the VSRAM and the horizontal scroll table for the lower playfield. It's logical that the Sonic object would run in the bottom half of the screen, and the Tails object in the top half, so that all necessary values (object positions, VSRAM, horizontal scrolling, etc) can be correct and ready to send to the VDP.

    Water is done via a raster IRQ that changes the palette to simulate the effects of water on the surroundings. However, there are actually two palette changes - one at the top of the water, and another one in the vertical blank to change the palette back to normal. Well, to implement 2P water, you'd need a total of *four* IRQs - one to set the water level of the top playfield, one to reset the palette inbetween the playfields, one to set the water level of the bottom playfield, and one to reset the palette before the next frame. I would also think that the object routines would run on an IRQ, so as to ensure them running 50/60 times per second. My guess is that the problem with water is due to the water IRQs interrupting the player object IRQs and at best causing the water to go all to hell, at worst totally fucking the whole code up.

    If anyone has actually studied the code and can refute anything I said above, please do.
     
  7. DDRKhat

    DDRKhat

    Keep on runnin' to the finish! Member
    Also I've found another reason that might be possible, if Sonic is underwater and Tails is not, Sonic hits a box which switches there places, what would happen to Tails? would Tails drown or not? plus Tails would still run at normal speed instead of having his speed reduced
     
  8. TechSonic

    TechSonic

    Member
    381
    0
    0
    You all seem to have fun finding glitches a lot.
     
  9. DDRKhat

    DDRKhat

    Keep on runnin' to the finish! Member
    We arn't finding glitches we're just debuting the 2p no water theory, why isn't this possible? ;)