Interest in Mode 1?

Discussion in 'Discussion & Q&A' started by Pacca, Feb 16, 2018.

Thread Status:
Not open for further replies.
  1. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    Out of curiousity, I looked into the Sega CDs mode 1 and tried to implement it. I failed horrendously, but I was able to detect the presence of a Sega CD properly, which is good enough for me.

    My problem, however, is that when you boot the Sega CD in Kega Fusion alongside any revision of Sonic 2 (rev00, rev01, rev02, and my hack), the graphics mess up. Sprites become invisible, animated level art doesn't work, the menu backgrounds don't look right, etc.

    The screenshots here are from a vanilla Rev01 Sonic 2 rom, with the Sega CD booted alongside it in Kega.
    [​IMG] [​IMG]
    [​IMG]

    I was hoping to add an easter egg or something if the Sega CD was detected, but it kind of defeats the point if said hardware makes the game unplayable :confused: That said, I can only test this in Kega Fusion, as I don't have any actual hardware to test it on, and Kegas' the only emulator that supports running the Sega CD and a Cartridge at the same time (that I know of).

    S3K seems to run into trouble here as well. It seems that all uncompressed artwork is scrambled when the Sega CD is running...
    [​IMG] [​IMG]
    Sonic 1 seems to work just fine though...

    Just to clarify, I'm not actually using the Sega CD here. All the screenshots are from unmodified Sonic 2 and S3K roms.
     
    Calvin likes this.
  2. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,759
    When I created a mode 1 for Chaos Layer, I had a similar problem. Turns out, Kega doesn't perform DMA transfers from ROM correctly in this mode.

    Sonic 1 remains unaffected, because all DMA transfers in that game, are always done from RAM, never from ROM (likely due to the cartridge type at the time).
     
    Calvin, vladikcomper and Pacca like this.
  3. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    So everything should work on hardware? That's reassuring, at least. It's a shame that any easter eggs I add won't be easy to emulate without graphical issues though. Actually, are there any other emulators that support mode 1? The most recent info I've seen on mode 1 compatibility was from 2011, around the time that Sonic 1 w/Redbook Audio came out.
     
  4. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    As far as I am aware, only Kega Fusion has any sort of Boot Mode 1 support. I don't believe Genesis Plus GX has it, I know Gens certainly doesn't, MAME's own setup is a mess, and others don't have MCD support, so they can't support it. Kega Fusion's handling of it is very half-assed, and I suspect it doesn't handle some of the data remapping properly, but never sat down and ran extensive tests to confirm such. Ultimately, the only reliable way to test is on hardware, as Kega Fusion's own implementation is highly flawed.

    On the note of Mode 1, though, are there any questions you have on it? You've got the attention of one of the two that brought the thing to light for the community...
     
    Pacca and AkumaYin like this.
  5. Clownacy

    Clownacy Forever Grumpy Staff

    Joined:
    Aug 15, 2014
    Messages:
    874
    Genesis Plus GX and its derivatives (Bizhawk) do support Mode 1. I've used it to test my Hyper Sonic in Sonic 1 hack before (which uses Mode 1 for music stuff). Despite being an S1 hack, it uses DMA transfers to load Sonic's art, and it isn't affected at all.

    Unlike Kega, you enable Mode 1 not by doing CTRL+B and enabling something in the INI, but having a .cue file alongside the .bin file. Can't help but find that a little daft when your Mode 1 game doesn't use a CD, but whatever.
     
    Pacca likes this.
  6. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    @LazloPsylus I'd like to start asking how to get it actually working, but we'd probably be here all day if I did. I've been trying to follow the example code laid out here, but it's in C (a language I only recognize vaguely from my short stint with java), and I'm obviously working with assembly. Like I mentioned earlier, I managed to recreate the code to identify the Sega CD BIOS, but that's the only thing that works; it locks up at the first "Reset Sub CPU" loop (the lines in the C code are identified as "Reset the Sub-CPU, request the bus"). I fear that this may be because I can't wrap my head around the odd syntax in the C example (it uses a bitwise on two numbers, and gets a Boolean... I have no clue).

    I appreciate the offer to help me out. If you're willing to put up with me being nearly clueless in regard to dealing with anything other then 68k ram, maybe you could explain some things to me in private.

    @Clownacy I'll have to check that out! I'd obviously prefer another emulator instead of overhauling all uncompressed art loading in Sonic 2 :rolleyes:

    EDIT: Bizhawk has a VDP debugging utility that works with Sega CD games! I can directly rip Sonic CD art :D
     
    Last edited: Feb 16, 2018
  7. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    Ah, alright. Good to know. I ran some searches for Genesis Plus GX's stuff, but I couldn't find any information on its support. Glad there's something else finally.

    I guess if people are getting interested in the thing again, I can run some unit tests to flesh out compatibility.

    Pacguy, I can certainly take a look at what you have and see what I can do to straighten out what's going on. The C implementation that's floating around is a nasty mess. I might be able to dig out my old implementations in pure assembly to bring some assistance.
     
    Pacca likes this.
  8. 노베디쿠스

    노베디쿠스 Pour your misery down on me Member

    Joined:
    Aug 26, 2013
    Messages:
    919
    I, too, have been messing around with Mode 1 support for a while now. So, regarding that, how would I go about getting a data disc to work alongside the cartridge ROM when booting it up in Kega or GPGX, if at all possible?

    Also, @LazloPsylus, I would also like to take a look at your implementation of Mode 1 initialization, if you still have it. I want to see how my implementation compares to yours.
     
  9. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    As I've discovered with my assisting of Pacguy, I've misplaced most of the original implementations I've worked on with Tristan over the years. I know there was also a drive crash at one point that likely caused some of the loss as well. The assistance I've been giving him has been a combination of retrieval from an ancient SQL backup of the MD Wiki, and memory. I could pass along what I've pieced back together to you in PM, but i's probably long past time that I just write a new implementation for reference, because looking back on this ancient code, there's *a lot* of issues with it, and I'm basically correcting as I go just to get a stable implementation he can use for reference, while kicking myself for losing my better, more recent implementations (by recent, I mean more in the 2013-2014 period, as it's been awhile since I've done Mode 1 dabblings).

    The problems of having so much stuff scattered in so many places...
     
  10. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,759
    While I still had to code it myself, Lazlo supplied me with hardware manuals and some invaluable verbal assistance regarding mode 1, I don't know if this would be of any help, but I could share what little I had.

    It'll merely be setup code, and PCM sound driver code though, nothing visual or CD access (I've only done those through mode 2, and they're tied to a project I can't exactly share). But I haven't seen anyone release any PCM related work on the CD around here, so I can only assume it's not something well explored by the community, and this stuff could be invaluable.

    I have been considering releasing my entire Mega Drive related archive here on SSRG at some point anyway, and I have no use for the Mega CD stuff, I only needed it to get clean PCM vocal playback in my game without disrupting the percussion quality, but with Dual PCM, I don't really need it now... So it wouldn't be a loss to me.

    While we're on subject, might I suggest collaborating and creating a sort of "mode 1" base open source, one that sets up properly and can be used universally. Perhaps multiple sources of doing things like; accessing CD data and audio, or performing visual sample code that'll get the CD hardware to scale art, and then transfer the output to VRAM in the correct manner, or playing back PCM data. I'm talking code, with an assembler, which can be assembled there and then to produce a ROM (but written such that it cannot be simply copy/pasted if you prefer not making it too easy), and is there for demonstration purposes, for those who are interested in writing something themselves on the subject and simply need guidance. Perhaps dedicate a section of the site towards this specific element, supply manuals all in one place.

    I think there are plenty of clever people here on the board, and most of them probably only need a few small bits of information, nothing major, and perhaps some examples just to nudge them in the right direction. Bringing the Mega CD to light is a wonderful thing, but it only works if the stuff isn't tucked away hidden from everyone, where it can easily get lost.

    Might I also suggest segregating these posts into a separate thread altogether?
     
    FireRat and Pacca like this.
  11. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    Seems like I'll probably be writing a new implementation this weekend anyway, as it looks like the old demons of the ancient, bug-ridden implementation are coming out in droves, so we'll see. It'll never be a nice and easy copy and paste job, short of just handing out the disassemblies with them pre-implemented. Usually takes some personal tweaking to adapt it to work in each setup. My implementation will probably be tooled to VASM as well, so adaptation will be needed for others to use it. I'll also likely write up the base to just do CD-DA, as I can't be bothered to re-tool any PCM drivers I have available currently, or get a scaling algo arranged-for (Novedicus seems to have some familiarity in that area, so he could perhaps contribute that).

    Splitting off, I'm thinking about it. If there's still more interest in it by morning, I'll probably do it.
     
    Pacca likes this.
  12. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,759
    Cool stuffs, I'll look into a PCM playback source then in that case, and if I get time, I'll make a scaling/rotation source, I mean, It's quite simple after all, not exactly rocket science, it's just finding the time. I think as soon as we get people involved, they'll understand how simple it is in practice by comparison to how they probably believe deep down, and that's what's important, encouraging them to make that first move =3
     
    Pacca likes this.
  13. 노베디쿠스

    노베디쿠스 Pour your misery down on me Member

    Joined:
    Aug 26, 2013
    Messages:
    919
    The only PCM shit I've dealt with hands on was just related to SMPS-PCM. I am much more familiar with working with the ASIC chip in 2M mode, though.
     
    MarkeyJester likes this.
  14. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    Yeah, the ASIC chip is more what I'm talking about. PCM chip, peoples' experiences are usually limited to SMPS-PCM, as far as I've seen. And that thing is broken to all hell. If I had it in better shape, I'd toss in the Eternal Blue PCM driver I've been working on researching, but that's nowhere near close to usable, so...

    Anyway, I'll split this off in a sec.

    ~E~: Done.
     
  15. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    @Clownacy How do you get Bizhawk to open in Mode 1? I have a valid .cue/.bin file pair (a copy of Sonic CD, that Kega uses successfully in both Boot 1 and Boot 2), and I placed them next to my rom. I renamed the .cue file after my rom (my rom is s2built.bin, so its' s2built.cue). Opening s2built.bin in Bizhawk doesn't activate Boot 1 though (and I can tell, because my hack in its' current state disables all SMPS music when the Sega CD is detected).
     
  16. Clownacy

    Clownacy Forever Grumpy Staff

    Joined:
    Aug 15, 2014
    Messages:
    874
    The .cue file actually has to reference the S2 .bin file. You can open it in a text editor and see how it works. Beyond that, I'm not sure. It's been a long time since I've used that emulator for Mode 1, and if memory serves, it can be very picky.
     
  17. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    I've been experimenting with adding the line "FILE "s2built.bin" BINARY" into the .cue file. This results in either no noticeable change, or makes the file unusable (seems I accidentally made it read my rom as part of the disc itself).

    EDIT: Tried messing with REM comments too, didn't get anything to happen. Odd that I can't find anything on Mode 1 support, other then an update post saying a bug was fixed.

    EDIT2: Realized I was using an old version of Bizhawk. Current version crashes when it load my rom though :confused: Seriously considering trying to get Mode 1 working on my wii at this point...
     
    Last edited: Feb 19, 2018
  18. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    Just popping in, I've not forgotten this, and actually got a good chunk of a bare base written up already. Working on running a few checks to see if I can offload a few tasks to BIOS-provided subroutines, or just replicate those routines. Not because I couldn't do these myself, but because I'd like to rely on replication of the base boot environment for the BIOS as much as reasonably possible. Get a clean and compatible setup first, make sure that's working, and then work back on the optimizations and shortcuts from there.
     
    MarkeyJester and Pacca like this.
Thread Status:
Not open for further replies.