DDR like demo

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Nov 07, 2012 5:57 pm

Do you disable ints before enabling the sram to initialize the sram? I do it like this:

Code: Select all

read_sram:
        move.w  #0x2700,sr          /* disable ints */
        moveq   #0,d1
        moveq   #0,d0
        move.w  0xA15122,d0         /* COMM2 holds offset */
        lea     0x200000,a0
        move.b  #1,0xA15107         /* set RV */
        move.b  #3,0xA130F1         /* SRAM enabled, write protected */
        move.b  1(a0,d0.l),d1       /* read SRAM */
        move.b  #2,0xA130F1         /* SRAM disabled, write protected */
        move.b  #0,0xA15107         /* clear RV */
        move.w  d1,0xA15122         /* COMM2 holds return byte */
        move.w  #0,0xA15120         /* done */
        move.w  #0x2000,sr          /* enable ints */
        bra     main_loop

write_sram:
        move.w  #0x2700,sr          /* disable ints */
        moveq   #0,d1
        move.w  0xA15122,d1         /* COMM2 holds offset */
        lea     0x200000,a0
        move.b  #1,0xA15107         /* set RV */
        move.b  #1,0xA130F1         /* SRAM enabled, write enabled */
        move.b  d0,1(a0,d1.l)       /* write SRAM */
        move.b  #2,0xA130F1         /* SRAM disabled, write protected */
        move.b  #0,0xA15107         /* clear RV */
        move.w  #0,0xA15120         /* done */
        move.w  #0x2000,sr          /* enable ints */
        bra     main_loop
For a MD game, you don't need to worry about setting/clearing RV - that's for the 32X. You also don't NEED to worry about the write-protect bit in 0xA130F1, but it doesn't hurt anything. Most devs use 1 to enable sram, and 0 to disable it.

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Wed Nov 07, 2012 7:18 pm

No i didn't.

To be honest, i use the code you gave me here

I'll test to do like this :

Code: Select all

| extern void sram_enable(void);
    .global sram_enable
sram_enable:
    move.w  #0x2700,%sr          /* disable ints */
    move.b  #1,0xA130F1
    rts

| extern void sram_disable(void);
    .global sram_disable
sram_disable:
    move.b  #0,0xA130F1
    move.w  #0x2000,%sr          /* enable ints */
    rts
When i want to read sram, i just call sram enable function, then read sram and finally sram disable function.

Code: Select all

sram_enable();
variable = sram_rd_byte(1);
sram_disable();
This should work, right?

I'm going to test it ^^

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Nov 07, 2012 10:34 pm

I didn't see it mentioned there, but I have mentioned elsewhere that whenever you have sram and the game is over 2MB in size, you have to disable ints before reading and writing, and you have to disable the sram before you reenable ints. The sram and rom cannot coexist at 0x200000 - you have one or the other. So the routines to read/write the sram cannot be above 0x20000, you must normally have the sram disabled, and before you enable the sram you must disable ints unless you can GUARANTEE the int code and any data used by ints are below 0x200000.

So the code given before is correct, but once your game exceeds 2MB, then you have to be more careful about reading/writing sram because of that overlap at 0x200000.

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Wed Nov 07, 2012 10:55 pm

you're right, i've always in mind that using sram with rom>2Mo is spécial.

Indeed, it's logical that sram command cannot be above 0x200000, i don't even think about that...

Moreover, my demo is perfectly working on regen and gens, but not on RH nor Kega Fusion (i've just tested it)

I suppose i would have to buy an everdrive or so, since bunring eprom every time i want to do a test is really boring and time consuming...

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Nov 07, 2012 11:34 pm

Or you could post a binary here for those of us with flash carts to try it for you.

Do you know where it's hanging? This is where I'd be logging the hell out of the thing. :lol:

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Wed Nov 07, 2012 11:43 pm

You can donwload binary here

On my MD, problems (wich don't appear on emu) are:
- no choice in option (this uses sram)
- at titlescreen, when not press a button, demo should start, but on RH, it's hanging :| (this don't use sram)
- when on song selection screen, if pressing B button, we come back to titlescreen but sometimes title is corrupt
- in game, up arrows don't work (it use sram cause there's 2 configs possible)
- in game, arrow are supposed to highlight in green when you tap at the good time, but on RH, always red
- in Sonic stage, 2 arrow sprites are missing

And surely other minus things :lol:

I've just bought an everdrive MD! :lol:

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Nov 08, 2012 4:01 am

Well, for one thing your rom header doesn't indicate sram. That's been discussed on the board.

Make sure that one of the first things you do in the hardware init is turn off the sram.

And yes, that binary doesn't run on real hardware. Just a blank screen and nothing.

EDIT: I ran the rom with sram turned off and it works fine (other than no sram of course). So it's clearly something to do with sram code. It crashes after trying to run the demo.

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Thu Nov 08, 2012 9:04 am

Here is my rom_head.c file

Code: Select all

#include "types.h"


const struct
{
    char console[16];               /* Console Name (16) */
    char copyright[16];             /* Copyright Information (16) */
    char title_local[48];           /* Domestic Name (48) */
    char title_int[48];             /* Overseas Name (48) */
    char serial[16];                /* Serial Number (2, 14) */
    u16 checksum;                   /* Checksum (2) */
    char IOSupport[16];             /* I/O Support (16) */
    u32 rom_start;                  /* ROM Start Address (4) */
    u32 rom_end;                    /* ROM End Address (4) */
    u32 ram_start;                  /* Start of Backup RAM (4) */
    u32 ram_end;                    /* End of Backup RAM (4) */
    char sram_sig[2];               /* "RA" for save ram (2) */
    u16 sram_type;                  /* 0xF820 for save ram on odd bytes (2) */
    u32 sram_start;                 /* SRAM start address - normally 0x200001 (4) */
    u32 sram_end;                   /* SRAM end address - start + 2*sram_size (4) */
    char modem_support[24];         /* Modem Support (24) */
    char notes[40];                 /* Memo (40) */
    char region[16];                /* Country Support (16) */
} rom_header = {
    "SEGA MEGA DRIVE ",
    "(C)FLEMTEAM 2011",
    "Oof will 2012                                   ",
    "Oof will 2012                                   ",
    "GM 00000000-00",
    0x0000,
    "JD              ",
    0x00000000,
    0x00020000,
    0x00FF0000,
    0x0000FFFF,
    "RA",
    0xF820,
    0x00200001,
    0x002000FF,
    "                        ",
    "DEMONSTRATION PROGRAM                   ",
    "JUE             "
};
I don't remeber if i did that, maybe should i recompile sources?

First i will do a test with a single rom <2Mo + sram to write a good code for sram since i don't even know if my code is suppose to work.
Then if it's working i'll code more difficult :lol:

Thanks for your help

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Thu Nov 08, 2012 9:56 am

Ok, i've modified my sram code. Now this is working on Fusion.
Could you (or anyone) test it on RH?

new bin here

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Nov 08, 2012 5:49 pm

No worky on RH (solid blank display)... your header is also not right. The serial field is 14 long, not 16. That puts everything off two bytes in the header after that.

Also, the comments on the ram_start/end are wrong - that's the work ram start/end. SEGA allotted 2MBytes of space for work ram, and presumably, future models would have possibly had more than 64KB. The ram_start/end allows the console bios to determine if the model has enough work ram for the game. Now SEGA only ever used 64K, so those fields are always 0x00FF0000 and 0x00FFFFFF (your ram_end is wrong as well).

You need to check the header of your generated binary in a hex editor to be certain all your fields are right. Look at a proper binary to get an idea for where everything should be, then look at yours. It was pretty easy to spot where your error was just by looking at the header in a hex editor.

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Thu Nov 08, 2012 7:40 pm

Ok, i will have a closer look at this!

Thanks :)

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Thu Nov 08, 2012 8:59 pm

I don't really understand what's happening now.

Header is modified (with Bastien's help), and last version can be downloaded here

On this page, you can download a small program too wich allow to test sram on RH.

I've burned an eprom with this small program and it's working on RH.

So if you could test dance impact (there's two versions on the link above) i will be thankful... :oops:

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Nov 08, 2012 9:21 pm

Your headers are STILL wrong - you still have too long a serial field; all that changed was the value of the two extra bytes. They need to be eliminated, not cleared. It's a problem on ALL your binaries.

SRAM_TEST - bad header, but works once you force the sram settings
DI - works up until it tries to do the level demo, then explodes
DI-FS - fails with a blank screen the same as always

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Thu Nov 08, 2012 9:51 pm

I see

Code: Select all

char serial[16];                /* Serial Number (2, 14) */ 
I have 14 characters.

Code: Select all

"GM 00000000-00"
I just changed it by eliminating two extra byte as you told me

Code: Select all

"GM 000000-00"
But i don't really understand why :oops:
DI - works up until it tries to do the level demo, then explodes
This problem don't seems to be caused by sram. I will fix it later, but thanks again for your tests.
I'm waiting for my everdrive now, this will be easier for testes :lol:

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Nov 08, 2012 11:00 pm

Code: Select all

    char serial[14];                /* Serial Number (2, 14) */ 
:wink:

Post Reply