=begin
#==============================================================================
Title: Unlimited Resolution
Date: Oct 24, 2013
Author: Hime
-------------------------------------------------------------------------------
Terms of Use
Free
-------------------------------------------------------------------------------
Description
This script modify Graphics.resize_screen to overcome the 640x480 limitation.
It also includes some modifications to module Graphics such as allowing the
default fade transition to cover the entire screen.
Now you can have arbitrarily large game resolutions.
-------------------------------------------------------------------------------
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
RGSS3 = RUBY_VERSION == '1.9.2'
if RGSS3 && (SCREEN_RESOLUTION[0] > 640 || SCREEN_RESOLUTION[1] > 480)
module Graphics
@@super_sprite = nil
class << self
unless method_defined?(:th_large_screen_resize_screen)
alias :th_large_screen_resize_screen :resize_screen
end
def freeze(*args, &block)
ensure_sprite
@@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
ss = @@super_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@@super_sprite.bitmap.fill_rect(ss.rect, Color.new(0, 0, 0, 255))
end
def fadeout(frames)
incs = 255.0 / frames
frames.times do |i|
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
unless method_defined?(:wait)
def wait(frame = 1)
frame.times {|i| update }
end
end
def ensure_sprite
if @@super_sprite.nil? || @@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 = lambda {|w,h,off| [w + off, h + off].pack('l2').scan(/.{4}/) }
#wh = -> w, h, off = 0 { [w + off, h + off].pack('l2').scan /.{4}/ }
w, h = wh.call(width, height, 0)
ww, hh = wh.call(width, height, 32)
www, hhh = wh.call(wt.first.succ, ht.first.succ, 0)
base = 0x10000000 # fixed?
mod = lambda {|adr,val| (DL::CPtr.new(base + adr))[0, val.size] = val}
#mod = -> adr, val { DL::CPtr.new(base + adr)[0, val.size] = val }
mod.call(0x195F, "\x90"*5) && mod.call(0x19A4, h) && mod.call(0x19A9, w)
mod.call(0x1A56, h) && mod.call(0x1A5B, w) && mod.call(0x20F6, w)
mod.call(0x20FF, w) && mod.call(0x2106, h) && mod.call(0x210F, h)
# speed up y?
#mod.(0x1C5E3, h)
#mod.(0x1C5E8, w)
zero = [0].pack(?l)
mod.call(0x1C5E3, zero) && mod.call(0x1C5E8, zero) && mod.call(0x1F477, h)
mod.call(0x1F47C, w) && mod.call(0x211FF, hh) && mod.call(0x21204, ww)
mod.call(0x21D7D,hhh[0])&& mod.call(0x21E01,www[0])
mod.call(0x10DEA8, h) && mod.call(0x10DEAD, w) && mod.call(0x10DEDF, h)
mod.call(0x10DEF0, w) && mod.call(0x10DF14, h) && mod.call(0x10DF18, w)
mod.call(0x10DF48, h) && mod.call(0x10DF4C, w) && mod.call(0x10E6A7, w)
mod.call(0x10E6C3, h) && mod.call(0x10EEA9, w) && mod.call(0x10EEB9, h)
th_large_screen_resize_screen(width, height)
end
end
end