Graph2Font (G2F): Converting and Building Atari Pictures in Character Modes

A full-screen ANTIC mode 4 picture of coloured squares in red, green and teal on black, crossed by diagonal striped characters

Graph2Font, almost always called G2F, is the Windows program behind a large share of modern Atari 8-bit title screens, demo pictures and game graphics. Its trick is to treat a picture as a grid of character cells. Instead of a 7,680-byte bitmap, you get a redefined character set or two plus a screen of character codes, with display list interrupts adding colours line by line, and player/missile overlays if you want them. The results look like bitmaps but use less memory and can be scrolled, animated and mixed with text like any character screen.

What you'll learn: what G2F is and where it came from, the screen modes and effects it handles, a practical workflow from PC image to Atari screen, the export formats, the known quirks, and two ways to use the output in your own program, one of them a tested MADS loader for the raw font and screen files.

What you need: Graph2Font (Windows, from g2f.atari8.info), an image editor such as GIMP, Altirra or atari800, and MADS for the loader. The character-mode background is in Redefined Character Sets and ANTIC Modes 4 and 5, and DLIs are covered in Display List Interrupts.

1. What G2F is

G2F is tebe's program. Tomasz Biela of Mad Team, who also wrote the MADS assembler and the Atari Interlace Studio converter, develops it and fixes its bugs. It started as a tool for converting graphics into characters, and grew into a full editor for multicolour Atari graphics. It works on the image in fields of 4×8, 2×8 or 8×8 pixels, the shapes of a character in the different modes. Its documentation was translated into English by Dracon and Miker, and the program was already well known on AtariAge by 2007. Version 4.0.2.3 was in use by 2019.

It has become a standard. Party pictures made with G2F go back at least to the Forever 2007 compo. Entries at Silly Venture, Lost Party and the Atari Last Party in the 2020s are routinely catalogued with "Graph2Font" as their picture format. Game developers use it for title screens, fonts and tiles.

2. What it can do

  • Character-mode pictures. Import a PC image (PNG and similar) and G2F splits it into characters, finds the unique ones and builds the font(s) and screen. Most often this is ANTIC mode 4 (BASIC GRAPHICS 12): 4×8 cells with two bits per pixel and four colours plus the inverse-character fifth colour. It also handles hi-res characters (ANTIC 2), and characters drawn in the GTIA modes, where each character becomes two 16-shade pixels wide.
  • More characters than one font. One font has only 128 characters, which isn't enough for a detailed full-screen image. G2F can switch character sets down the screen, and its JGP+ option (Options → JGP+ → Charset 2..8) builds pictures from two to eight sets.
  • Rasters. You can change colours on each scan line and even the GTIA mode between lines (for example GRAPHICS 9 and 11 lines interleaved, APAC-style). G2F generates the DLI code for you.
  • Player/missile overlays. Players can add colour on top of the playfield, including over hi-res areas. Image → Convert to PMG turns image data into player shapes.
  • Limits for your program. Special → Limitations → First Char / Last Char keeps a range of characters free, for example for your game's text.
  • Other formats. It converts a PNG to a MIC bitmap (raw ANTIC screen data with the colour registers appended), and it can put out other formats and pieces of the converted data.

It is not an automatic one-click converter. Users who expected one have given up on it. It's best understood as an editor that does the tedious bookkeeping (unique characters, colours per line, DLI timing) while you make the artistic decisions. For fully automatic conversion of photographs to static screens, RastaConverter produces better results at a much higher memory and CPU cost. G2F is the better fit for game screens.

3. A practical workflow

  1. Prepare the image on the PC. Scale it to the target resolution (160 pixels wide for mode 4, with pixels twice as wide as they are tall), adjust contrast and reduce it to an indexed palette in your image editor. A common split is Photoshop or GIMP for sizing and colour indexing, and G2F for producing the Atari version.
  2. Import into G2F and pick the mode. Watch the character count. If it goes over 128 per set, simplify the image, use more sets, or let areas repeat. A single all-black character can cover a lot of screen.
  3. Assign colours per line where the picture needs more than the mode's four or five.
  4. Test in an emulator. Turn off artifacting for hi-res work unless you're designing for it. Compare PAL and NTSC: colours differ, and pictures are often tweaked separately for each.
  5. Export in the form your project needs (next section), and keep the .g2f project file. It's what other G2F users can open and edit, and it's commonly posted alongside finished XEX files.

4. Export formats

Output What you get Notes
Executable (XEX) A self-contained viewer Optional compression. Built for 64K XL/XE machines
MADS assembler source Several files: the main .asm with display list, DLIs and data, plus helpers such as a .fad fade routine Include in your own MADS project
Mad Pascal (.PAS) Display list, resource file and DLI program Save As… with Mode = DLI
Raw data .fnt character set(s) and .scr screen codes For your own display code
MIC Bitmap screen data plus colours For bitmap-mode engines

Two things to know about the executable:

  • It needs 64K. The generated program switches the OS ROM out and installs its own NMI handler in the RAM at $FFFA, which gives its DLIs a few extra cycles. It does this for every picture, so G2F executables don't run on a 48K Atari 400 or 800, even when the picture itself would fit. To support those machines, export the assembler source and change the code that loads into RAM under the ROM.
  • It stores the whole screen. Every character code is stored, blank or not, and unused parts of the fonts are padded with zeros. The compressed option shrinks this a lot. One logo went from about 3.5 KB to 1.45 KB. Hand-trimming unused lines, or a packer such as ZX02, can do better still.

5. Using G2F output in your own program

Route 1: include the generated MADS source

The generated source defines a main procedure. A common approach is to wrap each picture in its own MADS .local scope, so that the labels of several pictures can't collide, remove or move the generated start-up and run lines, and call it:

        .local title_g2f
        icl 'title.asm'         ; the file exported by G2F (edited copy)
        .endl

        jsr title_g2f.main      ; show the picture

Keep your edits in a copy of the exported file, so that re-exporting doesn't wipe them out. With some G2F and MADS versions, a generated line such as mva #@dmactl(standard|dma|lineX1|players|missiles) dmactl fails with "Undeclared label STANDARD" when the code is inside a .local. Replacing the expression with a plain value fixes it.

Route 2: raw font and screen with your own display list

If you only need the picture and want full control (no OS replacement, 400/800 compatible), export the raw character set and screen and display them yourself. This complete loader was tested with a 1,024-byte font and a 960-byte (40 × 24) screen file:

; show.asm - display a character-mode picture from raw .fnt and .scr files
; build: mads show.asm -o:show.xex
SDMCTL  = $022F
SDLSTL  = $0230
CHBAS   = $02F4         ; shadow of CHBASE
COLOR0  = $02C4         ; COLOR0-COLOR3 = 708-711, COLOR4 = 712

        org $2000
start   lda #0
        sta SDMCTL              ; screen off while switching
        lda #<dlist
        sta SDLSTL
        lda #>dlist
        sta SDLSTL+1
        lda #>font
        sta CHBAS
        ldx #4
setcol  lda colors,x
        sta COLOR0,x
        dex
        bpl setcol
        lda #$22                ; normal playfield + display list DMA
        sta SDMCTL
        jmp *                   ; your program continues here

colors  dta $28,$C8,$96,$0E,$00 ; COLOR0..COLOR3, then COLOR4 (background)

dlist   dta $70,$70,$70
        dta $44,a(screen)       ; ANTIC mode 4 + LMS
        :23 dta $04             ; 23 more mode 4 rows (24 in total)
        dta $41,a(dlist)

        .align $400             ; a font must start on a 1K boundary
font    ins 'pic.fnt'
screen  ins 'pic.scr'           ; one byte per character cell, row by row

        run start

Adapt it to your export: set the number of mode 4 rows to the screen file's length divided by 40, copy the colour values G2F shows into colors, and add the DLIs (or copy them from the generated source) if the picture changes colours or fonts down the screen. In mode 4, a screen byte with bit 7 set draws pixel value 11 in COLOR3 instead of COLOR2, so inverse characters are a free fifth colour. If the screen data would cross a 4K boundary, split the display list with a second LMS.

For cartridges or tight memory, the screen data compresses well. G2F screen files are full of repeated bytes and rising runs of character codes ($06,$07,$08…). The GlurkRLE scheme, with an 80-byte ROM-safe decoder, was designed for exactly that (see GlurkRLE: A ROM-Friendly Compressor Tuned for Graph2Font Screens).

Troubleshooting and known quirks

  • The XEX shows nothing on a 400/800. It needs RAM under the OS ROM. Use the source export or the raw data instead.
  • A GTIA-mode picture is offset by a couple of pixels. One GTIA pixel equals four hi-res pixels, and G2F's preview doesn't model the GTIA mode 10 pixel shift used by HIP, RIP and TIP pictures. Check positions in an emulator.
  • Overlaps look wrong with PRIOR = 0. A preview bug in this case was reported for version 4.0.2.3. Again, trust the emulator.
  • Too many characters. Reduce detail, reuse characters, enable more character sets, or reserve fewer with the Limitations settings.
  • Label errors in MADS. Wrap each included picture in its own .local and fix any generated enum expressions as described above.

Further reading

  • The Graph2Font website, g2f.atari8.info: downloads, documentation and a gallery, including hi-res pictures with P/M overlays.
  • De Re Atari (Atari, Inc., 1982), chapters on ANTIC character modes, display list interrupts and player/missile graphics.
  • Mapping the Atari by Ian Chadwick (COMPUTE! Books): CHBAS (756), the colour registers 704–712 and PRIOR.
  • AtariAge's 8-bit programming forum, where many posters attach the .g2f project with their XEX. Opening them is the quickest way to learn the program.
  • On this site: Atari Graphics File Formats (MIC and other formats) and Charset Switching with DLIs.

Credits