The problem in the package - reimport [Firmware U5]

Doubts, help and support about QuickBMS and other game research tools
dean999
Posts: 2
Joined: Fri Mar 04, 2016 10:53 am

The problem in the package - reimport [Firmware U5]

Post by dean999 »

Firmware U5: http://rghost.ru/8jBVhdVyC

Error:
- REIMPORT mode enabled!
- open input file C:\Users\DEAN\Desktop\IA U5\Mp3_player_U5\Pack_2\U5\palette.pal
- open script C:\Users\DEAN\Desktop\IA U5\Mp3_player_U5\Pack_2\U5_edit.bms
- set output folder C:\Users\DEAN\Desktop\IA U5\Mp3_player_U5\Pack_2\U5

offset filesize filename
--------------------------------------

Error: incomplete input file 0: C:\Users\DEAN\Desktop\IA U5\Mp3_player_U5\Pack_2\U5\palette.pal
Can't read 2 bytes from offset 000b44e4.
Anyway don't worry, it's possible that the BMS script has been written
to exit in this way if it's reached the end of the archive so check it
or contact its author or verify that all the files have been extracted.
Please check the following coverage information to know if it's ok.

coverage file 0 0% 16 3349

Last script line before the error or that produced the error:
69 get Var short



Help mE))!

Image

Skript BMS:

Code: Select all

get CheckSum1 long
get Var long
get CheckSum2 long
get FSize1 long
get FSize2 asize


  callfunction SetPalette 1 0xB44E4
  callfunction SavePalette 1 "U5\\palette.pal"
 
  //Imag
  callfunction ExtractImage 1 0xB46E4  8 "U5\\bpp8\\Music.bmp"
  callfunction ExtractImage 1 0xB572A  8 "U5\\bpp8\\FM Radio.bmp"
  callfunction ExtractImage 1 0xB6770  8 "U5\\bpp8\\Record.bmp"
  callfunction ExtractImage 1 0xB7828  8 "U5\\bpp8\\Settings.bmp"
  callfunction ExtractImage 1 0xbce64  8 "U5\\bpp8\\Logo.bmp"
  callfunction ExtractImage 1 0xB8a3e  8 "U5\\bpp8\\Diskactive.bmp"
  callfunction ExtractImage 1 0xB886B  8 "U5\\bpp8\\DiskNoactive.bmp"
  callfunction ExtractImage 1 0xC2414  8 "U5\\bpp8\\Lock.bmp"
  callfunction ExtractImage 1 0xc1274  8 "U5\\bpp8\\Battery_begin.bmp"
  callfunction ExtractImage 1 0xc1409  8 "U5\\bpp8\\Battery_end.bmp"
  callfunction ExtractImage 1 0xc1540  8 "U5\\bpp8\\Charging.bmp"
  callfunction ExtractImage 1 0xc150d  8 "U5\\bpp8\\Battery_zaryad.bmp"
  callfunction ExtractImage 1 0xc14d6  8 "U5\\bpp8\\Battery_mid.bmp" 
  callfunction ExtractImage 1 0xc1760  8 "U5\\bpp8\\4.bmp" 
  callfunction ExtractImage 1 0xc18dc  8 "U5\\bpp8\\+.bmp"   
  callfunction ExtractImage 1 0xc19e1  8 "U5\\bpp8\\Low_Battery.bmp"
  callfunction ExtractImage 1 0xc1c84  8 "U5\\bpp8\\7.bmp"   

  callfunction ExtractImage 1 0xc23ec  8 "U5\\bpp8\\9.bmp"   
  callfunction ExtractImage 1 0xc2400  8 "U5\\bpp8\\10.bmp"
  callfunction ExtractImage 1 0xc2b19  8 "U5\\bpp8\\hold_text.bmp" 
  callfunction ExtractImage 1 0xc0e90  8 "U5\\bpp8\\CLA_1.bmp" 
  callfunction ExtractImage 1 0xc0f3d  8 "U5\\bpp8\\POP.bmp"
  callfunction ExtractImage 1 0xc0ba3  8 "U5\\bpp8\\dB.bmp"
  callfunction ExtractImage 1 0xc062c  8 "U5\\bpp8\\AM.bmp"
  callfunction ExtractImage 1 0xbda82  8 "U5\\bpp8\\19.bmp"
  callfunction ExtractImage 1 0xc0668  8 "U5\\bpp8\\PM.bmp"
  callfunction ExtractImage 1 0xc06a4  8 "U5\\bpp8\\NOR.bmp"
  callfunction ExtractImage 1 0xc06f4  8 "U5\\bpp8\\ROC.bmp"
  callfunction ExtractImage 1 0xc073f  8 "U5\\bpp8\\Jaz.bmp"
  callfunction ExtractImage 1 0xc078a  8 "U5\\bpp8\\CLA.bmp"
  callfunction ExtractImage 1 0xc07d5  8 "U5\\bpp8\\POP_1.bmp"   
  callfunction ExtractImage 1 0xc0820  8 "U5\\bpp8\\MET.bmp" 
  callfunction ExtractImage 1 0xc0875  8 "U5\\bpp8\\VOC.bmp"
  callfunction ExtractImage 1 0xc08c5  8 "U5\\bpp8\\USR.bmp" 
  callfunction ExtractImage 1 0xc097b  8 "U5\\bpp8\\M3B.bmp"   
  callfunction ExtractImage 1 0xc09cb  8 "U5\\bpp8\\BD.bmp"     
  callfunction ExtractImage 1 0xc09fd  8 "U5\\bpp8\\MP.bmp"   
  callfunction ExtractImage 1 0xb9b95  8 "U5\\bpp8\\Scroll.bmp"
  callfunction ExtractImage 1 0xb9de3  8 "U5\\bpp8\\33.bmp"
 
exit


startfunction SetPalette    // ARG1 PalOffset
  savepos SP_Pos
  goto SetPalette_ARG1

  // buffer for 16-bit rgb565
  log Memory_File1 0 0
  putvarchr Memory_File1 0x200 0

  // buffer for 32-bit argb8888
  log Memory_File2 0 0
  putvarchr Memory_File2 0x400 0

  for i = 0 < 0x100
    get Var short
    math Var s 2    // byte swap, transform from big-endian

    if i == 0x8A    // 1-bit alpha
      set AC byte 0
    else
      set AC byte 0xFF
    endif

    xmath RC "((Var >> 8) & 0xF8) | ((Var >> 13) & 0x07)"
    xmath GC "((Var >> 3) & 0xFC) | ((Var >>  9) & 0x03)"
    xmath BC "((Var << 3) & 0xF8) | ((Var >>  2) & 0x07)"
    xmath PX "(AC << 24) | (RC << 16) | (GC << 8) | BC"

    put Var short Memory_File1
    put PX long Memory_File2
  next i += 1

  // reset position, just in case
  goto 0 Memory_File1
  goto 0 Memory_File2

  goto SP_Pos
endfunction





// Export palette to JASC-PAL format
startfunction SavePalette   // ARG1 OutName

  string CRLF = 0x0A0D

  log Memory_File3 0 0
  putvarchr Memory_File3 0x1000 0

  string Text p= "%s%s%04x%s%3i%s" "JASC-PAL" CRLF 256 CRLF 256 CRLF
  put Text string Memory_File3
  goto -1 Memory_File3 SEEK_CUR  // to overwrite trailing zero byte


  goto 0 Memory_File2

  for i = 0 < 256
    get BC byte Memory_File2
    get GC byte Memory_File2
    get RC byte Memory_File2
    get AC byte Memory_File2

    string Text p= "%3i %3i %3i%s" RC GC BC CRLF
    put Text string Memory_File3
    goto -1 Memory_File3 SEEK_CUR

  next i += 1

  savepos PalSize Memory_File3
  log SavePalette_ARG1 0 PalSize Memory_File3

endfunction





startfunction ExtractImage   // ARG1 ImgOffset, ARG2 OutBpp, ARG3 OutName
  savepos EI_Pos
  goto ExtractImage_ARG1

  get BPP byte
  get Width short
  get Height short
 
  if BPP == 8
    if ExtractImage_ARG2 == 32
      set OutBpp 32
      set InfoSize 52     // sizeof (BITMAPV2INFOHEADER)
      set CompressType 3  // BI_BITFIELDS
      set PaletteSize 0
    elif ExtractImage_ARG2 == 24
      set OutBpp 24
      set InfoSize 40     // sizeof (BITMAPINFOHEADER)
      set CompressType 0  // BI_RGB
      set PaletteSize 0
    elif ExtractImage_ARG2 == 16
      set OutBpp 16
      set InfoSize 52     // sizeof (BITMAPV2INFOHEADER)
      set CompressType 3  // BI_BITFIELDS
      set PaletteSize 0
    else
      set OutBpp 8
      set InfoSize 40     // sizeof (BITMAPINFOHEADER)
      set CompressType 0  // BI_RGB
      set PaletteSize 256
      if ExtractImage_ARG2 != 8
        print "Invalid BPP value passed to ExtractImage, bit depth was set to default"
      endif
    endif

    xmath zHeight "0 - Height"
    xmath RowPadding "(Width * (OutBpp / 8)) & 3"
    if RowPadding != 0
      xmath RowPadding "4 - RowPadding"
    endif
    xmath ImgOffset "14 + InfoSize + (PaletteSize * 4)"
    xmath OutImgSize "(Width * (OutBpp / 8) + RowPadding) * Height"
    xmath ResultSize "ImgOffset + OutImgSize"


    log Memory_File3 0 0
    putvarchr Memory_File3 ResultSize 0

    // file header
    put 0x4D42          short Memory_File3  // bfType = "BM"
    put ResultSize      long  Memory_File3  // bfSize
    put 0               long  Memory_File3  // bfReserved 1, 2
    put ImgOffset       long  Memory_File3  // bfOffBits
    // info header
    put InfoSize        long  Memory_File3  // biSize
    put Width           long  Memory_File3  // biWidth
    put zHeight         long  Memory_File3  // biHeight
    put 1               short Memory_File3  // biPlanes
    put OutBpp          short Memory_File3  // biBitCount
    put CompressType    long  Memory_File3  // biCompression
    put OutImgSize      long  Memory_File3  // biSizeImage
    put 0               long  Memory_File3  // biXPelsPerMeter
    put 0               long  Memory_File3  // biYPelsPerMeter
    put PaletteSize     long  Memory_File3  // biClrUsed
    put 0               long  Memory_File3  // biClrImportant

    if OutBpp == 8
      goto 0 Memory_File2
      for i = 0 < PaletteSize
        get Var long Memory_File2
        put Var long Memory_File3
      next i += 1
    elif OutBpp == 16
      put 0x00F800      long  Memory_File3  // bV2RedMask
      put 0x0007E0      long  Memory_File3  // bV2GreenMask
      put 0x00001F      long  Memory_File3  // bV2BlueMask
    elif OutBpp == 32
      put 0xFF0000      long  Memory_File3  // bV2RedMask
      put 0x00FF00      long  Memory_File3  // bV2GreenMask
      put 0x0000FF      long  Memory_File3  // bV2BlueMask
    endif


    for i = 0 < Height
      for j = 0 < Width
        if OutBpp == 8
          get PX byte
          put PX byte Memory_File3
        elif OutBpp == 16
          get PX byte
          math PX *= 2
          getvarchr PX Memory_File1 PX short
          put PX short Memory_File3
        elif OutBpp == 24
          get PX byte
          math PX *= 4
          getvarchr PX Memory_File2 PX threebyte
          put PX threebyte Memory_File3
        elif OutBpp == 32
          get PX byte
          math PX *= 4
          getvarchr PX Memory_File2 PX long
          put PX long Memory_File3
        endif
      next j += 1

      for j = 0 < RowPadding
        put 0 byte Memory_File3
      next j += 1
    next i += 1

    savepos EndPos Memory_File3
    if EndPos == ResultSize
      log ExtractImage_ARG3 0 ResultSize Memory_File3
    else
      print "ExtractImage %ExtractImage_ARG1% %ExtractImage_ARG2% %ExtractImage_ARG3%: Endpos %POS% != %ResultSize%"
    endif
  else
    print "ExtractImage %ExtractImage_ARG1% %ExtractImage_ARG2% %ExtractImage_ARG3% failed - unexpected data"
  endif

  goto EI_Pos
endfunction

aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: The problem in the package - reimport [Firmware U5]

Post by aluigi »

The script can't be used for reimporting because it's a sort of "builder/generator" rather than an extractor.
Reimporting is possible only when you have a direct extraction of a file to disk.
dean999
Posts: 2
Joined: Fri Mar 04, 2016 10:53 am

Re: The problem in the package - reimport [Firmware U5]

Post by dean999 »

What should I do now?

palette.pal
Image
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: The problem in the package - reimport [Firmware U5]

Post by aluigi »

Difficult to give suggestions.
Probably you have to write a new tool that takes the information from the generated image and correctly puts them in the original file... lot of work.