=== Program Description ===

Contents

1. General
  1.1. Legal Stuff & Contacting the Programmer
  1.2. About & Features of AFX Image

2. Program components
  2.1. Command Box, Source and Destination window
  2.2. Filter Box
  2.3. "Buffers + Colors" Sheet
    2.3.1. Backgound
    2.3.2. Color modes
    2.3.3. Color stabilisation
    2.3.4. Dithering
    2.3.5. Buffer layout
  2.4. "Special + Output" Sheet
    2.4.1. Tiles
    2.4.2. Sprites
    2.4.3. Output formats & options

3. Format overview

4. Tutorials
  4.1. Animating images
  4.2. Creating Fonts
  4.3. Generating CFX Images
  4.4. Generating MLC Images
  4.5. User defined emulation sequences
  4.6. Gamma filter

5. Special Thanks


1. General

1.1. Legal Stuff & Contacting the Programmer

AFX Image is freeware, feel free to copy and distribute it like you want. It comes with absolutely no warranty, use is on your own risk!!! There are no known bugs or problems at the moment, but if you encounter any, I would be pleased if you tell me. Also suggestions are welcome every time.

My Email address(es):

AFX Image homepage:

See it also in the UCF File Sharing Area


1.2. About & Features of AFX Image

AFX Image is a PC program that creates images for AFX Add Ins (usable with every common AFX graphics engine + supporting special DynaGFX engine features such as Dynamic Color Emulation, RLE compression, image animation and fonts) as well as CFX pictures and images for MLC programs.



Features of Version 2.0:

2. Program components

2.1. Command Box, Source and Destination window



"Source" shows the original image, "destination" the one transformed and filtered due to your settings. Resize them by dragging the bar in the middle, select a background color by clicking somewhere onto the source (see Background). Destination will be updated automatically any time you load a new image or change one of the transformation settings.

  • Load Src: Load new source from a file (BMP)
  • Insert Src: Insert source from clipboard

  • Copy Dst: Copy destination to clipboard
  • Store Dst: Saves destination to a file (BMP)
  • Export Dst: Exports destination with the selected output options

2.2. Filter Box



Changing one of these filters will update the destination automatically. The middle of a filter bar means 0, negative the upper and positive to lower half.



Not really a filter, just adjusts the source/destination zoom.



Brightness filter



Contrast filter and contrast trigger. The trigger will have effect only for contrast <> 0, as it selects it's threshold. By default, threshold is 0.5 = middle grey meaning that differences in R/G/B levels from 0.5 will be scaled by the contrast factor. Changing the trigger top to bottom will make the contrast threshold descending from white to black.



Separated R/G/B lightning levels fading in/out R/G/B channels



Resets a filter to 0



Calls the gamma filter dialog

2.3. "Buffers + Colors" Sheet

Any change of this sheet's settings makes the destination being updated automatically.



2.3.1. Backgound

When checking the "Create BK" box, AFX Image will create an additional background layer. All source pixels wearing the transparency color represented by the panel above will become invisible in the destination then.

Select the transparent color either by clicking the panel to open a color dialog or by clicking somewhere into the source.

2.3.2. Color modes

  • RGB: Shows destination in true color RGB mode, only with filters applied. You can't export the image in this mode, but save it to BMPs only. If you don't want to generate an image for your calc but just want to apply some filters to a photo or something, you could use this mode.
  • RGB/Grey CFX: CFX RGB - and Grey scale oriented color modes (see Generating CFX Pictures)
  • BW 1/1: Native AFX BW mode (2 colors, 1 layer)
  • Grey 1/2: Native AFX grey scale mode (3 colors, 2 layer)
  • 4 Colors 3/2: DynaGFX 4 color mode (4 colors, 2 layers, 3 emulation cycles). It's compatible with 4nic8's 4 Colors Patch V. 2.0
  • 5 Colors 2/3: DynaGFX 5 color mode (5 colors, 3 layers, 2 emulation cylces). Compatible with Orwell's gxLib 1.0

2.3.3. Color stabilisation

This is an idea by Orwell how to avoid flickering in color emulation modes. For modes with n layers but less than 2^n colors, there are some colors with more than one way how to represent them (because you have 2^n combinations pixel on/off for each layer in spite off).

If we use two alternating representation methods for the same color pixel for pixel now (for the colors where this is possible at least), the result will be much better as the alternating pixels don't flicker synchronously. Thus, the whole surface's effective error caused by flickering consisting of more than one pixels will be the average of that pixels currently flickering and those that don't.



(consider the alternating pixels representing the same color in different ways)


For modes > 4 colors you always should check the "Use stabilisation" box, for modes <= 4 colors this makes no sense (as 2 and 4 color modes don't support it anyways, and 3 colors do but have an empty emulation sequence; 2 and 3 colors are native modes).

2.3.4. Dithering

AFX Image uses dithering to adapt a destination pixel's color the best possible way to a source pixel in current color mode. Dithering is very usefull when you want a picture to look as "real" as possible as it simulates more color steps then actual available (though it has nothing to do with color emulation technics). Using too much steps however looks crappy and sometimes it's even better to do it without dithring at all (especially for small images).

Dithering works with all color modes, even with user defined emulation sequences. Note, that CFX RGB mode supports 0, 1 and 3 steps only.

This is an example what an image in 3 color mode looks like with 0, 1, 3, 7 and 15 dithering steps:



2.3.5. Buffer layout


There are two different ways how to arrange the bytes in an image buffer, called Row and Column buffer layout

AFX Image supports both. Row layout (used by graphic modes D3 and DB of your calc) is much easier to handle for graphics engines and more usual therefore. But if you want to create images for graphic modes C3/CB or when generating CFX Pictures, you have to use Column layout.

2.4. "Special + Output" Sheet

Changings you make in this sheet will not be visible in the destination (though they are there), as they don't affect the image itself but output format/options, Font Creation/Image Animation, Sprites and Tiles only.



2.4.1. Tiles

AFX Image supports generating lists of images called "tiles" from one single image. This is a very usefull feature as it's much easier to handle a list with 20 images than handling 20 images separated, and it's also easier to make one big bitmap file and load it into AFX Image than creating 20 small files and process them seperated. Furthermore, Font Creation and Image Animation are based upon tiles.

Cut an image into tiles just by filling in either the "Tile Cols" (number of tiles per line) or "Tile Width" (width of a tile in pixels) box, the same for either "Tile Rows" (number of tiles per column) or "Tile Height" (height of a tile in pixels). Note that tile dimensions * tile count have to match the original image dimensions (e.g. you can't divide a 200x31 pixel image into 11x2 tiles).



The screenshot shows xamples\bomberman_2.bmp 288x48 pixels divided into 12x2 tiles


2.4.2. Sprites

You know the AFX calculator uses layer graphics where a pixel on the screen is represent by multiple layers "overlapping" each other, and within a layer a pixel represented by one bit only. Thus, a byte of a layer effects 8 pixels, but when copying image data to a layer we usually have to do this byte aligned and therefore can display an image on the display "8 pixel aligned" only (==> x=0,8,16,..., but not x=3,17,9,...).

Though there are two ways how to display an image at non - byte aligned positions: the first (called "scrolling")is to shift the image pixel for pixel (bit for bit) during runtime and move the shifted bits to the layers then. Both steps can be combined into one with special NEC V30 instructions "Ext", "Ins" very easily (DynaGFX for example supports scrolling using Ext/Ins).

Nevertheless, scrolling works slower than moving data directly/byte aligned into a buffer. Therefore the second method is to prepare several shifted versions of an image (2,4 or 8) pre runtime already and choose one of these versions each time the image is to be drawn during runtime, depending on the required x position. This of course takes more memory than the first method, but it's suggested for games needing high performance or that use engines not supporting scrolling. Note: it's called "sprites" because it's usually used for moving things such as the hero of the game, enemies and so on.

Select an item of the "Sprites" box in order to use the second method and prepare shifted images. If your picture consists of more than one tiles, it's applied to all of them.

  • Create 1/8: Don't prepare shifted tiles. You can display a tile at x=0,8,16,... only
  • Create 2/8: Create a copy shifted by 4 pixels. Tiles can be displayed at x=0,4,8,12,... , but take twice the memory
  • Create 4/8: Create 3 copies shifted 2,4 and 6 pixels (==> x=0,2,4,6,8,...)
  • Create 8/8: Tiles can be displayed at any x position, but image takes 8 times that memory total

2.4.3. Output formats & options

AFX Image provides the following output formats:


  • AFX Image: Stores the image buffer into a binary file. With "Write Header" checked, it's a special DynaGFX image supporting DynaGFX specific things like RLE, Font, Animation, ... . When "Append file" checked, an existing DynaGFX or binary file will not be overwritten but the additional data just added. DynaGFX files have an additional file header for it describing count, positions and sizes of the contained images
  • Pascal/C/Assembler source: Stores the image buffer (and the header when "Write Header" checked) into a textfile with Pascal, C or Assembler syntax. When "Append file" checked, an existing text file will not be overwritten but expanded by the additional source
  • CAT/MLC: Stores the image buffer into a CAT file with a Basic program containing MLC source code. Background layer, tilesizes 8x8 and 16x16, tiles and 2, 3 and 4 color mode supported. Other modes, sprites, font and image animation, header and RLE compression are not supported. When "Append file" checked, AFX Image will add a new Basic program into an existing CAT file
  • CAT/Picture: Stores the image into a CAT file containing a 4 color picture for CFX series. Tilesize 128x64 and CFX RGB/Grey modes supported, background layer, multiple tiles and all other things are not.

For CAT/MLC and CAT/Picture formats there are however some things you have to take a look for. See Generating MLC - and Generating CFX Images therefore.

3. Format overview

A quick overiew of what single formats do support. Note, that AFX Image even is able to link combinations declared as "not supported" here (such as CAT/Picture in 7 color mode), but they will not work on your calc then.

AFX Image/
Pascal/C/Assembler source
CAT/MLCCAT/Picture
Transparent color: Yes Yes No
BW, Grey, 4 color mode: Yes Yes No
DynaGFX color modes: Yes No No
CFX RGB/Grey modes: No No Yes
Buffer layout: Rows/ColumnsRowsColumns
More than 1 tiles: Yes (up to 255) Yes No
Tile size:Any (up to 255x255)8x8 and 16x16128x64
Sprites Yes No No
Font Yes No No
Animation Yes No No
RLE compression Yes No No

4. Tutorials

4.1. Animating Images

Step 1:

Animation is based upon Tiles: a certain tile of an image is drawn at a certain point of time. That calls "an event". The count of events may differ from the count of tiles, an animation sequence is a list of events. When the list's end is reached, it begins again from the start (the animation sequence is repreated; using DynaGFX animation routines on your calc however you can disable auto repeat).

This tutorial will use xamples\bomberman_2.bmp as example. Load it into AFX Image and select RGB color mode (we don't need to export it). This is what you'll see in source and destination window then:



Step 2:

Divide it into 12x2 tiles:



Step 3:

Now click the "Edit Assign Table" Button within the "Image Animation" box



The following dialog box will appear:



"VAM program" contains the event list, where one line is one event (the lines first argument is the tile's list index, the second the duration of the event in sec/50). However, space chars and empty lines are allowed.

Clicking at a tile causes an event to be added to the VAM program at current cursor position, the duration is set to contents of "Default delay in 1s/50" (you may change this). Of course, you also can edit the program manually (click into the program box) and load or store it to a textfile.

"Machine status" always shows you the state of the animation sequence (press "Play" button to initialize it; it's destroyed each time the program contents changes). The box shows you the actual time, current event index (Step#) and current event. Current tile is drawn in "VAM Surface" (that's what you see on your calc later).

The Buttons: Play, Pause, Stop = trivial, "Next Time" to increment the timer by one if animation is paused and "Next Step" to cause the sequence's next event.

Step 4:

When satisfied with your animation sequence, press "OK" button and back in the main program check "link animation data" on the "Special + Output" sheet. Exporting the image, it'll contain the animation sequence then.

Example 1: Running Bomberman

Example program stored in xamples\ani_bomber_1.txt

Example 2: Fast running Bomberman

Example program stored in xamples\ani_bomber_2.txt

Example 3: Bomberman doing various things

Example program stored in xamples\ani_bomber_3.txt

I won't explain it, Bomberman's doing various actions now. Just try it.

4.2. Creating Fonts

Fonts also are based upon tiles, where each entry of the ASCII table is associated with a tile index representing the char. Note that there are monochrome fonts that you can draw in each color you want during runtime (use BW mode without background layer), and fonts consisting of more layers (-> more colors) but you can't change color during runtime.

Step 1:

Load xamples\font_8x8.bmp containing 44 8x8 chars that our example is dealing with



Select "Special + Output" Sheet and enter tile dimensions 8x8 so that you see each char as a seperated tile in the source window.

Step 2:

Click the "Edit Assgign Table" button within the "Font" box. A dialog box will appear:



Step 3:

Select an index of the "Charset" list and either empty it or click a tile you want to associate with it. Do this with all chars you want to be part of your font and press "OK" button then.

Concluding, check the "Link font data" box in the "Special + Output" sheet. Exporting your image, it'll contain the charset association data.

4.3. Generating CFX Images

This is not very different from generating Images for AFX Add Ins. Just select "CAT/Picture" for output format and load an image that is 128x64 pixels in size. Disable background layer, multiple tiles and sprites and select "Column" for buffer layout. You may not use Font, Animation and RLE compression, check "Write Header" though.



Color modes supported by CAT/Picture format are "RGB CFX" and "Grey CFX" only, as CFX series has a "real" color display with white, orange, green and blue displayable. (Additional, BW 1/1 mode is supported for CFX BW images).

Grey CFX ("brightness-correct") mode:

This mode assumes light grey to be displayed as orange on the CFX screen, dark grey as green and black as blue. It considers the brightness levels of a pixel only and ignors the real colors. Grey CFX mode supports up to 15 dithering levels.

RGB CFX ("color-correct") mode:

This mode doesn't ignore the colors, red will be displayed as red, green as green and so on. It considers the absolute difference of R/G/B channels combined and takes the nearest color. However, the single pixel's lightning levels therefore will not match that exact as in Grey CFX mode. RGB CFX Mode supports 0, 1 and 3 step dithering only, as this works by antoher medthod than in all the other modes.

The screenshots below show original images and what they look like in RGB CFX and Grey CFX mode:

OriginalGrey CFXRGB CFX











Just transmit the produced CAT files to your Casio CFX using FA-123 or another comm software. In folder xamples you have the prepared examples bomberman_grey.cat and bomberman_rgb.cat

Note: AFX Image requests you to select a CFX palette. That has no effect except the form how destination is displayed. The CAT files produced are exactly the same though. "Virtual palette" is what CFX screenshots usually are presented like: ret, green, blue. "Real palette" is what you really see on your CFX: red in fact is orange, blue is dark blue.

4.4. Generating MLC Images

The only thing you have to watch out for here is that only color modes BW, Grey and 4 colors and tile sizes 8x8 and 16x16 are supported. Furthermore sprite creation, animation, fonts and RLE are unavailable, the rest is the same as for Add In Images (e.g. multiple tiles and a transparent color are supported).


8 16x16 MLC tiles in xamples\bomber_items_mlc.cat

4.5. User defined emulation sequences

Read the chapter about Color modes first of all and select "User sequence" for color mode. Click "Edit Sequence Table" within the color modes box to edit your emulation sequence (Note: it won't hurt for it when you know how color emulation sequences work at all. Read HERE). A dialog box will appear:



Enter your sequence into "Buffer Sequence" box and select the mode it's ought to be used on your calc. Press "Process" button to apply it.

AFX Image automatically will make all calculations necesarry to build the color mode: Count of colors, buffers and layers used ("Overview" box), layer allocation in memory and their values ("Subdivision" and "Layer values" boxes) as well as generation of primary and secondary color palettes ("Colors" box; secondary palette is used for color stabilisation).

You also can load/save color emulation from/to files, some predefined color modes are stored in Emu folder already. A bonus: the file format also can be read by DynaGFX engine. Thus, you don't need to integrate user defined color emulation sequences directly into your AFX programs, but you just need to lood an emulation file created by AFX Image during runtime :-)

4.6. Gamma filter

Lightning levels of different devices are not scaled equal sometimes. Maybe for one device the real lightning level rises with a square function, linear for the other and so on. For example the data a scanner delivers always is passed through a gamma filter before stored to a PC. Also some display drivers have gamma filters integrated.

Well, the lightning levels of a PC screen and that of the calc (when using 4 or more colors) appeared me not to be equal, as colors in the lower black and the upper white area seem to be closer each other than in the middle grey. That's why I added a gamma filter to AFX Image, though I rarely use it now :-/

If you want to use it, click the "Gamma" button in the filter box to see the following dialog:



"Gamme Curve" window displays the function used to translate PC into calc scale and vice versa. Click one of the buttons or within the curve window directly to change it (I believe that cosine is the function matching the most exactly). When "Use gamma correction" box checked, gamma filter will be applyed to the image. As for your "Generate ~ from ~ view" selection:

Generatefrommeans
CalcPC viewnormal appliance of the filter: source image is assumed to be a PC image, destination a calc image. AFX image will perform a PC scale to calc scale translation
PCPC viewsource is assumed to be a PC image, destination too. Thus, no gamma appliance.
PCcalc viewperforms a calc scale to PC scale translation

5. Special Thanks

Special Thanks to:

Orwell (Julien Patte)
Yuri Shaeffer
Epic Programming Studios
Oliver Coupelon