Jump to content
PacManPlus

Bitmap to 7800 Graphics Converter

Recommended Posts

Hi Everyone:

 

I've just completed BMP7800

BMP7800 is a utility to convert 256-Color Bitmaps to 7800 data.

 

It takes a .BMP file (only 256 colors are supported) and converts it to an assembly include file to be used with the ".include" directive in DASM in your source program. The colors are determined by the order the utility 'finds' the colors as it process the bitmap file. (This can be changed with the '-c' option explained below.)

The utility also supports 'mixed mode' bitmaps, where more than one display mode is contained within a single bitmap.

 

It uses the .NET 4 Framework, and is called from the command line:

 

bmp7800 -i:(name) -o:(name) [-c(color list)] [-m:(display mode)] [-z(scan lines per zone)] [-s(starting x,y point)] [-e(ending x,y point)] [-a] [-f]

 

Options:

-i: The absolute path/filename of the input bitmap file (e.g. -i:C:\DEV\7800\CHARMODE.BMP) - Required

-o: The absolute path/filename of the output assembly file (e.g. -o:C:\DEV\7800\CHARMODE.S) - Required

-c Specify the color palette index order, separated by commas (e.g. -c219,4,173) - Optional, order is by discovery if not specified.

-m: Display mode, valid values are (-m:160a, -m:160b, -m:320a, -m:320b, -m:320c*, -m:320d*) - Optional, default is 160a if not specified.

-z Number of scan lines per zone, valid values are 1-16 - Optional, default is 16 if not specified

-s Starting x,y point. This specifies the upper-left corner of the graphics within the bitmap you are trying to convert. This option is

usually (but not always) used when working with a mixed mode bitmap. - Optional, default is 0,0 if not specified

-e Ending x,y point. This specifies the lower-right corner of the graphics within the bitmap you are trying to convert. This option is also

usually (but not always) used when working with a mixed mode bitmap. - Optional, default is the end of the bitmap if not specified

-a Append mode. This option is used when working with a mixed mode bitmap. It tells the utility to a) append the data to the Output file, and b)

don't pad the bytes out to a page length. You would use this option for every pass of the utility (including the final one - see example) - Optional

-f Final mode. This option is used with the '-a' option above. It allows append mode to add the data to the output file, but additionally

pads the bytes out to a page length. It also allows the final preparation for DASM. (see example below) - Optional

 

*320c and 320d modes are not supported, yet.

Please note that when working with bitmaps that will be used for a single resolution on the 7800 (i.e. most of the time), you do not use the '-a' or '-f' options.

There is some error checking done by the application, and it will stop to let the user know if there is something wrong.

 

Upon successful completion, the utility will display to the user:

* The display mode

* The size of the input bitmap

* The zone size (i.e. number of scan lines per zone)

* The starting and ending points.

* The color indices, in the order it found them or was specified.

 

It will also display any warnings, i.e. if the output file isn't found when specifying the '-a' option (which is needed for the first run), or if the height of the bitmap is not evenly divisible by the zone height.

 

Examples:

(Please note that I had to convert these to PNG graphics so they would display)

post-1787-0-09136800-1464042512.png

BMP7800 -I:CHARMODE.BMP -O:CHARMODE.S -C1,2,3 -M:160A -Z16 -E127,127

(Please note that you do not need the '-M:160A', '-E127,127' or the '-Z16' option here; I put it in for completeness).

post-1787-0-42193200-1464042512.png

DEL CHARMODE320.S
BMP7800 -I:CHARMODE320.BMP -O:CHARMODE320.S -A -C8,9,13,6,10,14,1,2,16,4,17,18 -M:320A -Z8  -S0,0  -E127,47
BMP7800 -I:CHARMODE320.BMP -O:CHARMODE320.S -A -C8,9,13,6,10,14,1,2,16,4,17,18 -M:160A -Z16 -S0,48 -E127,95
BMP7800 -I:CHARMODE320.BMP -O:CHARMODE320.S -A -C8,9,13,6,10,14,1,2,16,4,17,18 -M:160B -Z16 -S0,96 -E127,111 -F

(Also note that being we are using 'append' mode here, you must delete the file first to make sure we aren't appending to an existing file)

...and, for the 320A mode, you don't need any color index past '-C8' (because it only uses one color), and the same with 160A mode and '-C8,9,13'. I just did that because I like things to line up. :D

 

post-1787-0-75235400-1464042512.png

bmp7800 -i:Sprites.bmp  -o:Sprites.S  -e127,127 -m:320a

.

 

post-1787-0-07849000-1464042513_thumb.png

bmp7800 -i:Sprites2.bmp  -o:Sprites2.S  -e1023,15 -m:320b -z16 -c8,7,6

.

NOTE: modes 320C and 320D have not been implemented yet.

I hope this will help everyone. I have also included source code, which is written for Visual Studio .NET 2012 in C#.

Thanks,

Bob

 

 

Thanks to RevEng and Albert for some ideas and discussion. :)

BMP7800.zip

BMP7800SourceCode.zip

Edited by PacManPlus
  • Like 16

Share this post


Link to post
Share on other sites

Ideas are cheap, and code isn't. :)

 

What I love about this utility is it's simple and straightforward to use for basic sprite-sheets, but allows you to pull off complex tricks too. Want to pull from multiple sprite-sheet bitmaps and combine different modes into one graphics data block? It does that. Want to do the same, except using different regions from a single sprite-sheet bitmap? It does that too.

 

Thanks for coding and sharing this tool Bob, and sharing the source code too! :D

 

[edit - basic 7800 Dev Wiki entry added]

  • Like 3

Share this post


Link to post
Share on other sites

Thanks Bob! Love stuff like this!

 

As an aside, this got me all pumped up thinking about one of my interests in the 80s ... seeing digitized photos on an 8bit computer. So common place now, but in 1986, it was COOL to see that!

 

Loved the digitized shots you used in your unreleased REzolve project.

  • Like 2

Share this post


Link to post
Share on other sites

I haven't tried this out yet, but I'm excited about the possibilities for 7800Basic developers. Creating graphics is a pretty big roadblock for new users and this could lower the bar a little bit. Thanks for sharing this Bob!

  • Like 2

Share this post


Link to post
Share on other sites

I haven't tried this out yet, but I'm excited about the possibilities for 7800Basic developers. Creating graphics is a pretty big roadblock for new users and this could lower the bar a little bit. Thanks for sharing this Bob!

I agree. Is it in the works to be implemented with 7800Basic as it seems to be available so far for the DASM assembler?

  • Like 1

Share this post


Link to post
Share on other sites

I'd be glad to add an "incgraphicblock" statement, or something along those lines. IMO using the sprite-sheet approach of BMP7800 vs. the single-sprite approach of 7800basic's incgraphic doesn't simplify things, so much as trade-off areas of complexity.

 

SPRITE-SHEET: makes palette management easier for multiple related sprites. Editing multiple sprites at the same time is easier.

SINGLE-SPRITE: rearranging graphics is easier. color-import of multiple palettes possible. no need to specify each sprite's byte-index and byte-width.

 

When using the proposed "incgraphicblock", the 7800basic coder would need to supply the info that incgraphic would automatically supply. (same as assembly coders do)

  • Like 2

Share this post


Link to post
Share on other sites

AWESOME tool hope you can add the 320C and 320D modes aswell soon...

 

I was playing around with the 7800Basic but stopped because I found the graphics converting to hard. This seems nice, also cool it's commandline so it can be scripted.

  • Like 1

Share this post


Link to post
Share on other sites

That's a neat little tool you have there, Mr. DeCrescenzo! I was going to send a PM in regards to assembly how-tos, but changed my mind after thinking about it.

  • Like 1

Share this post


Link to post
Share on other sites

For anyone looking for something other than photoshop or gimp, I have started using Aseprite to make my spritesheets.

 

Works great with Bob's program when you specify Aseprite to use its indexed color mode and use a canvas size of either 128 * 64 or 128 * 128 depending on 8 or sixteen high zones. Export as a bmp and feed it to BMP7800.

 

Late to the party here, but thanks for the program bob! :thumbsup:

  • Like 1

Share this post


Link to post
Share on other sites

have some question to the tool... I am not able to convert a proper bmp file...

 

so...in Gimp... it only works with greyscale bmp (so I loose colors)... and i need to reduce to 3 colors instead of 4... but then I loose again another color in gimp...

 

further... if I have a gfx which is 160x48... do I need to expand it to 1024x48 and then transfer 3x each zone and append?

 

is there another tool to generate interlave sprite sheets? if not... I guess I need to write my own :D

Share this post


Link to post
Share on other sites

Hey!

 

I'll try to help. What is happening when you try to convert four BMP file? Do you get an error? or a corrupt file? What does the output on the screen say?

Also Technically it is three colors, as one of them (the first one) is for the background.

 

Regarding the size, if you are using the same screen mode (i.e. 160A) for the entire .BMP, you don't have to run it 3 times. Run it once for the whole bitmap, specifying the size of the zone (-z8, or -z16, etc.) and it will figure out where the splits are.

PM me if you still have trouble.

 

Bob

  • Like 2

Share this post


Link to post
Share on other sites

bob... thanks...

 

why 3 colors incl. background? 01,10,11,00? are 4 combos ;) but I am not familiar. I am wondering that i managed all the stuff 2003 and totally fail 2017 :D.

 

so issue with converting complete 160x48 logo gfx was with BMP7800.exe -i:desire.bmp -o:desire.s the generated source file does not work out of the box in my code....

 

so how would that be generated in the source? what is the layout 40 bytes zone1 40 bytes zone2 40 bytes zone3 assuming standard default values 160a and default zone size 16?

Share this post


Link to post
Share on other sites

well...

 

when using a default 8x16 dummy BMP a simple bmp7800... generates a source file with 128 hex values per line...

 

when looking into memory it does $9000... $0980... etc next line data

Share this post


Link to post
Share on other sites

Hey!

 

I'm at work right now, but please PM me the BMP file you are using and I will take a look at it. Please make sure it's set at 256 colors... I don't know what will happen otherwise...

 

Thanks,

Bob

  • Like 2

Share this post


Link to post
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...