• Rise from your gwave!

2 Questions about Saturn CD functions

Discussion in 'Saturn Dev' started by legion stride, Jan 26, 2002.

  1. legion stride

    legion stride New Member

    Hi there,

    I was just wondering if there was anyone who could help me better understand the saturn's SGL CD functions. Everything else I've tried from the manuals works great (well...once you fix the typo's anyway...:)). But when I tried the CD reading sample program...the compiler said it was okay, however when I loaded it (using SSFEXE through a PAR+), it just hangs at the line:

    slCdLoadFile(cdhn, buf);

    I changed the filename to load a file on the CD, but no dice. So if anyone could help me on this, it would be great.

    Okay, wow, you're still reading huh? Heh, thanks! Now my second question is...once you've made a working '.BIN' file; How do you burn it to a CD so that it starts up like a regular saturn game?

    I burned the Phoenix Saturn Emulator ISO to CD and it was awesome how it started on its own. So I was just wondering which tools I would use. Cause I've got a few demos that I just want to try burning. But this question isn't quite as important as the first one.

    Hey, thanks just for hanging with me this long. Any help is appreciated. Okay, See ya'!!
     
  2. ExCyber

    ExCyber Staff Member

    To get a booting disc, the primary thing you need is a valid bootstrap. This is the first 16 sectors (32768 bytes) of an ISO 9660 / ECMA 168 filesystem. You should be able to just rip the first 32,768 of a good Saturn ISO and insert it into your ISO. How to do this depends on what mastering progam you're using. The standard Saturn boot code just loads the first binary on the disc to 06004000, so all you need to do for putting the files on the disc is to make sure your binary is the first file on the disc; usually naming it something like "00BOOT.BIN" (IIRC the Phoenix emulator uses "0SL.BIN") will do the trick.

    As for SGL, I think I'll defer to Takashi and Denis...
     
  3. Artemio Urbina

    Artemio Urbina New Member

    As for the bootstrap, I *think* that in the tutorial it is specified. Ifd it isn't, check the shooting example, it has the ip.bin file and all.

    About the CD functions, you need to boot from CD to use them if I remember right, Will not work from the AR as far as I remember (don't take me too seriously since I haven't coded for almost a year for the sat)
     
  4. CyberWarriorX

    CyberWarriorX New Member

    According to the psy-q devkit docs, you need to authenticate the CD first before you use it. Normally if you boot from the cd, this happens automatically. But if you upload a program using an ar+commlink, you'll need to use the following code before doing anything cd-related(stolen from sn systems' code, sorry):

    #define SYS_CDINIT1(i)

    ((**(void(**)(int))0x60002dc)(i))

    #define SYS_CDINIT2()

    ((**(void(**)(void))0x600029c)())

    int CdUnlock (void)

    {

    Sint32 ret;

    CdcStat stat;

    volatile int delay;

    SYS_CDINIT1(3);

    SYS_CDINIT2();

    do

    {

    for(delay = 100000; delay; delay--);



    ret = CDC_GetCurStat(&stat);

    } while ((ret != 0) || (CDC_STAT_STATUS(&stat) == 0xff));

    return (int) CDC_STAT_STATUS(&stat);

    }

    I've been meaning to release a couple of programs of mine using cd-reading, just haven't got around to it.

    Cyber Warrior X

    (Edited by CyberWarriorX at 1:38 am on Jan. 27, 2002)
     
  5. TakaIsSilly

    TakaIsSilly New Member

    Err... what Cyber said ^^; Except I had no idea the psy-q docs (and the solution for the problem) were available...
     
  6. ExCyber

    ExCyber Staff Member

    Would someone be kind enough to explain what that code actually does? I'm not exactly a newcomer to C, but I'm not a compiler :).
     
  7. CyberWarriorX

    CyberWarriorX New Member

    Available in general, no. But if you have the right connections, they can be acquired. ^^

    I actually found the code while looking through their extension library code.

    According to the comment at the begining of the source:

    "This function initialises the Saturn CD block causing it to read the Sega Security area. If you have a Psy-Q interface in the Saturn cart port then you must execute this function before you can use CDROM functions.

    25-May-95delay necessary in do loop else CDblock stalls."

    I hope this also answers your question too, Ex.

    Cyber Warrior X
     
  8. TakaIsSilly

    TakaIsSilly New Member

    Hnn, that delay loop also explains one of my questions, the fact that I need to do slSynch() every CD sector read.

    Also, doesn't "Sega Security area" means that it wil try and read the protection? If the person wants to load a file from a cd, that's no good, unless the system is chipped or he is forced to make a swap trick.
     
  9. legion stride

    legion stride New Member

    Thanks everyone!! It works great! :) Heh, and thanks for also explaining why it works. The data from the CD loaded fine...now I've just gotta step back and think about what I'm going to do with it, but at least when I do, I can finally make something larger than a few megs.

    Once again, thanks everyone for the awesome help!!
     
  10. ExCyber

    ExCyber Staff Member

    Nah, I wanted to know what the code actually means, primarily the couple of lines that look more like brainfuck than C :).
     
  11. CyberWarriorX

    CyberWarriorX New Member

    Taka: Yeah. From what I can understand, the drive is always locked until that area is read. Not really much you can do about that.

    Considering that a person has to go through the same thing if he burns a cd, I can't see how it's much of a loss.

    The really useful part of this code is that now people only have to burn 1 cd in order to test homebrewn cd-based programs. If they have any problems the first time around, all they have to do is upload the updated program(with the unlocking code included) to the appropriate memory address, and it should work.

    Ex: Other then what I cut and pasted, I have no idea. There might be something else in the docs, i'd have to take a look.
     
  12. legion stride

    legion stride New Member

    I was just wondering...is there ever a better time to use 'CDBUF_FUNC' instead of 'CDBUF_COPY' when setting the parameters for 'slCdLoadFile'?
     
  13. CyberWarriorX

    CyberWarriorX New Member

    Yes. When the file you're loading is larger the amount of free work ram. I would imagine it's best for streaming audio, etc. I never did get around to fittling around with it though.

    Cyber Warrior X
     
  14. legion stride

    legion stride New Member

    Ah, I gotcha

    Thank you much, you guys have helped me out alot
     

Share This Page