Log In  


Hey @zep,
me and other devs have been wondering if it’s possible to use custom palettes in our wallpapers.

At startup picotron displays the custom palette correctly, but it reverts back to the default one as soon as you click on the desktop.

I even tried changing the palette when I press an arrow key, but again, it stop working when you click on the desktop. It looks like there’s something forcing Picotron to show the default palette without noticing the wallpaper’s one

Is this intended or is it a bug?

Have you guys found any workaround?

-
EDIT: I just found one!
I modified this part inside /system/wm/wm.lua (line 1607 to 1635)

    if (awin) and not awin.desktop_filenav and not awin.wallpaper then

        -- 0.1.0c: only update when frame is not held (avoid flashing when running < 60fps)
        local val = _ppeek(awin.proc_id, 0x547f) -- might be nil if process recently ended
        if (val and val & 0x2 == 0)
        then
            --printh("@@ process palette "..time())

            -- grab the rgb display palette and video mode from that process
            -- to do: cross-process memcpy
            for i=0x5001,0x54ff,4 do
                poke4(i, _ppeek4(awin.proc_id, i))
            end
            poke(0x547c, _ppeek(awin.proc_id, 0x547c))

        else
            --printh("-- skipped resetting palette "..time())
        end

        -- copy mouselock state bits
        poke(0x5f28, _ppeek(awin.proc_id, 0x5f28))
        poke(0x5f29, _ppeek(awin.proc_id, 0x5f29))
        poke(0x5f2d, _ppeek(awin.proc_id, 0x5f2d))

    else
        --printh("** default rgb palette "..time())
        --pal(2)

        for i=0x5001,0x54ff,4 do
            poke4(i, _ppeek4(8, i))
        end
        poke(0x547c, _ppeek(8, 0x547c))
    end

Just by adding and not awin.desktop_filenav and not awin.wallpaper in the if statemet I made it change the wallpaper only when the current process is NOT the wallpaper or the desktop.
Else, I commented pal(2) and added this code:

for i=0x5001,0x54ff,4 do
    poke4(i, _ppeek4(8, i))
end

poke(0x547c, _ppeek(8, 0x547c))

Which just changes the palette to the wallpaper's one.



Indeed, when applying wallpaper with a custom palette to picotron and restarting the system, it appears at first, but it seems that the palette is all initialized and turns black when clicking on the desktop or something else.
I tried to change the palette in the _draw() function, but it didn't work.
Maybe I need to change tarminal.lua.
(A bit unrealistic, isn't it?)


I just found out a solution!

I changed this part inside /system/wm/wm.lua (line 1607 to 1635)

if (awin) then

        -- 0.1.0c: only update when frame is not held (avoid flashing when running < 60fps)
        local val = _ppeek(awin.proc_id, 0x547f) -- might be nil if process recently ended
        if (val and val & 0x2 == 0)
        then
            --printh("@@ process palette "..time())

            -- grab the rgb display palette and video mode from that process
            -- to do: cross-process memcpy
            for i=0x5000,0x54ff,4 do
                poke4(i, _ppeek4(awin.proc_id, i))
            end
            poke(0x547c, _ppeek(awin.proc_id, 0x547c))

        else
            --printh("-- skipped resetting palette "..time())
        end

        -- copy mouselock state bits

        poke(0x5f28, _ppeek(awin.proc_id, 0x5f28))
        poke(0x5f29, _ppeek(awin.proc_id, 0x5f29))
        poke(0x5f2d, _ppeek(awin.proc_id, 0x5f2d))

    else
        --printh("** default rgb palette "..time())
        pal(2) -- otherwise use default palette
    end

like this:

if (awin) and not awin.desktop_filenav and not awin.wallpaper then
        -- 0.1.0c: only update when frame is not held (avoid flashing when running < 60fps)
        local val = _ppeek(awin.proc_id, 0x547f) -- might be nil if process recently ended
        if (val and val & 0x2 == 0)
        then
            --printh("@@ process palette "..time())

            -- grab the rgb display palette and video mode from that process
            -- to do: cross-process memcpy
            for i=0x5001,0x54ff,4 do
                poke4(i, _ppeek4(awin.proc_id, i))
            end
            poke(0x547c, _ppeek(awin.proc_id, 0x547c))

        else
            --printh("-- skipped resetting palette "..time())
        end

        -- copy mouselock state bits
        poke(0x5f28, _ppeek(awin.proc_id, 0x5f28))
        poke(0x5f29, _ppeek(awin.proc_id, 0x5f29))
        poke(0x5f2d, _ppeek(awin.proc_id, 0x5f2d))

    else
        --printh("** default rgb palette "..time())
        --pal(2)

        for i=0x5001,0x54ff,4 do
            poke4(i, _ppeek4(8, i))
        end
        poke(0x547c, _ppeek(8, 0x547c))
    end

So I made it change the wallpaper only when the current process isn't the wallpaper or the desktop.
Else, I commented pal(2) and added this code:

for i=0x5001,0x54ff,4 do
            poke4(i, _ppeek4(8, i))
        end
        poke(0x547c, _ppeek(8, 0x547c))

Which just changes the palette to the wallpaper's one.

is this a nice solution? it seems to work fine for me!


at next boot, picotron will recreate its system files, so you will lose the change. (there is a way around that but it’s super cursed and not worth the trouble) you should try the sedish tool to edit system files at startup!


@merwok forgot to mention
You can do that or just copy your /system folder elsewhere (like in desktop), modify wm.lua in the new copied folder, save, close picotron and then (from host OS) move the copied system folder to the main picotron folder. Run Picotron and you’re done


2

that is the cursed workaround :]


It’s still less cursed than my wallpaper with the wrong palette hahaha Btw you delete /system and it resets to default. I don’t think zep made this by mistake



[Please log in to post a comment]