Just Beginner's Notes

Just Beginner's Notes

Alright. So I've been looking into Saturn dev again since I got home for the summer, and have myself a modification chip ordered for the Saturn.

But I am wondering about the best place to start. I'd love to begin understanding nearly everything about the Saturn possible, but...

Quite frankly, I've been reading through this documentation for a long time, and I can only say that I might be taking in about 65% of what I'm reading -- the SGL manuals are a bit easier, the SBL manuals are difficult, and trying to understand use of the SCU and SMPC directly is blowing my mind (I only have a very small background in understanding basic concepts of computing processes like interrupts, vector tables, etc).

I did recently rediscover some knowledge of make (which is always useful) and read through the GNU linker ld manuals and understand them mostly, which is quite useful as I now have some idea of the physical arrangement of memory in the Saturn programs.

But there's still a ton of stuff I don't know, and I haven't actually began programming anything yet. Use of the SGL seems somewhat simple (it remains to be seen, but it displays nowhere near the difficulty of, for example, the SBL). Using the SBL, I don't even know how to initialize the Saturn to save my life (the first manual regarding SCU and SMPC setup blows my mind).

Is this to be expected? Certainly people have said that 1) the documentation is hard to understand, 2) the documentation is especially hard to understand for someone relatively new to the hardware level of system programming, and 3) the documentation is even sometimes obfuscating essential information or just plain wrong.

I figure the best I can do is to begin using the SGL once I get my Saturn ready, but still...I'd like to be able to _understand_ what's happening under that thing.

In particular, I find the SCU and SMPC portions of the System Library User's Manual v1.0 to be especially hard to understand. In addtion, perhaps due to my not yet complete knowledge of C, much of the information in the SBL headers I find somewhat difficult. Has something to do with volatile void typecasts...at least, I think they're typecasts...when I run into those again I'll post a question or two about it.

At any rate, I doubt anybody here can solve all of my problems. But if you guys have any recommendation on where to start, I'd appreciate it.

PS: Unfortunately using a commslink-type or freewing interface doesn't seem practical for me as I have no clue how to build or find them, so I'd pretty much be stuck with just emulators and burning disks for the Saturn itself.
 
Just Beginner's Notes

I'm not sure what to tell you about where to start, but regarding your C confusion:

"volatile" is a subtle beast, but it mostly means "don't optimize this". It's used when a routine or location won't behave "normally" from the perspective of the program. For example, registers and ports often won't retain their contents between reads/writes, and sometimes just the act of reading or writing the register will trigger some action. In cases like this it's important that the compiler do exactly what your program says rather than treating it like a normal memory address (in which case the optimizer might alter the order of reads/writes or eliminate some completely in order to make the program faster).

"void" is essentially an undefined data type. As far as I know it can only be used for pointers and in function prototypes/declarations for functions that do not have a return value. In the case of pointers it is used to point to addresses that don't necessarily correspond to any particular data type.
 
Just Beginner's Notes

New question then: what exactly are those typecasts flying around in SEGA_SYS.H of the SBL6.0 include directory? That file is blowing my mind. It looks like it's full of macros to write values to memory, but I can't make much sense of it.

One particular line is:

#define SYS_CHKMPEG(_dummy_) \

( ( **(volatile Sint32(**) (Sint32) ) 0x6000274) (_dummy_))

What exactly is that with the double asterisks? It looks like it's casting the memory value at the hex location to Sint32 to 'volatile Sint32(**)', and then putting more double asterisks on it. A typecast of a typecast? And I'd imagine that define involves writing _dummy_ to that location, but I don't understand how -- the syntax of that define is completely unfamiliar to me.

Also, the "volatile void" thing I mentioned is also present in that file. If anybody could clear this up for me I'd much appreciate it.
 
Just Beginner's Notes

The macro performs a vectored function call, or a pointer to a function pointer. In other words, the memory location 0x6000274 contains the address of a function. That function takes one argument of type Sint32 and returns one Sint32.

Function pointers are one of C's most difficult-to-decipher constructs, but the cdecl program may help you understand them (and other declarations too).
 
Just Beginner's Notes

Function pointers...okay. Didn't think of that one...

What exactly is the cdecl program?
 
Just Beginner's Notes

cdecl converts between written descriptions and C type declarations or casts. It also has an "explain" mode which does the reverse. It's included in most *nix distributions and available on Windows through Cygwin.
 
Just Beginner's Notes

Is it a program or a library? I don't see it in Cygwin's package install lists. I'll keep looking though.

EDIT: Looks like a shell program that I don't have in my current install.
 
Back
Top