Low Resolution Graphics mixed with ROM font text
localroger
Posts: 3,452
I realized for this project I am targeting that I needed some simple graphics, but I wanted to use the ROM text font to save RAM. All of the graphic objects are horribly expensive in RAM. I found some code from days past for using user defined bitmaps with tv_text, but the resolution was way too fine and while they looked beautiful they ate RAM like mad. So it was time to learn PASM anyway...
This driver uses the ROM font to display 13 lines of 32 characters. I had to increase the hx from 4 to 5 to get enough time to run the code without missing waitvids. Starting at character code 256, it displays 8 by 8 bit characters bitmapped from $7FF8 down, so you don't have to declare how many characters you want to use; just reserve enough _stack for your maximum. The attached demo shows custom borders, 7-segment numbers mixed with normal text, and flicker free animation in a bitmapped field. The entire demo comes in at about 1400 longs, plus whatever bitmaps you want to define. The naked driver itself requires 1,039 longs, including the screen tile map.
In order to pull this off I had to create a 256 long table mapping 8-bit patterns to 32-bit patterns; I tried several other approaches but nothing else was fast enough even with hx stretched. At first this seems insane but it's not so bad because, if this were a true 8-bit tile machine incapable of using the ROM font, I'd need an 8-bit character font. 256 chars x 8 bytes = 2048 bytes or 512 longs, twice as much as my table takes. Even if you create a short table of only 128 chars it's a wash. And it lets you display the good looking ROM font along with simple graphics that don't take half the hub RAM.
I'd be interested if one of the PASM gurus could find a way to make it work at 40 characters, but it's not that important; this is for a display that doesn't need as much text as possible crammed in. It should work well with greater vx and hx, and it might even be amenable to the trick that ORs two ROM lines together per scan line, but there is an extra decision requiring 8 cycles before the ROM mapper can get to work and I haven't tried it.
I have included some simple tested graphics functions, but it's not compatible with the fast graphics package because the tiles are only 8 bits wide and not reversed.
Comments and suggestions appreciated; I'll put this in the obex if it looks useful to anyone else.
This driver uses the ROM font to display 13 lines of 32 characters. I had to increase the hx from 4 to 5 to get enough time to run the code without missing waitvids. Starting at character code 256, it displays 8 by 8 bit characters bitmapped from $7FF8 down, so you don't have to declare how many characters you want to use; just reserve enough _stack for your maximum. The attached demo shows custom borders, 7-segment numbers mixed with normal text, and flicker free animation in a bitmapped field. The entire demo comes in at about 1400 longs, plus whatever bitmaps you want to define. The naked driver itself requires 1,039 longs, including the screen tile map.
In order to pull this off I had to create a 256 long table mapping 8-bit patterns to 32-bit patterns; I tried several other approaches but nothing else was fast enough even with hx stretched. At first this seems insane but it's not so bad because, if this were a true 8-bit tile machine incapable of using the ROM font, I'd need an 8-bit character font. 256 chars x 8 bytes = 2048 bytes or 512 longs, twice as much as my table takes. Even if you create a short table of only 128 chars it's a wash. And it lets you display the good looking ROM font along with simple graphics that don't take half the hub RAM.
I'd be interested if one of the PASM gurus could find a way to make it work at 40 characters, but it's not that important; this is for a display that doesn't need as much text as possible crammed in. It should work well with greater vx and hx, and it might even be amenable to the trick that ORs two ROM lines together per scan line, but there is an extra decision requiring 8 cycles before the ROM mapper can get to work and I haven't tried it.
I have included some simple tested graphics functions, but it's not compatible with the fast graphics package because the tiles are only 8 bits wide and not reversed.
Comments and suggestions appreciated; I'll put this in the obex if it looks useful to anyone else.
Comments
I like the balls in the demo also ; )
Rick
I'm thinking of writing a few functions that will use the ROM font or have a custom font in 8x8 or 8x12 format.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jim Fouch
FOUCH SOFTWARE