pp256 to bmp converter plus

User projects written in or related to FreeBASIC.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

pp256 to bmp converter plus

Postby relsoft » Aug 16, 2006 12:02

I can't do anything really big because of the power outages we are experiencing these days. So I just thought this might be useful.

Reasons why I did this instead of using the ones already posted here
1. This saves multi-sized image. The converters posted here only works with fixed sized images. PP256 supports variable sized images
2. This also saves an index of the frames for each tileset in support for multi-sized images and ease of loading for any API you choose.
3. Interface in using the tilesets (in FBGFX mode) is the same as when using pp256.
4. Loading tilesets and indexing them is easy. After loading you could just put the frames according to index. No messy calculations of offsets. Loader does that for you.

Download whole package here:
http://rel.betterwebber.com/junk.php?id=76

PS.
Loading sample:

Code: Select all

'' loader_fbgfx.bas
'' relsoft 2006
'' loads the converted files and blits them using standard fbgfx commands
'' option explicit
'' Note:  If you want me to make a loader for both OpenGL and SDL just shout!

#include once "fbgfx.bi"
#include once "pp256_image.bi"

    dim as string bmp_file
    dim as string pal_file   
   
    ''Change this to whatever you'd want to load
    bmp_file = "organic.bmp"
    pal_file = "si.pal" 
   
   
    '' image data initializer see pp256_image.bi"
    dim image as ImageType   
    image.init = @image_init
    image.init( image )
   
   
    cls
    screen 18,8,,0 
       
   
    '' load the tileset
    image.m_filename  = bmp_file   
    init_palette_data  pal_file
    image.load_BMP_setl(image)
    dim i as integer
    i = int(rnd * (image.m_maxindex +1))
    put(0,0), @image.p_data[image.p_dataindex[i]],pset
sleep
end
badmrbox
Posts: 659
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Postby badmrbox » Aug 16, 2006 16:25

It works great :).
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Aug 16, 2006 23:53

Thanks!!

BTW, are you also interested in a Mappy(a great map editor) converter?

I use it to make maps for Space Impakto.
badmrbox
Posts: 659
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Postby badmrbox » Aug 17, 2006 17:10

BTW, are you also interested in a Mappy(a great map editor) converter?

I say yes! I have not been fiddling with Mappy but I have been thinking about it. I'm downloading mappy as I write this. Yes, a mappy converter would please me. :)
{Nathan}
Posts: 301
Joined: Jun 04, 2005 15:18
Location: Ohio
Contact:

Postby {Nathan} » Aug 17, 2006 21:19

relsoft wrote:Thanks!!

BTW, are you also interested in a Mappy(a great map editor) converter?

I use it to make maps for Space Impakto.


FOR THE LOVE OF GOD, YES!

I have been working tirelessly to get it working for a while but gave up because I couldn't compile the Allegro version under Linux. It really made me angry... so... a Mappy/Tiled (By Bjorn) converter would be great. If you can make this mappy converter, I could finally get back to work on my ScrollonaPixel project.
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Aug 17, 2006 21:25

Tiled maps are just XML; you should be able to parse them with any XML-reading library (expat, libxml2, ...). The actual map data is encoded with base64; I have written a decoder for that if you are interested.
{Nathan}
Posts: 301
Joined: Jun 04, 2005 15:18
Location: Ohio
Contact:

Postby {Nathan} » Aug 18, 2006 11:09

Yes, I would be interested in this base64 decoder.
Dr_D
Posts: 2391
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Aug 18, 2006 11:47

Also, I believe that Cha0s wrote an XML parser for LL. I'm not positive though. You would have to look in the source. ;)
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Aug 21, 2006 3:26

Here's a simple base64 decoder:

Code: Select all

dim shared _decode_tbl(255) as uinteger => { _
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _              ' 0..31
   0,0,0,0,0,0,0,0,0,0,0, _                                                        ' 32..42
   62,0,0,0,63, _                                                                  ' 43 (+), 44..46, 47 (/)
   52,53,54,55,56,57,58,59,60,61, _                                                ' 48..57 (0..9)
   0,0,0,0,0,0,0, _                                                                ' 58..64
   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25, _          ' 65..90 (A..Z)
   0,0,0,0,0,0, _                                                                  ' 91..96
   26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,_ ' 97..122 (a..z)
   0,0,0,0,0 }                                                                     ' 123..127

public sub base64_decode(byval dest as ubyte ptr, byval source as ubyte ptr, byval source_length as uinteger)
   dim buf as uinteger, src_ctr as uinteger
   
   source_length \= 4
   
   for src_ctr = 0 to source_length
      buf = (_decode_tbl(source[0]) shl 18) or _
            (_decode_tbl(source[1]) shl 12) or _
            (_decode_tbl(source[2]) shl  6) or _
            (_decode_tbl(source[3]))
      dest[0] = buf shr 16
      dest[1] = (buf shr 8) and &hFF
      dest[2] = buf and &hFF
      source += 4
      dest += 3
   next src_ctr
end sub

public function base64_decoded_length(byval source_length as uinteger) as uinteger
   dim ret as uinteger
   
   ret = (source_length \ 4) * 3
   if source_length mod 4 = 3 then
      ret += 2
   elseif source_length mod 4 = 2 then
      ret += 1
   end if
   
   return ret
end function
badmrbox
Posts: 659
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Postby badmrbox » Aug 21, 2006 12:56

Rel, what happened to that Mappy converter?
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Aug 22, 2006 3:40

badmrbox wrote:Rel, what happened to that Mappy converter?


Oops! Sorry, I was offline cuz the farm I tend is underwater. Plus we have gots us a nasty oil spill here.
http://newsinfo.inq7.net/breakingnews/m ... e_id=15756

I'll be cleaning the code up later and upload.

BTW, download the bmp2pp converter again. fixed a little bug that would make it fail on very large files.
badmrbox
Posts: 659
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Postby badmrbox » Aug 22, 2006 12:31

Oops! Sorry, I was offline cuz the farm I tend is underwater. Plus we have gots us a nasty oil spill here.
Have it been raining much where you are? I heard about the tanker. Not very nice at all.


I'll be cleaning the code up later and upload.
:)
Zamaster
Posts: 1024
Joined: Jun 20, 2005 21:40
Contact:

Postby Zamaster » Mar 14, 2011 2:51

I know this is dead. BUTTTT found this looking to use it, and I get an error in bmp_load_setl in allocating memory every time I try to use the demo, I don't know if rel hangs out here anymore though but if he or anyone else knows what the fix is, I'm all ears. thanks
badmrbox
Posts: 659
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Postby badmrbox » Mar 14, 2011 6:47

The organic.bmp found in the .zip is 0 bytes. Convert the .put and try again.
Edit: Spoke too soon. I can't get the example in the first post to work either but loader_fbgfx.bas works as it should.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Mar 14, 2011 8:00

Hi guys. I just downloaded the file and organ.put is ~64kb.

My advise on this:



Doing the above would make your memory requirements less and code is easy to manage.

An example of how to use the packer that uses OpenGL is here (though you could use FBGFX is you want)

http://www.file-pasta.com/s/586/B2B_Issue2.zip

I'm not on my coding computer right now so I can't test the zip.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest