CPCWiki forum

General Category => Programming => Topic started by: bluestar on 16:46, 07 July 24

Title: Load SYMBOL from DATA (Basic)
Post by: bluestar on 16:46, 07 July 24
Hi there,

I wonder if is possible to use SYMBOL reading pixels from DATA.

10 SYMBOL 255,[pixels from line 30]
30 DATA &7,&7,&6,&1E,&0,&0,&0,&0 (or in decimal)

Thanks in advance!

PS: using only BASIC
Title: Re: Load SYMBOL from DATA (Basic)
Post by: bluestar on 17:24, 07 July 24
Ok... each pixel is a separated variable... so I can read into an array

10 DIM a(8)
20 FOR i=1 TO 8
30 READ a(i)
40 NEXT i
50 SYMBOL 20,a(1), a(2), a(3), a(4), a(5), a(6), a(7), a(8)
60 DATA 255,222,222,4,5,6,11,67


Title: Re: Load SYMBOL from DATA (Basic)
Post by: abalore on 17:55, 07 July 24
I don't know if "using only BASIC" excludes POKE, but you can poke the values right after HIMEM, being the first defined character in SYMBOL AFTER in HIMEM+1, and the rest sequentially after it:

10 RESTORE
20 DEFINT a-z
30 SYMBOL AFTER 240
40 a!=HIMEM+1
50 FOR i=1 TO 8
60 READ b
70 POKE a!,b
80 a!=a!+1
90 NEXT
100 PRINT CHR$(240)
110 DATA 255,129,129,129,129,129,129,255


The advantage of this method is you can define all your characters in a single loop. Also is a lot faster than calling SYMBOL
Title: Re: Load SYMBOL from DATA (Basic)
Post by: ZorrO on 22:26, 07 July 24
More advance?  ::)  Look there:
https://www.cpcwiki.eu/forum/programming/basic-programming-tips/msg117543/#msg117543
Title: Re: Load SYMBOL from DATA (Basic)
Post by: McArti0 on 22:36, 07 July 24
Or...

1 restore 100
10 ?chr$(25);:for i%=0 to 8:read n%:?chr$(n%);:next
50 ?chr$(255)

100 DATA 255,0,170,0,55,0,170,0,55
Title: Re: Load SYMBOL from DATA (Basic)
Post by: bluestar on 18:32, 08 July 24
Quote from: abalore on 17:55, 07 July 24I don't know if "using only BASIC" excludes POKE, but you can poke the values right after HIMEM, being the first defined character in SYMBOL AFTER in HIMEM+1, and the rest sequentially after it:

10 RESTORE
20 DEFINT a-z
30 SYMBOL AFTER 240
40 a!=HIMEM+1
50 FOR i=1 TO 8
60 READ b
70 POKE a!,b
80 a!=a!+1
90 NEXT
100 PRINT CHR$(240)
110 DATA 255,129,129,129,129,129,129,255


The advantage of this method is you can define all your characters in a single loop. Also is a lot faster than calling SYMBOL

Noted. But no POKES this time  :P
Title: Re: Load SYMBOL from DATA (Basic)
Post by: bluestar on 18:39, 08 July 24
Quote from: McArti0 on 22:36, 07 July 24Or...

1 restore 100
10 ?chr$(25);:for i%=0 to 8:read n%:?chr$(n%);:next
50 ?chr$(255)

100 DATA 255,0,170,0,55,0,170,0,55
Oh... it works nice... 
How? I mean... chr$(255)chr$(0)chr$(170)....
Title: Re: Load SYMBOL from DATA (Basic)
Post by: andycadley on 18:52, 08 July 24
Chr$(25) is equivalent to the SYMBOL command. When you print it, the next nine bytes printed will be the character code, followed by the 8 bytes that define it.
Title: Re: Load SYMBOL from DATA (Basic)
Post by: bluestar on 19:21, 08 July 24
Quote from: andycadley on 18:52, 08 July 24Chr$(25) is equivalent to the SYMBOL command. When you print it, the next nine bytes printed will be the character code, followed by the 8 bytes that define it.
Cool!
Title: Re: Load SYMBOL from DATA (Basic)
Post by: McArti0 on 20:54, 08 July 24
?"ǂ"; : REM <--- CTRL-Y on CPC keyboard equ chr$(25)
Title: Re: Load SYMBOL from DATA (Basic)
Post by: abalore on 23:06, 08 July 24
Just curious, why you want to do it with DATA? Doing with SYMBOL is just replacing one word and it's more straightforward, with no extra code required.
Powered by SMFPacks Menu Editor Mod