[XP] RMXPAce -- Using the VX Ace engine in your XP games

Started by KK20, February 17, 2013, 04:38:51 pm

Previous topic - Next topic

Ethereal


KK20

Thanks for reminding me. Dropbox changed how the Public folder works so all the shared file links don't work anymore. I've updated the links on the first post.

Now because of this, I wonder how many old scripts/resources here are gone forever now since those users aren't active.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo

You should update the kit as well, I noticed the tilemap used is still v0.12b.

KK20

I can just release whatever fixes I made and call it v2.1 tomorrow. Still in the process of making a tech demo.

EDIT:
Updated to Version 2.1

  • Updated XPA Tilemap to v0.32

  • Removed Unlimited Resolution as this has been moved over to XPA Tilemap

  • Superclass Mismatch Fix moved lower in script list as it was not running Console Output

  • Updated Ruby 1.8 Methods to v1.1 (includes Array#to_s, String#delete and #[])


Download

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

KK20

I downloaded the Steam version of RMXP to test the weird issues it was having with XPA projects. One of them was the location of the RTP. Sure this can be easily resolved by either loading your project with all the RTP assets or installing the RTP package from the official RPG Maker website, but I found a way to read the registry of the RTP location. It seems to reside in
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Enterbrain\RGSS\RTP

so, knowing that, I updated the Load RTP script like so:
(change is in RPG::Path.getRTPPath)

#===============================================================================
# Load RTP File
# Author: joe59491, edit by LiTTleDRAgo
# Version : 1.40
#-------------------------------------------------------------------------------
# [ Description ]
# Loads RMXP RTP assets so that the user does not have to manually import all of
# them into their project.
#
# [ Instructions ]
# There is nothing to do here.
# Please keep this script in its current location.
#
# It is highly advised to not modify this script unless you know what you are
# doing.
#===============================================================================
if XPA_CONFIG::RTP_LOADER

module Load_RTP_File
 
  RMXP  = true
  RMVX  = false
  RMVXA = false

end

#==============================================================================
# ** Ini
#------------------------------------------------------------------------------
#  
#==============================================================================
module Ini
  #--------------------------------------------------------------------------
  # * self.readIni
  #--------------------------------------------------------------------------
  def self.readIni(item = "Title")
    buf = 0.chr * 256
    @gpps ||= Win32API.new("kernel32","GetPrivateProfileString","pppplp","l")
    @gpps.call("Game",item,"",buf,256,"./Game.ini")
    buf.delete!("\0")
    return buf
  end
end

#==============================================================================
# ** String
#------------------------------------------------------------------------------
#  
#==============================================================================
class String
  #--------------------------------------------------------------------------
  # ● UTF8_to_unicode
  #--------------------------------------------------------------------------
  def to_unicode 
    @mbytetowchar ||= Win32API.new("kernel32","MultiByteToWideChar",'ilpipi','I')
    len = @mbytetowchar.call(65001, 0, self, -1, 0, 0) << 1
    @mbytetowchar.call(65001, 0, self, -1, (buf = " " * len), len)
    return buf
  end
end

#==============================================================================
# ** RPG::Path
#------------------------------------------------------------------------------
#  
#==============================================================================
module RPG
  module Path
    #--------------------------------------------------------------------------
    # * Constant
    #--------------------------------------------------------------------------
    FindFirstFile = Win32API.new("kernel32", "FindFirstFileW", "PP", "L")
    FindNextFile  = Win32API.new("kernel32", "FindNextFileW", "LP", "I")
    ReadRegistry = Win32API.new("advapi32","RegGetValue","lppllpp","l")
    #--------------------------------------------------------------------------
    # * getRTPPath
    #--------------------------------------------------------------------------
    def self.getRTPPath(rgss,rtpname)
      return "" if rtpname == "" or rtpname.nil?
      size = [256].pack("L")
      # Get the registry value's length
      ReadRegistry.call(
        0x80000002, # HKEY_LOCAL_MACHINE
        "SOFTWARE\\Wow6432Node\\Enterbrain\\RGSS\\RTP",
        "Standard",
        2, # REG_SZ
        0, # Null
        0, # Null, so that we can get value's length
        size)
      buffer = size.unpack("L")[0] # Length stored in 'size'
      path = "\0" * buffer         # Now we know how long the string is
      # Get the registry value itself
      ReadRegistry.call(
        0x80000002, # HKEY_LOCAL_MACHINE
        "SOFTWARE\\Wow6432Node\\Enterbrain\\RGSS\\RTP",
        "Standard",
        2, # REG_SZ
        0, # Null
        path,
        size)
      path.delete!("\0")
      path = path + '/' # Ensure trailing forward slash to path name
      path = path.gsub("\\","/").gsub("//","/")
      path
    end
    #--------------------------------------------------------------------------
    # * Class Variable
    #--------------------------------------------------------------------------
    @@RTP = []
    if Load_RTP_File::RMXP
      @@RTP << self.getRTPPath('RGSS','Standard')
      (0..3).each do |i|
        @@RTP << self.getRTPPath('RGSS',Ini.readIni("RTP#{i.to_s}"))
      end
    end 
    @@RTP << self.getRTPPath('RGSS2',"RPGVX")    if Load_RTP_File::RMVX
    @@RTP << self.getRTPPath('RGSS3',"RPGVXAce") if Load_RTP_File::RMVXA
    @@RTP.reject! {|rtp| rtp.nil? || rtp.empty?}
    #--------------------------------------------------------------------------
    # * self.findP
    #--------------------------------------------------------------------------
    def self.findP(*paths)
      findFileData = " " * 596
      result = ""
      for file in paths       
        unless FindFirstFile.call(file.to_unicode, findFileData) == -1
          name = file.split("/").last.split(".*").first
          result = File.dirname(file) + "/" + name
        end
      end
      return result
    end
    #--------------------------------------------------------------------------
    # * self.RTP
    #--------------------------------------------------------------------------
    def self.RTP(path)
      @list ||= {}
      return @list[path] if @list.include?(path)
      check = File.extname(path).empty?
      rtp = []
      @@RTP.each do |item|
        unless item.empty?
          rtp.push(item + path)
          rtp.push(item + path + ".*") if check
        end
      end
      rtp.push(path)
      rtp.push(path + ".*") if check
      pa = self.findP(*rtp)
      @list[path] = pa == "" ? path : pa
      return @list[path]
    end
  end
end

#==============================================================================
# ** Audio
#------------------------------------------------------------------------------
#  
#==============================================================================
class << Audio
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  [:bgm_play,:bgs_play,:se_play,:me_play].each do |meth|
    $@ || alias_method(:"#{meth}_path", :"#{meth}")
    define_method(:"#{meth}") do |*args|
      args[0] = RPG::Path::RTP(args[0]) if args[0].is_a?(String)
      send(:"#{meth}_path",*args)
    end
  end
end

#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
#  
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # ● Alias Method
  #--------------------------------------------------------------------------
  $@ || alias_method(:rtp_path_init, :initialize)
  #--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    args[0] = RPG::Path::RTP(args.at(0)) if args.at(0).is_a?(String)
    rtp_path_init(*args)
  end
end

#==============================================================================
# ** Graphics
#------------------------------------------------------------------------------
#  This module handles all Graphics
#==============================================================================
class << Graphics
  #--------------------------------------------------------------------------
  # ● Alias Method
  #--------------------------------------------------------------------------
  $@ || alias_method(:rtp_path_transition, :transition)
  #--------------------------------------------------------------------------
  # ● transition
  #--------------------------------------------------------------------------
  def transition(*args)
    args[1] = RPG::Path::RTP(args.at(1)) if args[1].is_a?(String)
    rtp_path_transition(*args)
  end
end

end

I only tested this on a Win7x64. No guarantees if this is 100% foolproof.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo

Quote from: KK20 on June 19, 2017, 10:48:40 pm
I downloaded the Steam version of RMXP to test the weird issues it was having with XPA projects. One of them was the location of the RTP. Sure this can be easily resolved by either loading your project with all the RTP assets or installing the RTP package from the official RPG Maker website, but I found a way to read the registry of the RTP location. It seems to reside in
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Enterbrain\RGSS\RTP

so, knowing that, I updated the Load RTP script like so:
(change is in RPG::Path.getRTPPath)

*redacted*


You forgot VX and VXAce, the edit only hardcoding RTP for XP.
It should be:

"SOFTWARE\\Wow6432Node\\Enterbrain\\#{rgss}\\RTP",
"#{rtpname}",


Shortened ver
Spoiler: ShowHide
    #--------------------------------------------------------------------------
    # * getRTPPath
    #--------------------------------------------------------------------------
    def self.getRTPPath(rgss,rtpname)
      return "" if rtpname == "" or rtpname.nil?
      # Get the registry value's length
      reg = [ 0x80000002, # HKEY_LOCAL_MACHINE
              "SOFTWARE\\Wow6432Node\\Enterbrain\\#{rgss}\\RTP",
              "#{rtpname}",
              2, # REG_SZ
              0, # Null
              0, # Null, so that we can get value's length
              (size = [256].pack("L")) ]
      ReadRegistry.call(*reg)
      buffer = size.unpack("L")[0]   # Length stored in 'size'
      path = reg[5] = "\0" * buffer  # Now we know how long the string is
      # Get the registry value itself
      ReadRegistry.call(*reg)
      path.delete!("\0")
      path = (path + '/').gsub("\\","/").gsub("//","/")
      path # Ensure trailing forward slash to path name
    end


This will allow XPAce to load VX and VXAce RTP too (Priority RTP loaded will be XP > VX > VXA).

    # Tried these in Scene_Title
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    #-------------------------------------------------------------------------
    bmp = Bitmap.new("Graphics/Titles1/Book")
    @sprite.bitmap.stretch_blt(@sprite.bitmap.rect, bmp, bmp.rect)
    bmp.dispose
    #-------------------------------------------------------------------------


KK20

Updated to Version 2.2

  • Uses XPAT v0.35 (which was updated today)

  • Superclass Mismatch Helper got some minor changes

  • Load RTP now pulls from the registry (explained in posts above)

  • Marshal.load now calls Kernel#load_data instead as this method ensures strings are encoded in UTF-8



Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

KK20

Update to version 2.21

  • The Marshal.load encoding issue seems to be highly situational and rare to come by. Basically, unless you're a scripter and/or using some file-saving/-loading feature that RMXP does not natively support, I'm fairly certain you will never come across this. The only reported instance was with Blizzard's DREAM script. As such, I pulled the aliased method from the package.

  • XPA Tilemap updated to v0.36


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Jaiden

I seem to be having a bit of trouble with XPA Tilemap, notably, whenever the custom plane class is enabled, I can't launch the game without it crashing. ("Windows has encountered a problem...") etc. This means changing the resolution or enabling the no-wrap option.

I tested a clean project and the problem isn't there, so I understand this is a script conflict/configuration issue. The problem is I'm mostly unsure as to what to look for to try to debug/make things compatible.

I also am getting a considerable amount of map stutter. The game's FPS stays at 60, but I am getting horrible microstutters which I assume are event lag. Is this an inherent issue with RPG Maker XP? I noticed there is a bit of stutter in the clean project, I'm not sure if there are any potential solutions or it's just the nature of the beast.

KK20

It's not the Plane rewrite. I just commented out the Graphics module in the script and it stopped crashing. Still looking...
EDIT: It's the Unknown Scripter's resolution breaker code. Fuck.
EDIT 2: Oh thank god, it's an easy fix.

I'm not sure where you got your RGSS301, but it's definitely not from the 2.22 package. You need that specific one for the "assembly magic" that script uses. File size should be like 1053KB.
MD5 file hash: DD25855AC39D32DA033902FC58FA210B

As for the lag, can you give me an example? Everyone has different definitions for lag.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Jaiden

Hmm. I'll double check the .dll, I was pretty sure I was using the correct one but I'll have a look.

As for lag, I'll post an example. I haven't had a chance to test it on my non-Windows 10 machine so I've yet to rule out computer-aided problems.

Notably, scrolling the screen (using an event) shows it the most. It is not a smooth scroll, with significant stutters. I only assumed it was map related because if I use something to display the FPS, it doesn't drop below 60 even when the stutters occur. I'm going to take a minute to test on another computer, though.

Jaiden

Ah! It was the RGSS301.dll. That is bizarre, I was almost certain I copied it straight from the XPA folder, but perhaps I blacked out and replaced it with a different one, or something.

Lag still exists, will post an example of some kind when I get a moment.

Jaiden

An update on this, I have a demo for my game here:
http://forum.chaos-project.com/index.php/topic,15812.0.html
The "lag" I talked about is present walking around town.

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Jaiden

Positive. Even with it disabled, it's present. In the intro cutscene where it says "Three Months Later", I actually have the smooth scroller disabled (it was wonky with the "scroll map" event), and I noticed it skips around quite a bit.

I did try a fresh XPA install and still noticed it, though not as aggressively, especially with a larger map. I piled up a bunch of events and noticed it really doesn't make a difference, which is why I'm not sure if it is even event related.

Jaiden

Tried a few things, and got some different results (Clean project with just XPA):


  • Made a 50x50 map and put a bunch of events and a few layers of tiles in one spot; noticed a tiny bit of stuttering, mostly when moving in/out of areas with lots of events/tiles.


  • Had a thought that maybe tileset size made a difference, so I loaded in one of those "ultimate exterior" 256x10000 (or whatever) tilesets and tried selecting from different portions of the set, noticed a little more stutter in the areas with tiles but not as much.


  • Threw in a bunch of autotiles and noticed the stutter increased a fair amount, especially in the areas with autotiles.


  • To further this, I made a map with just animated autotiles and noticed the stutter was really obvious in the piles of autotiles.



I don't know of the likelihood of it relating to the Tilemap rewrite, and it's really hard to judge since RPG Maker XP used to be native 30FPS, I'm not sure if it's just an inherent flaw with RPG Maker XP.

KK20

It's most likely the tilemap rewrite then. But I don't know how I can improve it honestly.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Jaiden

Oh man, a "I don't know" from KK20 is rough. Do you think one of the other Tilemaps suggested in your OP would resolve the problem? Or not really, considering yours is written specifically for XPA?

Next question is transitions, the custom plane class nukes transitions and they don't work properly, I know this is known. Are there any recommended transition scripts, or is the resolution a bit more complicated than that?

Blizzard

November 08, 2017, 11:27:10 am #319 Last Edit: November 08, 2017, 11:37:13 am by Blizzard
KK20, have you thought about using SSE2 or something like that? It could heavily boost blitting performance and AFAIK most old CPUs support it. IIRC Pentium 2 already had SSE2 support. I definitely know that Intel Atom CPUs support at least SSE2. And IIRC AMD CPUs know how to emulate SSE2.

EDIT: https://en.wikipedia.org/wiki/SSE2

Keep in mind, this is next level shit, probably unlike anything you've done so far in terms of programming.

EDIT: What it does in short: Imagine you copy an array. The CPU has to copy value by value, there's not way around it. But if you use Intel intrinsics, you can make use of the media co-processor and literally copy multiple pieces of data at once. You tell the co-processor what you want copied and it executes it in a parallel manner rather than value by value. This is quite often used in image processing. I remember that either one or both libjpeg and libpng use them to improve loading speed. And it improves loading speed several times, maybe even more than a whole order of magnitude.

EDIT: I can't seem to find the code in libpng and libjpeg. But it does exist in libwebp.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.