Loading custom character sets

Basic and Machine Language

Moderator: Moderators

Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Loading custom character sets

Post by Legacy »

Pop quiz, you need to make a custom font for the first 6 character screen codes. What do you do?

1 poke 52, 28: poke 56, 28: clr
2 for i = 7168 to 7679:poke i,peek(i+25600): next
3 poke 36869,255
10 for l=7168 to 7175:read a:poke l,a:next
20 data 60, 66, 165, 129, 165, 153, 66, 60
30 print"{clr} @ @ @ @ "
run

of course this takes care of the first character which is the @ symbol and when run turns the @ into a :), but how do you read the next 5 characters?(ABCDE) :o :shock: :o

1 free up video memory at 7168, clear it
2 move 64 characters from ROM to RAM
3 get characters from RAM now
10 7168 = @, read data for @ put into @
20 make @ = :)
30 SHIFT + CLR/HOME and then PRINT 4 smiley faces aka @ key
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

cmon guys help pleaseeee , thats what i thought this place was for! pretty please with POKES on top?
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

ok so like i need a way to load the data into the pokes , i came up with this:
1 poke 52, 28: poke 56, 28: clr
2 for i = 7168 to 7679:poke i,peek(i+25600): next
3 poke 36869,255
20 c1=7168:c2=7168+7:c3=c2+7
30 read a,b,c
35 if a=1then : end
40 poke c1,a:poke c2,b:poke c3,c
50 c1=c1+1:c2=c2+1:c3=c3+1:goto30
60 data 0,0,0,0,0,0
65 data 0,0,0,0,0,0
70 data 0,0,0,0,0,0
75 data 0,0,0,0,0,0,1
run

but now its telling me OUT OF DATA error
those are really not 0's I just dont want you guys to know my top secret character font, you understand right ?

im so close here i can smell it
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

ok so i guess what is happening here, its getting all of its data, but then it keeps adding one to the c1,c2,c3 and it keeps looking for data because it is in an infinite loop, but it shouldnt be in a loop because it reached 1 in the data array, so i have no idea where i have gone wrong
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

1 poke 52, 28: poke 56, 28: clr
2 for i = 7168 to 7679:poke i,peek(i+25600): next
3 poke 36869,255
20 c1=7168:c2=c1+7:c3=c2+7
25 for t = 1 to 7
30 read a,b,c
40 poke c1,a:poke c2,b:poke c3,c
50 c1=c1+1:c2=c2+1:c3=c3+1
55 next :goto 25
60 data 48,254,240,48,254,240
65 data 96,192,192,96,204,239
70 data 192,108,239,192,96,118
75 data 254,56,64,254,60,30
run
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

this has some unusual side effects....


1 poke 52, 28: poke 56, 28: clr
2 for i = 7168 to 7679:poke i,peek(i+25600): next
3 poke 36869,255
20 c1=7168:c2=c1+7:c3=c2+7
25 for t = 1 to 7
30 read a,b,c
35 if a=1then : end
40 poke c1,a:poke c2,b:poke c3,c
50 c1=c1+1:c2=c2+1:c3=c3+1
55 next :restore:goto 25
60 data 48,254,240,48,254,240
65 data 96,192,192,96,204,239
70 data 192,108,239,192,96,118
75 data 254,56,64,254,60,30,1
run
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

u guys want to see me go bald dont u :cry:
User avatar
Kweepa
Vic 20 Scientist
Posts: 1315
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: Loading custom character sets

Post by Kweepa »

Ignore.
Last edited by Kweepa on Mon Jan 12, 2009 6:00 pm, edited 1 time in total.
User avatar
Kweepa
Vic 20 Scientist
Posts: 1315
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: Loading custom character sets

Post by Kweepa »

Just enlarge the L loop!

Code: Select all

1 poke 52, 28: poke 56, 28: clr
2 for i = 7168 to 7679:poke i,peek(i+25600): next
3 poke 36869,255
10 for l=7168 to 7168 + 6*8 - 1:read a:poke l,a:next
20 data 60, 66, 165, 129, 165, 153, 66, 60
21 data 60, 66, 165, 129, 165, 153, 66, 60
22 data 60, 66, 165, 129, 165, 153, 66, 60
23 data 60, 66, 165, 129, 165, 153, 66, 60
24 data 60, 66, 165, 129, 165, 153, 66, 60
25 data 60, 66, 165, 129, 165, 153, 66, 60
30 print"{clr}  @ A B C D E "
run
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

I just dont understand that math, according to you equation, L's first value is 7168 which has been freed up , but the last value should be 7168 + 6 * 8 - 1 which is equal to 57,391 which is way out of the parameters of the original freed up screen memory! 7168-7679. I wish I knew the logic behind it. Maybe im not following order of operations or something. But thank you Kweepa, that did the trick, so now I have to put you in the ending credits :P
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Multiplication has precedence over addition and subtraction:

7168+6*8-1 = 7168+48-1 = 7168+47 = 7215 <- correct evaluation
7168+6*(8-1) = 7168+6*7 = 7168+42 = 7210
(7168+6)*8-1 = 7174*8-1 = 57392-1 = 57391
(7168+6)*(8-1) = 7174*7 = 50218
Anders Carlsson

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

Post by Jeff-20 »

My Dear Aunt Sally. :lol:

(and old mnemonic device from my childhood. i can't remember if someone taught me that or I made it up).
High Scores, Links, and Jeff's Basic Games page.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

By the way, if you want to define an arbitrary number of characters, this device is quite handy:

10 A=7168
20 READ B:IF B<>-1 THEN POKE A,B:A=A+1:GOTO 20
25 POKE 36869,255:PRINT"@AB"
30 END : REM OR WHATEVER
40 DATA 128,64,32,16,8,4,2,1
42 DATA 24,36,36,24,60,66,66,0
44 DATA 24,60,126,255,255,126,60,24
46 DATA -1

This program will keep reading numbers until it encounters -1, which anyway is quite illegal to use with POKE. Instead of using a FOR loop, the address in A is increased for every byte read. Alternatively one could use a counter and write 7168+A, but it doesn't improve anything more than keeping count how many characters you have defined.
Anders Carlsson

Image Image Image Image Image
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

thanks carlson now i see that it is only really adding up to 47 and since 7168 is the first value being poked that counts as 48 total or 6 data characters of 8 bytes each and will stop at location 7215, I may just have to break down and create a whole new font, but my program is not going to be using alot of text. thanks again!!!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

If you need text at all and don't care about the font, it may be good to know that with POKE 36869,255 you get access to the first half of the ROM character set by using RVS ON. That means an inverted A displays as a regular A on screen. It allows for up to 64 custom characters as well as text on screen without using more than 512 bytes of RAM.
Anders Carlsson

Image Image Image Image Image
Post Reply