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.
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 .
UPDATE: All carillon functions are working on GBDK and also the sample player!.
Carillon Editor - ROM+Source (GBDK only)
//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
A bunch of things wrong.
.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:
.Player_Initialize = 0x4000 .Player_MusicStart = 0x4003 .Player_MusicStop = 0x4006 .Player_SongSelect = 0x400c .Player_MusicUpdate = 0x4100
.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.
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.
LD a,#.MusicBank ; Switch to MusicBank LD (.rROMB0),a
_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:
_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.
Offline
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 , 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:
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
Try:
.area _Playervars (ABS) .org 0xc7c0 .ds 0x30
Offline
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:
SECTION "Music",DATA[$4000],BANK[MusicBank] INCBIN "music.bin"
something like this? the bank option is not working
.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
This is so great! Thanks for sharing, I'll see if I can get this working with my carillon tracks.
Offline
Thanks for sharing this!
The problem is that .gbs files from Deflemask are usually huge
Last edited by sergeeo (2017-01-05 13:59:46)
Offline
sergeeo wrote:
Thanks for sharing this!
The problem is that .gbs files from Deflemask are usually huge
gbs player is very bad.. not for games or demos, just for playback.
Offline
I'm using gbtplayer for GBDK, but it lacks a couple of features I need (glissando, portamento and vibrato)... any hints?
Offline
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
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
I completed the port to GBDK, now all asm functions are working, see first post.
Offline
Awesome, thanks !
Offline
Wow dude!! i always want this, thanks
Offline
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