I have noticed that there are things in RGSS and RMXP that we actually don't know and that we should know. This topic is here to keep a list of all questions and answers about RGSS and RMXP that we will need to answer and implement. Feel free to edit this post when you add a new question and/or answer.
What are the max dimensions for the Table class?The maximum capacity of the Table class depends on the OS. The no single dimension can be large enough to have the Fixnum converted to a Bignum. This will vary between x86 and x64 processors, but here would be the formula to figure it out:
FIXNUM_MAX = (2**(0.size * 8 -2) -1)
FIXNUM_MIN = -(2**(0.size * 8 -2))
Other than that though, I do believe it is only limited to the computer's memory.
How exactly are Color, Tone, Rect and Table instances store in Ruby Marshal?
def _dump(d = 0)
[@red, @green, @blue, @alpha].pack('d4')
end
def self._load(s)
Color.new(*s.unpack('d4'))
end
def _dump(d = 0)
[@red, @green, @blue, @gray].pack('d4')
end
def self._load(s)
Tone.new(*s.unpack('d4'))
end
def _dump(d = 0)
[@x, @y, @width, @height].pack('l4')
end
def self._load(s)
Rect.new(*s.unpack('l4'))
end
def _dump(d = 0)
s = [3].pack('L')
s += [@xsize].pack('L') + [@ysize].pack('L') + [@zsize].pack('L')
s += [@xsize * @ysize * @zsize].pack('L')
for z in 0...@zsize
for y in 0...@ysize
for x in 0...@xsize
s += [@data[x + y * @xsize + z * @xsize * @ysize]].pack('S')
end
end
end
s
end
def self._load(s)
size = s[0, 4].unpack('L')[0]
nx = s[4, 4].unpack('L')[0]
ny = s[8, 4].unpack('L')[0]
nz = s[12, 4].unpack('L')[0]
data = []
pointer = 20
loop do
data.push(*s[pointer, 2].unpack('S'))
pointer += 2
break if pointer > s.size - 1
end
t = Table.new(nx, ny, nz)
n = 0
for z in 0...nz
for y in 0...ny
for x in 0...nx
t[x, y, z] = data[n]
n += 1
end
end
end
t
end
Does Table limit x, y, z if they are specified out of bounds or does it throw an error?If access is attempted outside the bounds of the table, the return value is nil.
How exactly is Table serialized as Marshal object?http://forum.chaos-project.com/index.php/topic,9103.msg140249.html#msg140249
What happens with Sprite#src_rect when Sprite#bitmap is set to a Bitmap instance or nil?The src_rect updates to the size of the bitmap bigger or smaller, when the bitmap is set to nil the src_rect is not changed.
What happens when you set Sprite#src_rect while Sprite#bitmap is nil?Nothing, the src_rect is set as normal.
What happens when you set Sprite#src_rect outside of the boundaries of Sprite#bitmap?Nothing, the src_rect is set as normal.
What is the z offset for the cursor, the bitmap size arrows, the pause graphic and the contents sprite?It's 2.
Window#viewport returns nil by default. What is it for? Is there a way to make it return something else or is this unused?Passing a viewport in a window does exactly the same like it does in a Sprite. It's just that this feature isn't used in RMXP.
What's the max value for number of frames in a transition?Only Fixnum values can can be used. If they number is large enough to be converted to a Bignum, it will throw a RangeError.
The exact value will vary depending on the processor.
What is the pixel color formula for the color blending used by plane, sprite and viewport?-
What is the pixel color formula for the tone blending used by plane, sprite and viewport?-
What are the formulas for calculating the Quick Settings (A, B, C, D, E) for actor parameters?-
What is the proper formula for the calculation of the new color value when using Bitmap#blt when any kind of opacity or alpha blending is involved?-
What does Graphics#frame_reset do?-
I can answer the color and tone question.
color
[@red, @green, @blue, @alpha].pack('d4')
tone
[@red, @green, @blue, @gray].pack('d4')
pack is an in-built ruby method that transforms an array into a byte string. Python has a module called struct that implements the same functionality.
I know what pack is, but I didn't know it was used for this. Good, then making a dump method won't be a problem.
You should edit my first post and add that. :P
As for the dimensions question, I thought there was a size limit to it. If there is none, then we won't have to implement one.
EDIT: I have added more questions. Feel free to answer and/or add your own.
BTW, Ryex, you should have edited my first post and inserted your answer there as well.
I answered the last question ind the _dump _load task
Added a new question:
What happens with Sprite#src_rect when Sprite#bitmap is set to a Bitmap instance or nil?
EDIT:
What happens when you set Sprite#src_rect while Sprite#bitmap is nil?
What happens when you set Sprite#src_rect outside of the boundaries of Sprite#bitmap?
EDIT:
What is the z offset for the cursor, the bitmap size arrows, the pause graphic and the contents sprite?
did some testing and answered all the above except the z question
Window#viewport returns nil by default. What is it for? Is there a way to make it return something else or is this unused?
I think it is just there as a remnant of the sprite class. I suppose it could be used manually, but I really can't ever see a need to do that.
I was thinking the same. I've seen somewhere that it was mentioned that the Window class is composed of several sprites. We will have to do the same approach sadly.
You can't even set the viewport, you can only get it and it's nil by default so I don't think it can have any use.
I think the viewport is set when you initialize the window, and you can pass it as an argument to the initialize method. The only time I've ever used it is when I am showing a non-opaque window over another window that isn't the same size. I just changed the dimensions of the viewport so that it excluded the area where the new window popped up for as long as the new window was visible - that way, the contents of the bottom window didn't obscure the contents of the top one. There are probably more profitable uses.
No, the viewport remains "nil" after initialization. Were talking more about the internal Window class, not Window_Base, which I don't think anyone ever initializes using Ruby script. I'm pretty sure Window#viewport is not used at all in all of RGSS.
I'm talking about Window too. It sets it to nil if you don't pass a viewport to the initialize method, but if you create the window like:
then the viewport method will return the viewport you passed and it will operate on the window. You might be right that it's never used though.
I've tested this myself over the weekend. Passing a viewport in a window does exactly the same like it does in a Sprite. It's just that this feature isn't used in RMXP.
Added a new question.
What's the max value for number of frames in a transition?
Added two new questions.
What is the pixel color formula for the color blending used by plane, sprite and viewport?
What is the pixel color formula for the tone blending used by plane, sprite and viewport?
I'm fairly certain that color blending is a strait blending
tone blending on the other hand I've done some experimentation with. and while it has a formula I have NO clue what it is it's not related to any Photoshop blending mode or a combination of them. I've been trying for a considerable amount of time and have not been able to replicate it. I'm almost certain that it has something to do with light sources or a existing filter.
Hm... Probably HSL is being used for blending.
Derp, added one for calculating the quick settings for actor parameters.
We can make our own even, but my math is getting a little rusty in my old age...
I've checked it out and I don't think it's that relevant. The was some randomness involved and it was basically a simple linear function. Just implement anything you like. In fact, I never even used the quick settings, I'm not sure it's needed.
I don“t know if you already got it, but what I used to for blend color and tone in sprites in my custom Player proyect was a custom pixel shader with this calculations
const char* pixelShader =
"float _alpha; \
float _colA; \
float _colR; \
float _colG; \
float _colB; \
float _toneR; \
float _toneG; \
float _toneB; \
float _toneGrey; \
sampler2D tex0; \
\
float4 main( float2 texCoord : TEXCOORD0): COLOR0 \
{ \
float4 color = tex2D( tex0, texCoord.xy ); \
if(color.a != 0) \
{ \
color.a = color.a * _alpha; \
\
if(_colA != 0) \
{ \
color.r = color.r * (1.0 - _colA) + (_colR * _colA); \
color.g = color.g * (1.0 - _colA) + (_colG * _colA); \
color.b = color.b * (1.0 - _colA) + (_colB * _colA); \
} \
\
if(_toneGrey == 0) \
{ \
color.r = color.r + _toneR; \
color.g = color.g + _toneG; \
color.b = color.b + _toneB; \
} \
else \
{ \
float grey = color.r * 0.299 + color.g * 0.587 + color.b * 0.114; \
float factor = 1.0 - _toneGrey; \
color.r = (color.r - grey) * factor + grey + _toneR + 0.5; \
color.g = (color.g - grey) * factor + grey + _toneG + 0.5; \
color.b = (color.b - grey) * factor + grey + _toneB + 0.5; \
} \
} \
return color; \
}";
Where:
color = the original (and then resultant) pixel color
_alpha = "opacity" propierty
_colX (with X = A R G B) = the "color" propierty
_toneX (with X = R G B Grey) = "tone" propierty
Note: tone calculations were made originally by vgvgf (author of the abandoned ARGSS proyect)
wow, this will probably help us a lot! thanks for that Metalero!
You probably just saved me an hour of work or so. xD
EDIT: I just looked at the code and I can see that there is some RGB-HSL conversion going on. I was already expecting something like this because of the saturation effect that the gray parameter has. Now I don't have to experiment with the formula and compare the results with RMXP.
What is the proper formula for the calculation of the new color value when using Bitmap#blt when any kind of opacity or alpha blending is involved?
Since we' switching to pixel shaders for some of the things, we can actually emulate RMXP's Bitmap#blt if we have the formula.
I have one that I require answered quickly.
What does Graphics#frame_reset do?
I have no idea, nor do I have any idea how to test it...
the help file says
QuoteResets the screen refresh timing. After a time-consuming process, call this method to prevent extreme frame skips.
I'm not sure what that means. or how a function could prevent frame skips
Likely need to force the game to lag while keeping an eye on the frame count.
I imagine its a worthless method without function. It would keep in style with Enterbrain.
I'll test a bit and see if I can figure something out.
It's possible that Graphics#update doesn't do frame syncing after Graphics#freeze has been called since there is no rendering going on anyway. ARC always does frame syncing so Graphics#frame_reset probably becomes useless.