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 - devkitSMS questions

Reply to topic
Author Message
  • Joined: 28 Jan 2017
  • Posts: 546
  • Location: Málaga, Spain
Reply with quote
devkitSMS questions
Post Posted: Thu Aug 11, 2022 7:39 pm
[Admin note: split from https://www.smspower.org/forums/14848-SMSDevkit ]

Hi everyone!

Let's see...

I am testing MBMLib and the possibility to use both MBMLib and PSGLib, using the first if the console has FM sound, getting back to the PSG library if not.

I took a mbm file (MASTLAMP.MBM) from the moonblaster 1.4 dsk and loaded in my (current) in development new game (which should be ready for the next competition) but does not work at all. It begins playing some odd sounds and at two-three seconds the game hangs.

I have tested some other files and did not get any success.

Can someone upload a demo with a mbm file and the source code???

Some additional insights?

Thanks!!!!
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3763
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Aug 11, 2022 7:58 pm
This is the code I used to test MBMlib while wrapping it into C language, you can use it as a very simple example.
Remove the parts about the SFX if you don't need that.

#include "../SMSlib/SMSlib.h"
#include "../MBMlib/MBMlib.h"
#include "assets2banks.h"

#define theModule  example_mbm
#define theSFX     sfx_example_bin

void main (void) {

  if (SMS_GetFMAudioCapabilities())
    SMS_EnableAudio (SMS_ENABLE_AUDIO_FM_ONLY);

  MBMPlay(theModule);

  for (;;) {
    SMS_waitForVBlank();
    MBMFrame();
    MBMSFXFrame();

    unsigned char kp=SMS_getKeysPressed();

    if (kp & PORT_A_KEY_RIGHT) {
      if (MBMGetStatus())
        MBMStop();
      else
        MBMResume();
    } else if (kp & PORT_A_KEY_LEFT) {
      if (MBMGetStatus())
        MBMStop();
      else
        MBMPlay(theModule);
    } else if (kp & PORT_A_KEY_DOWN) {
      if (MBMGetStatus())
        MBMFadeOut(15);
    } else if (kp & PORT_A_KEY_UP) {
      if (MBMGetStatus())
        MBMCancelLoop();
    } else if (kp & PORT_A_KEY_1) {
      MBMSFXPlay(theSFX);
    } else if (kp & PORT_A_KEY_2) {
      if (MBMSFXGetStatus())
        MBMSFXStop();
      else
        MBMSFXPlayLoop(theSFX);
    }

  }
}
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Fri Aug 12, 2022 7:22 am
I also have a jukebox kind of demo working. If you need it I can provide you with the code.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3763
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Aug 12, 2022 8:01 am
also note that you have to page in the module asset before MBMFrame calls (as with PSGlib) but you need to do it also before MBMPlay (or MBMPlayNoRepeat) calls.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 546
  • Location: Málaga, Spain
Reply with quote
A suggestion...
Post Posted: Sun Nov 12, 2023 11:51 am
Hi!

Not mandatory.... but it would be nice if we had a function to decompress zx7 to screen.

I mean, I have SMS_loadPSGaidencompressedTiles and SMS_loadZX7compressedTiles to load tiles (this zx7 function works well, battle tested).

I would want to have the zx7 version of SMS_loadSTMcompressedTileMapatAddr.

Why? because with that function I don't need to decompress a tilemap in memory before write it in vram, avoiding the need of maintain a temporal data array in ram (needing to have the max needed size along the game), being the zx7 compressor way better than the PSG or STM ones.

Regards.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3763
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sun Nov 12, 2023 2:29 pm
eruiz00 wrote
it would be nice if we had a function to decompress zx7 to screen.


There's already a function to safely decompress zx7 compressed data to any location in VRAM, which is SMS_decompressZX7toVRAM

if you want to decompress a tilemap directly to the PNT, just use:
SMS_decompressZX7toVRAM(your_map_data_zx7, SMS_PNTAddress);
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14688
  • Location: London
Reply with quote
Post Posted: Sun Nov 12, 2023 3:14 pm
But there isn’t (?) a way to decompress a tilemap area that isn’t the full width - not that you should care, normally.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3763
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sun Nov 12, 2023 3:37 pm
Maxim wrote
But there isn’t (?) a way to decompress a tilemap area that isn’t the full width - not that you should care, normally.


There's STM compression which can decompress a map that doesn't use the full width... but yes, there's no direct way to do that with zx7 compression. You'd have to decompress your zx7 blob to RAM and then use SMS_loadTileMapArea(x,y,src,width,height) to achieve the same result.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 546
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sun Nov 12, 2023 4:15 pm
It would be great to have a tilemap área functions but with zx7, bit It was a sugestión.

Fortunately tilemaps needs way less data than tiles, and we have stm also, so this is not a Big trouble.

I love the lib as It is.

Regards.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3763
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Nov 13, 2023 9:45 am
eruiz00 wrote
It would be great to have a tilemap área functions but with zx7, bit It was a sugestión.


I don't think this is going to happen, as a tilemap area is non contiguous memory and zx7 is an LZ based compression scheme so it needs to go back to previously uncompressed data and copy that over, which would be very VERY hard to do if that data isn't contiguous.

But, as said, as long as you decompress the whole tilemap, or at least a tilemap that is 32 tiles wide (the full width) you could use

SMS_decompressZX7toVRAM(your_map_data_zx7, XYtoADDR(0,some_y));
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!