It is currently Tue Sep 18, 2018 12:07 pm

All times are UTC - 7 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Strange GBS Problem
PostPosted: Sat Feb 18, 2006 11:38 am 

Joined: Tue Sep 13, 2005 7:53 am
Posts: 98
After ripping Keep the Balance, I find myself in a strange predicament. The rip works great when converted to a gb rom (w/ gbsplay 1.02), but fails to play correctly as a GBS file itself in all of the players I have tried.

Usually when a difference like this pops up, it's a result of incorrect banks being selected. Different players do different things when selecting a bank that's not present in the GBS file. However, when I checked to see if the correct bank values were being written in the rom conversion with a debugger, I found no potential problems. All bank numbers were correct.

I was wondering if anyone here has some insight as to what could cause this to problem. Here are the files (GBS and GB ROM conversion):

Below is some information on the rip:

The game contains seven tracks, each having it's own bank. In the game, the music data banks are at 0A-10. I relocated them to 02-08 in the GBS. The game's main music routines (init/play) are in bank 0, with some auxillary routines in bank 2 (which I relocated to bank 1 for the rip).

Also, the game's actual init routine is at $307, but I relocated it to $2307 for the GBS rip, changing all necessary hardcoded addresses. More precisely, I moved $200-$83F in the ROM to $2200-$283F in the GBS. This was done to make it work with gbsplay, which needs 1024 bytes. ($0-$3FF).

The game does a lot of stack manipulation/referencing in the music routines. For example, in the init routine, the song number is read from sp+04, where sp is the vale of the stack pointer immediately after the routine is entered. I accounted for this when writing the GBS's init wrapper.

The rip's init routine is as follows:

push af
la a,01
ld (2000),a    ; in the game itself, bank 02 is used
call 4000      ; initialize sound registers
ld a,05
ld (cafa),a    ; counter for play routine - routine is called once every 5 times
ld a,01
ld (c26e),a    ; needed so play routine is carried out
pop af
add a,0a       ; song number - same as in game bank number
ld c,a         ; transfer song number to the high byte of a 16-bit register
push bc        ; needed for stack alignment
push bc        ; game's init routines reads song number from this position
ld hl,4000
push  hl       ; address read from in game's init routine
call 2307      ; game's init routine
pop hl
pop hl
pop hl
call 4026      ; set up music tempo - bank # is 01 before called

Any help/information will be greatly appreciated.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 2 guests

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