A very tiny init for Mega Drive games

Discussion in 'Showroom Archive' started by Kaz, Oct 16, 2016.

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

    Kaz Well-Known Member Member

    Joined:
    Nov 2, 2013
    Messages:
    66
    Warning: Appears to work on TMSS consoles only due to directly writing SEGA to the VDP instead of using the safe routine, as someone on IRC warned me.

    This tiny init code packs in the usual startup code and data found in the Sega Genesis games and shoves it into the header, while keeping it under 400 bytes and sacrificing useful bells and whistles (checksum, error vectors [if you wish to use Flamewing's error debugger, this header is not for you!], I/O header, etc). I adapted and tested it in two Sonic games and they work quite well. Do not use this init if you do not know what you are doing and your game is not fully crash-free. Because the initialization data is in the header [INIT_VALS], do not enable any feature that autofixes the checksum. This also means removing fixheader from your build scripts. Remember, I only intended this as proof of concept, not for general use.

    http://pastebin.com/SWB8wgrD

    My original version sacrifices the titles and the region flags as well, to free up more space.
    http://pastebin.com/dvTZiNZd
     
    Last edited: Oct 16, 2016
    Misinko likes this.
  2. LazloPsylus

    LazloPsylus The Railgun Member

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    Fun idea, and good for you that you pushed yourself to do this, as it is cool to try and squeeze things to their absolute smallest just to say you have. The sacrifice of most all of the vector table makes for very bad things when any of the unhandled exceptions are triggered, though. Also triggers some panics from not having certain other items. 32x and MCD will *not* like that header at all, so please, for anyone thinking about using this, know exactly what the hell you're doing, because this is a very fragile thing.
     
    Pacca, Misinko and Soldaten like this.
  3. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    I didn't want to rain on your parade, but late last year, I took on a similar task:

    http://pastebin.com/KXpmQxQp

    This one handles TMSS correctly, as well as setting everything up (Z80, CRAM, VRAM, VSRAM, PSG, etc), and comes complete with a checksum check, all kept within exactly $100 bytes of the vector table (this means the other $100 bytes of the header/information table remains untampered with.

    Who knows, maybe you could improve on it further, and make it smaller?
     
    AkumaYin and vladikcomper like this.
Thread Status:
Not open for further replies.