Jump to content
IGNORED

GR8 Drawing Utils (Linux)


damosan

Recommended Posts

$ ls -l graphics8.pbm 
-rw-r--r-- 1 ivo ivo 7730 Dec 14 19:19 graphics8.pbm
$ echo $((7730-7680))
50
$ file graphics8.pbm 
graphics8.pbm: Netpbm image data, size = 320 x 192, rawbits, bitmap
$ od -Ax -tx1 graphics8.pbm | head -n 4
000000 50 34 0a 23 20 43 52 45 41 54 4f 52 3a 20 47 49
000010 4d 50 20 50 4e 4d 20 46 69 6c 74 65 72 20 56 65
000020 72 73 69 6f 6e 20 31 2e 31 0a 33 32 30 20 31 39
000030 32 0a ff ff ff ff ff ff ff ff ff ff ff ff ff ff
$ od -Ax -ta graphics8.pbm | head -n 4
000000   P   4  nl   #  sp   C   R   E   A   T   O   R   :  sp   G   I
000010   M   P  sp   P   N   M  sp   F   i   l   t   e   r  sp   V   e
000020   r   s   i   o   n  sp   1   .   1  nl   3   2   0  sp   1   9
000030   2  nl del del del del del del del del del del del del del del
$ dd if=graphics8.pbm of=graphics8.dat bs=1 skip=50
7680+0 records in
7680+0 records out
7680 bytes (7.7 kB, 7.5 KiB) copied, 0.0194114 s, 396 kB/s
$ 

Here's an example. I specifically chose 320x192, which is 7680 bytes, a well known size, which is exactly a full screen of graphics 8 (or 15).

 

In both od dumps you can clearly see that the header is 50 (0x32) bytes. But that is just to show it's correct to just do filesize minus 7680, which I did at the top :)

 

Considering you asked about Linux, I suppose you know how to handle the command line ;)

 

  • Like 2
Link to comment
Share on other sites

My BOSS-X System reads native GR8-sized BMP files (320 x 192 x 1 Bit) directly, it's not complicated, just ignore the header and read them from bottom to top. In Turbo-BASIC it might be slower than BGETting the image as one block, but it works without conversion.

 

GRAPHICS 8:SETCOLOR %2,%0,%0:SETCOLOR %1,%0,15:REM bit set = white

BGET #%1,DPEEK(88),50:REM ignore the header (its 50 bytes or 42 bytes?)

FOR P=DPEEK(88)+7640 TO DPEEK(88) STEP -40:BGET #%1,P,40:NEXT P:REM read stuff from bottom to top

 

This method might not suit your needs, especially in the final product, but it helps skipping at least one step while developing the game.

Edited by atarixle
Link to comment
Share on other sites

I hacked the following together and it does the trick with the images I'm editing via Gimp.  Error checking?  What's that?

 

D.

#!/usr/bin/python

import sys

if len( sys.argv ) != 3:
    print "usage: pbm2raw inputfile outputfile"
else:
    input_data = open( sys.argv[ 1 ] ).readlines()
    with open( sys.argv[ 2 ], "wb" ) as output_file:
        output_file.write( input_data[ 3 ] )
  • Like 1
Link to comment
Share on other sites

Here's a one-liner:

 

$ ls -l graphics8.pbm
-rw-r--r-- 1 ivo ivo 7730 Dec 18 16:30 graphics8.pbm
$ sed 1,3d graphics8.pbm > graphics8.raw
$ ls -l graphics8.raw
-rw-r--r-- 1 ivo ivo 7680 Dec 18 16:30 graphics8.raw
$

graphics8.pbm contains random data after the header. Just as your script, it assumes 3 lines of header. Theoretically, that could be more ;)

 

Edit:

$ dd if=graphics8.pbm of=graphics8.dat bs=1 skip=50 
7680+0 records in
7680+0 records out
7680 bytes (7.7 kB, 7.5 KiB) copied, 0.0216366 s, 355 kB/s
$ diff -s graphics8.dat graphics8.raw
Files graphics8.dat and graphics8.raw are identical

 

Edited by ivop
  • Like 1
Link to comment
Share on other sites

Why am I not surprised that dmsc comes up with an even better solution :)

 

Seems like -c bytes has been an option to tail, like, forever (and a POSIX standard), but I never used it before and was unaware of it.

 

And if your graphics 8 data is of a different dimension, you can use something like $((40*32)) instead of 7680, for only 32 lines of standard width graphics 8.

 

Edited by ivop
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...