Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Win32API -- is anyone familiar with it?

Hey,

I am using the FMOD Ex Audio module with RPG Maker XP (script here), so that I can use looping points, start music at certain points and overall have a more smooth audio system.

However, the game tends to get a 'script is hanging' error every now and then, and all the time on my 10-year-old PC. I messed around with what the cause could be, and after removing the FmodEx and looking up 'script is hanging' information (including Zeriab's), the problem is most likely using Win32API to pop up the fmodex.dll.Is there a way to avoid the 'script is hanging error' from this? In the RGSS editor, or maybe by making the dll smaller? I don't know, I even tried adding 'Graphics.update' in between the Win32API lines, but that doesn't help either.

Here is the part that I think is mainly crashing the game sometimes:

Code:
  #--------------------------------------------------------------------------

  # * Instance Variables

  #--------------------------------------------------------------------------

  @fmod_dll = FModEx::DLL.new               # The FMOD Ex DLL

  @fmod = FModEx::System.new(@fmod_dll)     # The global System object

  @fmod_se = []                             # Array of Sound Effects

  @rtp_folder = nil                         # Name of RTP folder

  #--------------------------------------------------------------------------

  # * Get Path of RTP Folder From Registry

  #-------------------------------------------------------------------------- 

  def self.getRTPFolder

    if @rtp_folder

      return @rtp_folder

    end

    open_key = Win32API.new('advapi32.dll', 'RegOpenKeyExA', 'LPLLP', 'L')

    Graphics.update # SLD

    query_value = Win32API.new('advapi32.dll', 'RegQueryValueExA', 'LPLPPP', 'L')

    Graphics.update # SLD

    close_key = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L')

    Graphics.update # SLD

    key = 0.chr * 4

    # Open a HKEY_LOCAL_MACHINE with KEY_READ attribute and save handle in key

    open_key.call(0x80000002, 'Software\Enterbrain\RGSS\RTP', 0, 0x20019, key)

    key = @fmod_dll.unpackInt(key)

    type = 0.chr * 4

    size = 0.chr * 4

One more thing: the 'script is hanging' error only appears 1-2 times at first after saving the project. After that, I don't get the error anymore until I change something in the project again and save it. As if it has to re-load a dll or something and it takes 1-2 'script is hanging' errors to fully load it into the cache. I don't know. This doesn't count for my PC where I receive the error literally ALL the time, though.

Edit: If anyone knows the problem but fixing it will take some work, I can offer a payment for that. I've been working with Micko for a while now, but unfortunately he's not too familiar with this problem. ^^
 

Zeriab

Sponsor

I haven't personally encounter any 'Script is Hanging' errors with that script, but I can tell you that making Win32API calls freezes ALL threads which includes the seperate thread calling Graphics.update in my script. I don't know of any way to fix this with an RGSS script alone.
A possible solution could be to create a new dll which creates a native thread to do the call and then in the ruby script you can poll for updates.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top