Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2016-10-06 16:40:33

Mills
Member
Registered: 2012-12-21
Posts: 132

GBDK and Carillon editor (awesome music player-composer)

Hi.

I ported the code from Carillon Editor/player to work with gbdk... well most of the job was made by nitro2k01 by pasting the code below smile.

UPDATE: All carillon functions are working on GBDK and also the sample player!.

Carillon Editor - ROM+Source (GBDK only)

Code:

//bank = rom bank where the song is stored
//sbank = rom bank where the samples are stored (0 = no samples)
//song = song number inside a bank (see carillon doc, song positions are fixed)
CP_LoadMusic(UINT8 bank,UINT8 sbank,int song); 
CP_UpdateMusic();
CP_StopMusic();

When a song has wave samples, it will use nearly all scanlines to play them correctly. But you'll still have some time to do basic stuff, like moving bkg or some sprites.


I also ported the code of GBS player, to gbdk, thanks to DevEd, this is working OK.

This is the working gbs player:

Deflemask2GB by DevEd - ROM+Source (GBDK)

GBS player is not very good for demos and games, because it was just made to play gbs files extracted from games, or composed with Deflemask.

Last edited by Mills (2017-03-29 11:18:03)

Offline

 

#2 2016-10-19 08:04:52

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 242

Re: GBDK and Carillon editor (awesome music player-composer)

A bunch of things wrong.

Code:

.Player_Initialize       =     0x40000
.Player_MusicStart       =     0x40030
.Player_MusicStop        =     0x40060
.Player_SongSelect       =     0x400c0
.Player_MusicUpdate      =     0x41000

There seems to be an extra zero at the end of each address which corrupts the jump to that address. It should probably be:

Code:

.Player_Initialize       =     0x4000
.Player_MusicStart       =     0x4003
.Player_MusicStop        =     0x4006
.Player_SongSelect       =     0x400c
.Player_MusicUpdate      =     0x4100

Code:

.MusicBank               =     1
.rROMB0                  =     1

.rROMB0 should probably be set to 0x2000 if it's referring to the bank switch register. This is wrong in the asm version too btw, but it doesn't really matter for a 32 kB ROM. But for any ROM bigger than 32 kB, both the GBDK and RGBDS version would fail.

Code:

        LDH     a,(.MusicBank)             ; Switch to MusicBank
        LDH     (.rROMB0),a

You shouldn't use ldh here. ldh is for accessing IO ports. Also, that's not how you load an immediate value into a register in GBDK asm. For that you need to use # if I remember correctly. What you were doing was to load data form IO register $ff01 and then writing it back to $ff01.

Code:

        LD     a,#.MusicBank             ; Switch to MusicBank
        LD     (.rROMB0),a

Code:

_CPlayer_LoadSong:
        LDH     a,(.MusicBank)             ; Switch to MusicBank
        LDH     (.rROMB0),a
        jp      .Player_MusicStart       ; Start music playing
        LDH     a,(.SongNumber)            ; Call SongSelect AFTER MusicStart!
        jp      .Player_SongSelect      ; (Not needed if SongNumber = 0)

The errors noted above, plus the following:

You're doing the trick of using jp instead of call. But you can only do that on the last call. When you're doing, jp .Player_MusicStart, that ends the _CPlayer_LoadSong routine, and the call/jump to .Player_SongSelect is never taken.

Any calls from c should make sure to preserve BC, since it may be used by the c compiler. All other registers are considered to be dispoable though. So in practice always push bc before a subroutine and pop bc at the end, unless you know for sure that b and c are not destroyed, such as is _scroll. The need to push/pop bc sadly means you can't do the jp trick either.

Something like this might work:

Code:

_CPlayer_LoadSong:
        push    bc
        LDH     a,#.MusicBank             ; Switch to MusicBank
        LDH     (.rROMB0),a
        call    .Player_MusicStart       ; Start music playing
        LDH     a,#.SongNumber            ; Call SongSelect AFTER MusicStart!
        call    .Player_SongSelect      ; (Not needed if SongNumber = 0)
        pop     bc
        ret

The push/pop bc should be done to all applicable routines called from c, not just this one of course.

That should be a good start. Not sure if there might be more problems as well. I don't have a gbdk environment set up myself so I can't check.


Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#3 2016-10-20 03:38:25

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and Carillon editor (awesome music player-composer)

nitro2k01 wrote:

That should be a good start. Not sure if there might be more problems as well. I don't have a gbdk environment set up myself so I can't check.

This is working perfect nitro2k01 smile, it compiles in gbdk without any error and it works on BGB. 

I'll now test how to use the rom number and SongNumber parameters from c, and I'll upload a commented sample.

There is also this part of the original asm code:

Code:

        SECTION "Reserved",BSS[$c7c0]

        ds      $30                     ; $c7c0 - $c7ef for player variables

I just commented that part because the player worked whithout it ,and i didn't know how to port this to gbdk.
But I understand I should not overwrite that address...  How can I tell gbdk not to overwrite that adress?


There is also a sample player in the carillon source, I might try to use it, But it requires a lot of "WaitLCDLine" functions and I don't know if it will be possible to use it with another gbdk functions.

Thanks a lot!

Offline

 

#4 2016-10-20 04:04:21

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 242

Re: GBDK and Carillon editor (awesome music player-composer)

Try:

Code:

    .area    _Playervars (ABS)
    .org    0xc7c0
    .ds    0x30

Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#5 2016-10-23 10:53:49

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and Carillon editor (awesome music player-composer)

nitro2k01 wrote:

Try:

Code:

    .area    _Playervars (ABS)
    .org    0xc7c0
    .ds    0x30

It didn't work, it showed an address overflow >=8000, if i set it to something smaller, the rom freezes.

So it is working well without that for the moment.

How can I specify the rom bank in which i want the music to be included? The original asm code has a BANK option:

Code:

 
        SECTION "Music",DATA[$4000],BANK[MusicBank]
        INCBIN "music.bin"

something like this? the bank option is not working

Code:

    
.area    _Music (ABS)
    .bank ........
    .org    0x4000
    .include "music.s"

For the moment, this is the fisrt version working very well with gbdk:
Carillon player - ROM+Source (GBDK)

Last edited by Mills (2016-10-23 10:55:30)

Offline

 

#6 2016-12-18 10:25:20

nordloef
New member
From: Sweden
Registered: 2008-03-11
Posts: 7
Website

Re: GBDK and Carillon editor (awesome music player-composer)

This is so great! Thanks for sharing, I'll see if I can get this working with my carillon tracks.


Game Boy music composer using Carillon Editor for games and demos. Check out my work HERE. Need music or sfx for your homebrew project? Feel free to drop me a line.

Offline

 

#7 2017-01-05 13:58:50

sergeeo
New member
Registered: 2017-01-05
Posts: 6

Re: GBDK and Carillon editor (awesome music player-composer)

Thanks for sharing this!

The problem is that .gbs files from Deflemask are usually huge sad

Last edited by sergeeo (2017-01-05 13:59:46)

Offline

 

#8 2017-01-05 16:41:28

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and Carillon editor (awesome music player-composer)

sergeeo wrote:

Thanks for sharing this!

The problem is that .gbs files from Deflemask are usually huge sad

gbs player is very bad.. not for games or demos, just for playback.

Offline

 

#9 2017-01-05 17:26:53

sergeeo
New member
Registered: 2017-01-05
Posts: 6

Re: GBDK and Carillon editor (awesome music player-composer)

I'm using gbtplayer for GBDK, but it lacks a couple of features I need (glissando, portamento and vibrato)... any hints?

Offline

 

#10 2017-01-15 08:52:55

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and Carillon editor (awesome music player-composer)

sergeeo wrote:

I'm using gbtplayer for GBDK, but it lacks a couple of features I need (glissando, portamento and vibrato)... any hints?

I don't know if gbt-player will be Updated.

For the moment, you can use this carillon player, it does not use any predefined effects, you just create them note by note, it is not difficult.

Last edited by Mills (2017-01-15 08:53:27)

Offline

 

#11 2017-01-15 11:01:42

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: GBDK and Carillon editor (awesome music player-composer)

Mills wrote:

sergeeo wrote:

I'm using gbtplayer for GBDK, but it lacks a couple of features I need (glissando, portamento and vibrato)... any hints?

I don't know if gbt-player will be Updated.

For the moment, you can use this carillon player, it does not use any predefined effects, you just create them note by note, it is not difficult.

I can assure you I'm not going to update the GBDK version, I only keep that version in my repository because apparently there's still people using it. It's just that it is a pain to develop anything advanced in assembly for GBDK.

Offline

 

#12 2017-03-05 17:41:44

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and Carillon editor (awesome music player-composer)

I completed the port to GBDK, now all asm functions are working, see first post.

Offline

 

#13 2017-03-06 04:36:12

MS-DOS1999
New member
Registered: 2017-02-28
Posts: 5

Re: GBDK and Carillon editor (awesome music player-composer)

Awesome, thanks !

Offline

 

#14 2017-03-26 17:21:23

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: GBDK and Carillon editor (awesome music player-composer)

Wow dude!! i always want this, thanks big_smile

Offline

 

#15 2021-06-28 13:16:58

skarab
New member
Registered: 2021-06-28
Posts: 1

Re: GBDK and Carillon editor (awesome music player-composer)

Hello Mills, I'm interested about a GBS player for GBDK, it seems you have made one but I cant find the source of it, thanks.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson