New Release: Fontastic

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

New Release: Fontastic

Post by Jeff-20 »

I almost named it Fontastico! :lol: I'm sleepy now, so don't expect the description to be super clear.

Ok, before you scream "Yet Another Character Editor!," understand that this is a font editor. It is designed for creating custom fonts. It does not have the features (flip, rotate, reverse, etc.) that KingTrode's or LCE have for game characters.

Unexpanded, of course. I realized my previous efforts were incredibly inefficient. My fonts were obliged to take up 3.5k but used only 1.5 for the actual font. So, I decided to use the extra memory to house an editor in each font. I really enjoyed making them, and I hope this editor makes it fun for new fonts to be created.

Image

DOWNLOAD
Additional sample fonts are available in a subdirectory. The basic program contains no font at all.

Instructions:
1 LOAD FONT - This replaces the default typeface with a new one.
2 EDIT FONT - This allows you to modify the font currently in memory.
3 NEW FONT - This will initialize memory to start a new font (30 seconds) -recommended the first time you run the program

Save your font. When you exit the program, a program line will appear at the top of the screen, you may edit the file name and device number before executing the line and thus saving your font. The default drive is 10 (because most of us have jim brain's amazing contraption). Change the number 10 to your drive number before executing the line.

Read the instructions for less obvious features.
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Some observations:

- Releasing cursor left, or cursor up "tends" to send the cursor in the opposite direction once. This is mainly visible in VICE, and is most probably related to the way you scan the keyboard (with PEEK(197) and PEEK(653)). When I used GETA$, I didn't notice these issues.

- Similarily, FONTASTIC sometimes misses SPACE, and doesn't toggle the bit, or by bad luck you just hold it long enough to toggle it twice. You should only allow for another toggle, when SPACE had been released in-between.

Michael
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Great observations. I wanted a "quick and dirty" editor. I would prefer to use joystick for cursor controls, but I thought that would not be convenient for all users. Do you think I should use GET statements to read the keys? I worry about speed.

I felt like font creation (where you're just modifying an existing shape) was very different from unique characters for games or images. I found my self just tapping here and there, so I didn't notice the issues you described.
High Scores, Links, and Jeff's Basic Games page.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

For those of you without the time to try it, here are all the included sample fonts with names I made up for them. I really hope someone makes a really good cursive font!

Image
Aero

Image
C64 (not related to the similarly named computer)

Image
Line

Image
Digi

Image
Fat

Image
War

Image
Down - the arguably useless but surprisingly readable favorite :D
High Scores, Links, and Jeff's Basic Games page.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

These are great fonts! I feel the urgent need to write something to use them...
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Jeff-20 wrote:I would prefer to use joystick for cursor controls, but I thought that would not be convenient for all users.
Granted. This is not an action game. ;)
Do you think I should use GET statements to read the keys? I worry about speed.
Yes, GET is a good choice - unless you want to check for key combinations not covered by PETSCII.

Furthermore, all keyboard input is buffered when you use GET, so no key presses are lost. And you shouldn't be concerned about speed at that place: if you do something like:

Code: Select all

zz GETA$
   IFA$="{LEFT}"THENGOSUBxx
   IFA$="{RIGHT}"THENGOSUByy
   [...]
   GOTOzz
in a loop near the start of the program, this is fast even if you test for a dozen different keys. xx, yy, etc. are sub-routines to handle the key-presses. There's another example I've put in the thread about VIC Life. (download as part of the MG batch suite)

I'd look for other places to speed up the program. Like copying the standard ROM font, or updating the zoomed display for another character.

For the character display in BASIC, you might try something like this:

INIT - this creates a string array with binary representations of numbers in the range 0..15, i.e. "*.*." <-> 10

Code: Select all

DIM C$(15)
FORT=0TO15
C$(T)=CHR$(46+4*((8ANDT)=8))
C$(T)=C$(T)+CHR$(46+4*((4ANDT)=4))
C$(T)=C$(T)+CHR$(46+4*((2ANDT)=2))
C$(T)=C$(T)+CHR$(46+4*((1ANDT)=1))
NEXT
DISPLAY - display character with its definition at address AD

Code: Select all

FORT=0TO7
BY=PEEK(AD+T)
PRINTC$(BY/16)C$(BYAND15)
NEXT
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Very creative! How much more memory would it use compared to what I did?
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Of course my method needs some more space, but with an interesting twist - Here are two variants of my method, and yours:

Code: Select all

Example 1: (Definitions via String-concatenation)

1 DIMC$(15):FORT=0TO15:J=8:C$="":FORS=1TO4:C$=C$+CHR$(46+4*((JANDT)=J)):J=J/2:NEXT:C$(T)=C$:NEXT
2 AD=32768
3 FORT=0TO7:BY=PEEK(AD+T):PRINTC$(BY/16)C$(BYAND15):NEXT

PRINT 3583-FRE(0) -> 304 bytes


Example 2: (Definitions in DATA lines)

10 DIMC$(15):FORT=0TO15:READC$(T):NEXT
15 AD=32768
20 FORT=0TO7:BY=PEEK(AD+T):PRINTC$(BY/16)C$(BYAND15):NEXT
25 DATA "....","...*","..*.","..**",".*..",".*.*",".**.",".***"
30 DATA "*...","*..*","*.*.","*.**","**..","**.*","***.","****"

PRINT 3583-FRE(0) -> 288 bytes


Example 3: (Jeff's implementation)

10 AD=32768
15 FORT=0TO7:L=PEEK(AD+T):J=128:FORI=0TO7:POKE7680+22*T+I,46+4*((LANDJ)=J):J=J/2:NEXT:NEXT

PRINT 3583-FRE(0) -> 122 bytes
I've printed the free space after the examples had been run, to include the room needed for variables.

Your implementation also requires the colour RAM being initialised at some other place.

Example 2 is equivalent to Example 1 - but the elements of the array C$() are read from DATAs, it is their only assignment, from a constant value. In that special case, the V2 BASIC interpreter points the string array to the DATA definitions themselves!

That's the reason Example 2 needs less space overall, even though the program code for itself needs more space (212 vs. 139 bytes) - there is no duplicate copy of the strings at the end of RAM.

P.S.: And Example 2 can lose another 34 bytes by omitting the quotes around the strings in the DATA lines, and leaving out the preceding spaces.
Post Reply