Quick character editor

Basic and Machine Language

Moderator: Moderators

Post Reply
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

Quick character editor

Post by ravenxau »

While at University today, I needed to design some characters i a hurry, so i whipped this program in a couple of minutes. To use it, clear the screen and design your character in the top left corner, using the first eight rows and first eight columns, fill any pixel to be displayed with a capital 'X'. When satisfied, type run and hit return, the 8 values for a data statement will be listed.

Code: Select all

0 fory=0to7:c=0:forx=7to0step-1
1 c=c-2^(7-x)*(peek(7680+y*22+x)=24):next:printc:next
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Neat idea! You could add a PRINT"{HOME}" before the first loop and TAB(9) or so in the other print, so you get each value on respective line.

Alternatively you could concatenate the values on a row with comma signs inbetween, perhaps even prefix it with a line number and DATA so you even easier can generate the data statement.

I wonder if it would get faster using a helper variable D=D*2 instead of the 2^(7-X) calculation executed 64 times. For clarity one could also add ABS() instead of negating the equation. Otherwise I have no suggestions. :-D
Anders Carlsson

Image Image Image Image Image
TNT
Vic 20 Hobbyist
Posts: 121
Joined: Wed Apr 29, 2009 5:46 am

Post by TNT »

Running x forwards helps with clarity, IMO 2^x is more clear than using additional variable for bit weight.

Code: Select all

0 fory=0to7:c=0:forx=0to7:c=c-2^x*(peek(7687+y*22-x)<>32):next:printc:next
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

You can run x forward, avoid the 2^x without using an extra variable and remove the need for doing y*22 every time like this ..

Code: Select all

0 fory=0to154step22:c=0:forx=0to7:c=c+c-(peek(7680+y+x)<>32):next:printc:next
.. this could be made faster by putting the 7680 and 32 into variables but I don't think speed is too much of a problem in such a short program.

Lee.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

And this one even works, when screen memory has been relocated, and it prints the numbers to the right-hand side of the matrix (download):

Code: Select all

1 OPEN1,3:PRINT"{HOME}";:FORY=1TO8:S=0:FORX=1TO8:GET#1,A$:S=2*S-(A$<>" "):NEXT:PRINTS"{LEFT,2 SPACE}":NEXT:CLOSE1
8)
Last edited by Mike on Thu Feb 20, 2014 5:42 pm, edited 2 times in total.
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

Post by ravenxau »

Leeeeee wrote:You can run x forward, avoid the 2^x without using an extra variable and remove the need for doing y*22 every time like this ..

Code: Select all

0 fory=0to154step22:c=0:forx=0to7:c=c+c-(peek(7680+y+x)<>32):next:printc:next
.. this could be made faster by putting the 7680 and 32 into variables but I don't think speed is too much of a problem in such a short program.

Lee.
cool - shortened to 1 line of code. One of the criteria for the "Holy Grail" class of utility programs. Also simplified the bit calculation. I am impressed sir!
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

Cute! This reminds me of my old C64 font editor program I wrote back in the '80s. My program didn't print out values, though, it simply read/wrote the data to the font held at 14K. The screen looked like:

Code: Select all

Q
..****..
.*....*.
*......*
*......*
*......*
*......*
.*....*.
..****..
? _
The idea was to use an input statement, and either READ or WRITE based on the input. To READ a character, you typed the character you wanted to READ and pressed ENTER. That meant that A$ had non-empty input. The program would PEEK(1024+9*40+2) to figure out which character you wanted, and it would draw "." and "*" to display that character.

If you moved the cursor to a different line to make edits, though, then A$ would return empty. That meant you wanted to do a WRITE. It would PEEK(1024) to figure out which character to WRITE the data to.

This program included no instructions at all. I was the only person to ever use it. But it offered good functionality. It was easy to READ a character, slightly modify it, and then WRITE to another character. This made it easy to make an entire font, since most letters are similar to other letters.
Post Reply