vgmrips

The forum about vgm files
It is currently 2022-05-18, 21:27:13

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: GEMS
PostPosted: 2022-05-06, 17:03:55 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
this audio driver GEMS have 4 banks - Sequences, Samples, Instruments and Envelopes. so you cant to edit sequence inside it. change one note to another - probalby you can, but add some new notes or new track into some melody... it will destroy all order. so it first needed to unpack to separate slots, then edit something, then pack back to banks.

GEMS: limitations.
this banks lave a limited slots. 127 for instruments, 95 for samples, 127 for envelopes and 127 for sequences. (samples can be only 95 because they calls by this way: set instrument for samples playing, then number note and that notes can be from $0 to $5F - 95). but some games need a much more samples - like MK3. they do a little mod for driver. usual driver GEMS have 4 banks and this types of instruments:
0 - FM type
1 - DAC (samples)
2 - PSG tone
3 - PSG noise
for that MK3 (same for WWF Arcade how it names...) they do additional Sequenses and Samples banks. and add new type - 4 type of instruments. it is same DAC, but just system knows it should select sample not from first banks, but second samples bank. some games have more, than 127 sequences. this is can be depend from 2 or 3 bytes offsets, that use driver.

samples. samples cant be larger than 65kb (65535 - two bytes $FFFF). they are usual 8 bit mono PCM samples. and can have different frequencys from 10.4khz to 5.2khz (same moded MK3 driver can have 6.5khz + 4bit DPCM samples). samples can be played only one. no any multisampling (exept same MK3 - it can play 2 samples, but cost of it - 6.5khz, not 10.4 as top quality of last version of GEMS. older GEMS versions - cant play this quality too. only some... 7.3 probably, like Zombie eat my neighbors). so it means when you try to start second sample, when still plays first one - it will interrupt playing old one and start play new one. if they have same priority. if different priority - for example first sample have bigger priority it will play until end, only then start play second one. or even not start second play at all. that priority sets inside of sequences. setting frequency can happen by two ways: first one setting by instrument setting, where 4 param is: get frequency flag from every sample header, 5 to $A - setting quality from 10.4 to 5.2 for every samples. second one - that sample's header. so it means physicaly it can be same one sample, but can have 2 headers with two different frequency flag and play different sound.

envelopes. envelopes have a bug. first part - it cant be more, than 4 envelopes at once (because driver have 128bytes buffer and per 32bytes per one envelope). if it will be 5 of them - it will hung system. second one - envelope cant have more than 9 "steps". one step is 3 bytes - counter (1b) and value (2b).

sequences. it can have up to 16 tracks. no any types order. channels getting happen by types of instruments and priority. first track can be samples, second PS tone, third FM... and etc. it have dynamic allocations channels. if FM type and PSG tone can be played at any free FM and PSG channels of real chips - samples can be played only with 6th channel of YM2612. noise PSG - only with 4th channel of SN76489. and when instrument will use special mode for 3channel - it can play only on 3th channel of YM2612 (sound of sonic tank for Dune the Battle for Arrakis for example).

volume. it set inside sequences and work only with FM instruments. samples and PSG is not obey that setting. and it have two variants - mastervolume - for all FM tracks of all sequences - some kind of global thing, or volume - for only one track of this song or sfx. if you want to change volume for PSG - you will need to create new PSG instrument with lower Attack and Systain param. and set that instrument for this part of track, where you need lower volume for PSG.

bpm - can be from 40 to... 295 probably (into 255 it is sure, but for 295 - dont remember sure). it sets by tempo command for track and "sfx" flag set 150bpm for sfx tracks. i mean sfx need "sfx" flag insted tempo.

*topic under work.


Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-06, 17:52:25 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
example for mod music in a game:
to get that GEMS inside of game - you will need find a place, where that banks lays. for this case can help GEMSScan by ValleyBell and you can get it here on a forum. it will make copy of banks and driver near rom file. but it can find not every time... and sometimes can find only driver, or even no driver too.
some arhive here, on forum: https://drive.google.com/file/d/0B5CSxr ... sp=sharing
some arhive here: https://drive.google.com/file/d/1bZhKsL ... sp=sharing
some addresses here:
http://elektropage.ru/forum/7-68-3#2624 (you need to press some spoiler button for reveal addresses - to make copy of banks from roms by manualy)

when you have banks - you need to unpack it. r57shell is make some combaine-splitter programm for that. it will create up to 127 folders, with 000-127 names... or like Comix Zone - 218 have. inside of that folders will lay data of each slot of Sequencys. with sequence, samples, envelopes and instruments. and sequence file will be as text file to easy understand this data. for this example you can see Aero Acrobat 2 game. and it is probably 2 bytes GEMS. for split 3bytes just need to add "3" into command line of bat file. change this one:
Code:
gems_split.exe "Aero the Acro-Bat 2 (U) [!] - 01 Instuments.bin" "Aero the Acro-Bat 2 (U) [!] - 02 Envelopes.bin" "Aero the Acro-Bat 2 (U) [!] - 03 Sequences.bin" "Aero the Acro-Bat 2 (U) [!] - 04 Samples.bin" game.cfg
pause

into this:
Code:
gems_split.exe "Aero the Acro-Bat 2 (U) [!] - 01 Instuments.bin" "Aero the Acro-Bat 2 (U) [!] - 02 Envelopes.bin" "Aero the Acro-Bat 2 (U) [!] - 03 Sequences.bin" "Aero the Acro-Bat 2 (U) [!] - 04 Samples.bin" game.cfg 3
pause


Attachments:
vgmripsGEMSarh01.zip [1.38 MiB]
Downloaded 7 times


Last edited by SeregaZ on 2022-05-11, 20:58:42, edited 1 time in total.
Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-06, 18:21:24 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
so with that splitter and combaine you can unpack and pack GEMS banks. to build - just start bat file game_gems_combine.bat (it will be compiled 2 bytes version. for 3bytes need to change gems_combine2b.exe inside bat file into gems_combine3b.exe)

it will work for most games. but sometimes GEMS was moded and this way is not work. as i say MK3 - additional banks and type of instrument, Zero Tolerance - it have only melodies inside sequences bank. but sfx calls from another place - special table. and partially Comix Zone - because it have ADPCM instead usual PCM. and etc cases.

for test you can use r57shell's rom builder. some jukebox. it have same folders with a data. i think you can easy understand what you should do to hear aero acrobat's sound from previous archive.
https://www.romhacking.net/forum/index. ... ic=16519.0

but it is only "unpack" case, right? but we need change sound in a original game. so... we can unpack, we can pack, we can test sound... and left only one case. you need to find place, where is lays addresses of banks inside a game. usual it is 4 bytes value - offset to bank. i am know only wrong way :) open game with hex editor. open, for example samples bank with hex editor. copy hex values from samples... first 2 lines per 16bytes. should be enough (exept cases, where samples bank have empty sound slots. it will have 000000000 at begining if file and we didnt find what we need).
Image

ok. we have 001D0470 addresses. then we need a place where this addresses and another banks, that you will find by same way - lays near each other. but we have a luck and game have only one place with this value 001D0470 look more close into that area. it should have all 3 another addresses - sequences, envelopes and instruments. and probably this is it:
Image
where which addresses, i am hope - you will know by your self. i mean which sequences, where envelopes and etc.


Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-06, 18:50:00 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
so you have moded banks, with changed melodies. we have addresses where should lays thems addresses. next can be brake all our hopes :) i can explain it with MK3. it is big game and take all 4 megabytes, that Sega Genesis can do. and problem is banks lays at the middle of a rom:
some data and code
gems banks
some data and code

if you know how - you can move data from the end of rom into up. but most of us - no have idea about it.
some data and code
some data and code
gems banks

for this case Zombie Eat My Neigbors - ideal game :) it have GEMS banks at the end of rom. no need to move anything. just write new banks into original place and no problem. with MK3 if you will write data into end of rom - it will exceed 4mb and all our hopes will dead (only custom emulator can play that rom over 4mb).

but we have luck again - Acrobat 2 only 2 megabytes rom. and we can easy to write new banks into end of rom. so for that we need ASM68K.EXE and make asm file for it. let it be "newacro.asm" and have this data:
Code:
   org $0
   incbin "Aero the Acro-Bat 2 (U) [!].bin" ; write into new rom file original one

   samplesaddress:
      incbin    "samples.bin" ; add into new rom file, after original rom - new samples bank

   sequencesaddress:
      incbin    "sequences.bin" ; add into new rom file, after original rom and samples bank - new sequences bank

   envelopesaddress:
      incbin    "envelopes.bin" ; add envelopes bank into end of current file - new rom file.

   instrumentsaddress:
      incbin    "patches.bin" ; add inst bank

   ; now we have file with original rom + 4 new banks at the end of rom.
   ; lets set new addresses into place, where original addresses was
   org $2EC4 ; jump into place, where addresses of samples was set before
   dc.l samplesaddress ; dc.l - say to ASM68K.EXE it should 4 bytes.
                  ; and "samplesaddress" will write addresses, that we remember when write banks here above

   org $2ECA
   dc.l sequencesaddress ; here and later can be mixed up.
                ; i am didnt check exactly this is sequences or envelope or instr. check you own

   org $2ED0
   dc.l envelopesaddress

   org $2ED6
   dc.l instrumentsaddress

*important! this ASM68K.EXE is ugly piece of shit! super glitched program, but it is only one we have. it need always some space before text. space or tab.
Code:
   org $2ED6 ; right
org $2ED6 ; wrong


next we need a bat file, that will call ASM68K.EXE and set for it our asm file. let it be "start.bat" file. with this text:
Code:
ASM68K.EXE /p  newacro.asm,NEW_Arcobat2.bin
pause

*important! you remember ASM68K.EXE is piece of shit? so "newacro.asm,NEW_Arcobat2.bin" should be without space.

pause here - to read any errors, that can be when ASM68K.EXE will try to compiled it. so start that bat file and you probably will get new version of Arcobat 2 with new sound :) start it with emulator and check.


Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-06, 19:00:21 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
to understand more deep about banks structure - you can get code from github. but it is PureBasic. i am hope programmer can easy understand what happen here :) i am add images for much easy explanations. and, dont remember sure, probably playing sound too - with external dll (it was remake ValleyBells GEMSPlay into dll by one my comrade - to attach that dll into my project. i am put it everywhere :)).
https://github.com/SeregaZ2004/GEMSReader
https://github.com/infval/GEMSPlay

all that operation above can be done with "one click" my software, with online GEMS database. maybe later will add this info more.


Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-07, 12:31:58 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
GEMS Online Database:
i am fix some old bugs... but not test too hard :) so some glitch can still alive.

so idea is: create some folder, put into it a game, what you need. before check Sega retro https://segaretro.org/GEMS it is sure GEMS or not. copy into that folder my program. start it. set path to emulator. then set path to rom file. and probably before you will need to update database of addresses... by button "online update addresses database". probably it will already have all addresses what you need. and then you can press "load". it will show at right window - all slots of GEMS banks. if database no have your game - get banks from arhives from post above. put rom and that banks into "address finder" folder. and start that finder. probably it will find what it need. then move rom to back. and press load. it will unpack slots. probably :)

remember - it will not work with moded games like ZT, MK3, WWF Arcade how it names... maybe Comix Zone and Ooze. and maybe another games... i remember woolfenstain have some "wrong" samples. and some Paws Furry... or like that. with that games can be problem too. it need more investigation what exactly it was moded.

remember part two, from creator remember part one:... when i write this phrase i am forgot what i want to say... ah! it will make some shit-hacks. as i say before about MK3 - it have:
data code from begining
gems banks
data code from ends

for this my GEMS switcher need to move that end's data into place, where was GEMS before:
data code from begining
data code from ends
new gems banks

but it will need a lot of work and knowledge to safely move data (change a billions addresses and offsets). so now it write new banks just to end of rom. it is waste a lot of space. but works. but only if you didnt exceed 4mb limit.

https://www.youtube.com/watch?v=5RfFL-vKORU


Attachments:
MultiGEMSDATABASE02.zip [973.85 KiB]
Downloaded 7 times


Last edited by SeregaZ on 2022-05-11, 21:00:19, edited 1 time in total.
Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-07, 12:36:40 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
for special cases ZT and MK3 i am make special version of GEMSSwitcher... but ZT is russian rom file and icon-images. it will need a little work to replace it into standart english images. but my proud is - it is first russian language sound hack :))) before was only text hacks. so with this manager you can translate sound into your local languages. if it will be interest - i am upload it too.


Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-12, 19:56:38 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
MIDI2GEMS:
actually... it is MIDI 2 Deflemask 2 GEMS (GEMS and can be RRR too... i mean Sound Images 1.2).

converter have some pack of midi like instruments, but they are not very well... but we have that we have. idea was make one-click software, but it was a little dificult :) too many nuances. why it need some third party soft - Deflemask? well... my GEMS tracker probably will never be finished. no have any inspiration for it. i am always say: i am not a programmer i am just manager, who collects ideas and make some mix of it. so it is not a final, ready to eat programm - it is just pack of ideas, what should be in this type of software. so my tracker is not very userfriendly and i have no skill to make same interface as Deflemask have. only far far far from Deflemask :) my will be too woodly software. so that is why i am no have inspiration to finish that, because i am already know my skills and see that programm in my head - too woodly. so that is why i am set Deflemask as middle part for converting. tracker's options of Deflemask is nice for that case and can help to fix any problem's places after converting. and no one is restrict to you use not a midi, but Deflemask from begining and make some songs directly in it, and then convert melodies into GEMS. and by my fault it is comes too into longbuild case - driver of Rock n Roll Racing was changed into GEMS and Alianger make a nice covers for that romhack. i am just need to convert it into the game... but! Alianger is a crazy man - he use all Deflemask's features that is exist! his covers have a millions effects... some slides, pedals, echoes, and etc thing. convert all of that is too dificult for me. i am like stright notes. with it no any problem :) works 1 in 1. but with effects... my variants sounds as drunk cats... i have no any formulas of that effects. only blind imaginations.

converter have urls with youtube video about explanations how to work with midi - selecting channels, mixing channels, selecting volumes, transport, select melody's size and etc thing, that i think should be here. and now new "d" version have only two small changes - when you select folder for GEMS - it want to get .cfg file, not as folder before. another one - it will cut midi file into 127 full notes, if midi too long. i am set 1 Deflemask's pattern = 1 full note length. so when it is too big melodie - it cut end of melodie. and show message about it. converter was made for GEMS switcher with GEMS online database. just need to set path into one of that millions folder and convert. that process i am show at the end of some another video (above)... probably Bloodshot.

converting into RRR - works, but need a special rom builder. it is no free access. i am no have permision to share it. and result not very well too... as far i am remember - some effects is didnt finished too. and bpm recount work wrong. i have same bpm for Billy Idol song and Final Countdown of Europe covers of Alianger - but after converter - driver play them with different bpm :) so one song play fine, another too slow. final result of converting of RRR have comments in a file. so it can be used for study driver by your own, if you interest what commands what means. if GEMS will make sequence file and instruments and modulation and samples - as separate files, but RRR will make one .asm file. it will have already have instrument's settings at the header. and that driver is bored by two things: it is not used PSG and size of full melody can be only up to 3kb! and when plays Larry's samples - melody is interrupt. Ti is make some changes into that driver. it was two ways of hack: samples of Larry not interrupt songs, but it have only 3kb per song (it some not documental things of cpu). and second way - songs can be up to 32kb, but Larry will interrupt songs, as original driver do (that is why RRR converter have $8000 switcher). but with changing driver RRR into GEMS - tyres scratch sound have some cliping :( i am didnt fix it whatever i am do. probably it need to edit code itself, where is call that sound. maybe it need just pause between recalls more bigger, than it is. idk. i am not a romhacker :)

do not rush to blame that Deflemask... yes, it is not a free program and ValleyBell not give a blessing for this tracker... but earlier it was free. and that legacy version still free and works fine and can be downloaded. it just no updates anymore. it have some glitches, but works fine. and main thing what it should do - it do. so... and second one: actually you no need that Deflemask to make convert from MIDI 2 Deflemask. just ignore that error, where system cant launch dmf file after convert, set that converted file in a window - bottom part of program and convert into GEMS's folder, what you need. but i think better to fix problems after converting inside of Deflemask and convert file only after it. for example you can change instrument to your own. because, as i am say before - presets is not very well (most of them send me MaliceX :) and i am still use them)... or change some notes, or volumes. many what it can be fixed.


Attachments:
MIDI2Deflemask04d.zip [883.12 KiB]
Downloaded 7 times
Top
 Profile  
 
 Post subject:
PostPosted: 2022-05-14, 18:35:38 
Offline

Joined: 2015-08-08, 13:56:52
Posts: 88
this post should be removed after The789Guy will download attach


Attachments:
Player.zip [64.68 KiB]
Downloaded 9 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
[ Time : 0.034s | 16 Queries | GZIP : On ]