Jump to content
IGNORED

RMT for in-game music?


Cybernoid

Recommended Posts

Hi all,

 

With all this talk of RMT and music generation for the 8bit, I have tried to insert a flavor of RMT into my game JellyBeans, but am having some difficulties (and I do not know if it is even technically feasible....)

 

Here is what I have done:

 

(1) Taken the rmtplayr.a65 and translated into something that ca65 can assemble. This seems okay and it links okay.

(2) Taken a .rmt file, and stripped the header (0xffff, , ) and inserted this into the code.

(3) Tried to initialize the RMT in the game by the following:

 


 ldx #<_MODULE;low byte of RMT module to X reg

 ldy #>_MODULE;hi byte of RMT module to Y reg

 lda #0 ;starting song line 0-255 to A reg

 jsr RASTERMUSICTRACKER

 

(4) Then inserted this during the deffered VBI time:


jsr RASTERMUSICTRACKER+3

 

I thought that this might work, but all I get is some hisses and pops and random noise, than doesn't last very long.

 

Any ideas? Can I even call the "play" function during VBI time?

 

Thanks,

--C

Link to comment
Share on other sites

Hi Schmutzpuppe,

 

Thanks for the reply. Hmmm, I am using the RMT functions from 0x3080 to about 0x3770. And, I have relocated the music.rmt file (short example included with RMT) to some random address (but starts on a page boundary...).

 

However, I may not have translated it into correct ca65 assembly...

 

 

I'll investigate some more.

 

Here is my included (yet messy currently) code...

 

Thanks,

C

rmt_player_ca65.zip

Link to comment
Share on other sites

Lol, I just saw that you wanna use the music within C.

 

Yeah, I am trying to add this to my C code. I am a glutton for punishment. :roll:

 

Oh well, thanks for the help. I'll mess around with it.

 

I am actually trying to use it during Deferred VBI:

 


LDY #<vbi

 LDX #>vbi

 LDA #$07

 JSR $E45C

 

but, it still doesn't work either way...

 

 

I'll probably get flamed for trying to code in C, but you can actually get code up and running fairly quickly this way. It is completely not optimized and I have a few weird compiler bugs, but....it is usable.

 

Thanks,

--C

Link to comment
Share on other sites

The RMT player doesn't use self modifying code does it?  If not, it shouldn't be a problem to port over to ca65 I should think.  Does that .s file actually assemble?

 

Hi Shawn! Yup, the .s file does assemble with ca65 just fine. I am using our discussion from the cc65.org list to create a second segment for RMT code. Seems to all assemble/compile okay. The disassembly from the emulator shows the code as being okay.

 

I know that the music wrapper uses self-modifying code, but I am not using this. I'll check the player itself... I am also going to disassemble the code supplied by Schmutzpuppe and include that in my code...

 

I have a few more experiments yet.

Link to comment
Share on other sites

The easiest thing would be a binary include I guess.

If you take a look at my sample you just need to replace the RMT track starting at $4000 to play a new song.

If you need the player on a different address than you can compile the source delivered with rmt and just include it (and modify the init and player address of course).

Link to comment
Share on other sites

Hi all,

 

With all this talk of RMT and music generation for the 8bit, I have tried to insert a flavor of RMT into my game JellyBeans, but am having some difficulties (and I do not know if it is even technically feasible....)

 

Here is what I have done:

 

(1) Taken the rmtplayr.a65 and translated into something that ca65 can assemble.  This seems okay and it links okay.

(2) Taken a .rmt file, and stripped the header (0xffff, , ) and inserted this into the code.  

(3) Tried to initialize the RMT in the game by the following:

 


 ldx #<_MODULE;low byte of RMT module to X reg

 ldy #>_MODULE;hi byte of RMT module to Y reg

 lda #0 ;starting song line 0-255 to A reg

 jsr RASTERMUSICTRACKER

 

(4) Then inserted this during the deffered VBI time:


jsr RASTERMUSICTRACKER+3

 

I thought that this might work, but all I get is some hisses and pops and random noise, than doesn't last very long.

 

Any ideas?  Can I even call the "play" function during VBI time?

 

Thanks,

--C

 

Hi!

 

Have you seen my latest game HexxagonXE? It uses RMT for music and for sound sfx as well. Song number is called via LDA #nr -> JSR RMT_ROUTINE_START+3. Try to look into my code.

 

F.

Link to comment
Share on other sites

 

Have you seen my latest game HexxagonXE? It uses RMT for music and for sound sfx as well. Song number is called via LDA #nr -> JSR RMT_ROUTINE_START+3. Try to look into my code.

 

I have not heard of this game until now. I have found the executable, but no source...

Very cool!

 

Did you do FreecellXE as well?

Link to comment
Share on other sites

Maybe you can take a look at the attach file I took one of your songs and include it in a small asm file.

At least you can see that it works in VBI ;)

 

 

Hmmm, it seems that you cannot locate the song anywhere besides $4000. I couldn't find where the player was looking at the passed values...

 

 

The following does not work:

 

 


org $2000



 LDX #$00

 LDY #$41

 LDA #$00

 JSR $3400



LDY #<vbi

 LDX #>vbi

 LDA #$06

 JSR $E45C



loop  JMP loop

vbi  JSR $3403

   	JMP $e462

   	

;Player at $3400-END and whatever from $3000-33ff

org $3000 

ins 'cyber1'

;The Song

org $4100

ins 'cyber2'

 

 

I have tried several values.

Link to comment
Share on other sites

Hahahahahahahaha!!!!

 

 

Game music!!!!

 

 

Okay, I relocated my screen data (was at 0x4000-0x4400) and placed my RMT file at 0x4000. Lo and behold, it works.

 

Apparently, RMT only works for data at 0x4000. Now, I just need to free up more space for more music, or figure out a way to make RMT work for a different memory location...

 

:D :music: :D

 

--C

Link to comment
Share on other sites

 

Have you seen my latest game HexxagonXE? It uses RMT for music and for sound sfx as well. Song number is called via LDA #nr -> JSR RMT_ROUTINE_START+3. Try to look into my code.

 

I have not heard of this game until now. I have found the executable, but no source...

Very cool!

 

Did you do FreecellXE as well?

 

Do you mean source code of game or source code of sounds part? I can send you the first one but all sounds were done by Raster and I don't have source of it. I just merged his binaries with my code and inserted routine calls.

 

And yes, I did FreeCellXE too.

 

F.

Link to comment
Share on other sites

Okay, I relocated my screen data (was at 0x4000-0x4400) and placed my RMT file at 0x4000.  Lo and behold, it works.  

 

Apparently, RMT only works for data at 0x4000.  Now, I just need to free up more space for more music, or figure out a way to make RMT work for a different memory location...

 

RMT module file is standard Atari binary file with from-to head data, because it contains many tables of pointers (with absolute memory values, no relative values from begin of module!). If you will save the music with function "Save as.." "RMT file", module will dedicated for default address - from $4000.

 

If you want use RMT music in your program, you should use "Export as.." "RMT stripped file". Then you can specify your own needed location for your RMT module data and this data will be stripped (i.e. without any redundant bytes, names of instruments, unused song parts e.t.c.).

 

So, please, use File - Export as - RMT stripped file.

 

If you will use "RMT stripped file", you can also use "RMT FEATure definitions" for speed/size optimization of RMT player routine for this one concrete module.

Link to comment
Share on other sites

Do you mean source code of game or source code of sounds part? I can send you the first one but all sounds were done by Raster and I don't have source of it. I just merged his binaries with my code and inserted routine calls.

 

I was looking for the game source. I wanted to see how you call the RMT code. But, I think I figured out the issues. Thanks for the offer. It is no longer needed...

 

The problem WAS, I could not figure out a way to merge binaries created with xasm with binaries created with cc65. But, I do not think this is needed anymore. I have a working translated RMT module (now in assembly that ca65 can read) and the information from Raster about the stripped RMT file is very useful!

 

 

 

If you want use RMT music in your program, you should use "Export as.." "RMT stripped file". Then you can specify your own needed location for your RMT module data and this data will be stripped (i.e. without any redundant bytes, names of instruments, unused song parts e.t.c.).  

 

Ah, okay! This makes sense. I did not know about this feature. I'll take a look at using this.

 

RMT is great by the way. Great job!!! I never thought I would be able to add music to my game(s) this easily. Sure, I had some setup issues, but really it only took me a few days to get the code working. If I had tried to insert music "by scratch", I would have been in trouble.

 

There are some great tools out there for doing code on the 8-bit: RMT, G2F, CC65... not to mention that the emulators are fairly robust these days with disassembly and memory inspection features. It is certainly easier to code on the 8bit than ever before. Me happy! :D

 

--C

Link to comment
Share on other sites

Have you seen my latest game HexxagonXE? It uses RMT for music and for sound sfx as well.

 

One more question: How do you use RMT for sound fx? Do you generate a RMT track during run time, or do you have tracks pre-built and just offset into the RMT file, play the sound fx, then stop playing?

 

Just curious, sounds like an interesting feature.

 

Also, I wonder if it is possible to be playing a 3 track song, then insert sound fx into the 4th track as the game plays. This way you have background music with sfx...

 

Thanks,

C

Link to comment
Share on other sites

Have you seen my latest game HexxagonXE? It uses RMT for music and for sound sfx as well.

 

One more question: How do you use RMT for sound fx? Do you generate a RMT track during run time, or do you have tracks pre-built and just offset into the RMT file, play the sound fx, then stop playing?

 

Just curious, sounds like an interesting feature.

 

Also, I wonder if it is possible to be playing a 3 track song, then insert sound fx into the 4th track as the game plays. This way you have background music with sfx...

 

Thanks,

C

 

Every sound or music is a single RMT track and I'm always playing just one. When request for another sound come I stop current one, wait for one VBI cycle and play the next one.

 

F.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...