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.

Win32 API / Optimization

DJ

Some guy that did RMXP before
Member

I saw many scripts that use Win32API but I don't know where to find information about this stuff
while i think i can do something to enhance my game with it.

I want to know about Win32API : such as Tutorial, List of commands,General methods of use.

Also I want some tips for optimization which are :

1. Is there any way to activate multi-core support for RMXP or any other RMs?
2. Is there any way to change graphic rendering engine? (Such as SDL or DirectDraw Based ones.)

Help plz :-/
 
All right, so I'll start with the most basic bit. WIn32API is an old part of Ruby that was marked as deprecated by the time Ruby 1.9 rolled around, and (I believe) removed by the time 2.0 rolled around. You can find some basic documentation on it here. It's a really small class, and I'd recommend reading the bit on it in the Pragmatic Programmer's Guide. (You'll need to scroll down a bit.) It basically amounts to an interface between Ruby and compiled .dll files.

As for your first question, about multi-core support: The short answer is an emphatic no. Now, even if RPG maker itself supported multi-core processing (which could effectively be done if and only if you rewrote and replaced Game.exe), you couldn't extend that support to Ruby. The reason behind that is that Ruby does a lot of weird things behind the scenes involving active memory and processing, and muti-core processing would require rewriting the base code for the entire language. Which, while it has been done, it has never been done in full, meaning that you would get a version of Ruby even more gimped than the one provided by RPG maker.

For your second question, I would like to forward you to this project. Now, that basically did the only thing you can do, which was use the RM* window as a launchpad for an entirely different application. Basically, he was running an entirely different 3D application and making it display through the RM* window. That's really the only way you can do it.
 

DJ

Some guy that did RMXP before
Member

Glitchfinder":1jozsxze said:
All right, so I'll start with the most basic bit. WIn32API is an old part of Ruby that was marked as deprecated by the time Ruby 1.9 rolled around, and (I believe) removed by the time 2.0 rolled around. You can find some basic documentation on it here. It's a really small class, and I'd recommend reading the bit on it in the Pragmatic Programmer's Guide. (You'll need to scroll down a bit.) It basically amounts to an interface between Ruby and compiled .dll files.

As for your first question, about multi-core support: The short answer is an emphatic no. Now, even if RPG maker itself supported multi-core processing (which could effectively be done if and only if you rewrote and replaced Game.exe), you couldn't extend that support to Ruby. The reason behind that is that Ruby does a lot of weird things behind the scenes involving active memory and processing, and muti-core processing would require rewriting the base code for the entire language. Which, while it has been done, it has never been done in full, meaning that you would get a version of Ruby even more gimped than the one provided by RPG maker.

For your second question, I would like to forward you to this project. Now, that basically did the only thing you can do, which was use the RM* window as a launchpad for an entirely different application. Basically, he was running an entirely different 3D application and making it display through the RM* window. That's really the only way you can do it.

Thanks very much for the reply, but I have more questions. I think i know methods, but the real problem is what args* i could put in.
I can't find stuff about that, such as :

Code:
module ScreenChanger

  begin

    @@kbe = Win32API.new('user32', 'keybd_event', %w(i i l l), 'v').freeze

  rescue Exception

    raise if $DEBUG

    raise( LoadError , "cannot read modules.(user32.dll)",caller(0))  

  end

  module_function

  def self.screen_mode_change

    @@kbe.call( 0xA4, 0, 0, 0)

    @@kbe.call( 13, 0, 0, 0)

    @@kbe.call( 13, 0, 2, 0)

    @@kbe.call( 0xA4, 0, 2, 0)

  end

end

this stuff. this thing changes screen mode (fullscreen / windowed) but i don't know what those 'user32', 'keybd_event'
all means and if there's any list or something about this kind of thing, please let me know.
 
DJ":3efy7y8x said:
Thanks very much for the reply, but I have more questions. I think i know methods, but the real problem is what args* i could put in.
I can't find stuff about that, such as :

Code:
module ScreenChanger

  begin

    @@kbe = Win32API.new('user32', 'keybd_event', %w(i i l l), 'v').freeze

  rescue Exception

    raise if $DEBUG

    raise( LoadError , "cannot read modules.(user32.dll)",caller(0))  

  end

  module_function

  def self.screen_mode_change

    @@kbe.call( 0xA4, 0, 0, 0)

    @@kbe.call( 13, 0, 0, 0)

    @@kbe.call( 13, 0, 2, 0)

    @@kbe.call( 0xA4, 0, 2, 0)

  end

end

this stuff. this thing changes screen mode (fullscreen / windowed) but i don't know what those 'user32', 'keybd_event'
all means and if there's any list or something about this kind of thing, please let me know.

For the specific example you used, it's looking for the keybd_event call from the default Windows .dll file, user32.dll. So, a more generic explanation is that the first argument is the name of a .dll file, which can either be located in the same directory as Game.exe, in the default C:/WINDOWS folder, or in C:/WINDOWS/system32. The second one is the name of a specific function you would like to call from the .dll file.
 

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