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 - Blast Arena (fixed screen shmup)

Reply to topic Goto page 1, 2  Next
Author Message
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Blast Arena (fixed screen shmup)
Post Posted: Thu Oct 19, 2023 9:13 pm
Last edited by badcomputer on Tue Dec 05, 2023 9:11 pm; edited 3 times in total
I've been working on a little game for the past few days. DevkitSMS has been a huge help (I only know C), along with a number of articles scattered across the internet, and of course this forum.

I have a few questions that I couldn't find answers for elsewhere.

- I'm quickly running out of bytes on bank2. I'm aware I need to switch banks when needed so I'm wondering how I should be planning this? Do I need to arrange all my tiles/maps on one, music on another? What about further code?

- I seem to be hitting a strong slowdown at about 8 sprites (8x16), and I'm using the tilemap for any other static entities, but is this reasonable performance for devkit/C only? I know there's only 8 per scanline but I might need more around the edge of the playfield where scanline might not be an issue.

Thanks for any help or pointers.

------------------

Updated 5th Dec 2023:

Version 1.0 was released and can be downloaded here: https://helpcomputer.itch.io/blast-arena

Or here: https://www.smspower.org/Homebrew/BlastArena-SMS

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Fri Oct 20, 2023 6:32 am
Swapping banks for data is extremely fast so it’s not unusual to simply select the bank before using each asset.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Fri Oct 20, 2023 7:24 am
Maxim wrote
Swapping banks for data is extremely fast so it’s not unusual to simply select the bank before using each asset.


That's a relief, thank you.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Oct 20, 2023 7:56 am
badcomputer wrote
I'm quickly running out of bytes on bank2. I'm aware I need to switch banks when needed so I'm wondering how I should be planning this? Do I need to arrange all my tiles/maps on one, music on another? What about further code?


Bank switching is used when you need more than 48 KiB for your ROM - with devkitSMS you have two possibilities:
- 32 KiB for your code plus any number of 16 KiB banks for your assets (art, music, SFXs, etc...) by using asset bank switching
- any number of 16 KiB banks for your code plus any number of 16 KiB banks for your assets by using both asset and code bank switching

You probably just need the first at this stage. Look into assets2banks, it's a tool (part of devkitSMS) that automatically arranges your assets into banks which then you'll link to your code.

When loading an asset in your program, you just have to 'map' its bank before accessing it - to make sure the CPU can access it.
Example: you have your sprites palette in a file called 'Sprites_palette.bin', and you put that in your asset folder.

Then, in your code, you'll simply do:

SMS_mapROMBank(Sprites_palette_bin_bank);
SMS_loadSpritePalette(Sprites_palette_bin);
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Fri Oct 20, 2023 8:35 am
sverx wrote
snip


That's great, thanks! I think I'll try to stay within 32KB for code this time to keep things simple.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Oct 20, 2023 9:54 am
badcomputer wrote
I seem to be hitting a strong slowdown at about 8 sprites (8x16), and I'm using the tilemap for any other static entities, but is this reasonable performance for devkit/C only? I know there's only 8 per scanline but I might need more around the edge of the playfield where scanline might not be an issue


The sprite per scanline limit and the slowdown are two different and unrelated issues. The first is because the VDP (the graphic chip) has a limit on how many sprites it can render on screen at each single line, the slowdown instead depends on how much efficient your code is - but since you're using Emulicious already, try the Procedure Profiler (under Tools->Profiler) to find out where exactly you're spending your CPU cycles.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Fri Oct 20, 2023 1:21 pm
Looks neat. I really dig your art. Great choice of colors.

I’ve got one gameplay-related question, though: Are there any disadvantages to just sticking to one of the walls? That would eliminate one direction from which enemies can approach at least.
  View user's profile Send private message
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Fri Oct 20, 2023 3:43 pm
sverx wrote
since you're using Emulicious already, try the Procedure Profiler (under Tools->Profiler) to find out where exactly you're spending your CPU cycles.


This is really useful, thanks! Predictably it was mainly the enemy collisions. 8 enemies with no slowdown seems sufficient for now though, especially compared to other games, so I'll stick with it.

Kagesan wrote
Looks neat. I really dig your art. Great choice of colors.

I’ve got one gameplay-related question, though: Are there any disadvantages to just sticking to one of the walls? That would eliminate one direction from which enemies can approach at least..


Thanks! I plan to have an enemy run along the arena walls, and enemies will spawn nearby too so you'll eventually need to move around.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Fri Oct 20, 2023 8:03 pm
A small update: today I added a teleport effect to help the player see incoming enemies.

Next is to add a bigger enemy for testing and a rail enemy around the play area.

I was also playing the SMS port of Super Smash T.V. for the first time and that's a bad port!

  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Sat Oct 21, 2023 4:32 pm
I managed to add the bg tilemap back to the play stage and added a new railgunner enemy (doesn't fire yet).
ezgif.com-gif-to-mp4 (1).mp4 (399.75 KB)
GIF converted to MP4

  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Sat Oct 21, 2023 9:34 pm
This is a bit of a simple question but I can't find a better way to do it.

When the game is paused the text "PAUSED" is written to the middle of the play area (see screenshot).

This sometimes overwrites tile-based entities (as seen in the screenshot, it can be an enemy or a star etc), so what I've been doing is storing the tile types underneath where the "PAUSED" will be before I set the tilemap text, and then setting the tiles back after the game is unpaused.

I thought I would be able to use SMS_loadTileMapArea and restore the small area of my original stage play area tilemap but for that you seem to need to have the exact same tilemap size to the screen area you want to write to, unless I'm misunderstanding it?

Is there a way to restore the tiles to the play area tilemap from my original tilemap or do I have to store them myself as I'm currently doing?
output-2.png (3.44 KB)
output-2.png

  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Sun Oct 22, 2023 8:40 am
badcomputer wrote
Is there a way to restore the tiles to the play area tilemap from my original tilemap or do I have to store them myself as I'm currently doing?


I don’t think there’s another way, unless sverx has implemented something like that in the devkit, which I doubt.

One other thing caught my attention. You said you are running out of space in the first 32K of the ROM, yet the game looks like exactly the sort of simplistic fun that would have come out on a Sega Card back in the day. Is the code generated from C really so much larger than pure assembly language? You do store your assets in compressed form, don’t you?
  View user's profile Send private message
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Sun Oct 22, 2023 9:22 am
Kagesan wrote

One other thing caught my attention. You said you are running out of space in the first 32K of the ROM, yet the game looks like exactly the sort of simplistic fun that would have come out on a Sega Card back in the day. Is the code generated from C really so much larger than pure assembly language? You do store your assets in compressed form, don’t you?


No, that's my fault, I was reading the makesms output incorrectly. I have all of Bank1 completely free but I was reading it the other way around, doh!
  View user's profile Send private message Visit poster's website
  • Joined: 27 Feb 2023
  • Posts: 136
  • Location: France
Reply with quote
Post Posted: Sun Oct 22, 2023 9:29 am
badcomputer wrote
When the game is paused the text "PAUSED" is written to the middle of the play area (see screenshot).

I suppose you have already thought about using sprites ? Several games remove some sprites from the screen and then use the available slots to display the PAUSE word. You only need 5 slots. Probably 4 if you write it with a tighter spacing. Removing the ship would gain 4 slots. You might want to remove enemies on that specific line though.

But otherwise simply memorize the 6 tile numbers in RAM and put them back with SetTileAtXY.

Also you can consider using the first bank of data as well without ever bothering about having to change banks, if you really only use 1. This is 16 KB of easy to use data :)
  View user's profile Send private message
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Sun Oct 22, 2023 10:08 am
cireza wrote
badcomputer wrote
When the game is paused the text "PAUSED" is written to the middle of the play area (see screenshot).

I suppose you have already thought about using sprites ? Several games remove some sprites from the screen and then use the available slots to display the PAUSE word. You only need 5 slots. Probably 4 if you write it with a tighter spacing. Removing the ship would gain 4 slots. You might want to remove enemies on that specific line though.

But otherwise simply memorize the 6 tile numbers in RAM and put them back with SetTileAtXY.


I'm planning to fill up the sprite tiles so don't want to waste any or use another bank. It's not a big deal I guess saving the tiles myself and setting them back after unpausing.

cireza wrote
Also you can consider using the first bank of data as well without ever bothering about having to change banks, if you really only use 1. This is 16 KB of easy to use data :)


I think 48KB total is more than enough to finish the game so can avoid bank switching, it would probably fit on the first 32KB too.
  View user's profile Send private message Visit poster's website
  • Joined: 18 Jul 2020
  • Posts: 375
Reply with quote
Post Posted: Sun Oct 22, 2023 1:00 pm
badcomputer wrote
This is a bit of a simple question but I can't find a better way to do it.

When the game is paused the text "PAUSED" is written to the middle of the play area (see screenshot).

This sometimes overwrites tile-based entities (as seen in the screenshot, it can be an enemy or a star etc), so what I've been doing is storing the tile types underneath where the "PAUSED" will be before I set the tilemap text, and then setting the tiles back after the game is unpaused.

I thought I would be able to use SMS_loadTileMapArea and restore the small area of my original stage play area tilemap but for that you seem to need to have the exact same tilemap size to the screen area you want to write to, unless I'm misunderstanding it?

Is there a way to restore the tiles to the play area tilemap from my original tilemap or do I have to store them myself as I'm currently doing?


I believe you can just point to the tile index you want to start with in your asset (In a not compressed scenario):

SMS_loadTileMapArea(tileX, tileY, &tilemap_data[(starting tile index)], 6, 1);

There's also SMS_saveTileMapArea. Which is essentially what you are already doing.

SMS_saveTileMapArea(tileX, tileY, &Array, 6, 1);

Then you can recall it using SMS_loadTileMapArea.

My apologies if I misunderstood your question.
  View user's profile Send private message
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Sun Oct 22, 2023 2:25 pm
xfixium wrote

I believe you can just point to the tile index you want to start with in your asset (In a not compressed scenario):

SMS_loadTileMapArea(tileX, tileY, &tilemap_data[(starting tile index)], 6, 1);

There's also SMS_saveTileMapArea. Which is essentially what you are already doing.

SMS_saveTileMapArea(tileX, tileY, &Array, 6, 1);

Then you can recall it using SMS_loadTileMapArea.

My apologies if I misunderstood your question.


Yes you can, thanks! I've removed my own array now and are reloading tilemap areas from the one generated by assets2banks.

The only issue with that is that I have to load each row at a time, because the width of the tilemap is usually wider than the area I want to reload but the array is 1 dimensional, but that's ok.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Oct 23, 2023 7:01 am
badcomputer wrote
This sometimes overwrites tile-based entities (as seen in the screenshot, it can be an enemy or a star etc), so what I've been doing is storing the tile types underneath where the "PAUSED" will be before I set the tilemap text, and then setting the tiles back after the game is unpaused.


yes, this is the best approach - save immediately before and restore immediately after

I would use
SMS_saveTileMapArea(13, 11, my_buffer, 6, 1)
to save the 6×1 tiles area starting at (13,11) into my_buffer (which needs to be 12 bytes wide - as it's 6 unsigned ints) and after you will restore that using
SMS_loadTileMapArea(13, 11, my_buffer, 6, 1)
so it doesn't matter how you manipulated the BG from your original map :)
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Mon Oct 23, 2023 4:39 pm
sverx wrote

yes, this is the best approach - save immediately before and restore immediately after

I would use
SMS_saveTileMapArea(13, 11, my_buffer, 6, 1)
to save the 6×1 tiles area starting at (13,11) into my_buffer (which needs to be 12 bytes wide - as it's 6 unsigned ints) and after you will restore that using
SMS_loadTileMapArea(13, 11, my_buffer, 6, 1)
so it doesn't matter how you manipulated the BG from your original map :)


Thank, sverx!

Quote
Info: 29023 bytes used/32768 total [88.57%] - size of output ROM is 32 KB
Info: [bank0 0] [bank1 3745] bytes free


Getting very close to 32KB now, and still code 3-4 enemies to add. But this is an interesting challenge.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Oct 23, 2023 5:54 pm
so you're aiming for a 32 KiB ROM with no bankswitching? Nice! May I ask you if you're using compressed assets and which compression schemes did you pick in case?
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Mon Oct 23, 2023 6:23 pm
sverx wrote
so you're aiming for a 32 KiB ROM with no bankswitching? Nice! May I ask you if you're using compressed assets and which compression schemes did you pick in case?


I'm not using any compression yet, but I think I'll have to soon.

The game loop and graphics are done.

With 3700 bytes remaining (plus any from compression or other tricks) I still need:

- 3-4 new unique enemy code
- sounds
- music (hopefully 2 tracks)
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Mon Oct 23, 2023 9:37 pm
I finished the rail enemies now but bad news is only 1965 bytes are remaining. I'll probably look at compression tomorrow and think where to save more bytes.

Here's a gif of the complete rail enemies.
ezgif.com-gif-to-mp4.mp4 (559.12 KB)
GIF converted to MP4

  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Tue Oct 24, 2023 7:35 am
well, music unfortunately takes quite a lot of space... OR it's very short and simple

but I suspect much of your tilesets and tilemaps can be compressed - basically everything you don't stream directly to VRAM in vblank, so whatever you load in VRAM before the action starts

there are a few compression schemes available in devkitSMS/SMSlib - you might want to look into ZX7 for tilesets and STM for tilemaps, if you prepare them using BMP2Tile there are plugins available to export binary data directly in these formats
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Tue Oct 24, 2023 8:25 pm
sverx wrote
well, music unfortunately takes quite a lot of space... OR it's very short and simple

but I suspect much of your tilesets and tilemaps can be compressed - basically everything you don't stream directly to VRAM in vblank, so whatever you load in VRAM before the action starts

there are a few compression schemes available in devkitSMS/SMSlib - you might want to look into ZX7 for tilesets and STM for tilemaps, if you prepare them using BMP2Tile there are plugins available to export binary data directly in these formats


I used ZX7 for tilesets which gave back about 9KB! I didn't see much with STM but I only have one tilemap at screen size and a lot of it are duplicate/empty tiles.

Info: 20734 bytes used/32768 total [63.28%] - size of output ROM is 32 KB
Info: [bank0 0] [bank1 12034] bytes free

Next I'll try to add basic sounds and music and see how much space I have left for enemy code.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Oct 25, 2023 7:03 am
badcomputer wrote
I used ZX7 for tilesets which gave back about 9KB! I didn't see much with STM but I only have one tilemap at screen size and a lot of it are duplicate/empty tiles.


OK so if the STM compression didn't save much, you can use ZX7 for the tilemap too, and likely save a few more bytes also because using ZX7 for both tiles and tilemaps it means you won't need two decompressors in your code.

So try converting the tilemap too to ZX7 compressed format and decompress it directly to VRAM's PNT using
SMS_loadZX7compressedTilesatAddr(your_tilemap_zx7,SMS_PNTAddress)
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1356
  • Location: italy
Reply with quote
Post Posted: Wed Oct 25, 2023 8:39 am
sverx wrote
well, music unfortunately takes quite a lot of space...
Music can take less space (in exchange for processing time, of course) if other formats are used. This is beyond the scope of this topic, but I wonder how feasible an "smps-lib" would be, since it's a well researched format (as Maxim himself brought up just a few days ago).
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Oct 25, 2023 8:56 am
sverx wrote

So try converting the tilemap too to ZX7 compressed format and decompress it directly to VRAM's PNT using
SMS_loadZX7compressedTilesatAddr(your_tilemap_zx7,SMS_PNTAddress)


Sorry I don't get this, isn't this for tiles and not for tilemaps?
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Oct 25, 2023 9:19 am
badcomputer wrote
Sorry I don't get this, isn't this for tiles and not for tilemaps?


ZX7 is a compressed format that can be used for any byte stream, so you can use it for tiles or for tilemaps or basically for everything you want to compress. Of course then you need to decompress somewhere, and it can be RAM or Video RAM, where both tiles and tilemaps are.

edit: oh, I see now, it's because of the function name
SMS_loadZX7compressedTilesatAddr
... yes, it's misleading, I should really rename that into
SMS_loadZX7compressedDataatAddr
or similar! :(

Tom wrote
Music can take less space (in exchange for processing time, of course) if other formats are used. This is beyond the scope of this topic, but I wonder how feasible an "smps-lib" would be, since it's a well researched format (as Maxim himself brought up just a few days ago).


If there is a decent asm source I could surely try to wrap that into C and make it a library, but the problem would anyway be that you would then need some tool to either convert or create music in such format. Then of course there's the space-time tradeoff...
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1356
  • Location: italy
Reply with quote
Post Posted: Wed Oct 25, 2023 9:47 am
Many tools targeting smps exist (mainly for its 16-bit variants, though I'm sure ValleyBell and I can help fill the gaps). As I said, though, this is definitely food for another topic, I don't like to pollute other discussions.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Oct 25, 2023 11:23 am
sverx wrote

ZX7 is a compressed format that can be used for any byte stream, so you can use it for tiles or for tilemaps or basically for everything you want to compress. Of course then you need to decompress somewhere, and it can be RAM or Video RAM, where both tiles and tilemaps are.

edit: oh, I see now, it's because of the function name
SMS_loadZX7compressedTilesatAddr
... yes, it's misleading, I should really rename that into
SMS_loadZX7compressedDataatAddr
or similar! :(


Ah, no problem, that makes sense thank you!

I have another question, sorry for all the questions but this is really a practice project and I'm setting up the toolchains as I go along!

I've made a 1 note VGM in DefleMask and assets2banks is converting it without error, but I have two issues:

- it doesnt sound right, seems to be in the wrong format?
- its 197 bytes for a 1 note sound!

Should I be converting the VGM into something else before assets2banks uses it, or is the issue with DefleMask?

Attached DefleMask pattern and array for the converted sound screenshots to show.

Thanks for all the continued help by the way, I would definitely be stuck without it.

Edit: This is the way I'm playing the sound too:

PSGSFXPlay(sfx_shoot_vgm, SFX_CHANNEL2);
sfx-issue.png (27.25 KB)
sfx-issue.png

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Wed Oct 25, 2023 11:33 am
Yes, VGM files need to be converted to PSG files to use with PSGLib.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Oct 25, 2023 12:37 pm
Maxim wrote
Yes, VGM files need to be converted to PSG files to use with PSGLib.


Thanks! It seems to have converted correctly now:

const unsigned char sfx_shoot_psg[3]={
0xff,0x3d,0x00};

I've followed the steps in https://github.com/sverx/PSGlib (I didn't find this before) and it says to start by calling PSGInit but that's not in PSGlib.h so do I still need to use it?

I ask because I'm getting no sound, so not sure what else is wrong.

I'm playing the sound on channel 3 which is what I converted it with and I'm calling PSGSFXFrame every frame, not sure what else might be wrong?
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Oct 25, 2023 2:55 pm
Yes, there's no PSGInit in the C library. See the list of functions here.

Regarding the correct approach - PSGlib supports music and SFXs but there's one main difference:
- music can use all the (4) audio chip channels
- SFXs can only use the 3rd wave channel (channel '2') and/or the noise channel (channel '3')
so when you convert a VGM file into a PSG file for an SFX you have to tell the converter which channel(s) it should use picking the correct option between

-2 for channel 2 only
-3 for channel 3 (the noise channel) only
-23 for both


edit: your shot SFX file doesn't seem correct, or at least it's too short to create something audible, unless you use the
PSGSFXPlayLoop()
function to play that indefinitely...

edit2: oh, and of course you should use
, SFX_CHANNEL3);
if your SFX uses the noise channel.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Wed Oct 25, 2023 4:26 pm
It should be noted that the tracker you use to create your music and sfx can impact the size of the data considerably.

Deflemask and Furnace tend to create unusually large vgms that compress poorly into psgs. If you find yourself running out of space, look if you can achieve satisfactory results with a more simplistic tracker like Mod2Psg2 and use vibrato effects only if absolutely necessary.

I actually always use Mod2Psg2 for all my sfx, as I find it most convenient for that task and you don’t need any fancy effects for sfx anyway.
  View user's profile Send private message
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Oct 25, 2023 6:37 pm
Thanks guys. I figured out the issue.

In DefleMask I was putting my note in channel 0 and trying to play it in 2. I've attached a screenshot how it looks in DefleMask now and works fine.

Having it like this in DefleMask though does seem to export the information in channels 0 and 1 and so seems to be useless bytes? Is this the issue that Kagesan mentioned?

I tried to use mod2PSG2 but it wouldn't work on Windows10 for me. I think it needs some old DLLs. Does mod2PSG2 trim the channels it doesn't use, or is there some other way to do this?

This is what the array looks like for my one note shooting sound:

const unsigned char sfx_shoot_psg[11]={
0xcf,0x47,0xd3,0x38,0xd5,0x38,0xd7,0x38,0xdf,0x3a,0x00};
deflemaskissue.PNG (3.16 KB)
deflemaskissue.PNG

  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Oct 25, 2023 7:56 pm
badcomputer wrote
This is what the array looks like for my one note shooting sound:

const unsigned char sfx_shoot_psg[11]={
0xcf,0x47,0xd3,0x38,0xd5,0x38,0xd7,0x38,0xdf,0x3a,0x00};


If I read that correctly, this makes an audible sound for 3 frames, then there are other 3 frames of silence at the end. I think you should remove these last 3 frames by making the Deflemask file one row shorter.

Hard to say it will make much difference, especially when there's no background music yet, but it's better to remove silence from SFXs anyway.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Oct 25, 2023 8:29 pm
sverx wrote
badcomputer wrote
This is what the array looks like for my one note shooting sound:

const unsigned char sfx_shoot_psg[11]={
0xcf,0x47,0xd3,0x38,0xd5,0x38,0xd7,0x38,0xdf,0x3a,0x00};


If I read that correctly, this makes an audible sound for 3 frames, then there are other 3 frames of silence at the end. I think you should remove these last 3 frames by making the Deflemask file one row shorter.

Hard to say it will make much difference, especially when there's no background music yet, but it's better to remove silence from SFXs anyway.


It seems to be working fine by removing those 3 bytes before the zero.

I assume that DefleMask or the converter is adding the others due to the "Off" note at the end? I would expect it to just add 0x00 for that though.

Now I have a different issue. If for example I play a shooting sound on channel 2 and then an explosion plays on channel 3, for some reason the explosion isn't playing most of the time, even when I don't run any checks to stop it. I'm not sure why?

Edit: I now just skip playing the shoot sound if anything more unique is playing. I think this is the normal way to solve this?
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Oct 26, 2023 6:29 am
badcomputer wrote
It seems to be working fine by removing those 3 bytes before the zero.

I assume that DefleMask or the converter is adding the others due to the "Off" note at the end? I would expect it to just add 0x00 for that though.


The 0x00 byte is not actually from the VGM file, it's the PSG file 'end of data' marker. I think the best approach is to fix the Deflemask file rather than hex-editing the PSG file as the format supports compression. Also if you removed the 0x38 you removed the last of the three audible frames.

As for using multiple SFXs at the same time: PSGlib supports playing only one SFX at a time, regardless of the channel it uses. So if you don't want an SFX to interrupt 'more important' ones, you should implement some priority system because the library doesn't do that for you and it will just stop any currently playing SFX to play the one you trigger.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Thu Oct 26, 2023 6:48 am
badcomputer wrote
Having it like this in DefleMask though does seem to export the information in channels 0 and 1 and so seems to be useless bytes? Is this the issue that Kagesan mentioned?

Nah, I was talking about music, mainly. SFX are usually short enough, so this doesn’t really matter.


badcomputer wrote
Does mod2PSG2 trim the channels it doesn't use, or is there some other way to do this?

I don’t think any tracker does that, but the converters that turn vgms into psg files do. That’s why it’s so important to state the channels used (2, 3 or 23) when converting SFX and stating them again when calling the SFX in the game. You can mess up your music big time if you forget either.

When converting your music, I strongly suggest using Calindro's converter, as I think it has a better compression rate than sverx's (sorry, sverx). SFX are so small, there’s not a whole lot to compress anyway.

One more suggestion to think about: Since there’s apparently a lot of shooting in your game, I'd consider making the shooting silent, as the constant repetition of that sound effect could get annoying really fast and also might clog at least one of your sound channels on a way that makes putting any parts of the music there pointless. I assume there will be plenty of action with explosions and stuff, so no one will probably miss the shooting effect.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Oct 26, 2023 9:04 am
Kagesan wrote
When converting your music, I strongly suggest using Calindro's converter, as I think it has a better compression rate than sverx's (sorry, sverx).


No worries, I'm actually suggesting Calindro's PSGTool too!
(but recently I fixed my tools so now they should be on par...)
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Oct 26, 2023 9:52 am
badcomputer wrote
I tried to use mod2PSG2 but it wouldn't work on Windows10 for me. I think it needs some old DLLs.


That's old software and sometimes it's hard to make it run properly. What's the error you're getting? This might help, in case.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Thu Oct 26, 2023 11:08 am
badcomputer wrote
This is what the array looks like for my one note shooting sound:

const unsigned char sfx_shoot_psg[11]={
0xcf,0x47,0xd3,0x38,0xd5,0x38,0xd7,0x38,0xdf,0x3a,0x00};

It just occurred to me that I know where those three frames of silence originate. You see, one line in the tracker does not actually represent one frame, unless you set tempo and speed accordingly. The default for Deflemask is six frames per line, afaik, so if you create a three frame sfx, presumably in the instrument editor, you'll still always get a file with six, because you can only address multiples of the preset frames per line.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Oct 26, 2023 1:32 pm
Kagesan wrote
It just occurred to me that I know where those three frames of silence originate. You see, one line in the tracker does not actually represent one frame, unless you set tempo and speed accordingly. The default for Deflemask is six frames per line, afaik, so if you create a three frame sfx, presumably in the instrument editor, you'll still always get a file with six, because you can only address multiples of the preset frames per line.


oh, I had assumed the six frames originated from having 3 frames per line and two lines total in the file instead, but it well may be as you said :|
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Thu Oct 26, 2023 5:10 pm
Thank you both for your advice.

Hopefully I don't need to optimise the audio any further but I'll know what to do if I have to. I think I will cut the player shoot noise altogether though.

Currently at 7732 bytes free and another couple of enemies and music to add. Also need a hardcoded list of events for each level but I can scale that to fit easily.

It feels like there's plenty of bytes left, and I haven't optimised any other code yet either, but we'll see.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Fri Oct 27, 2023 11:09 pm
The powerups and controls are now complete, added a player shield pickup and a "jump" ability which has cooldown.

I have about 4500 bytes remaining (without any optimisation yet) for sound/music and couple more enemies (to fit in 32KB/Sega Card).

  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Nov 01, 2023 9:14 am
Now you can decompress ZX7 to VRAM using:
SMS_decompressZX7toVRAM()
but
SMS_loadZX7compressedTilesatAddr()
remains as an alias for the same function anyway so you don't really need to change the code.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Nov 01, 2023 12:32 pm
sverx wrote
Now you can decompress ZX7 to VRAM using:
SMS_decompressZX7toVRAM()
but
SMS_loadZX7compressedTilesatAddr()
remains as an alias for the same function anyway so you don't really need to change the code.


Thanks! I think I will eventually use tilemap compression, even with only one main tilemap. I estimate I'll save about 600-800 bytes.

Good news: I completed my first full run of the game without any issues.

Bad news: I only have about 100 bytes remaining below 32Kb and have no sound or music included yet!

I might just settle for whatever size is needed for some good sound and music.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Nov 01, 2023 3:02 pm
badcomputer wrote
Bad news: I only have about 100 bytes remaining below 32Kb and have no sound or music included yet!


There are always a few tricks that can provide a few additional bytes - but first of all we should see how much we need for music.

Then, a 48 KiB ROM doesn't need paging hardware, and padding the file to 64 KiB will make it possible to run it on the EverDrive and similar cartridges.

Above 48 KiB, you need a mapper, and your code needs to bankswitch ROM pages when loading the assets.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Nov 01, 2023 8:19 pm
sverx wrote
badcomputer wrote
Bad news: I only have about 100 bytes remaining below 32Kb and have no sound or music included yet!


There are always a few tricks that can provide a few additional bytes - but first of all we should see how much we need for music.

Then, a 48 KiB ROM doesn't need paging hardware, and padding the file to 64 KiB will make it possible to run it on the EverDrive and similar cartridges.

Above 48 KiB, you need a mapper, and your code needs to bankswitch ROM pages when loading the assets.


I think I'm just gonna use 48KB ROM and get it finished, that will be more than enough. Seems little use trying to over-optimise when it's just a learning project anyway.

Now I just need sounds and music. I've made some basic sounds in DefleMask but my attempts at making music have been poor.

Is there a free source for SMS music anywhere I can use? I'm reluctant to just approach tracker musicians and ask for free, but if anyone would like to contribute a couple of short tracks (title screen and gameplay loop) I would be grateful.

Edit: Musician in Discord has kindly offered to make some music, so all good on that for now.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Oct 2023
  • Posts: 138
Reply with quote
Post Posted: Wed Nov 01, 2023 10:52 pm
sverx wrote

Then, a 48 KiB ROM doesn't need paging hardware, and padding the file to 64 KiB will make it possible to run it on the EverDrive and similar cartridges.


How would I go about padding it to 64KB for those carts?
  View user's profile Send private message Visit poster's website
Reply to topic Goto page 1, 2  Next



Back to the top of this page

Back to SMS Power!