Small Script: Extended Graphics.resize_screen

AloneForLong

Seksy Catgirl
Member
Joined
Feb 15, 2020
Messages
25
Reaction score
0
First Language
English
Primarily Uses
RMVXA
So, you know (if you ever use this anyway) that Graphics.resize_screen has an upper limit of 640 x 480.

I was wondering if anyone knew how to modify it so that you can resize the screen however you want. Of course, Graphics is a hidden class, so I don't know how to access the Graphics class so that I can alias and redefine the method, because I don't know what other methods it takes to resize the screen.

So if there are any really professional scripters still out there, maybe I could use your help.
It's just a small script, btw.
 

Xane

Veteran
Veteran
Joined
Jun 5, 2020
Messages
72
Reaction score
374
First Language
(US) English
Primarily Uses
RMVXA
The problem with a script request like this is that it hasn't been done already because it requires modifying the .dll to remove the hard coded limits which is against the EULA. At one point there was an official experimental .dll but was deprecated in favor of MV when that engine was released allowing this natively.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
280
Reaction score
106
First Language
English
Primarily Uses
RMXP

Suggest you read most of the thread.
 
Joined
May 14, 2020
Messages
17
Reaction score
1
First Language
English
Primarily Uses
RMVXA
I have here a script that allows unlimited resolution at the cost of unlimited responsibility.
With its own mysterious origin story no less: based on an incomprehensible magic number snippet by an anonymous author...

It breaks just about everything and is a hassle to work with. Use at your own risk.
I also don't know whether or not it messes with .dll or breaks that EULA
I only used it to take big beautiful screenshots for wallpaper purposes.

Code:
=begin
#===============================================================================
 Title: Unlimited Resolution
 Date: Oct 24, 2013
--------------------------------------------------------------------------------
 ** Change log
 Jun 6, 2014
   - Kaelan: fixed several bugs in the Plane class which prevented the sprite
     from being modified correctly. Patched for compatibility with Victor's
     Fogs and Overlays script. Include this after his script.
 Apr 20, 2014
   - added Kaelan's suggestion for disposing the viewport when done with it
 Nov 6, 2013
   - added some plane modifications to fix parallax images
 Oct 24, 2013
   - Initial release
--------------------------------------------------------------------------------   
 ** Terms of Use
 * Free
--------------------------------------------------------------------------------
 ** Description
 
 This script modifies Graphics.resize_screen to overcome the 640x480 limitation.
 It also includes some code to properly display maps that are smaller than the
 screen size.
 
 Now you can have arbitrarily large game resolutions.
 
--------------------------------------------------------------------------------
 ** Installation
 
 You should place this script above all custom scripts
 
--------------------------------------------------------------------------------
 ** Usage

 As usual, simply resize your screen using the script call
 
   Graphics.resize_screen(width, height)

--------------------------------------------------------------------------------
 ** Credits
 
 Unknown author for overcoming the 640x480 limitation
 Lantier, from RMW forums for posting the snippet above
 Esrever for handling the viewport
 Jet, for the custom Graphics code
 FenixFyre, for the Plane class fix
 Kaelan, for several bug fixes

#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_UnlimitedResolution"] = true
#===============================================================================
# ** Configuration
#===============================================================================
class << SceneManager
 
  alias resolution_run run
  def run(*args, &block)
    Graphics.ensure_sprite
    resolution_run(*args, &block)
  end
end

module Graphics
 
  @@super_sprite = Sprite.new
  @@super_sprite.z = (2 ** (0.size * 8 - 2) - 1)
 
  class << self
    alias :th_large_screen_resize_screen :resize_screen
    
    def freeze(*args, &block)
      @@super_sprite.bitmap = snap_to_bitmap
    end
    
    def transition(time = 10, filename = nil, vague = nil)
      if filename
        @@super_sprite.bitmap = Bitmap.new(filename)
      end
      @@super_sprite.opacity = 255
      incs = 255.0 / time
      time.times do |i|
        @@super_sprite.opacity = 255.0 - incs * i
        Graphics.wait(1)
      end
      @@super_sprite.bitmap.dispose if @@super_sprite.bitmap
      reform_sprite_bitmap
      Graphics.brightness = 255
    end
    
    def reform_sprite_bitmap
      @@super_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
      @@super_sprite.bitmap.fill_rect(@@super_sprite.bitmap.rect, Color.new(0, 0, 0, 255))
    end
    
    def fadeout(frames)
      incs = 255.0 / frames
      frames.times do |i|
        i += 1
        Graphics.brightness = 255 - incs * i
        Graphics.wait(1)
      end
    end
    
    def fadein(frames)
      incs = 255.0 / frames
      frames.times do |i|
        Graphics.brightness = incs * i
        Graphics.wait(1)
      end
    end

    def brightness=(i)
      @@super_sprite.opacity = 255.0 - i
    end
    
    def brightness
      255 - @@super_sprite.opacity
    end
    
    def ensure_sprite
      if @@super_sprite.disposed?
        @@super_sprite = Sprite.new
        @@super_sprite.z = (2 ** (0.size * 8 - 2) - 1)
        reform_sprite_bitmap
      end
    end
  end
 
  #-----------------------------------------------------------------------------
  # Unknown Scripter. Copied from http://pastebin.com/sM2MNJZj
  #-----------------------------------------------------------------------------
  def self.resize_screen(width, height)
    wt, ht = width.divmod(32), height.divmod(32)
    #wt.last + ht.last == 0 || fail('Incorrect width or height')
    wh = -> w, h, off = 0 { [w + off, h + off].pack('l2').scan /.{4}/ }
    w, h = wh.(width, height)
    ww, hh = wh.(width, height, 32)
    www, hhh = wh.(wt.first.succ, ht.first.succ)
    base = 0x10000000  # fixed?
    mod = -> adr, val { DL::CPtr.new(base + adr)[0, val.size] = val }
    mod.(0x195F, "\x90" * 5)  # ???
    mod.(0x19A4, h)
    mod.(0x19A9, w)
    mod.(0x1A56, h)
    mod.(0x1A5B, w)
    mod.(0x20F6, w)
    mod.(0x20FF, w)
    mod.(0x2106, h)
    mod.(0x210F, h)
    # speed up y?
    #mod.(0x1C5E3, h)
    #mod.(0x1C5E8, w)
    zero = [0].pack ?l
    mod.(0x1C5E3, zero)
    mod.(0x1C5E8, zero)
    mod.(0x1F477, h)
    mod.(0x1F47C, w)
    mod.(0x211FF, hh)
    mod.(0x21204, ww)
    mod.(0x21D7D, hhh[0])
    mod.(0x21E01, www[0])
    mod.(0x10DEA8, h)
    mod.(0x10DEAD, w)
    mod.(0x10DEDF, h)
    mod.(0x10DEF0, w)
    mod.(0x10DF14, h)
    mod.(0x10DF18, w)
    mod.(0x10DF48, h)
    mod.(0x10DF4C, w)
    mod.(0x10E6A7, w)
    mod.(0x10E6C3, h)
    mod.(0x10EEA9, w)
    mod.(0x10EEB9, h)
    th_large_screen_resize_screen(width, height)
  end
end

#===============================================================================
# Esrever's code from
# http://www.rpgmakervxace.net/topic/100-any-chance-of-higher-resolution-or-larger-sprite-support/page-2#entry7997
#===============================================================================
class Game_Map

  #--------------------------------------------------------------------------
  # overwrite method: scroll_down
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    last_y = @display_y
    if loop_vertical?
      @display_y += distance
      @display_y %= @map.height * 256
      @parallax_y += distance
    else
      dh = Graphics.height > height * 32 ? height : screen_tile_y
      @display_y = [@display_y + distance, height - dh].min
      @parallax_y += @display_y - last_y
    end
    @fog_y += loop_vertical? ? distance : @display_y - last_y if @fog_y
  end

  #--------------------------------------------------------------------------
  # overwrite method: scroll_right
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    last_x = @display_x
    if loop_horizontal?
      @display_x += distance
      @display_x %= @map.width * 256
      @parallax_x += distance
    else
      dw = Graphics.width > width * 32 ? width : screen_tile_x
      @display_x = [@display_x + distance, width - dw].min
      @parallax_x += @display_x - last_x
    end
    @fog_x += loop_horizontal? ? distance : @display_x - last_x if @fog_x
  end

end # Game_Map

#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map

  #--------------------------------------------------------------------------
  # overwrite method: create_viewports
  #--------------------------------------------------------------------------
  def create_viewports
    if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal?
      dx = (Graphics.width - $game_map.width * 32) / 2
    else
      dx = 0
    end
    dw = [Graphics.width, $game_map.width * 32].min
    dw = Graphics.width if $game_map.loop_horizontal?
    if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical?
      dy = (Graphics.height - $game_map.height * 32) / 2
    else
      dy = 0
    end
    dh = [Graphics.height, $game_map.height * 32].min
    dh = Graphics.height if $game_map.loop_vertical?
    @viewport1 = Viewport.new(dx, dy, dw, dh)
    @viewport2 = Viewport.new(dx, dy, dw, dh)
    @viewport3 = Viewport.new(dx, dy, dw, dh)
    @viewport2.z = 50
    @viewport3.z = 100
  end

  #--------------------------------------------------------------------------
  # new method: update_viewport_sizes
  #--------------------------------------------------------------------------
  def update_viewport_sizes
    if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal?
      dx = (Graphics.width - $game_map.width * 32) / 2
    else
      dx = 0
    end
    dw = [Graphics.width, $game_map.width * 32].min
    dw = Graphics.width if $game_map.loop_horizontal?
    if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical?
      dy = (Graphics.height - $game_map.height * 32) / 2
    else
      dy = 0
    end
    dh = [Graphics.height, $game_map.height * 32].min
    dh = Graphics.height if $game_map.loop_vertical?
    rect = Rect.new(dx, dy, dw, dh)
    for viewport in [@viewport1, @viewport2, @viewport3]
      viewport.rect = rect
    end
  end

end # Spriteset_Map

#-------------------------------------------------------------------------------
# FenixFyre's custom Plane, simply drawing a sprite. Needs to do something about
# the y-axis
#-------------------------------------------------------------------------------
class Plane
  attr_reader :ox, :oy
 
  alias :th_unlimited_resolution_initialize :initialize
  def initialize(viewport = nil)
    th_unlimited_resolution_initialize(viewport)
    @sprite = Sprite.new(viewport)
    @bitmap = nil
    @ox = 0
    @oy = 0
  end

  def method_missing(symbol, *args)
    @sprite.method(symbol).call(*args)
  end
 
  def bitmap=(bitmap)
    @bitmap = bitmap
    refresh
  end
 
  alias :th_unlimited_resolution_dispose :dispose
  def dispose
    th_unlimited_resolution_dispose
    @sprite.dispose if @sprite
    @sprite = nil
  end
 
  def bitmap
    @sprite.bitmap
  end
 
  def ox=(ox)
    w = @sprite.viewport != nil ? @sprite.viewport.rect.width : Graphics.width
    @ox = ox % w
    @sprite.ox = @ox
  end
 
  def oy=(oy)
    h = @sprite.viewport != nil ? @sprite.viewport.rect.height : Graphics.height
    @oy = oy % h
    @sprite.oy = @oy
  end
 
  def blend_type=(blend_type)
    @blend_type = blend_type
    @sprite.blend_type = blend_type
  end
 
  def opacity=(opacity)
    @opacity = opacity
    @sprite.opacity = opacity
  end
 
  def z=(z)
    @z = z
    @sprite.z = z
  end
 
  def tone=(tone)
    @tone = tone
    @sprite.tone = tone
  end
 
  def visible=(visible)
    @visible = visible
    @sprite.visible = visible
  end
 
  def refresh
    return if @bitmap.nil?
    w = @sprite.viewport != nil ? @sprite.viewport.rect.width : Graphics.width
    h = @sprite.viewport != nil ? @sprite.viewport.rect.height : Graphics.height
    if @sprite.bitmap != nil
      @sprite.bitmap.dispose
    end
    @sprite.bitmap = Bitmap.new(w * 2, h * 2)
      
    max_x = (w*2) / @bitmap.width
    max_y = (h*2) / @bitmap.height
            
    for x in 0..max_x
      for y in 0..max_y
        @sprite.bitmap.blt(x * @bitmap.width, y * @bitmap.height,
         @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height))
      end
    end

  end
end

#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base

  #--------------------------------------------------------------------------
  # alias method: post_transfer
  #--------------------------------------------------------------------------
  alias scene_map_post_transfer_ace post_transfer
  def post_transfer
    @spriteset.update_viewport_sizes
    scene_map_post_transfer_ace
  end

end # Scene_Map
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
280
Reaction score
106
First Language
English
Primarily Uses
RMXP
That's literally what I posted. And it's been discussed that it doesn't directly mod the DLL, just changes bits in memory, so it doesn't breach EULA.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
287
Reaction score
71
First Language
English
Primarily Uses
RMXP
Keep in mind that maps should be as large as to fill the game screen. It's been always like this since the first RM. Using smaller maps is a bad design by default.
So divide the width by 32 and do the same with the height. If there's some decimals, add an extra tile then. Those numbers will become the minimum tiles your maps will need to achieve that goal.
 
Joined
May 14, 2020
Messages
17
Reaction score
1
First Language
English
Primarily Uses
RMVXA
literally what I posted
You posted the whole thread of another guy asking for the same thing
I don't know why you did that
i provided the very script just by itself
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,253
First Language
English
Primarily Uses
RMVXA
If you want higher than 640 x 480 your best bet is to look for the beta thread on making ACE run on directx. That is your best and stablest option. Otherwise this cannot really be done as *no* one was given access to those hidden classes at all except the dev team of RPGMaker and they aren't talking.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
280
Reaction score
106
First Language
English
Primarily Uses
RMXP
I don't know why you did that
I was on mobile at the time. I provided a fix to a bug with the assembly part of the code as well as the thread to the development of Unlimited Resolution. It's a script that still has a host of problems if you assume everything will run like the default engine does, so it's good to see what other users came up with for solutions. I also believe the script is no longer publicly available and can be found on Hime's site only by a direct URL. As such, it's a lot to mention with just two thumbs.

your best bet is to look for the beta thread on making ACE run on directx

Otherwise this cannot really be done
What do you mean when a solution was already provided to the thread?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,253
First Language
English
Primarily Uses
RMVXA
As stated, none of those solutions are reliable. They may work for some, but for others they crash badly. Plus the solution even says it breaks about everything, see the post earlier in this thread too.

Its also why the high res DLL was pulled. It was never able to be fixed to be consistent enough for everyone to use it well, so it was dropped and never finished once MV came out.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
280
Reaction score
106
First Language
English
Primarily Uses
RMXP
Sure, they may be "hackish" ways of implementing it, but it's not impossible to do as you worded it in your post. There's a lot of scripts out there that aren't going to be compatible with everything; this is--obviously--no exception.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Having randomized space below my maps is like cheating, every map instantly starts out interesting. See? I just started on this one, and boom interesting!. :LZSexcite:

Moderators, you must have so much patience to be able to deal with everything. I mod in a server of sorts and today we just got a message, which, despite it's helpful constructive criticism, basically stated that all of the mods were jerks and that was the only reason our server was unlikeable. So, thank you, for having patience. You are appreciated! :kaoluv:
Haired slime? Trying some different styles of art. Maybe I can make some resources with this new kind of painting.......
i love my game very much
Uh, I'm probably overthinking this, but I think that some of my music sounds kinda...bad?
The melodies are just sort of awkward, and don't flow.
I'm really not sure what to do. Why am I even worrying about this? I don't even have a battle system yet!

Forum statistics

Threads
105,727
Messages
1,015,935
Members
137,410
Latest member
judicasino88
Top