Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - [VGM Pack] Battleship

Reply to topic
Author Message
  • Joined: 03 May 2012
  • Posts: 55
Reply with quote
[VGM Pack] Battleship
Post Posted: Tue Jun 02, 2015 6:52 pm
Last edited by Doommaster1994 on Tue Jun 02, 2015 7:30 pm; edited 1 time in total
http://www.smspower.org/Music/Battleship-GG

This game is basically a port of the NES game, including the music.

Gil Espeche told me he just ported the NES music to the Game Gear. Since both, he and Mark Knight aren't credited in the game, I listed both of them.

Also, a little interesting fact about the game:
Nicolas "Speed Racer" (Gaume) apparently got that name when he was visiting Mindscape in the USA and got a speeding ticket.
  View user's profile Send private message
  • Joined: 15 Sep 2009
  • Posts: 377
Reply with quote
Post Posted: Tue Jun 02, 2015 7:24 pm
This one was an interesting and challenging game to hack.
At first - thanks to sherpa for his "Location Hack" that made it trivial to find the PlaySong routine.

The game is interesting in that way, that all 3 melody channels always play at a constant volume. Starting/stopping notes is entirely done by setting the frequency of the channels to 0 or nonzero.
This introduces various artifacts when starting new songs from silence, because it sets the volume registers while loading the song, but the frequency registers are updated in the next frame interrupt. So it can play leftover frequencies for up to a full frame.
Also, it seems that NOT clearing the sound RAM completely can affect the beginning of the songs.

So, due to various reasons, the music trigger hack got a bit more complicated than I expected.

Anyway, here are my notes for the music trigger hack:
PlaySong:       275A
VInt:           1DF0
UpdateSequence: 2788
UpdateTracks:   2A74

1EC3    CD 74 2A    CALL    2A74h
->
1EC3    CD 3B 00    CALL    003Bh       ; check music trigger


002A    80 00       DB       80h, 00h   ; PSG Channel 0 frequency = 0
002C    A0 00       DB      0A0h, 00h   ; PSG Channel 1 frequency = 0
002E    C0 00       DB      0C0h, 00h   ; PSG Channel 2 frequency = 0
0030    9F BF DF FF DB       9Fh, 0BFh, 0DFh, 0FFh  ; PSG channel 0-3 volume = 0Fh (silence)

003B    CD 74 2A    CALL    2A74h       ; call UpdateTracks
003E    21 F0 DF    LD      HL, 0DFF0h  ; HL = Music Trigger
0041    7E          LD      A, (HL)
0042    B7          OR      A
0043    C8          RET     Z           ; ID 00 = do nothing
0044    36 00       LD      (HL), 00h   ; reset trigger byte
0046    FA 4d 00    JP      M, 004Dh    ; negative - stop music
0049    3D          DEC     A           ; 1-based index -> 0-based index
004A    C3 5A 27    JP      275Ah       ; Play Music

    ; stop music and clear track memory
004D    21 32 C4    LD      HL, 0C432h  ; HL = Sound RAM
0050    11 33 C4    LD      DE, 0C433h
0053    01 50 00    LD      BC, 0050h   ; clear 51h bytes (C432-C480)
0056    36 00       LD      (HL), 00h   ; reset trigger byte
0058    ED B0       LDIR
005A    CD 22 2B    CALL    2B22h       ; call InitSoundRAM
    ; silence PSG chip
005D    21 2A 00    LD      HL, 002Ah
0060    01 7F 0A    LD      BC, 0A7Fh   ; B = 0Ah (10 bytes to write), C = 7Fh (PSG port)
0063    ED B3       OTIR
0065    C9          RET

; Note: I can't use "JP 290Bh" to mute the PSG chip, because that only sets the volume to 0Fh.
;       But when a song is loaded, volume is set to 02h. So it will play the previous frequencies for 1 frame.
;       Setting the frequency to 0 for all channels works around that.

The music trigger is at DFF0. (Unfortunately there wasn't space for it in the sound RAM at C432-C480.)
Value 00 does nothing, 01-06 plays songs 00-05, 80-FF stops the music.

Note: The Pause Mode control byte is at C480.
A value of 00 skips the sound update. Loading a song sets this to 01.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Nov 2014
  • Posts: 365
Reply with quote
Post Posted: Wed Jun 03, 2015 12:09 am
Thanks for this. I love seeing this kind of detail. It's the kind of stuff I love reading about here at smspower, sadly sometimes in shorter supply than I'd like. I had no idea this kind of thing could seriously be an issue. There are issues with some games where the note doesn't drop to 0001 when the song ends, it keeps the value of the last note. Is that a similar issue?

I'll have to study this a bit closer and keep an eye out for other games affected by this. I suspect Arcade Classics might have the same or similar issue.

On a side note, that particular location hack came from Calindro. I'm usually loathe to accept or ascribe credit save where appropriate, but while I did most of the vast majority of work on that page, some have come from other sources, or even SGCs for a minority of the games.

I intentionally formatted that page not to consider the contributor, as I actually consider that unimportant. What's important is that the knowledge base is available for exploitation by interested parties, not necessarily exclusive to logging vgms or accessing music. The downside of that page, is that because of its focus on limiting the text litter as much as possible, important information such as music ids (not triggers) and the playsound, updatesound functions aren't explicitely listed. One of the reasons I prefer a pause hack besides the control, is that it explicitely lists the PlaySound function, making it to easier to find similar values in other locations. I originally intended to write a tutorial covnerting between the different types, but that has fallen away to more pressing and relevant concerns.

I definitely don't want anyone thinking it is "my" page. It's always been open for anyone to edit. It just tends to be that I am the major contributor, and I believe to date, all edits are mine :)

But anyone's invited.
  View user's profile Send private message
  • Joined: 03 May 2012
  • Posts: 55
Reply with quote
Post Posted: Wed Jun 03, 2015 12:11 am
Hey, sherpa. When will you be back on the chat? I needed to talk to you about a couple things. Thanks.
  View user's profile Send private message
  • Joined: 14 Apr 2013
  • Posts: 624
Reply with quote
Post Posted: Wed Jun 03, 2015 4:24 pm
Actually it was pretty easy finding the playSound function for this game.

Approaches similar to this one should help figuring out other games as well:
Calindro wrote
I checked the functions called by the VBLANK handler and found out that the updateSound function starts from $2788 and uses $c480 to determine whether sound is playing or not. So I setup a write watchpoint for $c480 with condition value > 0 and with the tracer enabled waited for it to trigger.
This revealed that the playSound function starts at $275a and takes the song id as parameter in A.
The song id for the menu song is loaded using xor a so it won't help you much for logging but the song id for the first level is loaded from $de.

I've written more messages like this but I'm not sure where to post them so people will find them when they need them. Always feel free to ask for info on a specific game until I know where to post the info. :)
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Wed Jun 03, 2015 6:23 pm
You can add this kind of thing to game pages in the development section. If the page doesn't exist, add it to the list in http://www.smspower.org/Development/Software-Index using the name of the main page and then click to create it.
  View user's profile Send private message Visit poster's website
  • Joined: 14 Apr 2013
  • Posts: 624
Reply with quote
Post Posted: Thu Jun 04, 2015 8:21 pm
Maxim wrote
You can add this kind of thing to game pages in the development section. If the page doesn't exist, add it to the list in http://www.smspower.org/Development/Software-Index using the name of the main page and then click to create it.

But they are just messages so they don't really follow any format appropriate for the wiki... can I maybe just add quotes there?
On the other hand I wonder if people interested in logging a certain title actually check the development pages for existing info?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Thu Jun 04, 2015 11:37 pm
Some games just have one line notes about small things that someone else may find useful on a technical level. The idea is that someone hacking the game might check there to see if anything was already done. Maybe not obvious if you're trying to rip the music but it's better linked than a forum post...
  View user's profile Send private message Visit poster's website
  • Joined: 28 Nov 2014
  • Posts: 365
Reply with quote
Post Posted: Thu Jun 04, 2015 11:48 pm
I usually do peek around the Development forum when I'm curious if anyone has posted something interesting about a game I'm working on. Sometimes I find I just replicated work needlessly when it was already available. Sometimes what I am looking for is hidden in a years' old forum post. I tend not to dig as much as I should. Early on, I'd even forget to check if there was a code posted for the game I was working on.

I tend to post my info in the music forum since that's whay 90% of my work revolves around, but even little things like the fact a game uses the r register for random encounters is interesting and useful to have available.

There probably is no one single location to find things.

The search bar can be an ally if you use it.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14740
  • Location: London
Reply with quote
Post Posted: Fri Jun 05, 2015 7:50 am
It's fine to post about a music pack hack on the forum thread for the pack, the context is good even if it's not keeping everything in one place. It's always good to check for a development page, music thread and PAR codes when you're hacking on a game. It's harder to find stuff in the forum because it's split up over time. Ideally we'd use the development page as an index linking to other stuff, especially the forum, but that's quite a task. There's plenty of interesting forum threads for individual games that deserve to be linked up, but it's hours of work to make those links...
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!