edit a .dat file with .pcx files in it

Everything else that doesn't fall into one of the other PB categories.
User avatar
TheAutomator
Enthusiast
Enthusiast
Posts: 112
Joined: Tue Dec 01, 2020 8:33 pm

edit a .dat file with .pcx files in it

Post by TheAutomator »

Are there any guys on this forum that know how to edit + extract from .DAT files from an old game?
it's a game from 1999 called Debris32, i have the full version that still works on windows 10 and would like to make a clone someday. :D

it would be nice to be able to extract the graphics from a .DAT file included inside the install directory of this game,
and i figured out how to extract some backgrounds but the spaceship and rocks etc seems to be more advanced...

opening the file in a hex editor clearly shows the silhouettes in an ASCII art way if you look at the text data.
extracting sounds and music was no problem at all, for that i had to use resource editor.

Any people that have some experience with this stuff?
To be clear, the game is abandonware so i'm not breaking any copyright laws as far as i know.

For the people interested in viewing the .DAT files themselves i can upload and share a google drive link if you want.
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: edit a .dat file with .pcx files in it

Post by Keya »

To be honest I don't think many people will waste their time trying to help you on such an outdated project that not many people will find appealling (without paying for say, a freelancer, to reverse-engineer the data format), but my recommendation to YOU for your own coding (if indeed it contains PCX files) is to study the PCX header, hopefully it will at least give you the size of each data object.
Last edited by Keya on Tue Jan 26, 2021 10:19 am, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

The graphic stuff is inside the graphics file :wink:

Code: Select all

;
; https://www.squarefree.com/2003/09/19/debris-32/
;
; direct download link:
; http://www.squarefree.com/mirrors/deb3210.exe
;

EnableExplicit


Structure HeaderStructure
  Filename.a[12]
  Offset.l
  Size.l
  Unknown.l
EndStructure


Define.i File, Out
Define Filename$, ExtractDirName$
Define *Buffer, *Header.HeaderStructure, *BufferEnd


Filename$ = OpenFileRequester("Choose a sw file", "", "Graphics|graphics.*", 0)
If Filename$
  File = ReadFile(#PB_Any, Filename$)
  If File
    *Buffer = AllocateMemory(Lof(File), #PB_Memory_NoClear)
    If *Buffer
      If ReadData(File, *Buffer, MemorySize(*Buffer)) = MemorySize(*Buffer)
        
        ExtractDirName$ = GetPathPart(ProgramFilename()) + "Graphics\"
        If FileSize(ExtractDirName$) <> -2
          CreateDirectory(ExtractDirName$)
        EndIf
        
        *Header = *Buffer
        *BufferEnd = *Buffer + MemorySize(*Buffer)
        While *Header < *BufferEnd And *Header\Filename[0] <> 0
          Debug PeekS(@*Header\Filename[0], 12, #PB_Ascii) + " Size: " + Str(*Header\Size) + " Offset: " + Hex(*Header\Offset) + " Unknown: " + Str(*Header\Unknown)
          
          If *Header\Filename[0] <> $FF
            Out = CreateFile(#PB_Any, ExtractDirName$ + PeekS(@*Header\Filename[0], 12, #PB_Ascii))
            If Out
              WriteData(Out, *Buffer + *Header\Offset, *Header\Size)
              CloseFile(Out)
            EndIf
            *Header + SizeOf(HeaderStructure)
          Else
            *Header = *Buffer + *Header\Offset
          EndIf
          
        Wend
      EndIf
      FreeMemory(*Buffer)
    EndIf
    CloseFile(File)
  EndIf
EndIf
The extracted files are no standard files. They look like direct RGB data.
Last edited by infratec on Tue Jan 26, 2021 1:25 pm, edited 2 times in total.
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

For the sound.dat file:

Code: Select all

;
; https://www.squarefree.com/2003/09/19/debris-32/
;
; direct download link:
; http://www.squarefree.com/mirrors/deb3210.exe
;

EnableExplicit


Structure RIFFStructure
  Riff.a[4]
  Length.l
  Wave.a[4]
EndStructure



Define.i File, Out, Found, i
Define Filename$, ExtractDirName$
Define *Buffer, *BufferEnd, *Ptr.Ascii, *Header.RIFFStructure


Filename$ = OpenFileRequester("Choose the sound file", "", "sounds|sounds.dat", 0)
If Filename$
  File = ReadFile(#PB_Any, Filename$)
  If File
    *Buffer = AllocateMemory(Lof(File), #PB_Memory_NoClear)
    If *Buffer
      If ReadData(File, *Buffer, MemorySize(*Buffer)) = MemorySize(*Buffer)
        
        ExtractDirName$ = GetPathPart(ProgramFilename()) + "Sounds\"
        If FileSize(ExtractDirName$) <> -2
          CreateDirectory(ExtractDirName$)
        EndIf
        
        *BufferEnd = *Buffer + MemorySize(*Buffer) - 4
        
        *Ptr = *Buffer
        Repeat
          If *Ptr\a = 'R'
            If PeekS(*Ptr, 4, #PB_Ascii) = "RIFF"
              *Header = *Ptr
              i + 1
              Out = CreateFile(#PB_Any, ExtractDirName$ + "Sound_" + RSet(Str(i), 3, "0") + ".wav")
              If Out
                WriteData(Out, *Header, *Header\Length + 8)
                CloseFile(Out)
              EndIf
              *Ptr + *Header\Length
            EndIf
          EndIf
          *Ptr + 1
        Until *Ptr >= *BufferEnd
        
      EndIf
      FreeMemory(*Buffer)
    EndIf
    CloseFile(File)
  EndIf
EndIf
User avatar
TheAutomator
Enthusiast
Enthusiast
Posts: 112
Joined: Tue Dec 01, 2020 8:33 pm

Re: edit a .dat file with .pcx files in it

Post by TheAutomator »

infratec wrote:The graphic stuff is inside the sw file :wink:

The extracted files are no standard files. They look like direct RGB data.
I don't see any extract folder after running your code unfortunately :(
EDIT: it's in the temp folder.

In the buyed version this SW file doesn't even exist, in the demo version it does.
Because the demo doesn't have all graphics it still needs to be the .dat file:

Image

your program seems to work with the DAT-file too, pretty cool code man!
But i have no clue how to get images out of the non *.PCX files :/
I would like to have the images of the ships and enemy's, is raw RGB data the same as just reading every
hex code and draw an RGB pixel on let's say a graphics window?

if you would be so kind to take a look here :)

https://drive.google.com/file/d/1zIXsNv ... sp=sharing

regards and many thanks for any help!
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

There were more files inside the graphics file.
There is an additional header section.

I modified the code above.
User avatar
TheAutomator
Enthusiast
Enthusiast
Posts: 112
Joined: Tue Dec 01, 2020 8:33 pm

Re: edit a .dat file with .pcx files in it

Post by TheAutomator »

infratec wrote:There were more files inside the graphics file.
There is an additional header section.

I modified the code above.
Thanks man! appreciated!!

And now comes the long painful process of finding out how to extract data from the non *.pcx files :cry:
wish me luck!
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

You need now for all Extractores the file

Debris32_Palette.pbi

Code: Select all

DataSection
  Debris32PCXPalette:
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 8, 8, 8
  Data.a 20, 20, 20
  Data.a 32, 32, 32
  Data.a 44, 44, 44
  Data.a 56, 56, 56
  Data.a 68, 68, 68
  Data.a 76, 76, 76
  Data.a 88, 88, 88
  Data.a 100, 100, 100
  Data.a 112, 112, 112
  Data.a 124, 124, 124
  Data.a 136, 136, 136
  Data.a 148, 148, 148
  Data.a 160, 160, 160
  Data.a 172, 172, 172
  Data.a 184, 184, 184
  Data.a 196, 196, 196
  Data.a 208, 208, 208
  Data.a 220, 220, 220
  Data.a 232, 232, 232
  Data.a 244, 244, 244
  Data.a 24, 0, 0
  Data.a 32, 0, 0
  Data.a 44, 0, 0
  Data.a 56, 0, 0
  Data.a 64, 0, 0
  Data.a 76, 0, 0
  Data.a 88, 0, 0
  Data.a 100, 0, 0
  Data.a 108, 0, 0
  Data.a 116, 4, 0
  Data.a 128, 12, 4
  Data.a 140, 20, 8
  Data.a 152, 32, 12
  Data.a 160, 44, 20
  Data.a 172, 56, 28
  Data.a 184, 72, 36
  Data.a 196, 88, 44
  Data.a 200, 92, 44
  Data.a 208, 100, 44
  Data.a 212, 108, 44
  Data.a 216, 116, 48
  Data.a 224, 124, 48
  Data.a 228, 132, 48
  Data.a 236, 140, 48
  Data.a 240, 148, 52
  Data.a 248, 160, 52
  Data.a 244, 168, 56
  Data.a 244, 176, 56
  Data.a 240, 184, 60
  Data.a 240, 188, 60
  Data.a 236, 196, 60
  Data.a 236, 204, 64
  Data.a 236, 208, 72
  Data.a 232, 216, 80
  Data.a 232, 220, 88
  Data.a 232, 224, 100
  Data.a 232, 228, 108
  Data.a 232, 232, 116
  Data.a 228, 232, 124
  Data.a 224, 232, 132
  Data.a 224, 232, 144
  Data.a 224, 232, 152
  Data.a 228, 236, 164
  Data.a 232, 240, 172
  Data.a 236, 240, 184
  Data.a 240, 244, 192
  Data.a 244, 248, 204
  Data.a 248, 252, 216
  Data.a 12, 4, 0
  Data.a 16, 4, 0
  Data.a 24, 8, 0
  Data.a 28, 12, 0
  Data.a 36, 20, 4
  Data.a 44, 24, 4
  Data.a 48, 28, 8
  Data.a 56, 32, 12
  Data.a 60, 36, 16
  Data.a 68, 44, 24
  Data.a 76, 48, 28
  Data.a 80, 56, 36
  Data.a 88, 60, 44
  Data.a 92, 68, 48
  Data.a 100, 76, 60
  Data.a 108, 84, 68
  Data.a 112, 88, 72
  Data.a 116, 96, 76
  Data.a 124, 104, 84
  Data.a 132, 112, 92
  Data.a 144, 120, 100
  Data.a 152, 132, 108
  Data.a 160, 140, 116
  Data.a 172, 148, 124
  Data.a 180, 160, 136
  Data.a 192, 168, 144
  Data.a 200, 180, 152
  Data.a 212, 188, 164
  Data.a 220, 200, 172
  Data.a 232, 208, 180
  Data.a 240, 220, 192
  Data.a 252, 232, 204
  Data.a 16, 8, 0
  Data.a 20, 12, 0
  Data.a 28, 16, 0
  Data.a 36, 20, 0
  Data.a 44, 28, 4
  Data.a 52, 32, 4
  Data.a 56, 40, 8
  Data.a 64, 44, 8
  Data.a 72, 52, 16
  Data.a 80, 56, 20
  Data.a 88, 64, 24
  Data.a 92, 68, 28
  Data.a 100, 76, 36
  Data.a 108, 84, 40
  Data.a 116, 92, 48
  Data.a 124, 100, 56
  Data.a 132, 108, 64
  Data.a 140, 116, 72
  Data.a 148, 128, 80
  Data.a 156, 136, 88
  Data.a 164, 148, 100
  Data.a 172, 156, 108
  Data.a 180, 168, 120
  Data.a 188, 176, 132
  Data.a 196, 188, 144
  Data.a 204, 196, 156
  Data.a 212, 204, 168
  Data.a 220, 216, 180
  Data.a 228, 224, 196
  Data.a 236, 232, 208
  Data.a 244, 244, 224
  Data.a 252, 252, 240
  Data.a 0, 4, 12
  Data.a 0, 12, 28
  Data.a 4, 24, 44
  Data.a 8, 36, 60
  Data.a 16, 52, 76
  Data.a 24, 68, 92
  Data.a 36, 84, 108
  Data.a 52, 104, 124
  Data.a 68, 120, 140
  Data.a 84, 140, 156
  Data.a 104, 160, 172
  Data.a 128, 180, 188
  Data.a 152, 196, 204
  Data.a 176, 216, 220
  Data.a 204, 232, 236
  Data.a 236, 252, 252
  Data.a 0, 8, 4
  Data.a 0, 20, 4
  Data.a 0, 28, 8
  Data.a 4, 40, 12
  Data.a 8, 52, 12
  Data.a 16, 64, 16
  Data.a 20, 76, 20
  Data.a 32, 84, 24
  Data.a 44, 96, 32
  Data.a 56, 108, 44
  Data.a 68, 124, 56
  Data.a 84, 136, 72
  Data.a 100, 152, 88
  Data.a 120, 164, 108
  Data.a 140, 180, 128
  Data.a 160, 196, 152
  Data.a 12, 4, 0
  Data.a 32, 8, 0
  Data.a 48, 12, 4
  Data.a 68, 20, 8
  Data.a 84, 28, 16
  Data.a 104, 36, 24
  Data.a 124, 44, 32
  Data.a 140, 56, 44
  Data.a 160, 68, 56
  Data.a 176, 84, 72
  Data.a 196, 100, 88
  Data.a 212, 120, 108
  Data.a 224, 140, 128
  Data.a 232, 160, 148
  Data.a 244, 180, 168
  Data.a 252, 200, 192
  Data.a 32, 0, 0
  Data.a 48, 0, 0
  Data.a 64, 0, 0
  Data.a 80, 0, 0
  Data.a 96, 0, 0
  Data.a 112, 0, 0
  Data.a 128, 0, 0
  Data.a 144, 4, 4
  Data.a 164, 4, 4
  Data.a 176, 16, 16
  Data.a 188, 28, 28
  Data.a 200, 32, 32
  Data.a 212, 36, 36
  Data.a 224, 44, 44
  Data.a 236, 52, 52
  Data.a 252, 60, 60
  Data.a 0, 48, 0
  Data.a 0, 64, 0
  Data.a 0, 80, 0
  Data.a 0, 92, 0
  Data.a 0, 108, 0
  Data.a 0, 124, 0
  Data.a 0, 140, 0
  Data.a 0, 152, 4
  Data.a 4, 164, 12
  Data.a 8, 180, 20
  Data.a 12, 192, 32
  Data.a 16, 204, 48
  Data.a 24, 216, 60
  Data.a 32, 228, 72
  Data.a 36, 240, 88
  Data.a 44, 252, 104
  Data.a 0, 0, 24
  Data.a 0, 0, 40
  Data.a 0, 0, 56
  Data.a 0, 0, 80
  Data.a 0, 4, 104
  Data.a 4, 12, 128
  Data.a 8, 20, 152
  Data.a 12, 32, 176
  Data.a 20, 44, 200
  Data.a 28, 60, 224
  Data.a 40, 80, 232
  Data.a 40, 96, 236
  Data.a 44, 116, 240
  Data.a 44, 136, 244
  Data.a 48, 156, 248
  Data.a 32, 168, 252
  Data.a 252, 0, 0
  Data.a 28, 252, 0
  Data.a 76, 0, 252
  Data.a 252, 252, 0
  Data.a 0, 0, 0
  Data.a 252, 252, 252
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
  Data.a 0, 0, 0
EndDataSection

For the font files:

Code: Select all

;
; https://www.squarefree.com/2003/09/19/debris-32/
;
; direct download link:
; http://www.squarefree.com/mirrors/deb3210.exe
;

EnableExplicit

Structure PBPixelStructure
  B.a
  G.a
  R.a
EndStructure

Structure RGBStructure
  R.a
  G.a
  B.a
EndStructure


IncludeFile "Debris32_Palette.pbi"



Define.i File, x, y, BytesPerPixel, LinePaddingBytes, Img, XPixels, YPixels, i, CharSize, Chars, XPos, YPos, CompleteImage
Define Filename$, ExtractDirName$
Define *FileBuffer, *FilePtr.Ascii, *ImgBuffer, *ImgPtr.PBPixelStructure, *ColorPtr.RGBStructure


Filename$ = OpenFileRequester("Choose a font dat file", "", "Font|font*.dat", 0)
If Filename$
  File = ReadFile(#PB_Any, Filename$)
  If File
    *FileBuffer = AllocateMemory(Lof(File), #PB_Memory_NoClear)
    If *FileBuffer
      If ReadData(File, *FileBuffer, MemorySize(*FileBuffer)) = MemorySize(*FileBuffer)
        
        XPixels = Val(Mid(GetFilePart(Filename$), 5))
        YPixels = Val(Mid(GetFilePart(Filename$), 7))
        
        CharSize = XPixels * YPixels
        Chars = MemorySize(*FileBuffer) / CharSize
        
        
        *FilePtr = *FileBuffer
        
        For i = 0 To Chars - 1
          
          If CreateImage(i, XPixels, YPixels, 24)
            If StartDrawing(ImageOutput(i))
              *ImgBuffer = DrawingBuffer()
              LinePaddingBytes = DrawingBufferPitch() - XPixels * 3
              *ImgPtr = *ImgBuffer
              
              For y = 0 To YPixels - 1
                For x = 0 To XPixels - 1
                  *ColorPtr = ?Debris32PCXPalette + (*FilePtr\a * 3)
                  
                  *ImgPtr\B = *ColorPtr\B
                  *ImgPtr\G = *ColorPtr\G
                  *ImgPtr\R = *ColorPtr\R
                                    
                  *ImgPtr + 3
                  
                  *FilePtr + 1
                Next x
                *ImgPtr + LinePaddingBytes
              Next y
              
              StopDrawing()
            EndIf
          EndIf
          
        Next i
        
        OpenWindow(0, 0, 0, ((XPixels * 3) + 2) * 8, ((YPixels * 3) + 2) * Chars / 8, GetFilePart(Filename$, #PB_FileSystem_NoExtension), #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
        
        CompleteImage = CreateImage(#PB_Any, XPixels * Chars, YPixels)
        If CompleteImage
          If StartDrawing(ImageOutput(CompleteImage))
            
            For i = 0 To Chars - 1
              
              DrawImage(ImageID(i), XPixels * i, 0)
              
              ResizeImage(i, XPixels * 3 , YPixels * 3, #PB_Image_Raw)
              
              
              ImageGadget(i, XPos, YPos, 0, 0, ImageID(i))
              
              XPos + (XPixels * 3) + 2
              If XPos > (XPixels * 3 + 2) * 8 - 2
                XPos = 0
                YPos + (YPixels * 3 + 2)
              EndIf
            Next i
            
            StopDrawing()
            
            SetClipboardImage(CompleteImage)
          EndIf
        EndIf
        
        Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
      EndIf
      
    EndIf
    FreeMemory(*FileBuffer)
  EndIf
  CloseFile(File)
EndIf
The problem is the color value.
Doesn't matter what I try, the color is wrong.

For the other dat files the way is the same, I can see the ship for example, but the colors are total wrong.
And the problem is, that the x and y size is not known. It is different for many files.

If you uncomment the if *FilePtr\a block, you can see the font 'clear'.
Last edited by infratec on Wed Feb 03, 2021 9:17 am, edited 5 times in total.
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

For the other pictures

Code: Select all

;
; https://www.squarefree.com/2003/09/19/debris-32/
;
; direct download link:
; http://www.squarefree.com/mirrors/deb3210.exe
;

EnableExplicit

Structure PBPixelStructure
  B.a
  G.a
  R.a
EndStructure

Structure RGBStructure
  R.a
  G.a
  B.a
EndStructure


IncludeFile "Debris32_Palette.pbi"


Define.a Byte
Define.i File, x, y, BytesPerPixel, LinePaddingBytes, Img, XPixels, YPixels, Pictures, i, XPos, YPos, YPictures, Event
Define Filename$, ExtractDirName$
Define *FileBuffer, *FilePtr.Ascii, *ImgBuffer, *ImgPtr.PBPixelStructure, *ColorPtr.RGBStructure



Filename$ = OpenFileRequester("Choose a graphic dat file", "", "dat|*.dat;*.xrf", 0)
If Filename$
  File = ReadFile(#PB_Any, Filename$)
  If File
    *FileBuffer = AllocateMemory(Lof(File), #PB_Memory_NoClear)
    If *FileBuffer
      If ReadData(File, *FileBuffer, MemorySize(*FileBuffer)) = MemorySize(*FileBuffer)
        
        Select MemorySize(*FileBuffer)
          Case 64
            XPixels = 8
            YPixels = 8
            Pictures = 1
          Case 432
            XPixels = 18
            YPixels = 24
            Pictures = 1
          Case 4096
            XPixels = 16
            YPixels = 16
            Pictures = 16
          Case 7048
            XPixels = 32
            YPixels = 26
            Pictures = 10
          Case 8192
            XPixels = 16
            YPixels = 16
            Pictures = 32
          Case 12288
            XPixels = 16
            YPixels = 16
            Pictures = 48
          Case 12672
            XPixels = 12
            YPixels = 12
            Pictures = 88
          Case 18432
            XPixels = 12
            YPixels = 12
            Pictures = 128
          Case 32768
            XPixels = 32
            YPixels = 32
            Pictures = 32
          Case 34560
            XPixels = 16
            YPixels = 16
            Pictures = 135
          Case 38400
            XPixels = 80
            YPixels = 80
            Pictures = 6
          Case 46800
            XPixels = 312
            YPixels = 150
            Pictures = 1
          Case 55296
            XPixels = 24
            YPixels = 24
            Pictures = 96
          Case 65536
            XPixels = 64
            YPixels = 64
            Pictures = 16
          Case 204800
            XPixels = 80
            YPixels = 80
            Pictures = 32
          Case 256000
            XPixels = 64
            YPixels = 64
            Pictures = 62
          Default
            XPixels = 16
            YPixels = 16
            Pictures = 1
        EndSelect
        
        
        *FilePtr = *FileBuffer
        
        For i = 0 To Pictures - 1
          
          If CreateImage(i, XPixels, YPixels, 24)
            If StartDrawing(ImageOutput(i))
              *ImgBuffer = DrawingBuffer()
              LinePaddingBytes = DrawingBufferPitch() - XPixels * 3
              *ImgPtr = *ImgBuffer
              
              For y = 0 To YPixels - 1
                For x = 0 To XPixels - 1
                  *ColorPtr = ?Debris32PCXPalette + *FilePtr\a * 3
                  *ImgPtr\B = *ColorPtr\B
                  *ImgPtr\G = *ColorPtr\G
                  *ImgPtr\R = *ColorPtr\R
                  *ImgPtr + 3
                  
                  *FilePtr + 1
                Next x
                *ImgPtr + LinePaddingBytes
              Next y
              
              StopDrawing()
            EndIf
          EndIf
        Next i
        

        If Pictures < 8
          YPictures = 8
        Else
          YPictures = Pictures
        EndIf
        
        OpenWindow(0, 0, 0, (XPixels + 2) * 8, (YPixels + 2) * YPictures / 8, GetFilePart(Filename$, #PB_FileSystem_NoExtension), #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
        
        
        For i = 0 To Pictures - 1
          
          ImageGadget(i, XPos, YPos, 0, 0, ImageID(i))
          
          XPos + XPixels + 2
          If XPos > (XPixels + 2) * 8 - 2
            XPos = 0
            YPos + (YPixels + 2)
          EndIf
        Next i
        
        Repeat
          Event = WaitWindowEvent()
          If Event = #PB_Event_Gadget
            SetClipboardImage(EventGadget())
          EndIf
        Until Event = #PB_Event_CloseWindow
      EndIf
      
    EndIf
    FreeMemory(*FileBuffer)
  EndIf
  CloseFile(File)
EndIf
Last edited by infratec on Wed Feb 03, 2021 2:01 pm, edited 9 times in total.
User avatar
TheAutomator
Enthusiast
Enthusiast
Posts: 112
Joined: Tue Dec 01, 2020 8:33 pm

Re: edit a .dat file with .pcx files in it

Post by TheAutomator »

:shock: wow nice!
this is so cool :mrgreen:

i have no clue what you are doing with the values here tho

Code: Select all

*ImgPtr\B = (*FilePtr\a >> 6) * 64
*ImgPtr\G = (*FilePtr\a & %00000111) * 32
*ImgPtr\R = ((*FilePtr\a & %00111000) >> 3) * 32
i wish i could understand it a little more, maybe i can fiddle my way out of the color problem that way.
things that come to mind now are, maybe its 8 / 16 or 32 bit and the conversion is wrong, is there an alpha channel that is overlooked, are the color values divided by some value because in the graphics menu of the game you can change how bright this everything should be, ...?

so basically you have a hex value per pixel right? or are they stored in one single hex number?
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

One pixel is one byte.
This was the to decode the color as 3-3-2 RGB Byte.
But it is not working.
So a 256 color palette is in use.
But it is not the standard windows palette.
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

I found a pallete inside Debris32.exe, but ...
it was not working as expected.

As last option I inspected the PCX pictures.
The INSTRUCT.PCX file used also a palette.
I exported it and ... YES!

I changed the listings above.
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: edit a .dat file with .pcx files in it

Post by infratec »

I updated the picture code above.

But inside the 25600 byte files are different resolutions inside.

I stop here.
The rest is yours.
User avatar
TheAutomator
Enthusiast
Enthusiast
Posts: 112
Joined: Tue Dec 01, 2020 8:33 pm

Re: edit a .dat file with .pcx files in it

Post by TheAutomator »

infratec wrote:I updated the picture code above.

But inside the 25600 byte files are different resolutions inside.

I stop here.
The rest is yours.
@infratec.. I'm speechless!
You are a true code guru, you have been so kind to put all this effort into helping me out.
1000X thanks for your help, if i can do something back for you let me know!

Kind regards!
User avatar
Otrebor
Enthusiast
Enthusiast
Posts: 199
Joined: Mon Mar 17, 2014 1:42 pm
Location: São Paulo, Brasil
Contact:

Re: edit a .dat file with .pcx files in it

Post by Otrebor »

TheAutomator wrote: @infratec.. I'm speechless!
You are a true code guru
Kind regards!
+1
Post Reply