Sega Saturn development

A place for people with an interest in developing new shmups.
Post Reply
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Sega Saturn development

Post by mrkotfw »

I've been working on a free open source library for the Sega Saturn for about a year. Even though the project is far from complete, I would like to spark up some interest in helping me further develop a better and more robust library.

The library is pretty basic and some parts are indeed broken. I'm actually rewriting the library all together to better focus on the "VDP1" and VDP2."

Anyways, here is a few examples of what my library can do (the current code in the CVS repository may or may not have the code for some of the examples below.)

The source is there for you all to hack or add onto it! All images are running on real hardware!

Here is the CVS repository.

Image
Image
Image
Image
Yaul: An awesome open source SEGA Saturn software development kit
Style-0
Posts: 36
Joined: Wed Jan 26, 2005 5:24 pm

Post by Style-0 »

NIce work!

I gonna take a look at this when I have some time. What library have you rewritten, your own? IS there anything high level out there on the web, official? I wpuld kill myself before even thinking about writing anything completly in assembler with the goal to make somyhing more than a 2600-lookish demo on this beast . :?
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

Hi! Thanks! And to answer your questions...

Q. Is there anything high level out there on the web. Like any official library?
A. There are official Sega libraries that are illegal to use if you're not licensed.

Q. What library have you rewritten? Your own?
A. Yes, this is my own library written from scratch. This library is pretty high-level and low-level at the same time. The library that I'm rewriting is "libyaul" which is the one found in the CVS repository.
Style-0 wrote:I would kill myself before even thinking about writing anything completely in assembler with the goal to make something more than a 2600-lookish demo on this beast. :?
The library is written in SH-2 assembler and plain ol' C. You can use C to write a very complex or even simple demo/game on the Saturn.

The rewritten library will be much better than the one currently in the CVS repository.

Again, thanks for your interest in my project! I would be more than happy to explain how the some of the hardware works. You can also check out this website out. Its heaven for programmers who want to learn about the mysterious beast. :wink:
Yaul: An awesome open source SEGA Saturn software development kit
User avatar
bay
Posts: 688
Joined: Sun Feb 05, 2006 5:19 am
Location: joisey

Post by bay »

as far ive i always understood, saturn with it's dual processors is a real pita to code really well for. however, it's 2d capabilities are primo.

im definately going to check out your library, im a sucker for console development.

related yet unrelated i'm fiddling with a copynes + ram carts lately.
woop.
User avatar
the2bears
Posts: 394
Joined: Wed Jan 26, 2005 6:08 am
Location: San Carlos, CA
Contact:

Post by the2bears »

bay wrote:as far ive i always understood, saturn with it's dual processors is a real pita to code really well for. however, it's 2d capabilities are primo.
Not only that but it's incredibly hard to emulate. Piratero, I haven't checked in ages, but what's the state of the emulators?

Bill
the2bears - the indie shmup blog
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

the2bears wrote:
bay wrote:as far ive i always understood, saturn with it's dual processors is a real pita to code really well for. however, it's 2d capabilities are primo.
Not only that but it's incredibly hard to emulate. Piratero, I haven't checked in ages, but what's the state of the emulators?

Bill
Yabause and SSF are both emulators that really stand out. Both of these from what I know can run at full speed with most of the hardware already emulated.

bay, you don't actually need to use both processors to program on the Saturn. You can just use the "Master SH-2" CPU for all your work. Most of my code pretty much revolves around using only one CPU.

For those of you who are interested, use my library's source code as a base for your (future?) projects. Some of the code may or may not work. Most of the "VDP1" is really broken.

The "2D" capabilities are great, but there is one thing that makes it all pretty difficult: VRAM cycle pattern timers.

Let's just say that you need to tell the "VDP2" processor when and how many times it should access VRAM. Real pain in the ass if you ask me. If there registers aren't setup correctly (Emulators ignore these 4 registers from what I know) the normal background won't be displayed!

I should get off my lazy ass and start working on the rewritten version of "libyaul!" :roll:
Yaul: An awesome open source SEGA Saturn software development kit
User avatar
cigsthecat
Posts: 929
Joined: Wed Jan 26, 2005 12:35 am
Location: Burbank, CA

Post by cigsthecat »

Exactly what is a "library" as it pertains to programming,etc.? I've read a wikipedia page about it, but I'd be curious to hear it explained by someone actually develeoping one in more layman's terms.
User avatar
the2bears
Posts: 394
Joined: Wed Jan 26, 2005 6:08 am
Location: San Carlos, CA
Contact:

Post by the2bears »

cigsthecat wrote:Exactly what is a "library" as it pertains to programming,etc.? I've read a wikipedia page about it, but I'd be curious to hear it explained by someone actually develeoping one in more layman's terms.
I'll give a quick definition, but others can chime in too. A library, in programming terms, is a set of functionality that can be logically separated and isolated. The reasons would be for re-use. An example, albeit a small one, would be a library for vectors. This would be functionality to create, add, subtract, cross-product etc. vectors that can then be used in almost all other games you'd write. You put it in a "library" in order to have it all in one place, and to access it and reuse it.

Bill
the2bears - the indie shmup blog
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

the2bears wrote:
cigsthecat wrote:Exactly what is a "library" as it pertains to programming,etc.? I've read a wikipedia page about it, but I'd be curious to hear it explained by someone actually develeoping one in more layman's terms.
I'll give a quick definition, but others can chime in too. A library, in programming terms, is a set of functionality that can be logically separated and isolated. The reasons would be for re-use. An example, albeit a small one, would be a library for vectors. This would be functionality to create, add, subtract, cross-product etc. vectors that can then be used in almost all other games you'd write. You put it in a "library" in order to have it all in one place, and to access it and reuse it.

Bill
Well said. In other words, a library is an archive of compiled object files in one file. A library is pretty much a large list of functions that a programmer can use to help them with their project. When compiled, the library must be linked.

Example
Instead of doing this every time you want to initialize the "VDP2."

Code: Select all

*(volatile unsigned short *)0x25f80000 = 0x8000;
*(volatile unsigned short *)0x25f800f0 = 0x0707;
*(volatile unsigned short *)0x25f800f2 = 0x0707;
*(volatile unsigned short *)0x25f800f4 = 0x0707;
*(volatile unsigned short *)0x25f800f6 = 0x0707;
*(volatile unsigned short *)0x25f80020 = 0x0000;
*(volatile unsigned short *)0x25f80010 = 0xffff;
*(volatile unsigned short *)0x25f80012 = 0xffff;
*(volatile unsigned short *)0x25f80014 = 0xffff;
*(volatile unsigned short *)0x25f80016 = 0xffff;
*(volatile unsigned short *)0x25f80018 = 0xffff;
*(volatile unsigned short *)0x25f8001a = 0xffff;
*(volatile unsigned short *)0x25f8001c = 0xffff;
*(volatile unsigned short *)0x25f8001e = 0xffff;
You can simply call this function from my library:

Code: Select all

yl_vdp2_init();
That's pretty much the idea here. I just shorten the amount of work you have to do.
Last edited by mrkotfw on Thu Mar 22, 2007 10:20 pm, edited 2 times in total.
Yaul: An awesome open source SEGA Saturn software development kit
User avatar
cigsthecat
Posts: 929
Joined: Wed Jan 26, 2005 12:35 am
Location: Burbank, CA

Post by cigsthecat »

OK, I see. So is this library you're making a dll? A lot of guys write dlls for Gamemaker (that's where I learned about them). For the most part they seem to target a specific new feature they want support for. Is your project basically a dll that covers a lot of ground specifically for the Saturn?
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

cigsthecat, yes. This library is statically linked when your project is compiled. The type of library you're talking is virtually the same except it is dynamically loaded when the binary (your game) is executed. Or before hand, not sure.
Yaul: An awesome open source SEGA Saturn software development kit
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

Just a small news update. I managed to get peripherals to work the correct way. I'll be able to detect the "NiGHTs" 3D controller pretty quick.
Yaul: An awesome open source SEGA Saturn software development kit
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

Yaul: An awesome open source SEGA Saturn software development kit
Style-0
Posts: 36
Joined: Wed Jan 26, 2005 5:24 pm

Post by Style-0 »

Nice, keep going and let us know about further progress. Maybe it's time for a movable sprite, if you have succeded in interfacing with the controller :)
User avatar
mrkotfw
Posts: 170
Joined: Sun Nov 26, 2006 3:15 am
Location: California

Post by mrkotfw »

Style-0 wrote:Nice, keep going and let us know about further progress. Maybe it's time for a movable sprite, if you have succeded in interfacing with the controller :)
Thanks!
In the video, the two "normal" sprites are moving, and yeah, the controller interface is implement 100%. Its called the "SMPC" which also has "commands" that can "turn off" the M68k, Slave SH-2, the CD-drive, soft reset the Saturn, etc.

You guys can checkout a snapshot of the code here.

I can write up a simple example to display a sprite:

Code: Select all

#include <system.h>

/* There is a maximum of 512 command table entries. */
struct vdp1_cmd cmd_list[512];

static void
load_normal_sprite(int offset)
{
        struct vdp1_cmd_sup sup;

        sup.cmdcolr = VDP1_CLUT_BASE;
        sup.cmdsrca = VDP1_VRAM_BASE;
        sup.w = 16;
        sup.h = 16;

        cmd[offset].cmdctrl = SUP_CTRL_COMM_NORMAL;
        cmd[offset].cmdpmod = SUP_PMOD_COLR_MODE_1 | SUP_PMOD_ECD_DISABLE; 
        cmd[offset].pa.x = 0;
        cmd[offset].pa.y = 0;

        yl_vdp1_cmd_normal_sprite(sup, cmd);
}

int
main(void)
{
        struct smpc_peripheral_digital pad;

        yl_system_init();

        /* Load the graphics here. */

        yl_vdp1_cmd_list_start();

        /* Send the "normal sprite" to the list. */
        load_normal_sprite(0);
 
        /* Last command table sent to the list should be a "DRAW END" command. */
        yl_vdp1_cmd_link_end(cmd_list);
        /* Send the list to "VDP1 VRAM." */
        yl_vdp1_cwb_send_list(cmd_list, yl_vdp1_cmd_list_size());

        while (1) {
                yl_vdp2_vsync();

                pad = yl_smpc_per_type_digital(SMPC_PER_PORT_1);

                if (pad.status == SMPC_PER_STATUS_CONNECTED) {
                        /* Press the start button to exit to the "CD Player" screen. */
                        if ((pad.button_pressed & SMPC_PER_DGTL_START) == 0)
                                yl_bios_exec_cd_player();

                        if ((pad.button_pressed & SMPC_PER_DGTL_LEFT) == 0)
                                cmd_list[0].pa.x--;

                        if ((pad.button_pressed & SMPC_PER_DGTL_RIGHT) == 0)
                                cmd_list[0].pa.x++;
                }
        }
}
Since school just started this week, I won't be able to fix or add any new features to the library as I'll be very busy with school. I have a very long list of the things that need to be fixed and added. As far as I'm concerned, the "VDP1" is near completition.

There is a graphic tool that I'm rewriting which produces a special file format that my library can handle. It will make life much easier.
Yaul: An awesome open source SEGA Saturn software development kit
Post Reply