Page 1 of 1

Me and my FSH files again xD

Posted: Thu Feb 24, 2005 5:25 pm
by Kaiser
Hey people :D

I've continued to research about the FSH file format. I know now a friend who has deciphered that code in Delphi. I might have a little chat with him about this later. Now, for what he has been telling me and such, the file format is organized, so I won't have some problems, but, I was wondering...

I noticed the PeekB function, and as the file is made in binary, meaning it's just some ascii gibberish, I was wondering if with that, and a special instruction, it would be possible to join those bytes and read them as an image, sorta like a CatchImage. If that's so, anyone have a little example of how is that done and if it's possible also to "move" the starting position from where PeekB starts?

Edit:

Okay I spoke with my friend and he showed me the Delphi source (which is downloadable :) ) I noticed he uses hex positions to place the "reading" cursor and uses words and bytes as data types for reading too. Any help with that? I can show the source of the whole function if any of you wish (which has implemented other file types I need, as FBJ and FS2, but he reads it the same way as FSHs :).

Edit 2:

This is from the convo:
"TMemoryStream is a TStream varient. That's an object set that abtracts basic read/write functions. Filestream loads/saves to a file, Memorystream uses memory blocks, Resourcestream works from EXE resources and so on."

I hope some of this information is useful :)

Posted: Fri Feb 25, 2005 1:12 pm
by blueznl
what is fsh?

Posted: Fri Feb 25, 2005 2:28 pm
by Kaiser
FSH is a Furcadia SHape file, from the game named Furcadia. Basically it's a file that stores XY values and one image. I could provide an example FSH and an FSH editor for you to see how it's composed and what exactly is, if neccessary.

Posted: Fri Feb 25, 2005 4:21 pm
by blueznl
not going to help you on the fsh side, but you can read blocks from a file into memory, type readbyte() hit [f1] and follow the links and you'll and up in the right direction :-)

Posted: Fri Feb 25, 2005 6:38 pm
by Kaiser
Hehe it's okay, besides, everyone's doing it now and nice utilities (not hacks or cracks, thanks God) have come out of it, I just wanted to translate that Delphi code to PB :P I'm gonna try that now, thanks :) I'll see what I'm capable to do :D

!

Posted: Sat Feb 26, 2005 12:26 am
by Kaiser
YAY Blue!! it really works ^_^ thanks!!! :D

One thing though, okay, I could read it all good :D now, I'm not very familiar with it but, how do I then "mix" those bytes and then convert them in an image for LoadImage? I think I need to mix the bytes for using them as whole for LoadImage, no? would that be my just a simple add? or another formula? as if byte1=30 and byte2=30 will be "3030" instead of 60? just that, and to know if then how can I put those bytes at use :)

Thanks again! :D

Posted: Sat Feb 26, 2005 12:59 am
by blueznl
it's not that simple, if it's an image, you have to figure out what format, header etc. which has little to do with purebasic but more with the file format...

Posted: Sat Feb 26, 2005 1:21 am
by Kaiser
Well I have the file format here, if this's any useful :/

Code: Select all

File:
unsigned short                     - chunk count
chunk count lots of unsigned short - chunk sizes in bytes
chunk count lots of chunk_structs  - chunks

chunk_struct:
unsigned byte         - width of entry
unsigned byte         - height of entry
signed byte           - X offset of entry
signed byte           - Y offset of entry (though when drawing bottom height + y offset is forced to be less than bottom of floor tile)
width * height bytes  - entries (refer to palette in PCX)
                        Note, stored as a windows bitmap, ie.
                        reflected (last row stored first).

Posted: Mon Feb 28, 2005 12:56 am
by Kaiser
Um... anyone? o.o;

Edit:

It's okay if nobody can help me with that... but at least, well, I could get some bytes.... how would I convert them to an image now? CatchImage? how?

Posted: Mon Feb 28, 2005 2:07 pm
by HeX0R

Code: Select all

Restore Start
Read Length.l

*buffer = AllocateMemory(Length)
For i = 0 To Length - 1
  Read byte.b
  PokeB(*buffer + i, byte)
Next i

Id.l = CatchImage(0, *buffer)
If OpenWindow(0, 1, 1, 32, 32, #PB_Window_SystemMenu, "")
  CreateGadgetList(WindowID())
  ImageGadget(0, 1, 1, ImageWidth(), ImageHeight(), ID)
  
  Repeat
  
  Until WindowEvent() = #PB_Event_CloseWindow
  
EndIf
FreeMemory(*buffer)
End




DataSection
  Start:
  Data.l 766
  Data.b 0, 0, 1, 0, 1, 0, 32, 32
  Data.b 16, 0, 0, 0, 0, 0, -24, 2
  Data.b 0, 0, 22, 0, 0, 0, 40, 0
  Data.b 0, 0, 32, 0, 0, 0, 64, 0
  Data.b 0, 0, 1, 0, 4, 0, 0, 0
  Data.b 0, 0, -128, 2, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, -128, 0, 0, -128
  Data.b 0, 0, 0, -128, -128, 0, -128, 0
  Data.b 0, 0, -128, 0, -128, 0, -128, -128
  Data.b 0, 0, -128, -128, -128, 0, -64, -64
  Data.b -64, 0, 0, 0, -1, 0, 0, -1
  Data.b 0, 0, 0, -1, -1, 0, -1, 0
  Data.b 0, 0, -1, 0, -1, 0, -1, -1
  Data.b 0, 0, -1, -1, -1, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, -69, -69, -69, -80
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 11, -69, -18, -52, -52, -52
  Data.b -52, -52, -18, -18, -32, 0, 0, 0
  Data.b 0, 11, -71, -103, -18, -52, -52, -52
  Data.b -52, -52, -18, -18, -32, 0, 0, 0
  Data.b 0, -69, -112, 0, 14, -52, -52, -52
  Data.b -52, -52, -18, -18, -32, 0, 0, 0
  Data.b 11, -103, 0, 0, 0, -52, -52, 0
  Data.b 0, 9, -101, 0, 0, 0, 0, 0
  Data.b -71, 0, 0, 0, 0, 12, -52, -64
  Data.b 0, 0, 9, -80, 0, 0, 0, 11
  Data.b -112, 0, 0, 0, 0, 0, -52, -52
  Data.b 0, 0, 0, -101, 0, 0, 0, -69
  Data.b -112, 0, 0, 0, 0, 0, 12, -52
  Data.b -64, 0, 0, -101, -80, 0, 0, -71
  Data.b 0, 0, 0, 0, 0, 0, 0, -52
  Data.b -52, 0, 0, 9, -80, 0, 11, -112
  Data.b 0, 0, 0, 0, 0, 0, 0, 12
  Data.b -52, -64, 0, 0, -101, 0, 14, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b -52, -52, -32, 0, -101, 0, 14, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, -52, -18, 0, -101, 0, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, 12, -18, -32, 9, -80, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, 0, -18, -18, 9, -80, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, 0, 14, -18, -23, -80, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -52, -52
  Data.b -52, -52, -18, -18, -23, -80, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -52, -52
  Data.b -52, -52, -18, -18, -23, -80, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, 0, 0, 0, 9, -80, -66, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, 0, 0, 0, 9, -80, 14, -18
  Data.b 0, 0, 0, 0, 0, -52, -64, 0
  Data.b 0, 0, 0, 0, -101, 0, 14, -18
  Data.b 0, 0, -18, 0, 0, -52, -64, 0
  Data.b 0, 0, 0, 0, -101, 0, 14, -18
  Data.b 0, 14, -18, -32, 0, -52, -64, 0
  Data.b 0, 0, 0, 0, -101, 0, 14, -18
  Data.b 0, -18, -18, -18, 0, -52, -64, 0
  Data.b 0, 0, 0, 9, -80, 0, 14, -18
  Data.b -98, -18, -18, -18, -32, -52, -64, 0
  Data.b 0, 0, 0, -101, -80, 0, 14, -18
  Data.b -18, -18, 0, -18, -18, -52, -64, 0
  Data.b 0, 0, 0, -101, 0, 0, 14, -18
  Data.b -18, -32, 0, 14, -18, -52, -64, 0
  Data.b 0, 0, 9, -80, 0, 0, 14, -18
  Data.b -18, -103, 0, 0, -18, -52, -64, 0
  Data.b 0, 9, -101, 0, 0, 0, 14, -18
  Data.b -32, -69, -112, 0, 14, -52, -64, 0
  Data.b 0, -101, -80, 0, 0, 0, 14, -18
  Data.b -32, 11, -71, -103, 14, -52, -64, 9
  Data.b -103, -69, 0, 0, 0, 0, 0, -18
  Data.b 0, 0, 11, -69, -103, -52, -103, -101
  Data.b -69, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, -69, -69, -69, -80
  Data.b 0, 0, 0, 0, 0, 0, -1, -16
  Data.b 31, -1, -1, -128, 3, -1, -2, 0
  Data.b 0, 7, -4, 0, 0, 7, -8, 0
  Data.b 0, 7, -16, 0, 0, 31, -32, 0
  Data.b 0, 15, -64, 0, 0, 7, -128, 0
  Data.b 0, 3, -128, 0, 0, 3, 0, 0
  Data.b 0, 1, 0, 0, 0, 1, 0, 0
  Data.b 0, 1, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 0, 0, 0, 0, 0, 0, 0
  Data.b 0, 1, 0, 0, 0, 1, 0, 0
  Data.b 0, 1, -128, 0, 0, 1, -128, 0
  Data.b 0, 3, -128, 0, 0, 7, -128, 0
  Data.b 0, 15, -128, 0, 0, 31, -128, 0
  Data.b 0, 63, -124, 0, 0, 127, -50, 0
  Data.b 0, -1, -1, -128, 3, -1
EndDataSection

Posted: Fri Mar 18, 2005 1:48 am
by Kaiser
WOW!! that works awesome!!!!!!! :D :D :D thanks a ton man! :D :D