Bmp2DHR and VBMP

 

 

 

About Bmp2DHR

 

Bmp2DHR is a feature-rich command-line utility for converting BMP files to native Apple II Double Hi-Res (DHGR) Color and Monochrome graphics files.

 

Bmp2DHR offers several additional output options, including 140 x 192 x 16 color BMP files and 560 x 192 Monochrome BMP files to display using VBMP in the following Apple II DHGR video modes:

 

 

See the AppleWin emulator screen-shots above of VBMP displaying Color and Monochrome BMP files produced from the same “true-color” image by Bmp2DHR.

 

While VBMP also displays 280 x 192 Monochrome BMP files compatible with Apple II Hi-Res (HGR) Monochrome mode, Bmp2DHR does not output these because I see little advantage to adding support to Bmp2HGR for displaying a Monochrome BMP in a lower resolution than 560 x 192.

 

About VBMP

 

VBMP is a BMP file viewer for the Apple II’s DHGR display written by in AppleSoft BASIC by Mario Patino (“Cybernesto”). VBMP calls a subroutine in 6502 machine code also written by Cybernesto to display its BMP files. This subroutine loads BMP files only in the 3 variations noted above. 16 color BMP files must be rigidly formatted.

 

VBMP does not use the color palette of a 140 x 192 x 16 color BMP. To VBMP, this is just “wasted space”. VBMP assumes that the DHGR color order has been used to encode the BMP scan-lines instead and assumes that the palette has been ordered properly, so 16-color BMP files created in programs like Windows Paint that do not provide support for custom palettes ordered in the DHGR color order are incompatible with VBMP.

 

VBMP’s display subroutine is a derivative work of an Apple II Hi-Res (HGR) BMP loader written by Arnaud Cocquičre, webmaster of http://www.ctrl-pomme-reset.fr/ and announced in the csa2 usenet news group on October 11, 2011. As part of that same thread Cybernesto announced VBMP in the csa2 usenet news group on July 3, 2013 and later provided a tutorial for creating BMP files in The GIMP for display with VBMP:

 

https://github.com/cybernesto/VBMP/wiki/Converting-a-picture-into-a-DHGR-color-image-using-the-GIMP

 

More about VBMP can be read at the following link:

 

https://github.com/cybernesto/VBMP/blob/master/README.md

 

About the VBMP Tutorial

 

The GIMP does a good job of scaling images for use with Bmp2DHR but its color mapping routines seem less robust than Bmp2DHR’s psycho-visual color mapping. The GIMP also has a much less robust selection of dithering options than Bmp2DHR.

 

Original Image

The GIMP – Wikipedia Palette

Bmp2HGR – Floyd Steinberg

The GIMP – VBMP Tutorial Palette

 

After reviewing Cybernesto’s tutorial I decided to offer a VBMP output option in Bmp2DHR because:

 

 

 

According to Cybernesto, the VBMP tutorial palette is the "exact" palette from Robert Munafo: http://mrob.com/pub/xapple2/colors.html

 

As far as I am concerned, the palette in the tutorial is awful and scaling an image for use with Bmp2DHR is The GIMP’s strongest and perhaps only feature when it comes to producing BMP files for use with VBMP’s loader subroutine.

 

Bmp2DHR Command Option “VBMP”

 

 

 

Bmp2DHR can be used to create 140 x 192 x 16 color BMP files to be displayed by VBMP in the Apple II’s Double Hi-Res (DHGR) Color mode from 16 color, 256 color and 24-bit Version 3 BMP input files (without color map) in the following sizes:

 

 

Bmp2DHR can also be used to create 560 x 192 monochrome BMP files to be displayed by VBMP in the Apple II’s Double Hi-Res (DHGR) monochrome mode from monochrome, 16 color, 256 color and 24-bit Version 3 BMP input files (without color map) in the following size:

 

 

560 x 192 monochrome BMP files can also be converted absolutely “verbatim” by using a 560 x 192 monochrome BMP file, but this is really only useful for producing native DHGR files and redundant for VMP.

 

Bmp2DHR provides the following rendering options:

 

 

In addition to VBMP-compatible output (option “VBMP”) Bmp2DHR provides the following (somewhat equivalent) output:

 

 

BMP Files Versus Native-mode DHGR Files

 

When it comes to writing an AppleSoft BASIC program that loads color bit-mapped graphics screens in DHGR, VBMP is more of a novel demo than a real improvement over loading the standard BSAVED AUX, BIN file pairs that was have been used for about 30 years. However, there are some advantages to using VBMP in an AppleSoft BASIC program:

 

 

There is another practical reason to deviate from Apple II native DHGR A2FC files or AUX, BIN file pairs to use an equivalent BMP file; BMP files are marginally smaller at 13942 bytes or 13886 bytes than the equivalent native mode DHGR file(s) at 16384 bytes because:

 

 

Whether file size difference is worth decoding a BMP file is debatable.  

 

Another debatable issue is VBMP’s GPL licence restriction; a loader for native mode DHGR files written in AppleSoft BASIC has no licence restrictions.

 

There are other more practical reasons why one might not want to do use VBMP:

 

 

Nevertheless, VBMP is an elegant tiny bit of fun code despite its display speed inefficiency over standard native DHGR files.

 

DHGR - A Zero Sum Game

 

 

There is only one DHGR video mode on an Apple II. This is unlike the IBM-PC’s CGA, EGA, and VGA displays which provide independent color and monochrome modes.

 

 

 

Since DHGR doesn’t know the difference between a monochrome and color BMP scan-line, Bmp2DHR could just as easily have also used a monochrome BMP file to provide color VBMP output and saved disk space.

 

 Original Image – 24-bit color

Burkes Dithering

Dithered and Cross-Hatched

Buckels Dithering

Dithered and Cross-Hatched

 

However, the purpose in providing VBMP compatible output in Bmp2DHR was certainly not to confuse anyone wanting to use VBMP.

 

For some folks VBMP is certain to amaze and delight with little effort on their part, so for this reason and in the interest of “breathing new life” into DHGR, Bmp2DHR provides a more robust DHGR BMP file output option than what Cybernesto suggests in his GIMP tutorial.

 

VBMP’s DISPLAY routine itself results in smaller (but slower) program code. However Cybernesto does it all for you and it sure as heck is simpler than what I have written in both C and BASIC as a DHGR slide-show using the “Classic approach” of actually needing to know something about the Apple II.

 

BASIC Programming Examples

 

Loading Native Mode DHGR Files

 

The following is how we program a DHGR slideshow in AppleSoft BASIC without using VBMP. We use native mode DHGR files and not BMP files.

 

 1  REM Double Hi-Res Slideshow in Applesoft BASIC

 2  REM By Bill Buckels February 2013

 3 D$ =  CHR$ (4): PRINT D$;"PR#3": PRINT : REM ENABLE 80 COL

 5  TEXT

 6  HOME

 7  PRINT  "****************************************************"

 8  PRINT  "*                                                  *"

 9  PRINT  "*  DHGR Slideshow, Bill Buckels, 2013              *"

 10  PRINT "*  Loosely Based on The Beagle Graphics Slideshow  *"

 11  PRINT "*  And a Slideshow by Andrew and Ivan Hogan        *"

 12  PRINT "*                                                  *"

 13  PRINT "*            1 -   Run Slideshow                   *"

 14  PRINT "*            ESC - Exit to AppleSoft               *"

 15  PRINT "*                                                  *"

 16  PRINT "* Slideshow: ESC - Quit and Exit to AppleSoft      *"

 17  PRINT "*            Left Arrow, Up Arrow - Previous Slide *"

 18  PRINT "*            Other Keys - Next Slide               *"

 19  PRINT "****************************************************"

 20  GET A$

 21  IF A$ =  CHR$ (27) THEN  GOTO 800

 22  IF A$ = "1" THEN  GOTO 24

 23  GOTO 5

 24  POKE 49246,0: REM DOUBLE HI-RES ON

 25  POKE 49239,0: REM HI-RES ON

 26  POKE 49232,0: REM GRAPHICS

 27  POKE 49234,0: REM FULL GRAPHICS

 28  PRINT D$;"PR#3": PRINT : REM ENABLE 80 COL

 33  DIM NAME$(20),TIME(20): ONERR  GOTO 40

 34  FOR I = 1 TO 20: READ NAME$(I),TIME(I): NEXT

 40 NUMBER = I - 1:I = 1: POKE 216,0: REM SET ONERR FLAG

 50  REM MAIN LOOP

 70 TEMP$ =  LEFT$ (NAME$(I),( LEN (NAME$(I)) - 4)) + ".AUX"

 71  POKE 49237,0: PRINT D$;"BLOAD ";TEMP$;",A$2000": PRINT

 72  POKE 49236,0: PRINT D$;"BLOAD ";NAME$(I);",A$2000": PRINT

 80 B = 0

 85  FOR J = 1 TO TIME(I) * 30

 86  REM PADDLE BUTTONS

 90  IF  PEEK ( - 16286) > 127 THEN J = TIME(I) * 44

 100  IF  PEEK ( - 16287) > 127 THEN J = TIME(I) * 44:B = 1

 101 K =  PEEK ( - 16384)

 105  REM ESCAPE KEY, ANY KEY, LEFT ARROW, UP ARROW

 110  IF K = 155 THEN  POKE  - 16368,0: GOTO 700

 115  IF K > 127 THEN  POKE  - 16368,0:J = TIME(I) * 44: REM ANY KEY

 120  IF K = 136 THEN B = 1: REM LEFT ARROW - BACK

 121  IF K = 139 THEN B = 1: REM UP ARROW - BACK

 125  NEXT J

 130  IF B THEN I = I + NUMBER * (I = 1) - 1: GOTO 50

 140 I = I - I * (I = NUMBER) + 1: GOTO 50

 141  REM FILENAMES AND SECONDS TO DISPLAY ARE ADDED HERE

 150  DATA WATERTOP.BIN,10

 170  DATA WMIDTOP.BIN,10

 180  DATA WMIDBOT.BIN,10

 200  DATA WATERBOT.BIN,10

 210  DATA WMIDBOT.BIN,10

 220  DATA WMIDTOP.BIN,10

 700  REM EXIT SLIDESHOW

 710  POKE 49247,0: REM DOUBLE HI-RES OFF

 720  POKE 49233,0: REM TEXT MODE

 730  POKE 49236,0: REM PAGE ONE

 740  PRINT D$;"PR#3": PRINT : REM ENABLE 80 COL

 800  TEXT

 810  HOME

 820  CALL  - 1184: CALL 42350

 830  REM  THIS IS THE END

 840  NEW

 

Loading BMP Files in DHGR Mode

 

The following is how Cybernesto has programmed his DHGR slideshow using VBMP:

 

 10 D$ =  CHR$ (4)

 15  FOR I = 1 TO 9: READ F$

 20  PRINT D$;"BLOAD ";F$;".BMP,A$4000"

 30  PRINT D$;"BRUN DISPLAY"

 35  FOR J = 1 TO 1000: NEXT J

 40  NEXT I

 45  POKE  - 16372,0: TEXT

 60  DATA  "IMAGE","SJOBS"

 70  DATA  "STEVES","A2C1984"

 80  DATA  "ADVTIME2","IRONMAN","SIMPSONS","SPONGEBOB","ZIMA2"

 

Download Bmp2DHR

 

Download Bmp2DHR at the following links:

 

Win32 and latest version complete with source:

http://www.appleoldies.ca/cc65/programs/dhgr/bmp2hr.zip

 

MS-DOS: http://www.appleoldies.ca/cc65/programs/dhgr/bmp2dhrMSDOS.zip

 

Other: (Linux, OSX): http://hoop-la.ca/apple2/appleoldies/bmp2dhr/

Additional Examples

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

All the best,

 

Bill Buckels

bbuckels@mts.net

October 18, 2014