Photonsters / PhotonS

repository for all things Photon S
The Unlicense
30 stars 5 forks source link

UI update file format #5

Open DSchndr opened 3 years ago

DSchndr commented 3 years ago

I have looked at P_UI_2_6.bin, it contains all images for the ui and presumably gets loaded onto the spi flash near stm32

Img format: 320x240 | 16bpp (2bytes per pixel) 5:6:5 (r:g:b)

(#1 goes 0h-30000h) (196608 dec)

IMG #1 0h - 25800h (Chinese Mainmenu)
a800h x FF (Padding)

IMG #2 30000h - 55800h (Chinese Filemenu)
a800h x FF (Padding)

...

743824h (24x57): right arrow with x above it
DSchndr commented 3 years ago

29 Images can be extracted, some currnently unknown data is at the end of the file

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;

namespace PhotonS_UIExtract
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("PhotonS-UIEXtract");
            Console.Write("File: ");
            string fp = Console.ReadLine();

            var fs = new FileStream(fp, FileMode.Open);
            var len = (int)fs.Length;
            var bits = new byte[len];
            fs.Read(bits, 0, len);

            int imagecount = 0;

            // Dump 25800h (one image) bytes per line, skip a800h padding
            for (int ix = 0; ix < len; ix += 0x25800)
            {
                var cnt = Math.Min(0x25800, len - ix);
                var line = new byte[cnt];
                Array.Copy(bits, ix, line, 0, cnt);

                ix += 0xa800;
                imagecount++;

                int stride = 4 * ((320 * 2 + 3) / 4);

                Bitmap im = new Bitmap(320, 240, stride, PixelFormat.Format16bppRgb565, Marshal.UnsafeAddrOfPinnedArrayElement(line, 0));

                im.Save($"ui_{imagecount}.bmp");             
            }
            Console.ReadLine();
        }
    }
}
IdontKnowWhatToNameThisAccount commented 3 years ago

How did you manage to extract the UI File? I've tried with the Photonsters UIExtractor, but I only ever get the "Invalid UI file!" error. Extracting the Photonsters Firmware for the Non-S works fine but I havent had any luck extracting the Photon S firmware. Did you modify the tool somehow?

DSchndr commented 3 years ago

Photon S has a different mainboard with completely diffrerent software on it. You cannot use Chitubox fw or ui on it

My vid should have a download link to the binary that can extract and pack Photon-S ui files https://www.youtube.com/watch?v=ioST-wdf2YM

Btw, if you think about using the ethernet port: forget it, it has absolutely no reference in the firmware and would need firmware patching (you could ask AndyBig) as well as adding the ethernet mac and port to the mainboard

IdontKnowWhatToNameThisAccount commented 3 years ago

Ok, thats a bummer. Just tried your tool, seems to work pretty well! I absolutely hate the stock firmware style so I might use this to make a dark mode firmware that looks like the photonsters firmware.