Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - .SDSCtag and .SMSheader

Reply to topic
Author Message
  • Joined: 01 Feb 2014
  • Posts: 536
Reply with quote
.SDSCtag and .SMSheader
Post Posted: Mon Sep 07, 2020 12:50 pm
In older versions of WLA-DX, if you didn't define .SMSheader and only used .SDSCtag, WLA-DX would automatically place the 'TMR SEGA' string, set the region to 4 (export SMS) and the romsize to 32 KB (regardless of actual size) then calculate the checksum for the first 32 KB minus the header. This was very convenient.

Now it seems to calculate romsize automatically. Does anyone know if it also calculates the correct checksum? The documentation still says that .computesmschecksum (which is invoked by .SDSCtag) only uses the range from $0000 - $7fef. Is that true? In that case it would be impossible to get a formally correct checksum for any ROM that's not 32 KB by using .SDSCtag alone.

Which would make .SMSheader a quasi-compulsive directive. Of course it's possible to just define .SMSheader, but I suspect it could lead to conflicts with .SDSCtag, if the two directives calculate their checksums from different ranges. It also means you can't define a smaller than real romsize deliberately to speed up the boot process.

Additionally, defining .SMSheader prevents you from placing something useful in the two unused bytes following the 'TMR SEGA' string (I like to put my callHL there).

Can someone shed a light on the exact workings of the two directives? Does one override the other?
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13347
  • Location: London
Reply with quote
Post Posted: Mon Sep 07, 2020 6:37 pm
I think it calculates the checksum correctly, and SDSCTAG implies a default SMSTAG, but you can supply a non-default as you wish.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 536
Reply with quote
Post Posted: Tue Sep 08, 2020 7:57 am
The question is: Does it calculate the checksum from the romsize specified in the header or from the actual size of the ROM? I think I'll run a few tests later this week to verify. I'll report back when I'm done.

However, another thing is definitely wrong: If not explicitly specified in SMSHEADER, the upper nibble of the byte at $7FFF defaults to 0, which is an invalid value for region information. In older versions of WLA-DX the default value used to be 4 (= export SMS), which it should be, as it's the only value any of the BIOSes actually checks for.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13347
  • Location: London
Reply with quote
Post Posted: Tue Sep 08, 2020 8:43 am
I feel partially responsible as I requested the feature, but I didn’t test all the possibilities. It should be easy enough to fix.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 536
Reply with quote
Post Posted: Thu Sep 10, 2020 4:37 pm
In older versions of WLA-DX, the region-and-romsize byte at $7fff always defaults to $4C, and the checksum is calculated from $0000 to $7fef.

I ran a few tests with the current version, and these are the results:

- If no SMSHEADER is defined at all and only SDSCTAG is used, the checksum is still calculated as if for a 32 KB rom, but the region and romsize both default to 0, resulting in an invalid region nibble and a mismatch between romsize and checksum.

- If SMSHEADER is used, but romsize is not defined, it defaults to $c, and the checksum is calculated accordingly, but if region is not defined in the header, it still defaults to 0, which is an invalid value.

- If SMSHEADER is used and romsize is defined, the checksum is calculated according to the romsize defined. If the defined romsize is bigger than the actual ROM, there's an error message and the checksum is not calculated. It defaults to zero instead.


tl;dr: You absolutely must use SMSHEADER and at the very least define a value for region if you want a valid header.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2734
Reply with quote
Post Posted: Thu Sep 10, 2020 9:00 pm
it's a bug and hopefully will be fixed soon...

meantime - yes, you have to define that explicitly.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 536
Reply with quote
Post Posted: Sun Sep 20, 2020 10:24 am
It's fixed now.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!