don't click here


Discussion in 'Technical Discussion' started by Bgvanbur, Apr 10, 2012.

  1. Bgvanbur


    Tech Member
    a disassembly, some small Sega CD projects
    I have hinted at my SCDTools before in previous posts and even released a few scripts individually. The SCDTools is a combination of PERL scripts along with some shell scripts. Some of the most useful are creating a Sega CD data track, converting images to Sega VDP formats, converting Sega VDP formats to images, converting wave to PCM, and decoding/encoding Sega CD Cinepak. All the scripts I have made for Sega CD development are located at:

    If you run each script you will get a full description of the script, but here is a (very) quick description of each script:

    Code (Text):
    1. scd68kdcleanup
    2.   Kind of cleans up output from 68kd (68k disassembler)
    3. scdasm
    4.   Wrapper for your favorite assembler and favorite options
    5. scdasmall
    6.   Run asmx, asm68k, and SNASM68K and verify they have the same output
    7. scdchecksum
    8.   A specific tool to make a 16 bit checksum for all but first two bytes
    9.   and put the 16 bit checksum at the first two bytes of the file.
    10.   Used for a specific homebrew game.
    11. scdcinepakencode
    12.   Encode a cinepak file
    13. scdcinepakencodeframe
    14.   Encode the image data for a cinepak frame
    15. scdget
    16.   Retreive the iso for the Sega CD in your CD-ROM
    17.   Uses dd program
    18. scdhex
    19.   Does a search and replace using hex strings (I used for Sonic CD hacking)
    20. scdimg2tile
    21.   Converts an image to Sega VDP data
    22.   Uses Perl's Image::Magick library
    23. scdimgvdppalette
    24.   TODO work in progress
    25. scdisofilefromoffset
    26.   Determines the filename from which an ISO byte index corresponds to
    27.   Uses isoinfo program
    28. scdlittle2bigword
    29.   I used this to convert cram part of savestate file the more convient endian
    30. scdmake
    31.   Used to make a Sega CD ISO
    32. scdmoviedecode
    33.   Used to decode a Cinepak for Sega file
    34. scdtile2img
    35.   Converts Sega VDP data to a PNG
    36. scdupdatebinfile
    37.   Takes a binary file and replaces it at a specified byte index in a file.
    38.   Useful for overwriting data in an ISO file.
    39. scdwav2pcm
    40.   Converts a wav file to Sega CD PCM data
    41. scdwrite
    42.   Writes Sega CD files out to a CD-R
  2. macaroni


    Great tools Bgvanbur. Thanks.

    I'm trying to use scdmake on windows.

    I get it to create the iso without any errors but the iso wont play. Freezes at Sega logo.

    When I run scdmake, 3 blank cmd windows open.

    I am thinking the problem is with the cfg file. I am just using the default cfg file.
    Or with these lines
    Code (Text):
    1. system("scdasm -v=$verbosity $ipasm $ipbin $iplst");
    Code (Text):
    1. system("scdasm -v=$verbosity $spasm $spbin $splst");
    I have tried hard coding the path
    Code (Text):
    1. system("C:\\Perl64\\bin\\scdasm -v=$verbosity $spasm $spbin $splst");
    and adding the perl command
    Code (Text):
    1. system("perl C:\\Perl64\\bin\\scdasm -v=$verbosity $spasm $spbin $splst");
    But that didn't seem to make a difference.

    This is the first time I have ever used Perl so that could be the problem.

    Any tips from anyone would be greatly appreciated. Thanks in advance.
  3. Bgvanbur


    Tech Member
    a disassembly, some small Sega CD projects
    In the SCDMAKE.CF you can add "$ipassemble = 0;" and "$spassemble = 0;" to have scdmake not assemble the IP and SP. When you do this, you need to make sure your IP.BIN and SP.BIN are updated appropriately.

    You mentioned in a PM that you wanted to use scdmake for Sonic CD. Here are the things needed to append to the SCDMAKE.CFG to be able to rebuild the Sonic CD.

    Code (Text):
    1. $ipassemble = 0;
    2. $spassemble = 0;
    4. # soniccd.isoinfo is the output of "isoinfo -l -I soniccd.iso"
    5. $isoMatch = 'soniccd.isoinfo';
    6. $isoMatchFileExtent = 0x17;
    8. # SEGA CD DEV manual says fill unused file bytes with 0xFF
    9. # but the Sega developed Sonic CD uses 0x00...
    10. $fillUnusedFileWithZero = 1;
    Here is the copy of the IP.BIN, SP.BIN, soniccd.isoinfo, and SCDMAKE.CFG I used to quickly rebuild Sonic CD. You also need to copy all of the files from the Sonic CD to the same directory. It will make an iso where the only differences are "useless" fields (such as file dates).

    Note: Sonic CD requires some files to be in a specific file locations in the ISO which is why we need the $isoMatch support.
  4. macaroni


    Thank you. It is working great.

    This line caused it to not work.
    $isoMatch = 'soniccd.isoinfo';
    But if I delete it everything seems to be working perfectly.

    And seems to be working with and without this line.
    $isoMatchFileExtent = 0x17;

    I am testing with Sonic CD but I want to be able to do with other games too. Do I need to make my own IP.BIN and SP.BIN files for each cd? How do I do that?

    Thank you very much. This tool and instructions have helped a lot.
  5. Bgvanbur


    Tech Member
    a disassembly, some small Sega CD projects
    You need to update to the latest scdmake for $isoMatch to work with a file with a .isoinfo suffix. Sorry that I forgot to mention that.

    IP is the initial program (used by the MAIN-CPU on the Genesis) and the SP is the system program (used by the SUB-CPU on the Sega CD). These are different for every game. To extract these for different CDs, you can now use the new scdextractipsp tool I just added to SCDTools!

    Sample usage:
    Code (Text):
    1. > scdextractipsp Z80ACCESS.ISO
    2. Making IP.BIN from ISO offset $00000784 with size $0000087C
    3. Making SP.BIN from ISO offset $00001000 with size $00000800
  6. theocas


    Tech Member
    I wrote a 'base' template for Sega CD development, and it includes some basic IP and SP code that you can probably work off of. I have these tools included with build scripts and all, but I haven't tested them on Windows so you're on your own there.