Nathan's Journal Help

Blogs » Nathan's Journal » G2 Bus + more demos
Thu 30 of Mar., 2006 06:48 PST

G2 Bus + more demos

Tags:  lxdream

Taking a break from the BIOS, and after some small video fixes there's a couple more (admittedly fairly basic) KOS demos that are confirmed running now. I noticed that libdream based demos appear to be having a problem with the following snippet of (dreamcast) code

void dc_snd_ram_write_wait() {
        volatile unsigned long *a05f688c = (unsigned long*)0xa05f688c;
        int i;

        for (i=0; i<0x1800; i++) {
                if (a05f688c[0] & 1) break;
        }
}

Why yes, that test _is_ backwards. For those playing along at home, the low bit of A05F688C (AKA the G2 status register) is set while the G2 bus is busy, and cleared when idle. So the above loop is actually waiting for the G2 to become busy rather than finish what it was doing. I'm not sure how this manages to actually work confused.

So... testing of the write FIFO is as follows: (Note that a "tick" here is not an exact measurement; It's roughly the time needed to poll the register and write the result back to main ram plus a half-dozen SH4 instructions).

Idle state is 0x0E (or at least, bits 1-3 were always 1 while testing). Immediately after executing a write to the G2 bus (ie to SPU ram), bit 5 is set, ie giving 0x2E. Shortly thereafter (within a couple of ticks) bit 4 is set, and bit 5 is cleared (0x1E). If there is a second write to the bus, bit 5 is set again, ie 0x3E.

At 2-3 ticks after bit 4 is set, bit 0 is set (0x1F or 0x3F). From this point, bit 4 remains high for roughly 1 tick per queued dword, and then bit 0 remains high for roughly 1.5 ticks per queued dword, eventually settling back to 0x0E.

My moderately uneducated guess is that bit 5 = data received from SH4, bit 4 = data queued, bit 0 = writing to G2 bus, but I could be wildly wrong. In any case, now to implement this...


Plasma demo (KOS)

2ndmix demo (KOS)

About me

Nathan is a full-time software engineer and part-time maintainer of several pieces of open-source software that noone has even heard of (most notably lxdream and elr). His interests include programming language design, distributed systems, emulation, Japanese, and go.