News: 11 March 2016 - Forum Rules

Author Topic: Ice Climber "Remastered" (100% Finished)  (Read 16724 times)

imkrut

  • Jr. Member
  • **
  • Posts: 49
    • View Profile
Re: Ice Climber "Remastered" (in progress 50+% ?)
« Reply #20 on: May 16, 2020, 12:54:56 am »
Technically, the transparency already worked, but there wasn't really a use for it, since the backgrounds were actually always in the background. :p

I've just committed a change on github that replaces the "show behind background sprites" Y/N flag with a 0 to 39 "priority" level for the background instead. The old "Y" is equivalent to 0 and the old "N" is equivalent to 10.  Foreground "backgrounds" use the 30 to 39 levels, and all backgrounds can use the PNG's alpha channel to get transparency effects, etc.  Only 1 background can be active at the same time per priority level, but that still means you can technically have 40 backgrounds active at the same time (although I'm sure performance will be pretty bad if you go that far :p)

These changes require that version "106" be set in the hires.txt file, and need the latest dev build of Mesen (you can grab it off of appveyor.)  Feel free to tinker with the new feature if you want, but keep in mind most people are not using dev builds and version 106 packs will not load on Mesen 0.9.9.

So, SourMesen, I finally got around actually doing something with the new feature, and I used it as an excuse to fiddle with the memory values, so basically got a condition anchored to the number of lives P1 or P2 has, and if greater than 0 (another value, can I compare values directly to numbers or only against other memory values? documentation seemed to imply only the first) it prints a small portrait of P1 or P2 with his name!



Pretty neat! Now I just need to get some kind of clue as to how to hook the music....

In a wishlist of features, (I think I mentioned this before) would be super cool to have MESEN load randomly an alt version of a tile if found.

kya

  • Jr. Member
  • **
  • Posts: 44
    • View Profile
Re: Ice Climber "Remastered" (100% Finished)
« Reply #21 on: May 16, 2020, 09:56:17 am »
Amazing work on TwinBee!
I am fond of your style, imkrut!

You add details so gently, that they look as if they were always there, but still bring that "early 16-bit" freshness.

Check out memoryCheckConstant conditions in Mesen, they do exactly what you want - compare memory values to constants.

mkwong98

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Ice Climber "Remastered" (in progress 50+% ?)
« Reply #22 on: May 17, 2020, 01:53:03 am »
Pretty neat! Now I just need to get some kind of clue as to how to hook the music....

https://www.mesen.ca/docs/hdpacks.html#replacing-audio-in-games

To replace the audio, you need to know when the game is sending the music start signal and the music stop signal to the sound engine of the game, then you need to stop that process and send a signal to special registers which is recognized by Mesen. The emulator will pick up that signal and play a music file instead.

You can either:
1. Hack the ROM so that when the sound engine receives a signal to start or stop music, send a signal to the special registers. 
2. Use LUA script instead of hacking the ROM. This is not the official method and the emulator doesn't run the script automatically.

Each game has its own sound engine so you have to study the game you are working on. People who create NSF file will know more about this(http://forums.nesdev.com/viewforum.php?f=6). For example SMB MEMORY MAP (http://www.romhacking.net/documents/345/) says $00fb is the RAM address of the queue for primary music. So I wrote a LUA script for replacing the first track in Super Mario Bros and it looks like this:

Code: [Select]
function playMusic(address, value)
  if value == 1 then
    emu.write(0x4105, 0, emu.memType.cpu)
    return 0
  else
    return value
  end
end

emu.addMemoryCallback(playMusic, emu.memCallbackType.cpuWrite, 0xFB)

The script listens for writes to 0xFB (addMemoryCallback), which is where the SMB sound engine picks up the track ID. Then the script calls the playMusic function to process the value of the write. When the track ID is 1, sends value 0 (the ID of the music file to be played by Mesen, matching the <bgm> tags in the hires.txt file) to special register at 0x4105 and changes the original value to 0 (silent in SMB sound engine). If the track ID is not 1, do not change the value to be written to 0xFB so that the sound engine will play that track as normal.

imkrut

  • Jr. Member
  • **
  • Posts: 49
    • View Profile
Re: Ice Climber "Remastered" (in progress 50+% ?)
« Reply #23 on: May 17, 2020, 02:31:46 am »
https://www.mesen.ca/docs/hdpacks.html#replacing-audio-in-games

To replace the audio, you need to know when the game is sending the music start signal and the music stop signal to the sound engine of the game, then you need to stop that process and send a signal to special registers which is recognized by Mesen. The emulator will pick up that signal and play a music file instead.

You can either:
1. Hack the ROM so that when the sound engine receives a signal to start or stop music, send a signal to the special registers. 
2. Use LUA script instead of hacking the ROM. This is not the official method and the emulator doesn't run the script automatically.

Each game has its own sound engine so you have to study the game you are working on. People who create NSF file will know more about this(http://forums.nesdev.com/viewforum.php?f=6). For example SMB MEMORY MAP (http://www.romhacking.net/documents/345/) says $00fb is the RAM address of the queue for primary music. So I wrote a LUA script for replacing the first track in Super Mario Bros and it looks like this:

Code: [Select]
function playMusic(address, value)
  if value == 1 then
    emu.write(0x4105, 0, emu.memType.cpu)
    return 0
  else
    return value
  end
end

emu.addMemoryCallback(playMusic, emu.memCallbackType.cpuWrite, 0xFB)

The script listens for writes to 0xFB (addMemoryCallback), which is where the SMB sound engine picks up the track ID. Then the script calls the playMusic function to process the value of the write. When the track ID is 1, sends value 0 (the ID of the music file to be played by Mesen, matching the <bgm> tags in the hires.txt file) to special register at 0x4105 and changes the original value to 0 (silent in SMB sound engine). If the track ID is not 1, do not change the value to be written to 0xFB so that the sound engine will play that track as normal.

Hey Mkwong98!!

Dang, that sounds like I'm waaaay above my head right now....I was hoping that there was an address/code inside the game that I could take note of using the built in debug functions in the emulator, or even something with the APU viewer....but I feel like it would be impossible for me to tackle this right now.

 Thanks a lot mate for all your help tho, will definitely try to look more into it and even ask on the Nesdev link you posted to see if someone is willing to explain where to start with that!

NesDraug

  • Full Member
  • ***
  • Posts: 182
    • View Profile
Re: Ice Climber "Remastered" (100% Finished)
« Reply #24 on: May 17, 2020, 04:18:08 pm »
Awesome work!

... This won't work with the 4player hack, right?

https://www.romhacking.net/hacks/4668/
Hello! You found my shop of strange and wonderful things!
https://www.tumblr.com/blog/nesdraug

imkrut

  • Jr. Member
  • **
  • Posts: 49
    • View Profile
Re: Ice Climber "Remastered" (100% Finished)
« Reply #25 on: May 17, 2020, 05:04:26 pm »
Awesome work!

... This won't work with the 4player hack, right?

https://www.romhacking.net/hacks/4668/

Haven't tried it, will look into it. Do you know if it's ok to bundle the patch with this? or how does that work?

NesDraug

  • Full Member
  • ***
  • Posts: 182
    • View Profile
Re: Ice Climber "Remastered" (100% Finished)
« Reply #26 on: May 17, 2020, 09:31:58 pm »
Haven't tried it, will look into it. Do you know if it's ok to bundle the patch with this? or how does that work?

You have to ask mishra about that. Nice fellow, even helped me when I made the Mario version of his hack.
https://www.romhacking.net/hacks/4744/
Hello! You found my shop of strange and wonderful things!
https://www.tumblr.com/blog/nesdraug

imkrut

  • Jr. Member
  • **
  • Posts: 49
    • View Profile
Re: Ice Climber "Remastered" (100% Finished)
« Reply #27 on: May 17, 2020, 09:51:57 pm »
Cool, I'll try and reach out