Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - zpaolo11x

Pages: [1] 2
1
Scripting / Foreach item oreder
« on: April 12, 2019, 04:57:24 AM »
I have this simple code:

Code: [Select]
local key_names = { "1": "A", "2": "B", "3": "C", "4": "D"}

foreach (key,val in key_names){
   print (key + " " + val +"\n")
}

Maybe I don't get it right but the console output of this code is

Code: [Select]
1 A
3 C
2 B
4 D

I would expect it to return

Code: [Select]
1 A
2 B
3 C
4 D

Also speaking of tables, what is the difference between something like this:

Code: [Select]
local aTable = { "first_key" : "Max Normal",
                 "second_key" : 42,
                 "third_key" : true};

and this:

Code: [Select]
local aTable = { "first_key" = "Max Normal",
                 "second_key" = 42,
                 "third_key" = true};

2
Scripting / CRT shaders and Intel 620 graphics adapter
« on: March 28, 2019, 11:34:28 AM »
I'm trying AM and my Arcadeflow layout on an HP spectre with Intel 620 integrated graphics. Performance is very good (it puts my Macbook Pro to shame :D ) but there's an issue with Lotte CRT shaders: they simply look transparent. Usually when a shader doesn't work I see the unmodified image, while here the image is simply absent. Is there a way to have a detailed log from GLSL shaders? Last but not least, I tried an old version of Arcadeflow with CGWG shader and it works :( suggetsions?

3
Scripting / zorder and performance
« on: March 21, 2019, 08:50:28 AM »
Excuse my complete ignorance... is there a performance hit if one "abuses" of zorder? Let's say my layout has a lot of zorder explicit declarations going on, is this worse than having everything layied out correctly in the first place?

4
Scripting / Changing filter vs changing search rule...
« on: February 12, 2019, 08:21:10 AM »
Is there a difference in the implementation of the response to those commands? In my theme when I bind a key to a command like

Code: [Select]
fe.list.filter_index = 2
I get the correct effect in any case, the list is updated, the layout responds as programmed and everything seems fine.
On the other hand if I bind a key to

Code: [Select]
fe.list.search_string = "Title contains Bubble"
I get weird results, sometimes it works, sometimes, especially if the current index is the first (the same as the filtered list), it updates everything but the first image. Generally it seems it updates all the metadata but not the artworks.

I know my theme is pretty complex and maybe I'm overlooking something but looking at the debug log it seems both method trigger the same transitions callbacks therefore I don't understand where the difference is :/

5
Scripting / Drop shadow layout, may be turned into something useful?
« on: January 20, 2019, 08:37:54 AM »
I've put together a simple layout to demonstrate my drop shadow code, here it works for wheel art but you can use it on any image. I'm not a good programmer but I'm sure someone might like the code and maybe build something useful with that (a class?) so that it can be used and re-used.

The parameters to play with to define the shadow are in the code, they are self explanatory except from shadow_downsample, this is a float parameter < 1.0 so that the shadow surface is built smaller than the original image and then enlarged. Since the shadow is smooth you won't loose detail and gain speed because the shader will be faster on a smaller image.

Have fun!

6
Scripting / Too many locals
« on: January 16, 2019, 08:35:28 AM »
Ok, I'm not a good programmer, I put everything in a single 3000 lines long layout file, the net result is that I sometimes get the "too many locals" error when running my layout. I have partially solved that consolidating variables into tables, but is it something that can be fixed?

7
General / Restyling of AM forums
« on: January 10, 2019, 02:14:04 AM »
I have played a bit with Firefox extension xStyle (it's like Stylish but without the privacy concerns :D ) and restyled the look of AM forums to look cleaner, smoother and also a bit dull so it doesn't catches the attention of coworkers LOL. I can share the CSS code if someone is interested :D


8
Scripting / Search string syntax
« on: December 27, 2018, 12:24:51 PM »
It would be great to have more info regarding the syntax of the search string, I know for example that you can use [] to insert variations of a string (so [Pp]latform equals Platform or platform) but other than that? Can I craft a string that finds games where Category is Something OR Something Else? Is there a way to insert an AND operator?

There's also an issue with special characters, for example I want to find all the games where category equals "Driving / Race (Chase View)" but the "(" and ")" seems to mess with the search string :(

9
Scripting / Changing the ordering of a list on the fly
« on: December 19, 2018, 06:12:51 AM »
Is there a way to change the order of a list from, say, "by name" to "by year"? The only thing I can do right now is create in AM two filters, one with sorting by year and one with sorting by title, but it would be really convenient if a layout could change this order on the fly...

10
Scripting / Check file existance with relative path
« on: November 27, 2018, 12:34:39 AM »
There are many ways to check if a file exists: one is

Code: [Select]
fe.path_test(fullpathfilename , PathTest.IsFile)

another is

Code: [Select]
try {file(fullpathfilename, "r" );return true;}catch(e){return false;}

Both work well if you have a full pathname but, AFAIK, they don't work on relative paths. You can get the AM working directory with FeConfigDirectory, which is fine, but I want to check if a file exists inside a folder of the current theme, without having to hardcode the theme name or having the user insert a variable with the theme full path.

Is there a way or a workaround to get at least the current theme folder name?

11
Themes / [RELEASED] Genres/Category artwork for Mame
« on: November 19, 2018, 08:56:25 AM »
I've completed a project to implement in the next version of my theme. The idea is to create genre or category icon for all my games. I had some rules to follow:

1) Being my theme Mame and arcade based I tried to find all the category names that are available, in catlist.ini, category.ini, catver.ini etc, then I parsed the genres/subgenre format so that, for example, Sports / Boxings becomes sportsboxing.png.

2) I wanted some retro look and a stylized vibe so I decided to limit myself to 16x16 pixels artwork with only one "color" (plus transparent background).

I decided to do all the subgenres and not only the main category, you can see a preview of the artwork here:

http://mixandmatch.it/catpic

Overall it's great fun trying to convey a category idea with that reduced resolution, also because if you want to reference a famous game for the genre sometimes you need to reinvent and scale down the sprites :)

In the attached archive you'll find all the PNGs in white on transparent (so you can change the color using set_rgb ), plus a nut to incorporate in your layout. The nut contains two function, one is category_pic() and is used as a magic token, so if you want to add a cat image just use

fe.add_image("[!category_pic]", etc

the other function in the nut is category_list() and you can call it at the beginning of your layout, it will output on the console the whole list of categories that are not present in the PNG folder. If you want me to add some just let me know!

Feel free to incorporate this icons (with credit) in your works and let me know if you like them :)

12
Themes / Brands monochrome logos
« on: October 22, 2018, 07:52:08 AM »
I'm working on a collection of monochrome logos from arcade brands, I took sources from many places, worked on reducing colors and cleaning up shapes, and adapted every logo to a 800x400 PNG image. The idea is to use them in a theme, so I wrote a routine that gets the brand name and produces an equivalent file name, stripping spaces and unnecessary characters.

So for example if the manufacturer is "Taito Corporation" the file will be taitocorporation.png, or if the manufacturer is "Raizing / Eighting" the file will be raizingeighting.png.

For licensed games I have yet to decide if it's better to strip the license data altogether or, as it is now, parse it so that "Cave (AMI Licens)" becomes caveamilicense.png.

I'm still gathering logos and working on the art, attached a sneak preview of the first 100 logos :D

13
Scripting / GLSL colorizer and color conversion routines
« on: October 09, 2018, 07:46:44 AM »
I jsut developed a small shader for colorizing, it uses HSL color space which looks much better than HSV. But in the code you can find some useful color conversion functions that you can use for many purposes like desaturation, hue rotation etc.

The shader requires an HSL vector of three values that are used for colorizing, plus a texture mix value if you want to blend (in RGB) the colorized with the default image.

Code: [Select]
uniform sampler2D texture;
uniform vec3 hsl;
uniform float texmix;

vec3 hsl2rgb( in vec3 c )
{
    vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
    return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
}

vec3 rgb2hsl( in vec3 c ){
  float h = 0.0;
float s = 0.0;
float l = 0.0;
float r = c.r;
float g = c.g;
float b = c.b;
float cMin = min( r, min( g, b ) );
float cMax = max( r, max( g, b ) );

l = ( cMax + cMin ) / 2.0;
if ( cMax > cMin ) {
float cDelta = cMax - cMin;
       
        //s = l < .05 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) ); Original
s = l < .0 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
       
if ( r == cMax ) {
h = ( g - b ) / cDelta;
} else if ( g == cMax ) {
h = 2.0 + ( b - r ) / cDelta;
} else {
h = 4.0 + ( r - g ) / cDelta;
}

if ( h < 0.0) {
h += 6.0;
}
h = h / 6.0;
}
return vec3( h, s, l );
}


vec3 rgb2hsv(vec3 c)
{
    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;
    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

void main()
{   

vec2 uv = gl_TexCoord[0].xy;

vec4 t0 = texture2D(texture, uv);
vec3 hsl0 = rgb2hsl (t0.rgb);

vec3 hsl1 = vec3(hsl.x,hsl.y,hsl0.z);

vec3 tch = hsl2rgb (hsl1);


gl_FragColor = vec4(mix(hsl.z*tch.xyz,t0.xyz,texmix) , gl_Color.a*t0.a);

}

This is a sample layout

Code: [Select]
local pic1 = fe.add_artwork("snap",0,0,400,400)
pic1.video_flags = Vid.ImagesOnly
pic1.preserve_aspect_ratio = false

local pic2 = fe.add_artwork("snap",400,0,400,400)
pic2.video_flags = Vid.ImagesOnly
pic2.preserve_aspect_ratio = false

local pic3 = fe.add_artwork("snap",800,0,400,400)
pic3.video_flags = Vid.ImagesOnly
pic3.preserve_aspect_ratio = false

local colorshader1 = fe.add_shader(Shader.Fragment,"colorizer.glsl")
colorshader1.set_texture_param("texture")
colorshader1.set_param("hsl",0.6,0.5,1.0)
colorshader1.set_param("texmix",0.0)
pic1.shader = colorshader1

local colorshader2 = fe.add_shader(Shader.Fragment,"colorizer.glsl")
colorshader2.set_texture_param("texture")
colorshader2.set_param("hsl",0.6,1.0,1.0)
colorshader2.set_param("texmix",0.0)
pic2.shader = colorshader2



14
Scripting / GLSL gaussian blur without nested surfaces
« on: October 08, 2018, 02:19:10 AM »
Inspired by Oomek work with feedback trails, I put together a quick and dirty layout for gaussian blur using a similar trick without need for nested surfaces.

What do you think? It scales down the initial surface so it can work on a lower resolution instance of the picture, but has issues if you turn on aspect ratio (you should then pass the actual resolution to the shader using subimg.x and subimg.y).

Code:

Code: [Select]

local picwidth = 64.0
local su0 = fe.add_surface(picwidth,picwidth)
local su1 = fe.add_surface(picwidth,picwidth)

local pic = su0.add_artwork("snap",0,0,picwidth,picwidth)
pic.video_flags = Vid.ImagesOnly
pic.preserve_aspect_ratio = false

local sh0 = fe.add_shader( Shader.Fragment, "gauss_kernsigma_o2.glsl" )
local sh1 = fe.add_shader( Shader.Fragment, "gauss_kernsigma_o2.glsl" )

pic = su0.add_clone (pic)
sh0.set_texture_param( "texture",pic)
sh0.set_param("kernelData", 21.0, 3.0)
sh0.set_param("offsetFactor", 1.0/picwidth, 0.0)
sh0.set_param("reverse",1.0)
pic.shader = sh0

pic = su1.add_clone (pic)
sh1.set_texture_param( "texture",su0)
sh1.set_param("kernelData", 21.0, 3.0)
sh1.set_param("offsetFactor", 0.0, 1.0/picwidth)
sh1.set_param("reverse",0.0)
pic.shader = sh1

su0.visible = false
su1.set_pos (0,0,600,600)


shader:

Code: [Select]

uniform sampler2D texture;
uniform vec2 kernelData;
uniform vec2 offsetFactor;
uniform float reverse;

void main() {

    vec3 incrementalGaussian;
    incrementalGaussian.x = 1.0 / (sqrt(2.0 * 3.14) * kernelData.y);
    incrementalGaussian.y = exp(-0.5 / (kernelData.y * kernelData.y));
    incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;

    vec2 uv = gl_TexCoord[0].xy;
    if (reverse == 1.0) {
       uv.y = 1.0 - uv.y;
    }
    vec4 color = vec4(0.0);
    float kersum = 0.0;

    color += texture2D(texture, uv) * incrementalGaussian.x;
    kersum += incrementalGaussian.x;
    incrementalGaussian.xy *= incrementalGaussian.yz;


    for (float i = 1.0 ; i <=   (kernelData.x - 1.0)*0.5 ; i++) {
        color += texture2D(texture, uv - i * offsetFactor ) * incrementalGaussian.x;         
        color += texture2D(texture, uv + i * offsetFactor ) * incrementalGaussian.x;         
        kersum += 2.0 * incrementalGaussian.x;
        incrementalGaussian.xy *= incrementalGaussian.yz;
    }
   
    gl_FragColor = color/kersum;
}


15
Scripting / Frosted glass menu background
« on: October 01, 2018, 01:30:23 AM »
I've worked a bit on this, and it seems I'm very close to have something working, you can see from the screenshots that I managed to make it work both on standard menus (like exit menu called with "esc" button, or filters menu) and on "custom" menus. I jsut need some other trickery to prevent the effect to be "doubled" if you call a standard menu from a custom menu :D

There are still some issues, but most of all I can't find a way to delete the screenshot I generate every time I need to update the background. Any suggestion?



Pages: [1] 2