[XP] Custom Resolution

Started by ForeverZer0, November 25, 2010, 03:28:40 am

Previous topic - Next topic

ForeverZer0

November 25, 2010, 03:28:40 am Last Edit: May 31, 2015, 02:59:57 pm by KK20
Custom Resolution
Authors: ForeverZer0, KK20, LiTTleDRAgo
Version: 0.97
Type: Game Utility
Key Term: Game Utility



Introduction

My goal in creating this script was to create a system that allowed the user to set the screen size to something other than 640 x 480, but not have make huge sacrifices in compatibility and performance. Although the script is not simply Plug-and-Play, it is about as close as one can achieve with a script of this nature.


Features
Note these were written at the time of v0.93. The following may not be entirely true for the later versions.

  • Totally re-written Tilemap and Plane class. Both classes were written to display the map across any screen size automatically. The Tilemap class is probably even more efficient than the original, which will help offset any increased lag due to using a larger screen size with more sprites being displayed.

  • Every possible autotile graphic (48 per autotile) will be cached for the next time that tile is used.

  • Autotile animation has been made as efficient as possible, with a system that stores their coodinates, but only if they change. This greatly reduces the number of iterations at each update.

  • Option to have the system create an external file to save pre-cached data for autotiles. This will decrease any loading times even more, and only takes a second, depending on the number of maps you have.

  • User defined autotile animation speed. Can change with script calls.

  • Automatic re-sizing of Bitmaps and Viewports that are 640 x 480 to the defined resolution, unless explicitely over-ridden in the method call. The graphics themselves will not be resized, but any existing scripts that use the normal screen size will already be configured to display different sizes of graphics for battlebacks, pictures, fogs, etc.

  • Option to have a log file ouput each time the game is ran, which can alert you to possible errors with map sizes, etc.




Screenshots

None.


Demo

Click here for the demo. Note, it uses v0.93.


Script

Here's the code for v0.93 (the last version ForeverZer0 made--few graphical issues):
Spoiler: ShowHide

#===============================================================================
# Custom Resolution
# Author: ForeverZer0
# Version: 0.93
# Date: 12.18.2010
#===============================================================================
#
# Introduction:
#
#   My goal in creating this script was to create a system that allowed the user
#   to set the screen size to something other than 640 x 480, but not have make
#   huge sacrifices in compatibility and performance. Although the script is
#   not simply Plug-and-Play, it is about as close as one can achieve with a
#   script of this nature.
#
# Instructions:
#
#  - Place the "screenshot.dll" from Fantasist's Transition Pack script, which
#    can be found here: http://www.sendspace.com/file/yjd54h in your game folder
#  - Place this script above main, below default scripts.
#  - In my experience, unchecking "Reduce Screen Flickering" actually helps the
#    screen not to flicker. Open menu with F1 while playing and set this to what
#    you get the best results with.
#
# Features:

#  - Totally re-written Tilemap and Plane class. Both classes were written to
#    display the map across any screen size automatically. The Tilemap class
#    is probably even more efficient than the original, which will help offset
#    any increased lag due to using a larger screen size with more sprites
#    being displayed.
#  - Every possible autotile graphic (48 per autotile) will be cached for the
#    next time that tile is used.
#  - Autotile animation has been made as efficient as possible, with a system
#    that stores their coodinates, but only if they change. This greatly reduces
#    the number of iterations at each update.
#  - System creates an external file to save pre-cached data priorities and
#    autotiles. This will decrease any loading times even more, and only takes a
#    second, depending on the number of maps you have.
#  - User defined autotile animation speed. Can change with script calls.
#  - Automatic re-sizing of Bitmaps and Viewports that are 640 x 480 to the
#    defined resolution, unless explicitely over-ridden in the method call.
#    The graphics themselves will not be resized, but any existing scripts that
#    use the normal screen size will already be configured to display different
#    sizes of graphics for transitions, battlebacks, pictures, fogs, etc.
#  - Option to have a log file ouput each time the game is ran, which can alert
#    you to possible errors with map sizes, etc.
#
# Issues/Bugs/Possible Bugs:
#
#   - Graphic related scripts and your graphics will need to be customized to
#     fit the new screen size, so this script is not for everyone.
#   - The Z-axis for the Plane class, which is used for Fogs and Panoramas has
#     been altered. It is now multiplied by 1000. This will likely be a minor
#     issue for most, since this class is very rarely used except for Fogs and
#     Panoramas, which are already far above and below respectfully.
#   - Normal transitions using graphics cannot be used. With the exception of
#     a standard fade, like that used when no graphic is defined will be used.
#     Aside from that, only special transitions from Transition Pack can be
#     used.
#
#  Credits/Thanks:
#    - ForeverZer0, for script.
#    - Creators of the Transition Pack and Screenshot.dll
#    - Selwyn, for base resolution script
#
#===============================================================================
#                             CONFIGURATION
#===============================================================================

  SCREEN = [1024, 576]
  # Define the resolution of the game screen. These values can be anything
  # within reason. Centering, viewports, etc. will all be taken care of, but it
  # is recommended that you use values divisible by 32 for best results.
 
  UPDATE_COUNT = 8
  # Define the number of frames between autotile updates. The lower the number,
  # the faster the animations cycle. This can be changed in-game with the
  # following script call: $game_map.autotile_speed = SPEED
 
  PRE_CACHE_DATA = true
  # The pre-cached file is mandatory for the script to work. As long as this is
  # true, the data will be created each time the game is test-played. This is
  # not always neccessary, only when maps are altered, so you can disable it to
  # help speed up game start-up, and it will use the last created file.
 
  RESOLUTION_LOG = true
  # This will create a log in the Game directory each time the game is ran in
  # DEBUG mode, which will list possible errors with map sizes, etc.
 
#===============================================================================
# ** Resolution
#===============================================================================

class Resolution
 
  attr_reader :version
 
  def initialize
    # Define version.
    @version = 0.93
    # Set instance variables for calling basic Win32 functions.
    ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
    title = "\0" * 256
    ini.call('Game', 'Title', '', title, 256, '.\\Game.ini')
    title.delete!("\0")
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call('RGSS Player', title)
    set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
    set_window_pos  = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @metrics         = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    # Set default size, displaying error if size is larger than the hardware.
    default_size = self.size
    if default_size[0] < SCREEN[0] || default_size[1] < SCREEN[1]
      print("\"#{title}\" requires a minimum screen resolution of [#{SCREEN[0]} x #{SCREEN[1]}]\r\n\r\n" +
            "\tYour Resolution: [#{default_size[0]} x #{default_size[1]}]")
      exit
    end
    # Apply resolution change.
    x = (@metrics.call(0) - SCREEN[0]) / 2
    y = (@metrics.call(1) - SCREEN[1]) / 2
    set_window_long.call(@window, -16, 0x14CA0000)
    set_window_pos.call(@window, 0, x, y, SCREEN[0] + 6, SCREEN[1] + 26, 0)
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call('RGSS Player', title)
  end
  #--------------------------------------------------------------------------
  def size
    # Returns the screen size of the machine.
    return [@metrics.call(0), @metrics.call(1)]
  end
  #--------------------------------------------------------------------------
  def snapshot(filename = 'Data/snap', quality = 0)
    # FILENAME =   Filename that the picture will be saved as.
    # FILETYPE =   0 = High Quality   1 = Low Quality
    @screen = Win32API.new('screenshot.dll', 'Screenshot', 'LLLLPLL', '')
    @screen.call(0, 0, SCREEN[0], SCREEN[1], filename, @window, quality)
  end
  #--------------------------------------------------------------------------
end

#===============================================================================
# ** Integer
#===============================================================================

class Integer
   
  def gcd(num)
    # Returns the greatest common denominator of self and num.
    min, max = self.abs, num.abs
    while min > 0
      tmp = min
      min = max % min
      max = tmp
    end
    return max
  end
 
  def lcm(num)
    # Returns the lowest common multiple of self and num.
    return [self, num].include?(0) ? 0 : (self / self.gcd(num) * num).abs
  end
end

#===============================================================================
# ** Graphics
#===============================================================================

module Graphics

  class << self
    alias zer0_graphics_transition transition
  end
 
  def self.transition(duration = 8, *args)
    # Call default transition if no instance of the resolution is defined.
    if $resolution == nil
      zer0_graphics_transition(duration, *args)
    else
      # Skip this section and instantly transition graphics if duration is 0.
      if duration > 0
        # Take a snapshot of the the screen, overlaying screen with graphic.
        $resolution.snapshot
        zer0_graphics_transition(0)
        # Create screen instance
        sprite = Sprite.new(Viewport.new(0, 0, SCREEN[0], SCREEN[1]))
        sprite.bitmap = Bitmap.new('Data/snap')
        # Use a simple fade if transition is not defined.
        fade = 255 / duration
        duration.times { sprite.opacity -= fade ; update }
        # Dispose sprite and delete snapshot file.
        [sprite, sprite.bitmap].each {|obj| obj.dispose }
        File.delete('Data/snap')
      end
     zer0_graphics_transition(0)
   end
end
end 

#===============================================================================
# ** RPG::Cache
#===============================================================================

module RPG::Cache
 
  AUTO_INDEX = [
 
  [27,28,33,34],  [5,28,33,34],  [27,6,33,34],  [5,6,33,34],
  [27,28,33,12],  [5,28,33,12],  [27,6,33,12],  [5,6,33,12],
  [27,28,11,34],  [5,28,11,34],  [27,6,11,34],  [5,6,11,34],
  [27,28,11,12],  [5,28,11,12],  [27,6,11,12],  [5,6,11,12],
  [25,26,31,32],  [25,6,31,32],  [25,26,31,12], [25,6,31,12],
  [15,16,21,22],  [15,16,21,12], [15,16,11,22], [15,16,11,12],
  [29,30,35,36],  [29,30,11,36], [5,30,35,36],  [5,30,11,36],
  [39,40,45,46],  [5,40,45,46],  [39,6,45,46],  [5,6,45,46],
  [25,30,31,36],  [15,16,45,46], [13,14,19,20], [13,14,19,12],
  [17,18,23,24],  [17,18,11,24], [41,42,47,48], [5,42,47,48],
  [37,38,43,44],  [37,6,43,44],  [13,18,19,24], [13,14,43,44],
  [37,42,43,48],  [17,18,47,48], [13,18,43,48], [13,18,43,48]
   
  ]
 
  def self.autotile(filename)
    key = "Graphics/Autotiles/#{filename}"
    if !@cache.include?(key) || @cache[key].disposed?
      # Cache the autotile graphic.
      @cache[key] = (filename == '') ? Bitmap.new(128, 96) : Bitmap.new(key)
      # Cache each configuration of this autotile.
      self.format_autotiles(@cache[key], filename)
    end
    return @cache[key]
  end

  def self.format_autotiles(bitmap, filename)
    # Iterate all 48 combinations using the INDEX, and save copy to cache.
    (0...(bitmap.width / 96)).each {|frame|
      # Iterate for each frame in the autotile. (Only for animated ones)
      template = Bitmap.new(256, 192)
      # Create a bitmap to use as a template for creation.
      (0...6).each {|i| (0...8).each {|j| AUTO_INDEX[8*i+j].each {|number|
        number -= 1
        x, y = 16 * (number % 6), 16 * (number / 6)
        rect = Rect.new(x + (frame * 96), y, 16, 16)
        template.blt(32 * j + x % 32, 32 * i + y % 32, bitmap, rect)
      }
      # Use the above created template to create individual tiles.
      index = 8*i+j
      tile = Bitmap.new(32, 32)
      sx, sy = 32 * (index % 8), 32 * (index / 8)
      rect = Rect.new(sx, sy, 32, 32)
      tile.blt(0, 0, template, rect)
      @cache[[filename, index, frame]] = tile
    }}
    # Dispose the template since it will not be used again.
    template.dispose }
  end

  def self.load_autotile(name, tile_id, frame = 0)
    # Returns the autotile for the current map with TILE_ID and FRAME.
    return @cache[[name, tile_id % 48, frame]]
  end
end

#===============================================================================
# ** Tilemap
#===============================================================================

class Tilemap
 
  attr_reader   :map_data, :ox, :oy, :viewport
  attr_accessor :tileset, :autotiles, :priorities
 
  def initialize(viewport)
    # Initialize instance variables to store required data.
    @viewport, @autotiles, @layers, @ox, @oy = viewport, [], [], 0, 0
    # Get priority and autotile data for this tileset from instance of Game_Map.
    @priorities, @animated = $game_map.priorities, $game_map.autotile_data
    # Create a sprite and viewport to use for each priority level.
    (0..5).each {|i|
      @layers[i] = Sprite.new(viewport)
      @layers[i].z = i * 32
    }
  end
   
  def ox=(ox)
    # Set the origin of the X-axis for all the sprites.
    @ox = ox
    @layers.each {|sprite| sprite.ox = @ox }
  end
 
  def oy=(oy)
    # Set the origin of the y-axis for all the sprites.
    @oy = oy
    @layers.each {|sprite| sprite.oy = @oy }
  end
 
  def dispose
    # Dispose all of the sprites and viewports.
    @layers.each {|layer| layer.dispose }
  end
 
  def map_data=(data)
    # Set the map data to an instance variable.
    @map_data = data
    # Clear any sprites' bitmaps if it exists, or create new ones.
    @layers.each_index {|i|
      if @layers[i].bitmap != nil
        # Dispose bitmap and set to nil.
        @layers[i].bitmap = @layers[i].bitmap.dispose
      end
      # Create new bitmap, whose size is the same as the game map.
      @layers[i].bitmap = Bitmap.new($game_map.width*32, $game_map.height*32)
    }
    # Draw bitmaps accordingly.
    refresh
  end
 
  def refresh   
    # Set the animation data from the file if it exists, or create it now.
    @animated = $game_map.autotile_data
    # Iterate through all map layers, starting with the bottom.
    [0,1,2].each {|z| (0...@map_data.ysize).each {|y| (0...@map_data.xsize).each {|x|
      tile_id = @map_data[x, y, z]
      # Go to the next iteration if no bitmap is defined for this tile.
      if tile_id == 0 # No tile
        next
      elsif tile_id < 384 # Autotile
        name = $game_map.autotile_names[(tile_id / 48) - 1]
        bitmap = RPG::Cache.load_autotile(name, tile_id)
      else # Normal Tile
        bitmap = RPG::Cache.tile($game_map.tileset_name, tile_id, 0)
      end
      # Determine what the layer to draw tile, based off priority.
      layer = @priorities[tile_id]
      # Perform a block transfer from the created bitmap to the sprite bitmap.
      @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
    }}}
  end
 
  def update
    # Update the sprites.
    if Graphics.frame_count % $game_map.autotile_speed == 0
      # Increase current frame of tile by one, looping by width.
      @animated[0].each_index {|i|
        @animated[2][i] = (@animated[2][i] + 1) % @animated[1][i]
        @animated[3][i].each {|data|
          # Gather data using the stored coordinates from the map data.
          tile_id, x, y = @map_data[data[0], data[1], data[2]], data[0], data[1]
          name, layer = @animated[0][i], @priorities[tile_id]
          # Load the next frame of the autotile and set it to the map.
          bitmap = RPG::Cache.load_autotile(name, tile_id, @animated[2][i])
          @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
        }
      }
    end
  end
end

#===============================================================================
# Game_Map
#===============================================================================

class Game_Map
 
  attr_reader :tile_size, :autotile_speed, :autotile_data, :priority_data
 
  alias zer0_load_autotile_data_init initialize
  def initialize
    # Load pre-cached data hashes. They will be referenced during setup.
    file = File.open('Data/PreCacheMapData.rxdata', 'rb')
    @cached_priorities = Marshal.load(file)
    @cached_autotiles = Marshal.load(file)
    file.close
    # Call original method.
    zer0_load_autotile_data_init
    # Store the screen dimensions in tiles to save on calculations later.
    @tile_size = [SCREEN[0], SCREEN[1]].collect {|n| (n / 32.0).ceil }
    @autotile_speed = UPDATE_COUNT
  end
 
  alias zer0_map_edge_setup setup
  def setup(map_id)
    @priority_data = @cached_priorities[map_id]
    @autotile_data = @cached_autotiles[map_id]
    # Call original method.
    zer0_map_edge_setup(map_id)
    # Find the displayed area of the map in tiles. No calcualting every step.
    @map_edge = [self.width - @tile_size[0], self.height - @tile_size[1]]
    @map_edge.collect! {|size| size * 128 }
  end

  def scroll_down(distance)
    # Find point that the map edge meets the screen edge, using custom size.
    @display_y = [@display_y + distance, @map_edge[1]].min
  end

  def scroll_right(distance)
    # Find point that the map edge meets the screen edge, using custom size.
    @display_x = [@display_x + distance, @map_edge[0]].min
  end
 
  def autotile_speed=(speed)
    # Keep the speed above 0 to prevent the ZeroDivision Error.
    @autotile_speed = speed
    @autotile_speed = 1 if @autotile_speed < 1
  end
end

#===============================================================================
# ** Game_Character
#===============================================================================

class Game_Character
 
  def screen_z(height = 0)
    if @always_on_top
      # Return high Z value if always on top flag is present.
      return 999
    elsif height != nil && height > 32
      # Iterate through map characters to their positions relative to this one.
      characters = $game_map.events.values
      characters += [$game_player] unless self.is_a?(Game_Player)
      # Find and set any character that is one tile above this one.
      above, z = characters.find {|chr| chr.x == @x && chr.y == @y - 1 }, 0
      if above != nil
        # If found, adjust value by this one's Z, and the other's.
        z = (above.screen_z(48) >= 32 ? 33 : 31)
      end
      # Check for Blizz-ABS and adjust coordinates for the pixel-rate.
      if $BlizzABS
        x = ((@x / $game_system.pixel_rate) / 2.0).to_i
        y = ((@y / $game_system.pixel_rate) / 2.0).to_i
        return $game_map.priority_data[x, y] + z
      else
        return $game_map.priority_data[@x, @y] + z
      end
    end
    return 0
  end
end

#===============================================================================
# ** Game_Player
#===============================================================================

class Game_Player
 
  CENTER_X = ((SCREEN[0] / 2) - 16) * 4    # Center screen x-coordinate * 4
  CENTER_Y = ((SCREEN[1] / 2) - 16) * 4    # Center screen y-coordinate * 4
 
  def center(x, y)
    # Recalculate the screen center based on the new resolution.
    max_x = ($game_map.width - $game_map.tile_size[0]) * 128
    max_y = ($game_map.height - $game_map.tile_size[1]) * 128
    $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
    $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  end 
end

#===============================================================================
# ** Sprite
#===============================================================================

class Sprite
 
  alias zer0_sprite_resize_init initialize
  def initialize(view = nil)
    # Unless viewport is defined, use the new default viewport size.
    view = Viewport.new(0, 0, SCREEN[0], SCREEN[1]) if view == nil
    # Call original method.
    zer0_sprite_resize_init(view)
  end
end

#===============================================================================
# ** Viewport
#===============================================================================

class Viewport
 
  alias zer0_viewport_resize_init initialize
  def initialize(x=0, y=0, width=SCREEN[0], height=SCREEN[1], override=false)
    if x.is_a?(Rect)
      # If first argument is a Rectangle, just use it as the argument.
      zer0_viewport_resize_init(x)
    elsif [x, y, width, height] == [0, 0, 640, 480] && !override
      # Resize fullscreen viewport, unless explicitly overridden.
      zer0_viewport_resize_init(Rect.new(0, 0, SCREEN[0], SCREEN[1]))
    else
      # Call method normally.
      zer0_viewport_resize_init(Rect.new(x, y, width, height))
    end
  end
 
  def resize(*args)
    # Resize the viewport. Can call with (X, Y, WIDTH, HEIGHT) or (RECT).
    self.rect = args[0].is_a?(Rect) ? args[0] : Rect.new(*args)
  end
end

#===============================================================================
# ** Bitmap
#===============================================================================

class Bitmap
 
  alias zer0_resolution_resize_init initialize
  def initialize(width = 32, height = 32, override = false)
    if width.is_a?(String)
      # Call the filename if the first argument is a String.
      zer0_resolution_resize_init(width)
    elsif [width, height] == [640, 480] && !override
      # Resize fullscreen bitmap unless explicitly overridden.
      zer0_resolution_resize_init(SCREEN[0], SCREEN[1])
    else
      # Call method normally.
      zer0_resolution_resize_init(width, height)
    end
  end
end

#===============================================================================
# ** Plane
#===============================================================================

class Plane < Sprite
 
  def z=(z)
    # Change the Z value of the viewport, not the sprite.
    super(z * 1000)
  end
 
  def ox=(ox)
    return if @bitmap == nil
    # Have viewport stay in loop on X-axis.
    super(ox % @bitmap.width)
  end
 
  def oy=(oy)
    return if @bitmap == nil
    # Have viewport stay in loop on Y-axis.
    super(oy % @bitmap.height)
  end
 
  def bitmap
    # Return the single bitmap, before it was tiled.
    return @bitmap
  end
 
  def bitmap=(tile)
    @bitmap = tile
    # Calculate the number of tiles it takes to span screen in both directions.
    xx = 1 + (SCREEN[0].to_f / tile.width).ceil
    yy = 1 + (SCREEN[1].to_f / tile.height).ceil
    # Create appropriately sized bitmap, then tile across it with source image.
    plane = Bitmap.new(@bitmap.width * xx, @bitmap.height * yy)
    (0..xx).each {|x| (0..yy).each {|y|
      plane.blt(x * @bitmap.width, y * @bitmap.height, @bitmap, @bitmap.rect)
    }}
    # Set the bitmap to the sprite through its super class (Sprite).
    super(plane)
  end
 
  # Redefine methods dealing with coordinates (defined in super) to do nothing.
  def x; end
  def y; end
  def x=(x); end
  def y=(y); end
end
 
#===============================================================================
# DEBUG Mode
#===============================================================================

if $DEBUG
  if PRE_CACHE_DATA
    tilesets = load_data('Data/Tilesets.rxdata')
    maps, priority_data, autotile_data = load_data('Data/MapInfos.rxdata'), {}, {}
    maps.each_key {|map_id|
      map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
      data = map.data
      tileset = tilesets[map.tileset_id]
      priorities = tileset.priorities
      autotiles = tileset.autotile_names.collect {|name| RPG::Cache.autotile(name) }
      animated = [[], [], [], []]
      autotiles.each_index {|i|
        width = autotiles[i].width
        next unless width > 96
        parameters = [tileset.autotile_names[i], width / 96, 0, []]
        [0, 1, 2, 3].each {|j| animated[j].push(parameters[j]) }
      }
      [0, 1, 2].each {|z| (0...data.ysize).each {|y| (0...data.xsize).each {|x|
        tile_id = data[x, y, z]
        next if tile_id == 0
        if tile_id < 384
          name = tileset.autotile_names[(tile_id / 48) - 1]
          index = animated[0].index(name)
          next if index == nil
          above = []
          ((z+1)...data.zsize).each {|zz| above.push(data[x, y, zz]) }
          animated[3][index].push([x, y, z]) if above.all? {|id| id == 0 }
        end
      }}}
      table = Table.new(data.xsize, data.ysize)
      (0...table.xsize).each {|x| (0...table.ysize).each {|y|
        above = [0, 1, 2].collect {|z| data[x, y-1, z] }
        above = above.compact.collect {|p| priorities[p] }
        table[x, y] = above.include?(1) ? 32 : 0
      }}
      priority_data[map_id], autotile_data[map_id] = table, animated
    }
    file = File.open('Data/PreCacheMapData.rxdata', 'wb')
    Marshal.dump(priority_data, file)
    Marshal.dump(autotile_data, file)
    file.close
    RPG::Cache.clear
  end
 
  if RESOLUTION_LOG
    undersize, mapinfo = [], load_data('Data/MapInfos.rxdata')
    file = File.open('Data/PreCacheMapData.rxdata', 'rb')
    cached_data = Marshal.load(file)
    file.close
    # Create a text file and write the header.
    file = File.open('Resolution Log.txt', 'wb')
    file.write("[RESOLUTION LOG]\r\n\r\n")
    time = Time.now.strftime("%x at %I:%M:%S %p")
    file.write("  Logged on #{time}\r\n\r\n")
    lcm = SCREEN[0].lcm(SCREEN[1]).to_f
    aspect = [(lcm / SCREEN[1]), (lcm / SCREEN[0])].collect {|num| num.round }
    file.write("RESOLUTION:\r\n  #{SCREEN[0].to_i} x #{SCREEN[1].to_i}\r\n")
    file.write("ASPECT RATIO:\r\n  #{aspect[0]}:#{aspect[1]}\r\n")
    file.write("MINIMUM MAP SIZE:\r\n  #{(SCREEN[0] / 32).ceil} x #{(SCREEN[1] / 32).ceil}\r\n\r\n")
    file.write("UNDERSIZED MAPS:\r\n")
    mapinfo.keys.each {|key|
      map = load_data(sprintf("Data/Map%03d.rxdata", key))
      next if map.width*32 >= SCREEN[0] && map.height*32 >= SCREEN[1]
      undersize.push(key)
    }
    unless undersize.empty?
      file.write("The following maps are too small for the defined resolution. They should be adjusted to prevent graphical errors.\r\n\r\n")
      undersize.sort.each {|id| file.write("    MAP[#{id}]:  #{mapinfo[id].name}\r\n") }
      file.write("\r\n")
    else
      file.write('    All maps are sized correctly.')
    end
    file.close
  end
end

# Call the resolution, setting it to a global variable for plug-ins.
$resolution = Resolution.new

Below are two types of v0.96b, which addresses some bugs and entirely changes the way the tilemap is drawn.
Normal Version
DLL-less Version
* With the DLL-less version, there is no need to put 'screenshot.dll' in your project folder

LiTTleDRAgo modified the existing script further to bring the script to v0.97. Download it:
HERE!


Instructions


  • Place script below default scripts, and above "Main".

  • (OPTIONAL) Download Transition Pack by Fantasist from here (contains 'screenshot.dll'): http://www.sendspace.com/file/yjd54h

  • Alternate 'screenshot.dll' download link: http://www.sendspace.com/file/aiirus

  • Place the screenshot.dll from it in the game folder if using v0.93 or Normal version.

  • (OPTIONAL) Because larger resolutions do not change the positions of windows in scenes, LiTTleDRAgo created a script that centers these windows to make them look more visually appealing. Get it here.


  • Any further instructions are in the script.




Compatibility

This script is not going to be for everyone obviously. A bigger screen means bigger chance of lag.
Custom scripts will need to be made to have windows for your CMS, CBS, and other scenes fill the screen properly.

I have created a second thread for numerous compatibility fixes. You can also make requests for new ones.
Go here to view the post.


Credits and Thanks


  • ForeverZer0, for the script.

  • Creators of Transition Pack and screenshot.dll

  • Selwyn, for base resolution script.

  • KK20, for v0.94 (and above) and the Tilemap rewrite (many hours and pages of notes went into this to make it one of the most realistic rewrites out there)

  • LiTTleDRAgo, for using some methods from his Core Engine script to make a DLL-less version and continued support/contributions by editing the existing script and creating compatible add-ons



Author's Notes

Please report any bugs/issues/suggestions. KK20 will be happy to fix them.
EDIT: KK20 will no longer be providing support. He has moved on to XP Ace Tilemap.
Enjoy!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

<3

So that's what you've been up to. <3

You think that your Tilemap is more efficient? Have you tested it or is it just an assumption? After all, the original Tilemap was made in C++.
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.

Wizered67

Whenever I try to use this amazing script, it gives me an error on line 136.
no implicit conversion from nil to integer


And yes, I did put in the screenshot.dll

ForeverZer0

@blizz:
I admit it is just an assumption. To be quite honest, I am not exactly sure how the default Tilemap works. From what I can see (at my current scripting level), I can't see how it could be much more efficient, if is using standard RGSS scripts.

@wizered:
I can't seem to reproduce the problem. If you can upload me an example project that it does it in, I will be happy to look into it. The script is not quite finished yet, and it is very possible that there are some bugs left to track down.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

The Niche

Well Zero, an impressive performance. I'm proud to have my soul owned by you :L. Anyway, I'd suggest making it so the window enlarges to the point that it's fullscreen, but doesn't overlap the taskbar.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Wizered67

Maybe it's just my computer. Anyway, I started a new project and it still gives the error. I uploaded the demo at http://www.sendspace.com/file/26ks62.

Guilink

Quote from: Wizered67 on November 25, 2010, 11:05:55 am
Whenever I try to use this amazing script, it gives me an error on line 136.
no implicit conversion from nil to integer


And yes, I did put in the screenshot.dll


I have the same error!

:huh:
Waiting for BABS Controller for RMX-OS update! '-'

www.manaextreme.blogspot.com (my brazilian game-newblog)

ForeverZer0

November 25, 2010, 01:31:30 pm #7 Last Edit: November 25, 2010, 01:32:41 pm by ForeverZer0
One thing to try is to restart your computer after putting in the screenshot.dll
I know Ryex had a similar issue with the WeatherCreator not reading the display.dll, but after he restarted, it worked fine. This is just an idea, but it is worth a try. Like I said, it will not do it for me, and is likely an issue with your PC's settings that I am not aware of.

Also, ensure that the dll is named exactly as this, and all downcase, although I'm not sure if it matters:

                                                           screenshot.dll

(Never used the marquee before, just trying it out  ;))
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Wizered67

November 25, 2010, 01:35:16 pm #8 Last Edit: November 25, 2010, 01:39:23 pm by Wizered67
In a few minutes a may try restarting, but I don't think thats the problem as I'm already using Game Guy's screenshot script that uses the screenshot.dll in a different project.

edit: are you sure its not just your script?(no offense) I just tried  different resolution script and it worked fine on my computer.....

Guilink

I also tried rebooting and it did not work
Waiting for BABS Controller for RMX-OS update! '-'

www.manaextreme.blogspot.com (my brazilian game-newblog)

Wizered67

I'm not a very good scripter and I don't claim to be, but is it possible that the reason we are getting the error is that Resolution.new is not being called? When I put Resolution.new in the self.snapshot area, it does this
Spoiler: ShowHide
I'm not quite sure if this is how the script was intended to work. The only problem is that it randomly gives an "undefined method +" error, although I don't know if that is my fault.

ForeverZer0

November 25, 2010, 01:57:07 pm #11 Last Edit: November 25, 2010, 01:59:30 pm by ForeverZer0
I would say "yes" its the script right away, but not everyone is having this problem. I'm not going to take offense at that by the way. I don't know of a scripter who has never had bugs/problems with their scripts. I know I have had my share  ;).

But anyways, the fact that some experience it, while others don't, with the only difference being the hardware and PC settings kind of narrows it down. I would love to be able to help you, I don't like having scripts out there that don't work, but I personally cannot get it reproduce the error, and the best I can do is make educated guesses at what it could be.

The script makes calls using the Win32API module to make low-level calls to functions on your computer, which any number of priviledge levels, parental controls, etc. could effect, along with basic configuration settings. All of these are factors that I cannot foresee, nor account for in the script.

:O.o:
Uh-oh. I may have forgot to include the method to call it. Resolution.new does need called. My bad.
I updated the instructions.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Wizered67

Okay, so by using Resolution.new in the self.snapshot it does indeed work. However, after I move for I while I get an
undefined method + for nil:NilClass

on the line
 return $game_map.priority_data[$game_map.map_id][@x, @y] + z

ForeverZer0

Call it in Main, before processing begins, not in snapshot. It needs called before the game starts, not during every transitions. I updated the post and instructions. They are a little more clear. It was my fault I forgot to mention that it needed called. Left that part out.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Wizered67

November 25, 2010, 02:30:35 pm #14 Last Edit: November 25, 2010, 02:33:48 pm by Wizered67
Okay, I did that, but it still gives the same error.

edit: Also, if possible, you should make it so that you can't do alt + enter for fullscreen as that messes up the script.

ForeverZer0

Okay, I may have found a possible bug.
Add things to all three layers, save the map, and see if it still does it.
Let me know. If that fixes it, it is indeed a problem with the script.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

Props to you zero. I've seen you've done quite some scripting. Nice job :)

Wizered67

That still doesn't fix it......

ForeverZer0

I see from your pic that the resolution is changing. So what exactly is the problem, and when exactly is the problem occuring? During transitions? Just walking around? I'm sorry, but I am lost on this one... :O.o:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

I was thinking about using your Tilemap class in CP if it was more efficient. That's why I'm asking. :) I think the best way to test it would be a raw test on a couple of bigger maps with quite a number of events to see which one works better. Also, careful with the memory.
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.

Wizered67

Sorry for being confusing. The problem is that when I get to the map, after walking around for a while, it will suddenly crash and give me the error I mentioned before.

ForeverZer0

November 25, 2010, 07:07:24 pm #21 Last Edit: November 26, 2010, 12:26:36 am by ForeverZer0
@blizz
I can do some testing, if you would like. The map I have been using for testing this script is somewhat large, though I'm sure there will be larger maps in most people's games. I have a method I made for testing efficiency, which can log the number of miliseconds a method takes to execute. It's not perfect, but it will usually get you in the ballpark.

I know I am walking a thin line with the memory. This is actually about the third version. I was torn trying to delegate on when to make sacrifices to on-the-fly processing, and when to do it to RAM. This version is pretty close to what the final version will be. I do have one question with regards to loading the cached data. Would it be more efficient to load the entire hash when the game is loaded and reference it only the key I need for the map, or not load any of it, and only load the values of the hash for the map on the fly when the map is created. I really don't know how efficient the method is to open a file and Marshal load it, so I wanted to stay clear of constantly loading data this way every time a new map is encountered.
The reason for the files was to drastically reduce the number of iterations needed to be done at run-time, which I think could help with any lag issues due to a larger map.

One more question, in ABSEAL, how did you come up with the value of 1600 for the sprite size. I want to also include an aliased method in the final version that will resize the sprite accordingly for the defined resolution if ABSEAL or BABS is being used.


EDIT:

TEST MAP SIZE: 1024 x 576

Okay, after some testing, here are the results. The average time a map takes to initialize is 0.320 with this script, and only 0.070 without it. This is definitely something I need to look into. The average update time is dead even, both ending with an average time of 0.025 after 400 updates (Graphics.update included).

I'm relatively pleased with the results. Although the initialization timing is longer (still only 1/3 of a second), I did manage to keep the update method the same, which is far more important. This basically means that once the map is loaded, no sacrifice is being made updating a screen 192% larger.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

impressive man impressive. the init time is hardly a problem, and when you thing about it i makes sense as it uses more memory for a larger screen there is no way it could not use more memory and it is a fair trade off for dead even update times on a larger screen. how big was the screen you were testing on? and will you test the limits and go higher to see the effect?
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

The test map was 1024 x 576, and yes I plan to test it on even bigger maps, though not until tomorrow.
I'm sleepy. Too much turkey.

Glad you like.  :haha:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

no I mean what was the screen size normal it is 640 by 480 what was it in the test? and will you test bigger like 1600 x I forget the standard resolution (clearly that is an extreme and likely never be used but it is still a good thing to know.)
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Quote from: ForeverZer0 on November 25, 2010, 07:07:24 pm
I know I am walking a thin line with the memory. This is actually about the third version. I was torn trying to delegate on when to make sacrifices to on-the-fly processing, and when to do it to RAM. This version is pretty close to what the final version will be.


If you keep it within several MB, then it's not a problem. Even a couple of dozens of MB are marginally acceptable.

Quote from: ForeverZer0 on November 25, 2010, 07:07:24 pm
I do have one question with regards to loading the cached data. Would it be more efficient to load the entire hash when the game is loaded and reference it only the key I need for the map, or not load any of it, and only load the values of the hash for the map on the fly when the map is created. I really don't know how efficient the method is to open a file and Marshal load it, so I wanted to stay clear of constantly loading data this way every time a new map is encountered.
The reason for the files was to drastically reduce the number of iterations needed to be done at run-time, which I think could help with any lag issues due to a larger map.


In Blizz-ABS I load the passability data on demand as well and it doesn't seem to be a problem. You should definitely calculate it in advance and load it separately. But whether you want to load it all at once or only load the current map, that's up to you. I think loading only the current map is fine.

Quote from: ForeverZer0 on November 25, 2010, 07:07:24 pm
One more question, in ABSEAL, how did you come up with the value of 1600 for the sprite size. I want to also include an aliased method in the final version that will resize the sprite accordingly for the defined resolution if ABSEAL or BABS is being used.


I needed a high threshold value so I simply used 1600. I could have used 0xFFFFFFFF, but there was no need for it. 1600 should cover the size of most, it not all character sprites that somebody would use. This is actually used to destroy the sprite when it's outside of the screen since RMXP renders sprites outside of the screen. Feel free to take parts of that code and adapt it.

Quote from: ForeverZer0 on November 25, 2010, 07:07:24 pm
TEST MAP SIZE: 1024 x 576

Okay, after some testing, here are the results. The average time a map takes to initialize is 0.320 with this script, and only 0.070 without it. This is definitely something I need to look into. The average update time is dead even, both ending with an average time of 0.025 after 400 updates (Graphics.update included).

I'm relatively pleased with the results. Although the initialization timing is longer (still only 1/3 of a second), I did manage to keep the update method the same, which is far more important. This basically means that once the map is loaded, no sacrifice is being made updating a screen 192% larger.


The initialization might possible take longer on relatively smaller maps due to the extra data loaded, but I'm sure that larger maps should load faster than without your script. There's usually a threshold under which a script like this is actually less efficient. But that actually doesn't matter since the difference is so small that you won't notice (0.3 seconds is really not something that you notice that much compared to 0.07).
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.

ForeverZer0

@ryex
Sorry, I just scanned your message and thought you were asking the screen size. The test map size was 75 x 55. It had a medium amount of events on it, though with this particular test, I was not so much concerned with the effect events happen to have. I'll probably do some more in-depth testing tonight, with even larger maps, and test differences with the number of events, etc, etc.

Future plans:

  • Adjust the way the autotile and priority data is loaded.
  • Create a method to have ABSEAL work correctly with this.
  • Make some fixes for a few default systems, such as weather, message boxes, etc.
  • Possibly find a way to create a way to have windows automatically correct themselves using a different resolution, but I doubt this is very practical, and will likely lead to only more issues. 
  • Attempt to cut down on RAM usage if possible.

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

lol I WAS taking about screen size you just kept saying map size. so the resolution was 1024 x 576? wow thats fairly big you should go to at least 1400 x 900 to test it out.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

My monitor resolution is only 1366 x 768.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

I could test it out. My resolution is 1920 x 1200 well its actually my grandmas but same difference.

Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

WhiteRose

My monitor is 1920x1200. I could test it for you if you'd like.

The Niche

Ok, I've got a probwem with the script. If I try to use it with BABS, it throws me an error, complaining about the pixel_rate in BABS part 3 being undefined for nil class.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

123th

error in game map
  def setup(map_id)
...
...
...
   $game_system.scroll_x = 0

undefined method "scroll_x=" for nil:NilClass

ForeverZer0

Quote from: 123th on December 12, 2010, 05:26:14 pm
error in game map
  def setup(map_id)
...
...
...
    $game_system.scroll_x = 0

undefined method "scroll_x=" for nil:NilClass


I have no clue where your getting that from. That's not in the script, nor is even the proper class to reference "scroll_x". That is used in Game_Map, not in Game_System. You either added that as an edit yourself, or it is a mistake in another script you are using, nothing to do with this one.

What are other scripts are you using?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

123th

Quote from: ForeverZer0 on December 12, 2010, 06:01:03 pm
What are other scripts are you using?


mmm... damned patch... reinstall rmxp really help  :shy:

ForeverZer0

December 12, 2010, 07:04:13 pm #36 Last Edit: December 12, 2010, 08:56:28 pm by ForeverZer0
I added a few compatibility fixes, which I placed in a new section in the main post. Currently the fixes only include the weather systems (that I know of), but expect more to come soon. Feel free to ask for a fix, but I only will be doing it for either default RMXP scripts, or widely popular and distributed scripts. I will not being doing it for some obscure script that know one ever heard of that you found on a random forum located in Cambodia.

EDIT: Nevermind. I'm starting a new topic with it.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

The Niche

Quote from: The Niche on December 12, 2010, 09:58:27 am
Ok, I've got a probwem with the script. If I try to use it with BABS, it throws me an error, complaining about the pixel_rate in BABS part 3 being undefined for nil class.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

G_G

@F0, sorry I havent been able to test the script with the resolution. I'm sorry. Got really busy at my grandmas house then forgot about it. I might be able to return the results within 2-3 weeks.

ForeverZer0

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

oh ya, for got about the test stuff, finals drove it right out of my head. I went a head and did that.

but got this error the prevented me from testing:
---------------------------
Project1
---------------------------
Script 'resolution' line 481: NoMethodError occurred.

undefined method `+' for nil:NilClass
---------------------------
OK   
---------------------------

that line reads
return $game_map.priority_data[$game_map.map_id][@x, @y] + z


this might have something to do with how I set up my maps considering where the error is. as such I'v uploaded the project files for you
http://www.sendspace.com/file/7934y4

good luck!
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

fjurio

I get this error:

Spoiler: ShowHide


The first time i forgot the screenshot.dll but now i placed it in the game folder and still get this error.

I copied the script in a new project and didnĀ“t chance anything.

ForeverZer0

I'll look into both problems. I still have a few minor bugs to work out, that's why I released it as v.0.9. I was hoping people using it could help me track a few down, so thanks for letting me know.

What's odd, though is that many get no errors, while others get a variety of different errors.

Here's what I will be likely changing before v.1.0:

  • Have priority data load differently for each map.
  • Possibly write a script to provide the same feature as the screenshot.dll to avoid errors, incompatibility, and platform issues.
  • Fix a few other minor bugs I can't think of right now, and attempt to improve overall coding.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

WhiteRose

Quote from: Ryex on December 14, 2010, 03:26:57 am
oh ya, for got about the test stuff, finals drove it right out of my head. I went a head and did that.

but got this error the prevented me from testing:
---------------------------
Project1
---------------------------
Script 'resolution' line 481: NoMethodError occurred.

undefined method `+' for nil:NilClass
---------------------------
OK   
---------------------------

that line reads
return $game_map.priority_data[$game_map.map_id][@x, @y] + z


this might have something to do with how I set up my maps considering where the error is. as such I'v uploaded the project files for you
http://www.sendspace.com/file/7934y4

good luck!


I was getting a similar error, so it's not unique to Ryex.

The Niche

Quote from: The Niche on December 13, 2010, 03:30:47 am
Quote from: The Niche on December 12, 2010, 09:58:27 am
Ok, I've got a probwem with the script. If I try to use it with BABS, it throws me an error, complaining about the pixel_rate in BABS part 3 being undefined for nil class.



Gah...I feel unloved...
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

ForeverZer0

@niche
Sorry, I will address that, too.  ;)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

The Niche

Aw, you're the best, Zero, *hugs*
*Not sucking up at all*
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

ForeverZer0

@ryex
I looked in to your problem and found the answer. For some reason the cached data for the start map was only for a map of 20 x 15, but it was actually 100 x 100. Probably from old data before you expanded the map, but was not overwritten. I simple erased the priority data from the Data folder, had it re-cache and it worked like a charm.
This is definitely another bug to work out (simple to fix) for the completed version. I'm glad you found it, though, thanks!  ;)

@niche
Gonna check out your problem next. I have been lazy and done nothing with RMXP the past few days.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

The Niche

Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Wizered67

Quote from: ForeverZer0 on December 17, 2010, 06:20:45 pm
@ryex
I'm glad you found it, though, thanks!  ;)

Hey, I've been having the same problem since the first page. lol.  :o

ForeverZer0

@wizered
Have you attempted re-pasting the script. I had downloaded your project, ran it, got the error. Before I bothered looking throught the script I re-copied the script into your project and it ran fine. Not sure what the copy-paste error was, I am not gonna bother comparing each script to find the difference, but it fixes your problem.  ;)

@BABS users:
I'm working on compatibility for BABS at the moment. Found a fix to the pixel_rate error, but found another right after it. I discovered that a blank map without a tileset will throw errors. Need to fix that now.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.


ForeverZer0

December 17, 2010, 08:57:33 pm #52 Last Edit: December 18, 2010, 12:00:44 am by ForeverZer0
Quote from: Wizered67 on December 17, 2010, 08:47:16 pm
Nevermind.


Then don't do it.  I just did it and it fixes your problem.  I thought that's what you wanted.  Silly me.


EDIT:
Anyways, updated the script to 0.92 (getting there...)
I added some compatibility fixes for BABS. It is by no means 100% compatible with every feature as of yet, but should at least allow for you to play the game without it crashing. I've yet to go through and make fixes for screen centering, ABSEAL sprite size, etc.

I already have a bunch of fixes made for a lot of common scripts that I was going to post in another thread so that you could simply use the ones you needed, but alas, the 403 Error, my arch-nemeisis at CP, remains a worthy adversary and will not allow me to share it with all of you.   :(
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

December 18, 2010, 05:44:19 am #53 Last Edit: December 18, 2010, 03:56:45 pm by Blizzard
F0, email me the whole post. I can try to update your first post instead.

EDIT: There you go.
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.

ForeverZer0

<3

And I mean this in as heterosexual way as I can:  :-*, you sexy man.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

WhiteRose

Hmm, I'm having a rather unusual issue. The game runs if I launch it from the Game.exe executable as administrator (I'm running Windows 7,) but if I either launch it not as an admin, or from the RMXP program, it crashes before drawing the title screen. Has anyone else run into this problem?

ForeverZer0

December 18, 2010, 04:58:32 pm #56 Last Edit: December 18, 2010, 05:02:11 pm by ForeverZer0
Quote from: WhiteRose on December 18, 2010, 04:52:48 pm
Hmm, I'm having a rather unusual issue. The game runs if I launch it from the Game.exe executable as administrator (I'm running Windows 7,) but if I either launch it not as an admin, or from the RMXP program, it crashes before drawing the title screen. Has anyone else run into this problem?


Is it a "no implicit conversion from Nil to Integer" error?
If it does happen to be this, try moving the "Resolution.new" line to different places and see if it helps. I kept getting this error myself before. The problem is with the transitions. The resolution needs to be changed before any call is made for a transition, else it will crash. I think something in BTEST or DEBUG makes a call or something, I haven't looked that deep into it as of yet, since I found a temporary fix, but this will be fixed before version 1.0. At least I hope that's the error you are getting...



EDIT: I also just noticed that autotiles aren't updating in the newest version. Oops.
        Guess that needs fixed now, too.  :???:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Agckuu Coceg

Hm, that's a good point, FZ. At the present moment already it is possible to name your system very and of very outstanding. By the way, the small demand in regard to this: it is possible create the compatibility of this system with scripts used old Tilemap class, like this Tileset Animator?

http://www.4shared.com/file/ls4NPAMJ/Tileset_Animator.html

I'm not retarded, but I'm busy. Sorry for patience.


ForeverZer0

December 19, 2010, 02:48:00 am #58 Last Edit: December 19, 2010, 05:03:23 am by ForeverZer0
Making it compatible could be done easily. I believe you would only need to add a "@tilemap.refresh " near the end of the update method to call it when the tilemap bitmap is changed.

I would advise against that script, even for the default Tilemap script, though. You may has well just re-label the script to "LAG". It takes quite a bit for the entire game map to be re-drawn every 10 frames. I wouldn't have a window be re-drawn that often if not neccessary, let alone the tilemap.


EDIT: I also fixed bug with autotiles in newest version. I forgot a lone little "if" as a condition for a "next", therefore it would always "next" to the next iteration and not store data.

EDIT2:
Alright, I did the following:
  • Did some overall coding improvements.
  • Fixed possible error that could occur if transition occurs before resolution is initialized.
  • Fixed possible error that could occur if log file tried to be created when the data file was not present.
  • Changed the Resolution module to a class. Now uses a global variable to create an instance, which can also double as a plug-in variable for other scripts to check for its presence.

    I ALSO UPLOADED A DEMO

    This should be helpful for those who are still having issues with it not working at all. If the demo just flat doesn't work, the only problem it can be is some type of PC setting or something. This doesn't neccessarily mean that it can't be fixed, though. If you still encounter problems with the game running using the demo, please still report it and I can attempt to find a way around it.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

123th

Quote from: ForeverZer0 on December 19, 2010, 02:48:00 am
Making it compatible could be done easily. I believe you would only need to add a "@tilemap.refresh " near the end of the update method to call it when the tilemap bitmap is changed...

Spoiler: ShowHide
mmm... yes, lag as result, but no animation.  :wacko:

ForeverZer0

@123th

I actually just spent a couple minutes looking at it, and the reason it doesn't work is that the script changes the name in the Tilemap class and not Game_Map. My script doesn't even define that variable, it simply reads the name of the tileset from Game_Map. If the script is adapted to change the name of $game_map.tileset_name, and then refreshed, it will work. Its not even practical to use, but it will work.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

IserLuick

An awesome script indeed. Congratulations!  :haha:

If this data can help, I found an interesting error with the script; when I press Alt + Enter to have the game full screen, the resolution changes to the default 640x480, and most interesting, if I press alt+enter again to switch to window mode, the window gets to default size and not the one defined by the script. Another interesting thing is that when this happens, the position of the player remains the same as defined by the script (I tested this on the demo); for example, if I get to the center of the screen with the custom resolution, when I press Alr + enter the resolution changes but the player does not appear in the center of the screen anymore, and when I move the screen moves, but it moves accordingly to the custom resolution.

This do not crashes the game, it only "resets" the resolution to its original value and messes up a bit with the player's position.

Good luck!
Greetings!  :)

ForeverZer0

I noticed that as well.
I may be able to fix this, but it is going be a little buggy to fix it. The Alt+Enter combo is a command used by the Windows platform, not by RMXP. Basically, the game doesn't even know if it is in fullscreen or not.

I may be able to make some type of fix that checks the for the button input, checks if the screen is going back to default, and then re-initialize the Resolution to revert it back.

I would actually prefer to somehow disable ability to do so, but then the script would have to be distributed with a very slightly modified version of Game.exe.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

Oh F0. I completely forgot xD. I can test your thing now. Great way to break out my new computer. Though it'd be nice to know whats steps and setups I should test. Let me know and sorry...xD

ForeverZer0

There's actually a number of ways you could test it. I used a console to view the data in real time, and used something like this in Spriteset_Map:


time = Time.now
@tilemap.update
puts Time.now.to_f - time


I also used a few variations to see the averaged number, etc, etc.

Try different maps, different screen sizes, number of sprites, etc.
You can also keep an eye on the FPS and see how it is affected.
The good 'ol "Is the game lagging?" test is also pretty good.  :P

Thanks again!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

holly!

tested at 1400, 900

with a 100 x 100 map with 79 events
I got 23 - 25 fps on average and the game process was using 50% of my CPU (2.5 GH dual core)
init: 0.404000043869019
update: 0.00600004196166992
update: 0.00600004196166992
update: 0.00566665331522624
update: 0.00575000047683716
update: 0.00560002326965332
update: 0.00566669305165609
update: 0.00571431432451521
update: 0.00575000047683716
update: 0.00577775637308757
update: 0.0056999683380127
update: 0.00581815026023171
update: 0.00583330790201823
update: 0.00584613359891451
update: 0.00592855044773647
update: 0.00593331654866537
update: 0.00593747198581696
update: 0.00594115257263184
update: 0.00594442420535617
update: 0.00610524729678505
update: 0.00614998340606689
update: 0.00614284333728609
update: 0.00613635236566717
update: 0.00613042582636294
update: 0.00616665681203206
update: 0.00615999221801758
update: 0.00615384028508113
update: 0.00614814405088071
update: 0.00614285469055176
update: 0.00613793011369376
update: 0.00613333384195964



then I tested a 50x50 map on the same res with 16 events
30 - 32 fps
40 - 45% CPU

init: 0.141999959945679
update: 0.00300002098083496
update: 0.00250005722045898
update: 0.00200001398722331
update: 0.00150001049041748
update: 0.00139999389648438
update: 0.00133335590362549
update: 0.00114287648882185
update: 0.0011250376701355
update: 0.00111116303337945
update: 0.00110006332397461
update: 0.00100005756724965
update: 0.00100006659825643
update: 0.00100005589998685
update: 0.0010000467300415
update: 0.00100003878275553
update: 0.00100003182888031
update: 0.00100002569310805
update: 0.00100002023908827
update: 0.00094738759492573
update: 0.000950014591217041
update: 0.00095239139738537
update: 0.000909100879322399
update: 0.000913049863732379
update: 0.000916669766108195
update: 0.000920000076293945
update: 0.000923074208773099
update: 0.000925920627735279
update: 0.000928563731057303
update: 0.000931032772721915
update: 0.000933329264322917
update: 0.000935485286097373
update: 0.000937506556510925
update: 0.000909097266919685
update: 0.000911768744973575
update: 0.000885718209402902
update: 0.000888890690273709
update: 0.000891898129437421
update: 0.000894741008156224
update: 0.000897438098222781
update: 0.000900000333786011
update: 0.000902437582248595
update: 0.000904758771260579
update: 0.000906977542611056
update: 0.000909090042114258
update: 0.000911108652750651
update: 0.000913039497707201
update: 0.000893613125415559
update: 0.000895828008651733
update: 0.000897952488490513
update: 0.000899996757507324
update: 0.000901960859111711
update: 0.000884615457974947
update: 0.000905662212731703
update: 0.000907412281742802
update: 0.000909098711880771
update: 0.000910720654896327
update: 0.000912285687630637
update: 0.000896556624050798
update: 0.000898312714140294
update: 0.000900010267893473
update: 0.000901648255645252
update: 0.000903233405082457
update: 0.000904768232315306
update: 0.000890631228685379
update: 0.000892312710101788
update: 0.000878792820554791
update: 0.000880600801154749
update: 0.000882359112010283
update: 0.000869571298792742
update: 0.000871433530535017
update: 0.000873246663053271
update: 0.000875009430779351
update: 0.000876720637491305
update: 0.000878385595373205
update: 0.000866673787434896
update: 0.000855270184968647
update: 0.000857151948012315
update: 0.000846162820473695
update: 0.000848109209084813
update: 0.000850009918212891
update: 0.000851863696251387
update: 0.000865866498249333
update: 0.000867481691291533
update: 0.000869058427356538
update: 0.000858834210564108
update: 0.000860474830450014
update: 0.000862080475379681
update: 0.000863646919077093
update: 0.000853943021109935
update: 0.000933345158894857
update: 0.000934079453185364
update: 0.000923926415650741
update: 0.000924743631834625
update: 0.000925543460440128
update: 0.000926326450548674
update: 0.000927095611890157
update: 0.000927848914234909
update: 0.000928584410219776
update: 0.000929307455968375
update: 0.000930016040802002
update: 0.000930708233672794
update: 0.00092158364314659
update: 0.000922344263317516
update: 0.000923090256177462
update: 0.0009238220396496
update: 0.000924542265118293
update: 0.000925246800217673
update: 0.000925940495950204
update: 0.000926621463320671
update: 0.000927287882024592
update: 0.000927942293184298
update: 0.000928585018430437


I did NOT expect it to do that well
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

I'm pleased with that. Although the hardware will be the primary factor determining lag, I did attempt it to make it update the least number of objects. ABSEAL should make it even better.

I would still suggest against using screen sizes so large. Aside from the fact that you need to keep it in a range of sizes that pretty much anybody's screen is big enough for, there is going to be at least some performance loss using a larger resolution.


@ryex
Thanks a bunch for the testing!  :D
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

dani3

Sorry to necropost, but there is a problem concerning events on the map. I set a resolution of 1024x768 and they disappear when they move.

Blizzard

Are you using a custom anti-lag script? Make sure it's set up properly and if there is no special setup for this, you will need to edit it.
Either way make sure that all Viewport instances in Spriteset_Map are set up properly to the new resolution (only where needed obviously).
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.

dani3

Thank you blizzard, I suspect it's XAS that causes that... I will try to tweak with those scripts to see if I can solve this issue.

Zexion

I know this is old, and I don't know if anyone would be willing to fix this, but it's kind of an annoying bug.
If you place an autotile on the first layer, and place ANYTHING on the second layer (over the autotile of course) it stops animating, AND loses it's passability rules.

KK20

Bleh, that's probably a problem in the rewritten Tilemap class. God knows I don't even want to try studying that...yet. (I probably will since my Advance Wars kinda needs it, but this is low on my priority list right now)





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Heretic86

I've noticed a couple problems right off the bat.

#1  Resolution is not adjusted for Full Screen Resolutions.  Resolution is still set at 640x480.  At least for me. (XP 32)

#2  While in Full Screen, bottom and right side of map are not dispalyed properly.  The map stops scrolling, but the character can continue to walk to off screen where the map normally continues, but not visible due to failed scrolling.

#3  Also Full Screen related.  Character is centered in positions other than center of the screen.  Im sure this is directly related to being rendered as 640x480 and calculated for alternate resolutions.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

G_G

All those problems have to due with RMXP's built in fullscreen crap. I don't believe there is anyway to change the resolution in fullscreen as that's set in the underlying engine. And since the screen is forced to 640x480 and the script thinks it's a different resolution, that's why the scrolling and centering isn't working properly. Long story short, can't fullscreen with this script.

Zexion

I think the autotile problem has to do with that system that checks if the autotile needs to be updated. I think it should always be updated if it exists. I just wouldn't know what to change, but I think it's in this part of the code...
  def map_data=(data)
    # Set the map data to an instance variable.
    @map_data = data
    # Clear any sprites' bitmaps if it exists, or create new ones.
    @layers.each_index {|i|
      if @layers[i].bitmap != nil
        # Dispose bitmap and set to nil.
        @layers[i].bitmap = @layers[i].bitmap.dispose
      end
      # Create new bitmap, whose size is the same as the game map.
      @layers[i].bitmap = Bitmap.new($game_map.width*32, $game_map.height*32)
    }
    # Draw bitmaps accordingly.
    refresh
  end
 
  def refresh   
    # Set the animation data from the file if it exists, or create it now.
    @animated = $game_map.autotile_data
    # Iterate through all map layers, starting with the bottom.
    [0,1,2].each {|z| (0...@map_data.ysize).each {|y| (0...@map_data.xsize).each {|x|
      tile_id = @map_data[x, y, z]
      # Go to the next iteration if no bitmap is defined for this tile.
      if tile_id == 0 # No tile
        next
      elsif tile_id < 384 # Autotile
        name = $game_map.autotile_names[(tile_id / 48) - 1]
        bitmap = RPG::Cache.load_autotile(name, tile_id)
      else # Normal Tile
        bitmap = RPG::Cache.tile($game_map.tileset_name, tile_id, 0)
      end
      # Determine what the layer to draw tile, based off priority.
      layer = @priorities[tile_id]
      # Perform a block transfer from the created bitmap to the sprite bitmap.
      @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
    }}}
  end
 
  def update
    # Update the sprites.
    if Graphics.frame_count % $game_map.autotile_speed == 0
      # Increase current frame of tile by one, looping by width.
      @animated[0].each_index {|i|
        @animated[2][i] = (@animated[2][i] + 1) % @animated[1][i]
        @animated[3][i].each {|data|
          # Gather data using the stored coordinates from the map data.
          tile_id, x, y = @map_data[data[0], data[1], data[2]], data[0], data[1]
          name, layer = @animated[0][i], @priorities[tile_id]
          # Load the next frame of the autotile and set it to the map.
          bitmap = RPG::Cache.load_autotile(name, tile_id, @animated[2][i])
          @layers[layer].bitmap.blt(x*32, y*32, bitmap, Rect.new(0, 0, 32, 32))
        }
      }
    end
  end
end

KK20

Figured it out. It wasn't because of any of those. :P Nice effort though.

Near the bottom under DEBUG Mode

above = []
((z+1)...data.zsize).each {|zz| above.push(data[x, y, zz]) }
animated[3][index].push([x, y, z]) #if above.all? {|id| id == 0 }

That can all be replaced with

animated[3][index].push([x, y, z])


Anything with a priority of 0 placed on top of the autotile, however, will not appear.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

KK20

Script has been updated to version 0.94. It addresses some bugs that users have found and I have fixed.

  • Changing a map's panorama more than once closed the game

  • When caching the maps, if your project had a lot of maps (we're talking hundreds), the project would get a 'Script is hanging' and close

  • Tiles placed on layers over an animating autotile prevented the autotile from animating. It also disrupted passability rules.

  • Transparent animating autotiles would not be transparent due to overlapping of images. (It is recommended that your autotile have a priority higher than 1 to prevent seeing the panorama/black viewport behind it)

  • $game_map.data[x,y,z] = tile_id did not make graphical changes to the map instantly. (The actual code to do this was quite a doozy!)






   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Terv

Quote$game_map.data[x,y,z] = tile_id did not make graphical changes to the map instantly.

Thank you for providing a function that is no less than vital to my project any plans for a special limited signature edition of your project I could throw my money at?

ExoReality

If I copy the script version 0.94 into the old demo I get this glitch:


I did something wrong? D:

Terv

July 24, 2013, 08:27:57 am #79 Last Edit: July 24, 2013, 08:29:40 am by Terv
Quote from: KK20 on December 24, 2012, 01:41:51 pmAnything with a priority of 0 placed on top of the autotile, however, will not appear.
If you change the brige's tiles' priority to 1 they appear again; however they also overlap the player and the autotile beneath blocks the path. You could just merge the autotile and the bridge in Photoshop and put them on a single layer, but this doesn't work for animated autotiles, like the water on your screen. So a fix is needed.

KK20

Noted. I'll look into it either today or tomorrow depending on how much I have to study for my midterm.

EDIT:
I see what the problem is. Unfortunately, my best solution would be to make a complete change as to how the maps are drawn. Right now the script uses 6 sprites (basically viewports of differing z-values) and draws tiles based on priority (all tiles of priority zero are drawn on the lowest viewport) and layer (all tiles on the bottom layer are drawn first). The first idea that came into my head was to create 18 of those sprites, one for each layer and every level of priority. I don't know how well this would work performance-wise. I need to think about it some more when I have free time.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

KK20

Script updated to v0.95.

Biggest change is the way how the tilemap is drawn. In the old version, there were only 6 sprites to draw the entire bitmap, one for each level of priority. Now there are numerous sprites for each LAYER (the three you are aware of in the map editor), PRIORITY, and ANIMATED AUTOTILE. Animating autotiles are large sprites that take up the entire length of the map. It also creates an equal number of sprites to the number of frames of animation the autotile has. The game simply does a series of turning these sprites in/visible numerous times to simulate animation. Compared to previous versions, you would receive much lag on maps that used a heavy amount of animating autotiles. However, this will probably be harder on the CPU, make note.

Testing would be appreciated. I forgot to add some checks to retain the tilemap graphics should the player change scenes or transfer to the same map. I'll probably do that sometime soon, but still call it v0.95.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Zexion

Omg, once you finish the scene thing this will literally be perfect. I honestly love this script 100x more than any of the others, but the autotile bug really annoyed me. I'll test it out a bit and see what happens.

LiTTleDRAgo

Report

- the autotile problem is now gone, but the FPS drop still occured (in XAS, at clean project FPS is OK)
- Script Hanging Error when used in project with many large maps (not XAS, I'm testing it at clean project)


Click to Enlarge

- transition problem (result is same, no matter what is the image used)


Click to Enlarge

- it's just a suggestion, can you remove dependency for screenshot.dll in RGSS3 engine? (there is Graphics.snap_to_bitmap method in there, screenshot.dll is not necessary isn't it?)

KK20

August 12, 2013, 07:56:20 pm #84 Last Edit: August 12, 2013, 10:52:40 pm by KK20
There always seems to be something wrong with XAS. Yeah, still want to know how King's reduces lag/CPU-usage so well in comparison to what I did. From what I'm understanding of his script, it's just drawing each row of tiles as separate graphics but keeping autotiles and 384+ tile_ids separate. I'll have to experiment sometime.

I wonder what the script is hanging is for. Did it happen before the title screen (I'm guessing this) or after? Probably something went wrong with caching the maps. Oh wait, I think it's the "Graphics.update hasn't been called in 10 seconds" problem while drawing the map. Should be easy to fix.

Quote from: ForeverZer0's words
#   - Normal transitions using graphics cannot be used. With the exception of
#     a standard fade, like that used when no graphic is defined will be used.
#     Aside from that, only special transitions from Transition Pack can be
#     used.

Are you basically asking me if I could change that?

That method doesn't exist in RMXP sadly. Without it, the game can't make a simple fade transition anymore. For RGSS3, yeah I guess you could substitute for that change. I'm mainly writing this with XP in mind.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Terv

August 12, 2013, 10:39:52 pm #85 Last Edit: August 12, 2013, 10:44:07 pm by Terv
King has implemented a way of initially drawing+caching the whole map at the beginning, which results in big maps (200x200+) consuming 1 GB of RAM (or even more) but makes for a good performance gain. I've translated his notes in the script's header, it's in the kit in case you haven't seen it yet.

KK20

August 15, 2013, 02:28:13 am #86 Last Edit: August 15, 2013, 02:30:21 am by KK20
There has to be something more to it though. I mean, the only real thing that sounds different from his than this is that he draws the tiles in rows while this draws in HUGE SPRITES that cover the entire map. Unless few large sprites performs worse than lots of smaller sprites...

EDIT: Alright, I have studied his script, and it's pretty much what I thought. It creates a sprite for each row (so maximum size [$game_map.width * 32, 32]) for animating autotiles (new class for each different autotile) and tilemap/stationary autotiles (new class for each priority level). He only makes the row sprite's width as long as it needs to be, i.e. (x-coordinate of furthest right tile + 32) - (x-coordinate of first sprite). Animating autotiles follow this setup but their width is multiplied by however many frames of animation it has (animation is handled via src_rect method). All layers are drawn on one sprite. Update method only covers the first row outside of the top and bottom of the screen and all rows in-between (probably reason for better performance). The only thing I beat him in is $game_map.data[x,y,z]=tile_id... his redraws the entire tilemap while mine can make a quick two line call (fill_rect then blt).

I was having trouble creating bitmaps for 200x200 maps, probably because 6400x6400 sprites eat up so much space, especially since I'm making a good number of them. Also found out priority 1 tiles are handled wrong (I think I commented something out), but this might be the case for all priorities in general.

I'll probably try incorporating his method for the heck of it and see where it takes me.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Zexion

By the way, I found a bug with the new version! If you open the menu and close it, it gives an error:
line 588: RGSSError Occured
failed to create bitmap

Also, the wierdest thing just happened...I did this once and it actually closed with no error, but I did it again and it errored out o.o

KK20

Yeah I noted that in my post above. It's probably too much memory being taken up.
Quote from: Zexion on August 15, 2013, 11:36:19 pm
I did this once and it actually closed with no error, but I did it again and it errored out o.o

I thought I disposed everything properly though...hmmm. I guess I have something to do tonight and tomorrow.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

KK20

So after a few solid weeks of working on this, I have a new working Tilemap class. I still have some things left to finish with it, but I'd like for others to test it out and report any bugs or script incompatibilities. Smooth scrolling scripts will work (to an extent) if you remove any decimal numbers in the calculations.
Spoiler: ShowHide

#===============================================================================
# Custom Resolution
# Authors: ForeverZer0, KK20
# Version: 0.96
# Date: 6.1.2013
#===============================================================================
#
# Introduction:
#
#  My (ForeverZer0's) goal in creating this script was to create a system that
#  allowed the user to set the screen size to something other than 640 x 480,
#  but not have make huge sacrifices in compatibility and performance. Although
#  the script is not simply Plug-and-Play, it is about as close as one can
#  achieve with a script of this nature.
#
# Instructions:
#
#  - Place the "screenshot.dll" from Fantasist's Transition Pack script, which
#    can be found here: http://www.sendspace.com/file/yjd54h in your game folder
#  - Place this script above main, below default scripts.
#  - In my experience, unchecking "Reduce Screen Flickering" actually helps the
#    screen not to flicker. Open menu with F1 while playing and set this to what
#    you get the best results with.
#
# Features:

#  - Totally re-written Tilemap and Plane class. Both classes were written to
#    display the map across any screen size automatically. The Tilemap class
#    can stand as an entirely separate script. More information about it can
#    be found here:

#
#  - Every possible autotile graphic (48 per autotile) will be cached for the
#    next time that tile is used which equates to faster loading times.
#  - Autotile animation has been made as efficient as possible, with a system
#    that stores their coodinates, but only updates them if visible on screen.
#    This greatly reduces the number of iterations at each update.


#  - System creates an external file to save pre-cached data priorities and
#    autotiles. This will decrease any loading times even more, and only takes a
#    second, depending on the number of maps you have.


#  - User defined autotile animation speed. Can change with script calls.
#  - Automatic re-sizing of Bitmaps and Viewports that are 640 x 480 to the
#    defined resolution, unless explicitely over-ridden in the method call.
#    The graphics themselves will not be resized, but any existing scripts that
#    use the normal screen size will already be configured to display different
#    sizes of graphics for transitions, battlebacks, pictures, fogs, etc.
#  - Option to have a log file output each time the game is ran, which can alert
#    you to possible errors with map sizes, etc.
#
# Issues/Bugs/Possible Bugs:
#
#   - Graphic related scripts and your graphics will need to be customized to
#     fit the new screen size, so this script is not for everyone.


#   - Normal transitions using graphics cannot be used. With the exception of
#     a standard fade, like that used when no graphic is defined will be used.
#     Aside from that, only special transitions from Transition Pack can be
#     used. The script, and its variations, can be found here:


#   - Smooth scrolling scripts may need edits to work with the new Tilemap. The
#     best way to solve the problem is changing any decimal numbers into
#     integers found within that script (for example, change 16.0 to 16). The
#     overall quality of the effect may be deminished somewhat.
#
#
# *** For the latest updates and notes, please visit the script's page here:
#
#
#
#  Credits/Thanks:
#    - ForeverZer0, for script.
#    - Creators of the Transition Pack and Screenshot.dll
#    - Selwyn, for base resolution script
#    - KK20, for Version 0.94 and above and the Tilemap class
#
#===============================================================================
#                             CONFIGURATION
#===============================================================================

  SCREEN = [640,480]###[1024, 576]
  # Define the resolution of the game screen. These values can be anything
  # within reason. Centering, viewports, etc. will all be taken care of, but it
  # is recommended that you use values divisible by 32 for best results.
 
  UPDATE_COUNT = 8
  # Define the number of frames between autotile updates. The lower the number,
  # the faster the animations cycle. This can be changed in-game with the
  # following script call: $game_map.autotile_speed = SPEED
 
  PRE_CACHE_DATA = true
  # The pre-cached file is mandatory for the script to work. As long as this is
  # true, the data will be created each time the game is test-played. This is
  # not always neccessary, only when maps are altered, so you can disable it to
  # help speed up game start-up, and it will use the last created file.
 
  RESOLUTION_LOG = true
  # This will create a log in the Game directory each time the game is ran in
  # DEBUG mode, which will list possible errors with map sizes, etc.
 
#===============================================================================
# ** Resolution
#===============================================================================

class Resolution
 
  attr_reader :version
 
  def initialize
    # Define version.
    @version = 0.93
    # Set instance variables for calling basic Win32 functions.
    ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
    title = "\0" * 256
    ini.call('Game', 'Title', '', title, 256, '.\\Game.ini')
    title.delete!("\0")
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call('RGSS Player', title)
    set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
    set_window_pos  = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @metrics         = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    # Set default size, displaying error if size is larger than the hardware.
    default_size = self.size
    if default_size[0] < SCREEN[0] || default_size[1] < SCREEN[1]
      print("\"#{title}\" requires a minimum screen resolution of [#{SCREEN[0]} x #{SCREEN[1]}]\r\n\r\n" +
            "\tYour Resolution: [#{default_size[0]} x #{default_size[1]}]")
      exit
    end
    # Apply resolution change.
    x = (@metrics.call(0) - SCREEN[0]) / 2
    y = (@metrics.call(1) - SCREEN[1]) / 2
    set_window_long.call(@window, -16, 0x14CA0000)
    set_window_pos.call(@window, 0, x, y, SCREEN[0] + 6, SCREEN[1] + 26, 0)
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call('RGSS Player', title)
  end
  #--------------------------------------------------------------------------
  def size
    # Returns the screen size of the machine.
    return [@metrics.call(0), @metrics.call(1)]
  end
  #--------------------------------------------------------------------------
  def snapshot(filename = 'Data/snap', quality = 0)
    # FILENAME =   Filename that the picture will be saved as.
    # FILETYPE =   0 = High Quality   1 = Low Quality
    @screen = Win32API.new('screenshot.dll', 'Screenshot', 'LLLLPLL', '')
    @screen.call(0, 0, SCREEN[0], SCREEN[1], filename, @window, quality)
  end
  #--------------------------------------------------------------------------
end

#===============================================================================
# ** Integer
#===============================================================================

class Integer
   
  def gcd(num)
    # Returns the greatest common denominator of self and num.
    min, max = self.abs, num.abs
    while min > 0
      tmp = min
      min = max % min
      max = tmp
    end
    return max
  end
 
  def lcm(num)
    # Returns the lowest common multiple of self and num.
    return [self, num].include?(0) ? 0 : (self / self.gcd(num) * num).abs
  end
end

#===============================================================================
# ** Graphics
#===============================================================================

module Graphics

  class << self
    alias zer0_graphics_transition transition
  end
 
  def self.transition(duration = 8, *args)
    # Call default transition if no instance of the resolution is defined.
    if $resolution == nil
      zer0_graphics_transition(duration, *args)
    else
      # Skip this section and instantly transition graphics if duration is 0.
      if duration > 0
        # Take a snapshot of the the screen, overlaying screen with graphic.
        $resolution.snapshot
        zer0_graphics_transition(0)
        # Create screen instance
        sprite = Sprite.new(Viewport.new(0, 0, SCREEN[0], SCREEN[1]))
        sprite.bitmap = Bitmap.new('Data/snap')
        # Use a simple fade if transition is not defined.
        fade = 255 / duration
        duration.times { sprite.opacity -= fade ; update }
        # Dispose sprite and delete snapshot file.
        [sprite, sprite.bitmap].each {|obj| obj.dispose }
        File.delete('Data/snap')
      end
     zer0_graphics_transition(0)
   end
end
end 

#===============================================================================
# ** RPG::Cache
#===============================================================================

module RPG::Cache
 
  AUTO_INDEX = [
 
  [27,28,33,34],  [5,28,33,34],  [27,6,33,34],  [5,6,33,34],
  [27,28,33,12],  [5,28,33,12],  [27,6,33,12],  [5,6,33,12],
  [27,28,11,34],  [5,28,11,34],  [27,6,11,34],  [5,6,11,34],
  [27,28,11,12],  [5,28,11,12],  [27,6,11,12],  [5,6,11,12],
  [25,26,31,32],  [25,6,31,32],  [25,26,31,12], [25,6,31,12],
  [15,16,21,22],  [15,16,21,12], [15,16,11,22], [15,16,11,12],
  [29,30,35,36],  [29,30,11,36], [5,30,35,36],  [5,30,11,36],
  [39,40,45,46],  [5,40,45,46],  [39,6,45,46],  [5,6,45,46],
  [25,30,31,36],  [15,16,45,46], [13,14,19,20], [13,14,19,12],
  [17,18,23,24],  [17,18,11,24], [41,42,47,48], [5,42,47,48],
  [37,38,43,44],  [37,6,43,44],  [13,18,19,24], [13,14,43,44],
  [37,42,43,48],  [17,18,47,48], [13,18,43,48], [1,2,7,8]
   
  ]
 
  def self.autotile(filename)
    key = "Graphics/Autotiles/#{filename}"
    if !@cache.include?(key) || @cache[key].disposed?
      # Cache the autotile graphic.
      @cache[key] = (filename == '') ? Bitmap.new(128, 96) : Bitmap.new(key)
      # Cache each configuration of this autotile.
      new_bm = self.format_autotiles(@cache[key], filename)
      @cache[key].dispose
      @cache[key] = new_bm
    end
    return @cache[key]
  end

  def self.format_autotiles(bitmap, filename)
    if bitmap.height > 32
      frames = bitmap.width / 96
      template = Bitmap.new(256*frames,192)
      # Create a bitmap to use as a template for creation.
      (0..frames-1).each{|frame|
      (0...6).each {|i| (0...8).each {|j| AUTO_INDEX[8*i+j].each {|number|
        number -= 1
        x, y = 16 * (number % 6), 16 * (number / 6)
        rect = Rect.new(x + (frame * 96), y, 16, 16)
        template.blt((32 * j + x % 32) + (frame * 256), 32 * i + y % 32, bitmap, rect)
      }}}}
      return template
    else
      return bitmap
    end
  end
 
end

#===============================================================================
# ** Tilemap
#===============================================================================

class Tilemap
 
  attr_reader   :map_data, :ox, :oy, :viewport
  attr_accessor :tileset, :autotiles, :priorities
 
  def initialize(viewport)
    # Initialize instance variables to store required data.
    @viewport, @autotiles, @tile_sprites, @ox, @oy = viewport, [], [], 0, 0
    @current_frame, @total_frames = [], []
    @tilemap_drawn = false
    @ox_oy_set = [false, false]
    # Get priority data for this tileset from instance of Game_Map.
    @priorities = $game_map.priorities
    # Holds all the Sprite instances of animating tiles (keys based on tile's ID)
    @animating_tiles = {}
   
  end
  #-----------------------------------------------------------------------------
  # Initialize all tile sprites. Draws three sprites per (x,y).
  #-----------------------------------------------------------------------------
  def init_tiles
    # Determine how many frames of animation this autotile has
    for i in 0..6
      bm = @autotiles[i]
      if bm.nil?
        @total_frames = 1
      elsif bm.height > 32
        @total_frames[i] = bm.width / 256
      else
        @total_frames[i] = bm.width / 32
      end
      @current_frame[i] = 0
    end
    # Turn on flag that the tilemap sprites have been initialized
    @tilemap_drawn = true
    # Create a sprite and viewport to use for each priority level.
    (0...((SCREEN[0]/32+2) * (SCREEN[1]/32+2))*3).each{|i|
      @tile_sprites[i/3] = [] if @tile_sprites[i/3].nil?
      @tile_sprites[i/3][i%3] = Sprite.new(@viewport)
      # Shorter and easier to work with for below
      tile = @tile_sprites[i/3][i%3]
      # Assign tile's respective ID value
      tile.tile_sprite_id = i
      # Draw sprite at index location (ex. ID 0 should always be the top-left sprite)
      tile.x = (i % ((SCREEN[0]/32+2)*3) / 3 * 32) - 32 + (@ox % 32)
      tile.y = (i / ((SCREEN[0]/32+2)*3) * 32) - 32 + (@oy % 32)
      map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32
      # If the tile happens to be drawn along the outside borders of the map
      if map_x < 0 || map_x >= $game_map.width || map_y < 0 || map_y >= $game_map.height
        tile.z = 0
        tile.bitmap = RPG::Cache.picture('')
        tile.src_rect.set(0,0,0,0)
      else # Tile is actually on the map
        tile_id = @map_data[map_x,map_y,i%3]
        if @priorities[tile_id] == 0
          tile.z == 0
        else
          tile.z = tile.y + @priorities[tile_id] * 32 + 32
        end
        # No tile exists here
        if tile_id == 0
          tile.bitmap = RPG::Cache.picture('')#@tileset
          tile.src_rect.set(0,0,0,0)
        elsif tile_id >= 384 # non-autotile
          tile.bitmap = @tileset
          tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)
        else # autotile
          tile.bitmap = @autotiles[tile_id/48-1]
          tile.src_rect.set(((tile_id % 48) % 8)*32,((tile_id % 48) / 8)*32, 32, 32)
          @animating_tiles[i] = tile if tile.bitmap.width > 256
        end
      end
    }
    # Sprite ID located at top left corner (ranges from 0..map_width * map_height
    @corner_index = 0
  end
 
  #-----------------------------------------------------------------------------
  # Makes update to ox and oy. Sprites out of range will be moved based on these
  # two values.
  #-----------------------------------------------------------------------------
  def ox=(ox)
    #
    unless @tilemap_drawn
      @ox = ox
      @ox_oy_set[0] = true
      return
    end
   
    return if @ox == ox
    # Shift all tiles left or right by the difference
    shift = @ox - ox
    @tile_sprites.each {|set| set.each{|tile| tile.x += shift }}
    @ox = ox
    # Determine if columns need to be shifted
    col_num = @corner_index
    return unless @tile_sprites[col_num][0].x <= -49 || @tile_sprites[col_num][0].x >= -17

    modTileId = ((SCREEN[0]+64)*(SCREEN[1]+64))/1024   
    # If new ox is greater than old ox
    if shift < 0
      # Move all sprites in left column to the right side and change bitmaps
      # and z-values
      (0...(SCREEN[1]/32+2)).each{|n|
        j = ((SCREEN[0]/32+2) * n + col_num) % modTileId
        @tile_sprites[j].each_index{|i|
          tile = @tile_sprites[j][i]
          @animating_tiles.delete(tile.tile_sprite_id)
          tile.x += 64 + SCREEN[0]
         
          map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32
          tile_id = @map_data[map_x,map_y,i]
         
          if tile_id.nil?
            tile.z = [map_y * 32, 0].max
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
            next
          else
            if @priorities[tile_id] == 0
              tile.z = 0
            else
              tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32
            end
          end
          if tile_id == 0
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
          elsif tile_id >= 384
            tile.bitmap = @tileset
            tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)
          else
            auto_id = tile_id/48-1
            tile.bitmap = @autotiles[auto_id]
            tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)
            @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1
          end
        }
      }
      # New corner should be the tile immediately right of the previous tile
      col_num /= SCREEN[0]/32+2
      col_num *= SCREEN[0]/32+2
      @corner_index = (@corner_index + 1) % (SCREEN[0]/32+2) + col_num
    else
      # Shift right column to the left
      # Gets the right column
      row_index = col_num / (SCREEN[0]/32+2)
      row_index *= (SCREEN[0]/32+2)
      col_num = (@corner_index - 1) % (SCREEN[0]/32+2) + row_index
     
      (0...(SCREEN[1]/32+2)).each{|n|
        j = ((SCREEN[0]/32+2) * n + col_num) % modTileId
        @tile_sprites[j].each_index{|i|
          tile = @tile_sprites[j][i]
          @animating_tiles.delete(tile.tile_sprite_id)
          tile.x -= 64 + SCREEN[0]
         
          map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32
          tile_id = @map_data[map_x,map_y,i]
          if tile_id.nil?
            tile.z = [map_y * 32, 0].max
            tile.bitmap = @tileset
            tile.src_rect.set(0,0,0,0)
            next
          else
            if @priorities[tile_id] == 0
              tile.z = 0
            else
              tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32
            end
          end
          if tile_id == 0
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
          elsif tile_id >= 384
            tile.bitmap = @tileset
            tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)
          else
            auto_id = tile_id/48-1
            tile.bitmap = @autotiles[auto_id]
            tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)
            @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1
          end
        }
      }
      col_num /= SCREEN[0]/32+2
      col_num *= SCREEN[0]/32+2
      @corner_index = (@corner_index - 1) % (SCREEN[0]/32+2) + col_num
    end
  #  puts @corner_index
  end
 
  #-----------------------------------------------------------------------------
 
  def oy=(oy)
    #
    unless @tilemap_drawn
      @oy = oy
      @ox_oy_set[1] = true
      return
    end
   
    return if @oy == oy
    # Shift all tiles up or down by the difference, and change z-value
    shift = @oy - oy
    @tile_sprites.each {|set| set.each{|tile| tile.y += shift; tile.z += shift unless tile.z == 0 }}
    @oy = oy
    # Determine if rows need to be shifted
    row_num = @corner_index
    return unless @tile_sprites[row_num][0].y <= -49 || @tile_sprites[row_num][0].y >= -17
    # Needed for resetting the new corner index much later.
    modTileId = ((SCREEN[0]+64)*(SCREEN[1]+64))/1024
   
    # If new oy is greater than old oy
    if shift < 0
      row_num /= SCREEN[0]/32+2
      row_num *= SCREEN[0]/32+2
      # Move all sprites in top row to the bottom side and change bitmaps
      # and z-values
      (0...(SCREEN[0]/32+2)).each{|n|
        # Run through each triad of sprites from left to right
        j = n + row_num
        @tile_sprites[j].each_index{|i|
          # Get each individual tile on each layer
          tile = @tile_sprites[j][i]
          @animating_tiles.delete(tile.tile_sprite_id)
          tile.y += 64 + SCREEN[1]
          # Determine what map coordinate this tile now resides at...
          map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32
          # ...and get its tile_id
          tile_id = @map_data[map_x,map_y,i]
          # If no tile exists here (effectively out of array bounds)
          if tile_id.nil?
            tile.z = [map_y * 32, 0].max
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
            next
          else # Tile exists. Figure out its z-coordinate based on priority
            if @priorities[tile_id] == 0
              tile.z = 0
            else
              tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32
            end
          end
          # If empty tile
          if tile_id == 0
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
          # If not an autotile
          elsif tile_id >= 384
            tile.bitmap = @tileset
            tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)
          else # Autotile
            auto_id = tile_id/48-1
            tile.bitmap = @autotiles[auto_id]
            tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)
            @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1
          end
        }
      }
     
      @corner_index = (@corner_index + (SCREEN[0]/32+2)) % modTileId
    else
      row_num = (@corner_index - (SCREEN[0]/32+2)) % modTileId
      row_num /= SCREEN[0]/32+2
      row_num *= SCREEN[0]/32+2
      (0...(SCREEN[0]/32+2)).each{|n|
        # Run through each triad of sprites from left to right
        j = n + row_num
        @tile_sprites[j].each_index{|i|
          # Get each individual tile on each layer
          tile = @tile_sprites[j][i]
          @animating_tiles.delete(tile.tile_sprite_id)
          tile.y -= 64 + SCREEN[1]
          # Determine what map coordinate this tile now resides at...
          map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32
          # ...and get its tile_id
          tile_id = @map_data[map_x,map_y,i]
          # If no tile exists here (effectively out of array bounds)
          if tile_id.nil?
            tile.z = [map_y * 32, 0].max
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
            next
          else # Tile exists. Figure out its z-coordinate based on priority
            if @priorities[tile_id] == 0
              tile.z = 0
            else
              tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32
            end
          end
          # If empty tile
          if tile_id == 0
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
          # If not an autotile
          elsif tile_id >= 384
            tile.bitmap = @tileset
            tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)
          else # Autotile
            auto_id = tile_id/48-1
            tile.bitmap = @autotiles[auto_id]
            tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)
            @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1
          end
        }
      }
      @corner_index = (@corner_index - (SCREEN[0]/32+2)) % modTileId
    end
#   puts @corner_index
  end
 
  #-----------------------------------------------------------------------------
  # Dispose all the tile sprites
  #-----------------------------------------------------------------------------
  def dispose
    # Dispose all of the sprites
    @tile_sprites.each {|set| set.each{|tile| tile.dispose }}
    @tile_sprites.clear
    @animating_tiles.clear
  end
  #-----------------------------------------------------------------------------
  # Set map data
  #-----------------------------------------------------------------------------
  def map_data=(data)
    # Set the map data to an instance variable.
    @map_data = data
   
    @animating_tiles.clear
    # Initialize tiles if not created. Else, dispose old bitmaps and set new ones.
    if @tile_sprites == []
      #init_tiles
    else
      # Clear any sprites' bitmaps if it exists, or create new ones.
      @tile_sprites.each {|set| set.each_index{|i|
        tile = set[i]
        tile.bitmap.dispose
       
        map_x, map_y = tile.x/32, tile.y/32
        if map_x < 0 || map_x >= SCREEN[0]/32 || map_y < 0 || map_y >= SCREEN[1]/32
          tile.z = [map_y * 32, 0].max
          tile.bitmap = @tileset
        else
          tile_id = @map_data[map_x,map_y,i]
          tile.z = map_y * 32 + @priorities[tile_id] * 32
          if tile_id >= 384
            tile.bitmap = @tileset
            tile.src_rect.set((tile_id - 384 % 8)*32,(tile_id - 384 / 8)*32, 32, 32)
          else
            auto_id = tile_id/48-1
            tile.bitmap = @autotiles[auto_id]
            tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)
            @animating_tiles[tile.tile_sprite_id] = tile
          end
        end
      }}
    end
  end
  #-----------------------------------------------------------------------------
  # Update the tile sprites; make changes to the map_data and update autotiles
  #-----------------------------------------------------------------------------
  def update
    if Input.trigger?(Input::SHIFT)
      list = []
      list.push(@corner_index)
      @tile_sprites.each{|set| list.push(set[0].y)}
      p list
    end
    # Can't update anything if the ox and oy have not yet been set
    return if @ox_oy_set != [true, true]
    # If the tilemap sprites have not been initialized, GO DO IT
    if !@tilemap_drawn
      init_tiles
    end
   
    # If made any changes to $game_map.data, the proper graphics will be drawn
    if @map_data.table_changes != nil
      @map_data.table_changes.each{|item|
        x,y,z,tile_id = item
        # Make actual change to table
        @map_data[x,y,z] = tile_id
        # If this changed tile is visible on screen
        if x >= @ox/32 - 1 and x <= (@ox+SCREEN[0])/32 and
        y >= @oy/32 - 1 and y <= (@oy+SCREEN[1])/32
         
          # Locate which tile sprite is at this location
          x_dif = x - (@ox/32 - 1)
          y_dif = y - (@oy/32 - 1)
         
          sprite_id = @corner_index % (SCREEN[0]/32+2)
          sprite_id += x_dif
          sprite_id %= (SCREEN[0]/32+2)
          sprite_id += (SCREEN[0]/32+2) * (@corner_index/(SCREEN[0]/32+2))
          sprite_id += y_dif * (SCREEN[0]/32+2)
          sprite_id %= ((SCREEN[0]+64)*(SCREEN[1]+64))/1024
          p [@ox,@oy,x_dif,y_dif]
          tile = @tile_sprites[sprite_id][z]
          @animating_tiles.delete(tile.tile_sprite_id)
          #Figure out its z-coordinate based on priority
          if @priorities[tile_id] == 0
            tile.z = 0
          else
            tile.z = 32 + (tile.y/32) * 32 + @priorities[tile_id] * 32
          end
          # If empty tile
          if tile_id == 0
            tile.bitmap = RPG::Cache.picture('')
            tile.src_rect.set(0,0,0,0)
          # If not an autotile
          elsif tile_id >= 384
            tile.bitmap = @tileset
            tile.src_rect.set(((tile_id - 384) % 8) * 32,((tile_id - 384) / 8) *32, 32, 32)
          else # Autotile
            auto_id = tile_id/48-1
            tile.bitmap = @autotiles[auto_id]
            tile.src_rect.set(((tile_id % 48) % 8)*32 + @current_frame[auto_id] * 256,((tile_id % 48) / 8)*32, 32, 32)
            @animating_tiles[tile.tile_sprite_id] = tile if @total_frames[auto_id] > 1
          end
        end
      }
      @map_data.table_changes = nil
    end

    # Update the sprites.
    if Graphics.frame_count % $game_map.autotile_speed == 0
      # Increase current frame of tile by one, looping by width.
      for i in 0..6
        @current_frame[i] = (@current_frame[i] + 1) % @total_frames[i]
      end
      @animating_tiles.each_value{|tile|
        frames = tile.bitmap.width
        tile.src_rect.set((tile.src_rect.x + 256) % frames, tile.src_rect.y, 32, 32)
      }
    end
  end
end

#===============================================================================
# Game_Map
#===============================================================================

class Game_Map
 
  attr_reader :tile_size, :autotile_speed, :autotile_data, :priority_data
 
  alias zer0_load_autotile_data_init initialize
  def initialize
    # Call original method.
    zer0_load_autotile_data_init
    # Store the screen dimensions in tiles to save on calculations later.
    @tile_size = [SCREEN[0], SCREEN[1]].collect {|n| (n / 32.0).ceil }
    @autotile_speed = UPDATE_COUNT
  end
 
  alias zer0_map_edge_setup setup
  def setup(map_id)
    # Call original method.
    zer0_map_edge_setup(map_id)
    # Find the displayed area of the map in tiles. No calcualting every step.
    @map_edge = [self.width - @tile_size[0], self.height - @tile_size[1]]
    @map_edge.collect! {|size| size * 128 }
  end

  def scroll_down(distance)
    # Find point that the map edge meets the screen edge, using custom size.
    @display_y = [@display_y + distance, @map_edge[1]].min
  end

  def scroll_right(distance)
    # Find point that the map edge meets the screen edge, using custom size.
    @display_x = [@display_x + distance, @map_edge[0]].min
    #p @display_x
  end
 
  def autotile_speed=(speed)
    # Keep the speed above 0 to prevent the ZeroDivision Error.
    @autotile_speed = speed
    @autotile_speed = 1 if @autotile_speed < 1
  end
 
  alias get_map_data data
  def data
    # For the Tilemap class to recognize that tile graphics need changing
    @map.data.make_changes = true
    get_map_data
  end
 
end
=begin
#===============================================================================
# ** Game_Character
#===============================================================================

class Game_Character
 
  def screen_z(height = 0)
    if @always_on_top
      # Return high Z value if always on top flag is present.
      return 999
    elsif height != nil && height > 32
      # Iterate through map characters to their positions relative to this one.
      characters = $game_map.events.values
      characters += [$game_player] unless self.is_a?(Game_Player)
      # Find and set any character that is one tile above this one.
      above, z = characters.find {|chr| chr.x == @x && chr.y == @y - 1 }, 0
      if above != nil
        # If found, adjust value by this one's Z, and the other's.
        z = (above.screen_z(48) >= 32 ? 33 : 31)
      end
      # Check for Blizz-ABS and adjust coordinates for the pixel-rate.
      if $BlizzABS == nil
        x = ((@x / $game_system.pixel_rate) / 2.0).to_i
        y = ((@y / $game_system.pixel_rate) / 2.0).to_i
        return $game_map.priority_data[x, y] + z
      else
        return $game_map.priority_data[@x, @y] + z
      end
    end
    return 0
  end
end
=end
#===============================================================================
# ** Game_Player
#===============================================================================

class Game_Player
 
  CENTER_X = ((SCREEN[0] / 2) - 16) * 4    # Center screen x-coordinate * 4
  CENTER_Y = ((SCREEN[1] / 2) - 16) * 4    # Center screen y-coordinate * 4
 
  def center(x, y)
    # Recalculate the screen center based on the new resolution.
    max_x = ($game_map.width - $game_map.tile_size[0]) * 128
    max_y = ($game_map.height - $game_map.tile_size[1]) * 128
    $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
    $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  end 
end

#===============================================================================
# ** Sprite
#===============================================================================
class Sprite
  attr_accessor :tile_sprite_id
  alias tile_sprite_id_init initialize
  def initialize(view = nil)
    # No defined ID
    @tile_sprite_id = nil
    # Call original method.
    tile_sprite_id_init(view)
  end
end

#===============================================================================
# ** Viewport
#===============================================================================

class Viewport
 
  alias zer0_viewport_resize_init initialize
  def initialize(x=0, y=0, width=SCREEN[0], height=SCREEN[1], override=false)
    if x.is_a?(Rect)
      # If first argument is a Rectangle, just use it as the argument.
      zer0_viewport_resize_init(x)
    elsif [x, y, width, height] == [0, 0, 640, 480] && !override
      # Resize fullscreen viewport, unless explicitly overridden.
      zer0_viewport_resize_init(Rect.new(0, 0, SCREEN[0], SCREEN[1]))
    else
      # Call method normally.
      zer0_viewport_resize_init(Rect.new(x, y, width, height))
    end
  end
 
  def resize(*args)
    # Resize the viewport. Can call with (X, Y, WIDTH, HEIGHT) or (RECT).
    self.rect = args[0].is_a?(Rect) ? args[0] : Rect.new(*args)
  end
end
#===============================================================================
# ** Bitmap
#===============================================================================
class Bitmap
 
  alias zer0_resolution_resize_init initialize
  def initialize(width = 32, height = 32, override = false)
    if width.is_a?(String)
      # Call the filename if the first argument is a String.
      zer0_resolution_resize_init(width)
    elsif [width, height] == [640, 480] && !override
      # Resize fullscreen bitmap unless explicitly overridden.
      zer0_resolution_resize_init(SCREEN[0], SCREEN[1])
    else
      # Call method normally.
      zer0_resolution_resize_init(width, height)
    end
  end
end
#===============================================================================
# Table
#===============================================================================
class Table
  attr_accessor :make_changes, :table_changes
 
  alias set_method []=
  def []=(x,y=nil,z=nil,v=nil)
    # If making changes to game_map.data
    if @make_changes
      @table_changes = [] if @table_changes.nil?
      @table_changes.push([x,y,z,v])
      @make_changes = false
    end
    # Call original method
    if z == nil
      set_method(x,y)
    elsif v == nil
      set_method(x,y,z)
    else
      set_method(x,y,z,v)
    end
  end
end

=begin
#===============================================================================
# ** Sprite
#===============================================================================
# Added ID variable for tile sprites
class Sprite
  attr_accessor :tile_sprite_id
  alias zer0_sprite_resize_init initialize
  def initialize(view = nil)
    # No defined ID
    @tile_sprite_id = nil
    # Unless viewport is defined, use the new default viewport size.
    view = Viewport.new(0, 0, SCREEN[0], SCREEN[1]) if view == nil
    # Call original method.
    zer0_sprite_resize_init(view)
  end
end



#===============================================================================
# ** Plane
#===============================================================================

class Plane < Sprite
 
  def z=(z)
    # Change the Z value of the viewport, not the sprite.
    super(z * 1000)
  end
 
  def ox=(ox)
    return if @bitmap == nil
    # Have viewport stay in loop on X-axis.
    super(ox % @bitmap.width)
  end
 
  def oy=(oy)
    return if @bitmap == nil
    # Have viewport stay in loop on Y-axis.
    super(oy % @bitmap.height)
  end
 
  def bitmap
    # Return the single bitmap, before it was tiled.
    return @bitmap
  end
 
  def bitmap=(tile)
    @bitmap = tile
    # Bug fix for changing panoramas
    return if tile.nil?
    # Calculate the number of tiles it takes to span screen in both directions.
    xx = 1 + (SCREEN[0].to_f / tile.width).ceil
    yy = 1 + (SCREEN[1].to_f / tile.height).ceil
    # Create appropriately sized bitmap, then tile across it with source image.
    plane = Bitmap.new(@bitmap.width * xx, @bitmap.height * yy)
    (0..xx).each {|x| (0..yy).each {|y|
      plane.blt(x * @bitmap.width, y * @bitmap.height, @bitmap, @bitmap.rect)
    }}
    # Set the bitmap to the sprite through its super class (Sprite).
    super(plane)
  end
 
  # Redefine methods dealing with coordinates (defined in super) to do nothing.
  def x; end
  def y; end
  def x=(x); end
  def y=(y); end
end



#===============================================================================
# DEBUG Mode
#===============================================================================

if $DEBUG #if running in debug/testplay mode
  if PRE_CACHE_DATA # If precache configuration is true
    # load all tilesets in database
    tilesets = load_data('Data/Tilesets.rxdata')
    # maps = mapinfos, priority_data and autotile_data are empty hashes
    maps, priority_data, autotile_data = load_data('Data/MapInfos.rxdata'), {}, {}
    # For each map ID
    maps.each_key {|map_id|
      # load map file
      map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
      # map data is loaded (3D-Table)
      data = map.data
      # get the map's tileset
      tileset = tilesets[map.tileset_id]
      # get tileset's priorities (*0 to *5)
      priorities = tileset.priorities
      # get autotiles that tileset uses and load their bitmaps, storing them in cache
      autotiles = tileset.autotile_names.collect {|name| RPG::Cache.autotile(name) }
      animated = [[], [], [], []]
      # for each autotile in array by index (0 to number of autotiles)
      autotiles.each_index {|i|
        width = autotiles[i].width
        # go to next autotile if width is 96 or less (non-animating)
        next unless width > 96
        # [name of autotile, frames of animation, 0, empty array]
      ###  parameters = [tileset.autotile_names[i], width / 96, 0, []]
        parameters = [tileset.autotile_names[i], width / 256, 0, []]
        # now store these values into variable 'animated'
        [0, 1, 2, 3].each {|j| animated[j].push(parameters[j]) }
      }
      # for each z-index, for each y-coordinate, for each x-coordinate
      [0, 1, 2].each {|z| (0...data.ysize).each {|y| (0...data.xsize).each {|x|
        # get tile_id at (x,y,z)
        tile_id = data[x, y, z]
        # ignore if tile is blank square (top left on tileset)
        next if tile_id == 0
        # if autotile
        if tile_id < 384
          # get autotile name that this tile belongs to
          name = tileset.autotile_names[(tile_id / 48) - 1]
          # find this autotile's array index in 'animated'
          index = animated[0].index(name)
          # skip if not an animated autotile
          next if index == nil
      #---------------------------------------------------------------------
      # Most of the following below has been removed due to graphical errors
      #---------------------------------------------------------------------
   #       above = []
          # Check layers above current z-layer, pushing tile_ids if they exist
   #       ((z+1)...data.zsize).each {|zz| above.push(data[x, y, zz]) }
          # if all the above tile IDs are blank squares, then store this tile ID
          animated[3][index].push([x, y, z]) #if above.all? {|id| id == 0 }
        end
      }}}
      # make a new table that is as tall and as wide as the map's size
      table = Table.new(data.xsize, data.ysize)
      # run through each square on this grid top to bottom, left to right
      (0...table.xsize).each {|x| (0...table.ysize).each {|y|
      # get tile IDs one space north of current tile on all layers (e.g. trees)
        above = [0, 1, 2].collect {|z| data[x, y-1, z] }
        # get priorities of tile IDs we collected, replacing values in 'above'
        above = above.compact.collect {|p| priorities[p] }
        # if any of the priorities collected is 1, then our current spot (x,y)
        # is equal to 32. Else, 0.
        table[x, y] = above.include?(1) ? 32 : 0
      }}
      priority_data[map_id], autotile_data[map_id] = table, animated
      # If project has a lot of maps, this will ensure you will not get a
      # 'Script is hanging' error when caching
      Graphics.update
    }
    file = File.open('Data/PreCacheMapData.rxdata', 'wb')
    Marshal.dump(priority_data, file)
    Marshal.dump(autotile_data, file)
    file.close
    RPG::Cache.clear
  end
 
  if RESOLUTION_LOG
    undersize, mapinfo = [], load_data('Data/MapInfos.rxdata')
    file = File.open('Data/PreCacheMapData.rxdata', 'rb')
    cached_data = Marshal.load(file)
    file.close
    # Create a text file and write the header.
    file = File.open('Resolution Log.txt', 'wb')
    file.write("[RESOLUTION LOG]\r\n\r\n")
    time = Time.now.strftime("%x at %I:%M:%S %p")
    file.write("  Logged on #{time}\r\n\r\n")
    lcm = SCREEN[0].lcm(SCREEN[1]).to_f
    aspect = [(lcm / SCREEN[1]), (lcm / SCREEN[0])].collect {|num| num.round }
    file.write("RESOLUTION:\r\n  #{SCREEN[0].to_i} x #{SCREEN[1].to_i}\r\n")
    file.write("ASPECT RATIO:\r\n  #{aspect[0]}:#{aspect[1]}\r\n")
    file.write("MINIMUM MAP SIZE:\r\n  #{(SCREEN[0] / 32).ceil} x #{(SCREEN[1] / 32).ceil}\r\n\r\n")
    file.write("UNDERSIZED MAPS:\r\n")
    mapinfo.keys.each {|key|
      map = load_data(sprintf("Data/Map%03d.rxdata", key))
      next if map.width*32 >= SCREEN[0] && map.height*32 >= SCREEN[1]
      undersize.push(key)
    }
    unless undersize.empty?
      file.write("The following maps are too small for the defined resolution. They should be adjusted to prevent graphical errors.\r\n\r\n")
      undersize.sort.each {|id| file.write("    MAP[#{id}]:  #{mapinfo[id].name}\r\n") }
      file.write("\r\n")
    else
      file.write('    All maps are sized correctly.')
    end
    file.close
  end
end
=end

# Call the resolution, setting it to a global variable for plug-ins.
$resolution = Resolution.new

I have removed the Pre-Cache feature that existed previously with this script. It is still questionable as to whether or not this was helping to reduce load time (further testing required). Still requires screenshot.dll for the basic fade feature for resolutions bigger than 640x480.

As a reminder, this script was designed for XP and is meant to run on XP games. Its ability to run on XPA games is merely a coincidence.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

khkramer

Has anyone gotten this to work with Pokemon Essentials?

G_G

I figured Pokemon Essentials would already support custom resolutions, doesn't it include a tilemap rewrite?

khkramer

Quote from: gameus on October 21, 2013, 08:01:58 pm
I figured Pokemon Essentials would already support custom resolutions, doesn't it include a tilemap rewrite?


It does support custom resolutions, however as far as I know F0's method is way faster.

G_G

Rather than trying to get this script to work, maybe try doing this?

http://forum.chaos-project.com/index.php/topic,12899.0.html

It'll definitely make your game a lot smoother/faster.

KK20

Poccil's rewrite starts losing performance on maps bigger than 100x100. F0's can't even run large maps (~250x250 or larger, can't remember) without eating all the computer's memory. Using my later versions (except the unfinished v96) won't help that cause either.

I've plugged my tilemap rewrite into my Advance Wars Engine and it's holding up pretty well. I'm fixing up all the last things while testing for performance. I'll post the official v96 when I'm satisfied with it.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

khkramer

Quote from: gameus on October 22, 2013, 06:31:48 am
Rather than trying to get this script to work, maybe try doing this?

http://forum.chaos-project.com/index.php/topic,12899.0.html

It'll definitely make your game a lot smoother/faster.


I know but it's a lot of work when you're using Pokemon Essentials with RMX-Os plus some extra scripts for compatibility.
I've tried it before, and there were so many bugs I just gave up.

Moshan

 Hello! I'm not sure if this is the script I'm using...but I will post it here.
So...I'm trying to use the VX Ace Engine in my RMXP Project...and I have this "strange" error:
Spoiler: ShowHide

Q is ForeverZer0's RGSS1+Ace engine compatible script.

ForeverZer0

Quote from: adytza001 on October 23, 2013, 01:22:10 pm
Q is ForeverZer0's RGSS1+Ace engine compatible script.


I have written no such plugin for using this script with the ACE engine.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

Make the line above it this

if $BlizzABS && $game_system.pixel_rate > 0

In regards to future problems with XP-converted projects, I suggest posting them here or here.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Moshan

Quote from: ForeverZer0 on October 23, 2013, 03:27:38 pm
Quote from: adytza001 on October 23, 2013, 01:22:10 pm
Q is ForeverZer0's RGSS1+Ace engine compatible script.


I have written no such plugin for using this script with the ACE engine.

# Custom Resolution (RGSS1+Ace engine compatible)
# Author: ForeverZer0
# Version: 0.94
# Date: 6.1.2013

These are the first lines of the code...I assumed that it was your code.
Quote from: KK20 on October 23, 2013, 05:04:18 pm
Make the line above it this

if $BlizzABS && $game_system.pixel_rate > 0

In regards to future problems with XP-converted projects, I suggest posting them here or here.

Thank you! And sorry for posting this here.

ForeverZer0

Oh, I see.
I did write the original Custom Resolution script for RGSS1, and I assume that comment was added since the script is used sometimes with the ACE engine and RMXP. I was thinking that there was a separate compatibility script out there that had my name on it, which I have not written.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Zexion

I'd like to ask a question about this script. It's an error that's really bugged me from the beginning, but is so small I never mentioned it. Why can't maps be default size? They always display half empty when I use default maps with a smaller resolution, but if I increase the size just one tile in any direction, it works fine o.o

KK20

Oh, nice find. I see what the problem is actually.

Recall that the tilemap is being drawn by a series of Bitmap objects. It uses 'blt' to draw the tiles onto it. This is how the layers are initialized.

@layers[i].bitmap = Bitmap.new($game_map.width*32, $game_map.height*32)

A map of 20 x 15 would return a bitmap of size 640 x 480. Now look at this:

class Bitmap
 
  alias zer0_resolution_resize_init initialize
  def initialize(width = 32, height = 32, override = false)
    if width.is_a?(String)
      # Call the filename if the first argument is a String.
      zer0_resolution_resize_init(width)
    elsif [width, height] == [640, 480] && !override                    #<========== Right there
      # Resize fullscreen bitmap unless explicitly overridden.
      zer0_resolution_resize_init(SCREEN[0], SCREEN[1])              #<===== And the cause of it all
    else
      # Call method normally.
      zer0_resolution_resize_init(width, height)
    end
  end
end

The bitmaps being used to draw the tilemap are being resized to your resolution's size, hence why you see nothing to the right and down on the map.

The fix is this:

@layers[i].bitmap = Bitmap.new($game_map.width*32, $game_map.height*32, true)





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

KK20

Updated at v0.96b. Thanks to LiTTleDRAgo for his Core Engine so that I can remove the dependency for screenshot.dll! :beer:

I still don't believe my Tilemap rewrite is truly finished, hence the beta. I also didn't bother to document the script much. Good luck trying to understand how the Tilemap rewrite works; it's really not that complicated though. Just think of it making 32x32 sprites for every tile that you can see and moving them one at a time to display what needs to be shown. I was actually pretty surprised how fast it runs, and my computer isn't anything special--no, really, it isn't.

Report issues and stuff. You know the drill by now. Edit at your own risk.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

November 16, 2013, 12:48:44 pm #104 Last Edit: November 16, 2013, 12:58:23 pm by LiTTleDRAgo
it's quite a feat for normal project (almost no lagg detected)
haven't tested on heavy projects because lack of free time


by the way, can you remove this line in the script?

($imported ||= {})[:drg_core_engine] = 1.39


it will cause trouble if someone using any of my script that require the full version of my core engine
(although I wonder why you're copying almost half of it, when you're only need snap_to_bitmap method to remove screenshot.dll dependency?)

Zexion

Nice update @KK20. Also, thanks for that fix(?), I haven't tried it, but I will as soon as I can!

KK20

November 17, 2013, 12:31:31 am #106 Last Edit: November 17, 2013, 01:11:49 am by KK20
@Drago

Done. Thanks for pointing that out. I'd appreciate the testing :D
I tried removing as much as I could to get the snap_to_bitmap to work. I gave up removing one section, test, remove another, test, etc. Not sure what you mean by I only need the snap_to_bitmap method when it's not as easy as copy-pasting just the method itself. I guess I could make a rewrite of the method if that's what you mean.

@Zexion

Thanks :) Yeah, the fix works--I explained the logical reason behind it after all.

EDIT: Just realized I left a bunch of unnecessary code in the scripts (like debugging buttons and messages for testing purposes). They are removed.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

November 17, 2013, 02:04:12 am #107 Last Edit: November 17, 2013, 05:30:41 pm by LiTTleDRAgo
Trimmed : *Link Removed*

also bug report:

KK20

Ah thanks for trimming it up :)

And fixed the bug that you mentioned. The three lines involving PreCacheData are never used, so I just deleted them.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

sekiraze

im gonna get crazy and ask for this:

http://www.rpgrevolution.com/forums/index.php?showtopic=51938

I almost fainted when i saw all these scripts inside.

KK20






   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

G_G

Probably wants the custom resolution in it. Iunno.

sekiraze

Quote from: gameus on December 25, 2013, 12:54:02 pm
Probably wants the custom resolution in it. Iunno.


only for the battle-scene where the fighters face off: i want to only use this part for my game.
sorry for being not precise enough!

KK20

Still confused. I don't see how Custom Resolution would even apply.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

sekiraze

nvm then, im a sleep deprived man. ideas come and go.

sekiraze

lets hope this is not considered spam;
but i have an idea! (ive actually slept !)

Since fullscreen mode does not work, ive been thinking and thinking. how about this:

you have to put in your Y and X-Pixel sice. Lets assume it is 1024x768. Lets also asume your Screen Size is 1600 by 900.
What if instead of streching the game window a black frame surrounds the game window for some sort of "cinematic" fullscreen?

sum thing like this:

Spoiler: ShowHide


i dunno, i had this idea playing SNES just couple of minutes ago. there is this module that allowes you to put in GB games inside.

Spoiler: ShowHide


cuz if you push the bumper you have a variaty of bg's to choose from, and also the black one surrounding errything :3

JUST AN IDEA!

KK20

I have considered doing that actually. I remember seeing a script elsewhere that did that.

One idea I also had was to change the computer's screen resolution to the game's resolution, provided such a resolution exists. Other than experimenting with DLL calls, I don't think I ever tried to see if this would ever be a viable solution.

Most likely I'll just do that black border thingy, but I still want to play with my other idea too.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

sekiraze

awaiting the awesome /o/ Can't wait!

PhoenixFire

Yeah, me too. Personally I would rather use this one instead of Kings, and the better it gets, the more I like it =)
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

sekiraze

Quote from: DigitalSoul on December 28, 2013, 08:52:22 am
Yeah, me too. Personally I would rather use this one instead of Kings, and the better it gets, the more I like it =)


Kings? :o what does that mean?

KK20

King is another scripter in the German community. He has his own Tilemap rewrite script.
PROS:
- Very smooth, FPS is pretty constant
- LiTTleDRAgo has made it compatible with a lot of scripts
CONS:
- Big maps = long loading times
- On top of that, you can't have very large maps as it will consume a lot of RAM
- Also on top of that, changing individual tiles (via $game_map.data[x,y,z] = TILE_ID) redraws the entire tilemap which leads to more loading times

Compared to mine
PROS:
- Change game resolution (duh)
- Smooth; dips a few FPS under normal but it is hardly noticeable
- Fast map loading times and can run 500 x 500 maps with autotiles on every layer easily
CONS:
- In VXA converted projects, even though the Tilemap#update method is faster, the game stutters on higher resolutions
- Not compatible with many scripts yet
- Still need to address the fullscreen issue





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

sekiraze

Quote from: KK20 on December 28, 2013, 02:01:28 pm
King is another scripter in the German community. He has his own Tilemap rewrite script.
PROS:
- Very smooth, FPS is pretty constant
- LiTTleDRAgo has made it compatible with a lot of scripts
CONS:
- Big maps = long loading times
- On top of that, you can't have very large maps as it will consume a lot of RAM
- Also on top of that, changing individual tiles (via $game_map.data[x,y,z] = TILE_ID) redraws the entire tilemap which leads to more loading times

Compared to mine
PROS:
- Change game resolution (duh)
- Smooth; dips a few FPS under normal but it is hardly noticeable
- Fast map loading times and can run 500 x 500 maps with autotiles on every layer easily
CONS:
- In VXA converted projects, even though the Tilemap#update method is faster, the game stutters on higher resolutions
- Not compatible with many scripts yet
- Still need to address the fullscreen issue


looked into it; didn't like it for some reasons. i find yours better tbh. truly speaking i find yours running smoother. well maybe at least for now, because my maps aren't filled too much with events but if i would NEED to chose, i chose yours.

KK20

December 28, 2013, 09:49:58 pm #122 Last Edit: December 29, 2013, 05:10:07 pm by KK20
Note that King's rewrite was meant for VXA. I tried plugging it in an RMXP project for the heck of it and the graphics were all displayed wrong.

Massive Edit:

Going back to this:
Quote
- In VXA converted projects, even though the Tilemap#update method is faster, the game stutters on higher resolutions

I found out the problem. RGSS300.dll included in the kit (which is a modified version to handle larger game resolutions) cannot handle a ton of sprites. Performance drops significantly when a couple thousand sprites are created.

Of course the unmodified RGSS300.dll and RGSS301.dll can handle many sprites fairly well--it's just you can't change the screen resolution to anything but 640x480.

I even did the method described here, but it performs just as bad as the RGSS300.dll did.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

PhoenixFire

...I completely missed the part where the .dll is no longer a dependency... So I think I very well might try swapping this one in =)

Good job on this man!
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

LiTTleDRAgo

January 15, 2014, 12:47:11 am #124 Last Edit: January 16, 2014, 08:26:12 am by LiTTleDRAgo
resolution change: *Link Removed*
$resolution.change_resolution(800,600)


also, I write a simple addon to adjust default menu position to the center of the screen: Click


KK20

Well that looks interesting. I'll be sure to incorporate that into the script. I see you've been working on the script a bit from the added methods and aliases everywhere. :)

I like how it reverts the resolution back to what it should be when coming out of fullscreen. Going into fullscreen, though, looked weird--I could see the Window's Start button and highlight over items in my taskbar. Also, it seems you've changed the way the screen scrolls; no matter the resolution, it still uses the 640x480 "center-rule," if you get what I mean.

That add-on is really helpful for first-time users. I'll link to it in the first post. Thanks for your continued support :D

I've been wanting to get back to finishing this but other priorities, ya know?

SUPER EXCITED EDIT:

Okay, so I have been wondering for the longest time how Cremno's NoF12 (more importantly No Alt+Enter inside it) works. I was looking around the various keyboard functions until I found RegisterHotKey. After reading it and UnregisterHotKey, I got the impression that this was what I was looking for.

So, to see how the method worked, I whipped up this little thing and put it in module Resolution#initialize at the very end:

    @reghotkey = Win32API.new('user32', 'RegisterHotKey', 'LIII', 'I')
    @reghotkey.call(0, 1, 0x4001, 0x0D)

To those confused, it basically says "Register new hotkey ALT+Enter to current thread". The 0x4001 is just a combination of MOD_NOREPEAT and MOD_ALT, as seen on the page I linked to. 0x0D is the virtual key code for Enter.

I go to testplay the game and, to my surprise, Alt+Enter no longer put the game into fullscreen no matter how hard I tried. Curious, I ran another game at the same time and couldn't get it to fullscreen either--at least, not until I closed the game with this snippet in it first. This outcome is exactly the same as the NoF12.dll approach.

Would anyone care to back this up and remark if I've made an amazing discovery?





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Blizzard

If this really works, wanna bet that they made a DLL just so nobody can just copy it? xD
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.

KK20

Yep! I'll agree to that reason.

DLL scripters think they're so cool because no one can see their code. I Falcon Punch their jaws.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Blizzard

The only 2 reasons to make a DLL for RMXP are:

1. Complex CPU-heavy code or code that needs to run as fast as possible and therefore needs optimizations.
2. Code accessing several of other DLLs and for the sake of readability and wrapping making a new DLL with a simpler interface (usually still needs the other DLLs).

Somebody may consider encryption to be something that goes into a DLL, but every half-assed programmer knows that encryption based on obfuscation and/or algorithm complexity is weak encryption. Making DLL just for a few Win32API calls is really overkill.
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.

LiTTleDRAgo

January 16, 2014, 07:16:41 am #129 Last Edit: January 16, 2014, 09:27:04 am by LiTTleDRAgo
@kk20 : the center way is my miss, I tried to whip the script so that it can use undersized map (the map will be centered in the screen) but ran into glitch, you can look by creating an undersized map and have player walk around the border

edit : OK, it's fixed now, you can also use undersized map and that map will be centered in the screen, flickered map when fullscreen also fixed: Click

I don't think Resolution Log is needed anymore, since the "Undersized Map Graphical Bug" was beautified into a feature.

AliveDrive

Quote from: Blizzard on January 16, 2014, 03:28:49 am
The only 2 reasons to make a DLL for RMXP are:
...
Making DLL just for a few Win32API calls is really overkill.


So correct me if I'm wrong, but does this mean that H-Mode7 (which uses a DLL) could perhaps be done without a DLL?

This would be incredible for me, because I am working on making a game that's compatible with Neko which does not support DLL to my knowledge. Sorry for off topic.
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

Blizzard

H-Mode 7 (and normal Mode 7) are both int he first category IMO. They are CPU-intense and need all the optimization they can get.

Neko should still support any kind of SO file that was compiled as Ruby extension.
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.

AliveDrive

Well then maybe there is hope for it.

Currently the project runs without crashing and I can access the menu but when in the main screen it is always just black.

I wonder if my Galaxy S4 is powerful enough to run this without lag/at all.
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

KK20

Quote from: LiTTleDRAgo on January 16, 2014, 07:16:41 am
edit : OK, it's fixed now, you can also use undersized map and that map will be centered in the screen, flickered map when fullscreen also fixed: Click

I don't think Resolution Log is needed anymore, since the "Undersized Map Graphical Bug" was beautified into a feature.

Can't believe I forgot to comment on this. *cough*

ARFGHH! I've been wanting to implement that "center undersized map" idea for a long time now. Yes, with that, the Resolution Log is no longer needed. Now if only there is a no-DLL solution to ALT+Enter, we can finally address fullscreen options (otherwise, we're stuck with NoF12).

Take my hugs. All of them!





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

January 17, 2014, 06:39:50 am #134 Last Edit: January 18, 2014, 04:24:39 am by LiTTleDRAgo
there still problem at FPS, (I got 15FPS at resolution 1024x576 from F0's map in the demo)
I suspect there was too many unnecessary calculation in the script


Click to enlarge

KK20

January 17, 2014, 01:04:55 pm #135 Last Edit: January 20, 2014, 12:23:53 am by KK20
I'm getting around 28 standing still and around 21 when moving. Same resolution, same map.
I get the same results again on my stress test map (500x500, 3 layers of nothing but 7 animating autotiles).
Turning off "Reduce Screen Flicker" brings the numbers back up a bit (35 standing still).
Of course, this is being tested on a normal XP project, not a VXA converted one--which I have remarked about previously in this thread.

I don't know what could be considered an unnecessary calculation though. Like I have also said before, a large number of sprites dangerously lags the game, even if you don't update them. Something as simple as

s = []
for i in 1...5000
s.push(Sprite.new)
end

in Main is enough to drop FPS significantly. A resolution of 1024x576 uses 1920 sprites to draw the map. If you want to increase performance but sacrifice memory, use Bitmaps. Note that there's a limit for how many bitmap objects you can have before the game suddenly closes (just under 10,000) and that 100 100x100 size bitmaps takes less memory than 1 1000x1000 bitmap. EDIT: Huh, I could have sworn it was...my last test says otherwise.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

I just lol-ed when I creating this script: http://forum.chaos-project.com/index.php/topic,13795.0.html
at first I want to create something like multi layer script, but for some reason it become like that

LiTTleDRAgo

January 27, 2014, 05:56:54 am #137 Last Edit: February 17, 2014, 01:21:51 am by LiTTleDRAgo
found a bug with weather

Spoiler: ShowHide


also, the fix: *Link Removed*

KK20

:up:

I really appreciate the amount of work you are putting into making this script better and compatible with the add-ons you have made so far. I seriously need to spend some time to look at what you have done so far and keep up with the changes.

I guess the next things to work on are fullscreen and zoom-in/-out.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

well, I don't think zoom is possible the way the script is

in King's tilemap, all I had to do is just


      sprite.x = @rows[i,0]*32-ox
      sprite.y = i*32-oy
      sprite.zoom_x = $game_map.zoom_x || 1.0
      sprite.zoom_y = $game_map.zoom_y || 1.0
      sprite.x = (sprite.x * sprite.zoom_x)
      sprite.y = (sprite.y * sprite.zoom_y)


but in your code, I can't do that the same way in King's

KK20

Which is why this will take a bit more creative thinking than plug-n-play. I did write something that was able to zoom in and out, but moving around bugged the tiles. I also don't think the events were aligned properly. Haven't worked on it in a couple months.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

January 28, 2014, 07:19:32 am #141 Last Edit: February 17, 2014, 01:20:56 am by LiTTleDRAgo
CR map zoom (bugged) : *Link Removed*
CR 0.97 : *Link Removed*
too bad I couldn't get rid the bugs

KK20

Should point out that the Integer class is pointless now. Should have time to look at it tomorrow.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!


KK20

Just tried out 97a. The Tilemap#ox=/oy= are a bit slower now, the latter being about 3-5 times slower in comparison to 96b.
Code: ox method

0.002 - 0.004
vs
0.003 - 0.006 with the occasional 0.015, which is interesting to note

Code: oy method

0.004 - 0.006
vs
0.011 - 0.025, significant enough to be very noticeable in game


But you implemented a working map zoom, and for which, I am forever grateful to your dedication~





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

yeah, I'm aware of that, there are so many calculation needed for the zoom coordinates
also, those differences didn't very noticeable in my OS (both of the 96b and 97a runs at 15-17 FPS in WinXP)

Zexion

Okay so I tried drago's custom resolution out. On my laptop it worked perfectly fine. Same as usual. On my moms... I got like 12 FPS and there wasn't anything on the screen aside from tiles and one event. I switched back to 0.96 and it was fast again o.o  30 FPS

KK20

Well at least it's not only me :P I wonder what's really hitting the performance hard? If it is the zoom calculations, why not devote the sections in v97a to only exist in the Map Zoom Add-on?

I'm using 96b in my Advance Wars for the Tilemap rewrite. Still runs at 39-40 FPS with Fog of War on (that's two instances of Tilemap).





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Ryex

February 07, 2014, 04:39:12 pm #148 Last Edit: February 07, 2014, 04:44:54 pm by Ryex
allow me to offer my optimization knowledge


while (t = @tile_sprites[col_num]) && (t[0].x/t[0].zoom_x <= -49*t[0].zoom_x || t[0].x/t[0].zoom_x >= -17*t[0].zoom_x) && @anti_hang < 100


this is killing you I bet (not the only thing but a major contributor)
remember it gets run as is every loop. that means t[0] calls t.[](0) and has to resolve the object 6 times every loop. if you bound t[0] to a local name that would provide some speed up.
if you can do the same with the object's .zoom_x and .x properties instead of resolving them off the object with a call every time that might help too.
also you do the same division (t[0].x/t[0].zoom_x) twice, doing it once and binding it to a local name might help (that might need some testing I'm not familiar with the overhead of integer division vs name binding)
next, .zoom_x is a float yes? then your dividing an int by a float. in a typed and compiled language this wouldn't be an issue as the compiler would automatically optimize but in ruby we're doing this all at run time and as an int/float operation is technically impossible for the CPU ruby first has to coerce the int to a float, at run-time, every time it happens. same thign applies for all mathematical operations between floats and ints
lastly the
(t = @tile_sprites[col_num]) &&

while clever in that it is a clean way to set up for the while call, you introduce the somewhat unnecessary testing condition that @tile_sprites[col_num] exists every loop. if you've written everything correctly this condition should NEVER be false and if it can be then something else has gone wrong and you should look into that

all this in mind the line should probably be written as

t = @tile_sprites[col_num]
txf = t.x.to_f
tzoom_x = t.zoom_x
tratio = txf/tzoom_x
while (tratio <= -49.0*tzoom_x || tratio >= -17.0*tzoom_x) && @anti_hang < 100
    #rest of loop code
    #...
    #...
   
    col_num = @corner_index   

    t = @tile_sprites[col_num]
    txf = t.x.to_f
    tzoom_x = t.zoom_x
    tratio = txf/tzoom_x
end #end of while





(($resolution.width + 64)*($resolution.height + 64)).floor / 1024

is there really a float in there that makes the .floor call necessary? in fact if you want an integer result it might be faster to force everything to integer first, there is a reason computers measure power in FLOPS, integer operations are insignificant vs floating point ones. that applies everywhere you end up using floats. drop to integers as soon as you can provided you wont lose needed precision.

Less optimization and more questioning implementation
@tile_sprites[j] && @tile_sprites[j].each_index do |i|

I'm unsure if the objective is to only loop if @tile_sprites[j] exists or if your trying to get a union or intersection of the arrays to loop over. only the former makes sense and I'm unsure of the performance of using an if statement over taking advantage of the way ruby only processes the statement after the && if the first returned a truthy value.
then I question the necessity of once again checking to ensure existence. if the condition really can happen then something else is wrong. and again, it's just one more operation in a loop that adds run time if you don't need it.

summery:
avoid all floating point operations you can.
avoid repeated calls or operations
avoid unnecessary name resolution
avoid implicit coercion at run-time
if you need to do constant checking for existence of an object INSIDE A LOOP then something is wrong elsewhere.

of course you probably should not take my word for all this. do your own tests.

don't take this as a smack down of your skills in any way. everyone has their coding style and ruby is a language where there are 100 ways to do something. it's just not always the fastest. it's taken me years and college classes to learn how to optimize

I'll leave with one final word. never prematurely optimize. only optimize if you NEED to and have profiles to prove that a method or function is eating a significant amount of time.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

KK20

I'll leave that for Drago to do since this is all his doing :P
I never took a good look at the code yet, but that first line...yeah, I can see how performance is lost.

Nice input by the way. Algorithms and/or engine design are kinda my interest now.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

February 07, 2014, 07:51:59 pm #150 Last Edit: February 07, 2014, 09:18:18 pm by LiTTleDRAgo
@kk20
do you have a copy of 0.97a?
I have accidentally updated the pastebin with a bugged 0.97b and I lost ver 0.97a

@ryex
thanks for the input, honestly I didn't know until now that Float have higher cost for performance.

KK20






   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

LiTTleDRAgo

February 07, 2014, 09:05:20 pm #152 Last Edit: February 17, 2014, 01:20:34 am by LiTTleDRAgo
try this (v0.97c) : *Link Removed*

Zexion

February 08, 2014, 01:07:38 am #153 Last Edit: February 08, 2014, 11:58:37 pm by Zexion
I just tryed 0.97c and I get this wierd map glitch o.o
Spoiler: ShowHide


Also, it is VERY laggy at this screen resolution. To be fair though, I tried 0.96b at the same resolution and it's very laggy aswell. I think this laptop just sucks lol. In any case, the map glitch thing still happened

Edit: Also, I tried to use this with the ACE engine thing, and it didn't work. The line it was pointing to was Plane < Sprite
and the error was type mismatch.

LiTTleDRAgo

February 11, 2014, 01:05:09 am #154 Last Edit: February 13, 2014, 11:52:24 am by LiTTleDRAgo
v0.97e = http://pastebin.com/rWLhY7wg

cleaned up code, fix weather, fog & panorama zoom

Zexion

I tried it alone, and it doesn't work o.o I don't know why, but it doesn't.
NoMethodError on line 21 of Spriteset_Map (the default one)
points to this:
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)

Again, this is with the vxa/xp engine mod only.

Another wierd thing to note, if I use Me(tm) and put it above other scripts, and then put this at the bottom. It works. It's laggy though and idk if the lag is from two tilemap rewrites or if it's the normal lag I would get from your script. At the moment though, I can tolerate the lag because it also fixes the bug that crashes the system when transferring maps.

LiTTleDRAgo

February 15, 2014, 06:26:43 pm #156 Last Edit: February 15, 2014, 06:28:59 pm by LiTTleDRAgo
@^ reuploaded, there are some typo in the script

also, if you're using RGSS3, don't use map larger than 20 x 15 (lags when scrolling) or resolution larger than 640 x 480 (stack to deep)
it seems that RGSS3 engine can't handle a huge number of sprites smoothly

Zexion

February 15, 2014, 06:43:06 pm #157 Last Edit: February 15, 2014, 06:46:38 pm by Zexion
It's kinda a bummer that I can't use bigger maps. I prefer this script over the other (Me tm) because it fixes the random crashing, but the other one had less lag. In any case, what do you recommend I do to get around the 20x15 map restriction? Some maps simply don't make sense to confine to 20x15

Edit: I just test played it, and it seemed to lag less now. Map is 38x46, but there are only two events. I don't know if it will be a problem once there are more events and more sprites on the screen... also forgot to mention that it works alone now :D

LiTTleDRAgo

February 15, 2014, 10:56:07 pm #158 Last Edit: February 17, 2014, 01:19:45 am by LiTTleDRAgo
well, that's ok if you're fine with the lags when the map is scrolling.

Zexion

Well, actually... this last update is way better than before o.o It used to lag a whole lot on all my maps, but now it only stutters a tiny little bit on big maps. (Essentially the same as me(tm)'s) Which is pretty good seeing as it lagged a lot more when I first transferred it over to this laptop with v0.96c and RGSS104E. My moms laptop is significantly slower than mine so the average user should be fine.

Ryex

Yay! my input has help Drago refine this masterpiece!

Great Job Drago.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Mollalosso

March 01, 2014, 10:30:31 am #161 Last Edit: March 02, 2014, 02:19:51 am by Mollalosso
(Sorry for my bad english)
Hi guys, i have problem with any script resolution. Exclusive problem verified in battleback, i have insert image 1024x576 but visualy solo 1/4 . how can i resolve? ty.

Resolved
I change in "Spriteset_Battle this:

@viewport1 = Viewport.new(0, 0, 1300, 745)
and
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 1300, 745)

Zexion

I keep getting wrong argument type String (expected Module) at this line:
       if args.at(1) != '' && !include?(path) && RESIZE_BITMAP

On drago's latest

LiTTleDRAgo

just delete that method and the error will fixed

Zexion

Now I get the error on line 509
unless include?(key)

LiTTleDRAgo


Zexion

Okay so I've been experiencing wierd issues with this script lately. For some reason, when I first got my laptop back, this ran at 1024x576 with no stuttering at all on a huge 80x56 map with autotiles + some events. Now the same map stutters when moving diagonally. I haven't added any additional scripts since then, so I don't understand what happened lol. Anywho, I found an old version of this 0.93 to be exact, and it runs flawlessly. Or at least without more than the default amount of stuttering.
Why is this?

KK20

My tilemap rewrite in v0.96 uses a large number of sprites to create each tile for each layer. 1024x576 map uses 34*20*3 sprites, or 2040 sprite objects. And that's just for the tilemap drawing alone--we haven't even touched the windows, events, animations, etc.

There's been a toss up over how many sprites you can have at one time and not lose performance. My Windows 7 can have thousands of sprites and show almost no sign of lag in RMXP. In an RMXPA project, the lag was largely noticeable (FPS of single digits). However, I think it is due to the modified RGSS3 file provided in the package since 5000 sprites created in a RMVXA project didn't slow anything down for me. You need that file in order to create larger resolutions than 640x480 (going any further with an unedited one stretches the graphics). Drago reported his Windows XP lagging a lot, both in RMXP and RMXPA.

v0.93 uses large, map-sized bitmaps. These are handled much better than sprites (you can have thousands and there is no drop in FPS anywhere) but they eat a lot of memory. You are limited to how big your map can be because of this (run Task Manager and see for yourself). You also have to consider that to draw the tilemap, the script uses a lot of Bitmap#blt calls before the map is loaded. Also, to update the animating autotiles, Bitmap#blt must be called frequently. v0.93 has a lot of graphical display errors (you pointed one or two of them actually).

v0.96 (and above) hardly uses any memory and does a series of Sprite#src_rect to draw the tilemap, which is extremely fast compared to Bitmap#blt. You can make 500x500 maps with autotiles galore and have pretty nice performance. It's just larger resolutions are iffy at this point.

The real challenge becomes trying to find a nice balance between Sprites and Bitmaps or having to suck it up and sacrifice something.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Zexion

March 22, 2014, 03:24:07 am #168 Last Edit: March 22, 2014, 12:41:37 pm by Zexion
original post: ShowHide
The problem for me right now, is that I don't want to develop for one resolution and switch to another later on. I feel that the 640x480 is kinda limiting in terms of screen space. I've tried everything at this point for bigger resolutions. It is really odd to me that both your latest + drago's latest worked flawlessly a few weeks ago and now I'm seeing major stuttering. It doesn't even fix when I size it down in half (512x288), which is wierd because my laptop has decent specs so it shouldn't be this bad. I don't want to up-res the game if it's going to cause lag for the few people that actually play my game, but I really do want to have a bigger resolution.
My closest to no lag has been using Me(tm)'s rewrite, but it causes display errors with sprites that have alpha transperency. I can't even get the others to work XD
The thing is that I had already started to up-res the menu's that I've made, and I forgot to backup the main menu's original code >.< so now I'm reluctant to go back to default resolution. The graphics are still there but meh... it's like a few days worth just rewriting that.

Do you know of anything that I could do that could possibly help the performance? I'm going to install updates and turn off my pc completely for the night (because I never turn it off XD) and see if that helps.


Edit: Okay so this morning I tried it again, and it was still stuttering. Then I noticed that my hud was all pixely as if it was being redrawn over itself constantly. I'm not sure what went wrong with the script since I hadn't touched it in this project for weeks, but I replaced the code with some from my battlesystem project and the hud fixed, which seemed to fix the lag. This explains why I started lagging all of the sudden..

KK20

So it was just your script in the end? You're using RMXP and not RMXPA right?





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Zexion

Yeah it was my script, and I used to use RMXPA but I've switched back to just xp.
I've actually decided just to keep the 640x480 resolution. Though the script doesn't cause too much lag, it does have a visible amount of screen tearing, and I'm mainly concerned with it lagging too much for others. I don't expect most people to have good setups like most of us on C-P do, so it might be too much lag for anyone using an underpowered laptop. For now I am sticking to no custom resolution. For smaller resolutions though, this is definately my go-to script :P

Wingard

Hey!  :D Id like to use this fantastic script but after some testing i see that version 0.97 gives me some bugs (but its still much more stable than 0.96b since provides no crashes). Two screenies to help me visualise the issue:
http://s27.postimg.org/te0gy8t35/image.jpg
http://s27.postimg.org/xlv96zuip/image.jpg
As you can see some of the objects are not being displayed in-game (inside red rectangle). They are however blocking the way (stone, bush). The problem is present in any given resolution. Any help, please? :) Do i need to upload the map?

KK20

Just want to update that I've been working on a DLL Tilemap rewrite for the past week. I'm still experimenting with performance and optimizing it. I'll also try to get it to work with RGSS3 later too. And yes, I'll release the source :P





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

chrissummers

Hey there, sorry for the digging but I reeeeally love what this script does, however ... I got some issues ^^

For me, fps below 30 always seem very bad and worsen the experience considerably. With resolutions above ~800*600 on many maps, I already feel a difference, and anything rather big (~1200*~900) is pretty much unplayable. I would of course use a resolution that is still good performance wise but higher than default. The missing fullscreen option however makes this a hard choice.

So my questions are: Will there be an update for better fps and/or fullscreen within the next two months? I am working on a game that I will use in school (as a teacher) and would really love to use a version of this script.

Thanks for the work you put in!

KK20

You can try Goldaryn Multiple Resolution. I seem to be able to get constant 40 FPS at a 1024x768 resolution. It also allows fullscreen, provided your monitor can support it. Poccil's tilemap rewrite (which comes with the script, same one used in the Pokemon Essentials Kit) performs well on XP but is missing some core Tilemap features that I need for my own uses; I also have no idea how it works.

RPG Maker isn't exactly made for large resolution games (otherwise, resolution setting wouldn't be so damn hard to do). The drawing process is nothing fantastic and starts to lag when multiple sprites are present on the screen.

I was working on a DLL rewrite, but got too invested with trying to find ways to optimize it under this current circumstance. I might just find the time to finish what I started and release it for others to give feedback on it. Until ARC or F0's RPG.NET are finished, you will have to make do with the weak graphics engine RPG Maker utilizes. Or just forgo the whole resolution thing altogether.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

chrissummers

Hi there,

thanks for your quick response :)

I will take a look at Goldaryns Solution. What are the missing features you are speaking of?

The only reason a resolution change would help me, is, that I am trying to make a historically authentic game and some houses or especially the main church are quite huge and far bigger than what is normally visible on screen. That, to some degree, takes away some of the "wow"factor, as the player just cant see the whole building at once (or even half of it).

KK20

For my game, I need to be able to change the tile graphics on the fly by using $game_map.data[x,y,z] = tile_id. Poccil's Tilemap rewrite does not allow for such changes. I was also working on XP Ace (uses the VX Ace engine for XP games, resulting in smoother gameplay) and Poccil's rewrite had graphical errors. There might have been more, but I can't recall what they were. Anyways, I need other features as well, and the fact I can't understand how his rewrite works means it is useless for me to modify it.

That sounds pretty interesting, especially as a teacher, not as a student. Be sure to share your product when it's done! :)





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

R5GAMER

October 17, 2014, 09:47:35 pm #177 Last Edit: October 19, 2014, 10:50:59 pm by R5GAMER
On RMX-OS it works ;)

The probleme is that it seems like the hero is always stuct in a resolution 640x480...
..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

KK20

The update is nearing testing phase.
Spoiler: ShowHide

If you can't tell, the autotiles have different update times. Completely configurable based on filename too.

In this exact spot, 50 FPS on 1024x576 resolution. Pretty sure this is the best you can get thanks to the inefficient Sprite class. I will actually add in an option that allows you to remove priority level 5 tiles from your game (effectively turning them into priority 4) which will help improve FPS. I believe that is a sacrifice worth making as it benefits larger resolutions immensely (observed gain of 20~30FPS for 1200x800).

Then again, since this is mostly a Tilemap rewrite, it probably would be better to just make a new topic.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Wecoc

Quote from: KK20For my game, I need to be able to change the tile graphics on the fly by using $game_map.data[x,y,z] = tile_id. Poccil's Tilemap rewrite does not allow for such changes.


Are you sure about that? I copied the Poccil's Tilemap directly from upokecenter on an empty project, and $game_map.data[x, y, z] = tile_id works well on map.
I also tried the Dll-less Resolution Script without anything more and the call doesn't work any more; as I can see the table @map_data is not used internally as much as in Poccil's.

But it has the new method $game_map.change_tile(x, y, z, tile_id) which does exactly the same, so it's not a big problem.

By the way, I would also add a get_tile:

  def get_tile(x, y, z)
    return spriteset.tilemap.map_data[x, y, z] if spriteset.is_a?(Spriteset_Map)
  end


Quote from: KK20I will actually add in an option that allows you to remove priority level 5 tiles from your game (effectively turning them into priority 4) which will help improve FPS.


That sounds great!

Zexion

Quote from: Wecoc on October 27, 2014, 09:22:40 am
Quote from: KK20I will actually add in an option that allows you to remove priority level 5 tiles from your game (effectively turning them into priority 4) which will help improve FPS.

That sounds great!

Not to mention, since you're not a noob that's going to do 1852x1256 size, it probably won't even need that option. Soooo hyped for the latest tilemap, it's already done wonders for my game ._. well the one map, lol. I am now official kk20 cheerleader, bust out tha pom poms y'all

KK20

I'd like to just retract my statement that the gain of 20 FPS was a mistake. I think I was using the wrong bitmap sizes and number of sprites. On actual inspection, removing one priority layer added about another 5 FPS. I'll still keep this feature (who knows, someone might find it useful).

Been having trouble trying to figure out shaking, but everything else is coming along smoothly.

@Wecoc:
Really? I must have been using an older version then. Or confusing it with another tilemap rewrite. I might have to check it again to see if it's more compatible with XP Ace.
And I'm pretty sure I made my v0.96 tilemap rewrite still work with $game_map[x,y,z] = t_id; I tested that extensively to ensure it worked. Drago is solely responsible v0.97. Perhaps you're talking about that one?





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!

Wingard

Hi. Would it be possible to change or create an addon for this script for it to take the height and width values from an external file? Like a notepad "resolution.txt" placed in game folder or something like that. I made a scaling interface for my little game and id like the player to be able to choose by himself which resolution he prefers to play at, without me decompressing the game and changing it for him every time. Script/addon would read two values from the file and assign them to two respective variables which IDs would be set in it. This way by reffering to these two variables the interface would know how it should adjust itself.  :)

tasuku13


Try this script on my game.Script work so well.But Plane class is still 640 * 480 pixel.

Try on MOG scene menu...still the same.Plane class is still in 640 * 480 area pixel.

Can someone help me fix this?

KK20

It's hard to say what the real issue could be. The script already handles Planes by using a rewrite, drawing bitmaps that stretch to the resolution's size. The script also handles resizing viewports that are 640x480 in size.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



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

Join the CP Discord Server!