Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
hello, good day.
how can you change the character pointer to another address to create new characters?
I want to change all characters.
greetings
Posts: 1,811
Threads: 56
Joined: Aug 2019
Reputation:
25
You can use UDG as always, or use the normal CHARS ptr.
CHARS ptr is a ROM variable that must point to Address of your chars - 256.
You can declare an UInteger variable to be mapped to CHARS (23568)
Code: DIM CHARS As UInteger AT 23568
Now you can read and set this variable to point to your new char table with
Code: CHARS = Myaddress - 256
---
Boriel
Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
hello, thanks for the help.
what do I have to write now so that I can change the character "K"?
thanks.
greetings
Posts: 1,811
Threads: 56
Joined: Aug 2019
Reputation:
25
To change only the character "K" I suggest to use UDG (User Defined Graphics).
If you compile with the --sinclair option, the compiler will enable several features at once, to maximize compatibility with Sinclair's ROM BASIC.
Then you can POKE at USR "k" + i, using READ and DATA:
Code: FOR i = 0 TO 7
READ a
POKE USR "k" + i, a
NEXT i
REM PRINT the UDG "k"
PRINT "\K \K"
DATA 85, 170, 85, 170, 85, 170, 85, 170
Please read here about using UDGs:
https://zxbasic.readthedocs.io/en/docs/syntax/
---
Boriel
Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
12-08-2024, 01:02 PM
(This post was last modified: 12-08-2024, 01:04 PM by funkheld.)
hello, good day.
why is the letter "Y" not ok?
number_y:
DATA 129,129,129,129,129,129,129,129
greetings
Code: cls
RESTORE number_h
FOR i = 0 TO 7
READ a
POKE USR "h" + i, a
NEXT i
RESTORE number_k
FOR i = 0 TO 7
READ a
POKE USR "k" + i, a
NEXT i
RESTORE number_y
FOR i = 0 TO 7
READ a
POKE USR "y" + i, a
NEXT i
PRINT "\H \H"
PRINT "\K \K"
PRINT "\Y \Y"
number_h:
DATA 255, 129, 129, 129, 129, 129, 129 ,255
number_k:
DATA 85, 170, 85, 170, 85, 170, 85, 170
number_y:
DATA 129,129,129,129,129,129,129,129
Posts: 1,811
Threads: 56
Joined: Aug 2019
Reputation:
25
funkheld Wrote:hello, good day.
why is the letter "Y" not ok?
ZX Spectrum UDGs are available only until letter "U".
If you need more graphics, you will have to use normal chars PTR, which is the 1st method I described.
I think this is already answered here in the forum somewhere (you have to set CHARS ROM var to the address of your data minus 256). This process is a bit more convoluted, if you don't have experience doing it.
---
Boriel
Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
12-12-2024, 07:26 AM
(This post was last modified: 12-12-2024, 07:27 AM by funkheld.)
hello, thanks for the help.
maybe you can explain the complicated stuff about the characters to me?
at 76 I still want to learn something new.
(you have to set CHARS ROM var to the address of your data minus 256)
zx-basic can asm.
thanks.
greetings
Posts: 1,811
Threads: 56
Joined: Aug 2019
Reputation:
25
12-12-2024, 08:55 AM
(This post was last modified: 12-12-2024, 08:55 AM by boriel.)
funkheld Wrote:hello, thanks for the help.
maybe you can explain the complicated stuff about the characters to me?
at 76 I still want to learn something new.
(you have to set CHARS ROM var to the address of your data minus 256)
zx-basic can asm.
thanks.
greetings
ZX Spectrum ROM uses some variables (System Variables, see https://skoolkid.github.io/rom/buffers/sysvars.html).
The variable CHARS (at position 23606, UInteger) points to the ROM charset used to print the text font. You can change this to point to another location and use our own font (or custom graphics) the same way as UDG. The only difference is that CHARS points to the position minus 256.
Also, unlike UDG, you need to reserve a block of memory to store these new fonts, and you can use an array of Ubytes for that. For example:
Code: DIM chars_ptr As UInteger AT 23606: REM declares a variable mapped to CHARS
DIM original_value As Uinteger
REM declare 5 characters (8 bytes each)
DIM graphic_data(5 * 8) => {
254, 0, 0, 254, ... _
253, 0, 0, 253, ... _
...
}
LET original_value = chars_ptr: REM save original value, which should be 15360
LET chars_ptr = @graphics_data(0) - 256: REM new position of the 1st char minus 256
PRINT PAPER 1; INK 6;" ": REM printing a space now prints the 1st character of the new charset
LET chars_ptr = original_value : REM restore ROM value to use normal charset font
PRINT PAPER 1; INK 6; " ": REM should print a SPACE now
---
Boriel
Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
hello thanks for help.
greeting
Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
12-13-2024, 10:27 AM
(This post was last modified: 12-13-2024, 10:30 AM by funkheld.)
hello, her is one error :
error is : Undeclared array " graphics_data"
thanks
greeting
----------------------
DIM chars_ptr As UInteger AT 23606: REM declares a variable mapped to CHARS
DIM original_value As Uinteger
REM declare 2 characters (8 bytes each) , graphic_data(15) = 0 to 15 is 16 byte
DIM graphic_data(15) => { 254, 0, 0, 254,255,255,255,255,253, 0, 0, 253,0,0,0,0}
original_value = chars_ptr: REM save original value, which should be 15360
>>>>>>> chars_ptr = @graphics_data(0) - 256: REM new position of the 1st char minus 256 : error
PRINT PAPER 1; INK 6;" ": REM printing a space now prints the 1st character of the new charset
chars_ptr = original_value : REM restore ROM value to use normal charset font
PRINT PAPER 1; INK 6; " ": REM should print a SPACE now
-------------------------------------
Posts: 1,811
Threads: 56
Joined: Aug 2019
Reputation:
25
funkheld Wrote:hello, her is one error :
error is : Undeclared array " graphics_data"
thanks
greeting
----------------------
DIM chars_ptr As UInteger AT 23606: REM declares a variable mapped to CHARS
DIM original_value As Uinteger
REM declare 2 characters (8 bytes each) , graphic_data(15) = 0 to 15 is 16 byte
DIM graphic_data(15) => { 254, 0, 0, 254,255,255,255,255,253, 0, 0, 253,0,0,0,0}
original_value = chars_ptr: REM save original value, which should be 15360
>>>>>>> chars_ptr = @graphics_data(0) - 256: REM new position of the 1st char minus 256 : error
PRINT PAPER 1; INK 6;" ": REM printing a space now prints the 1st character of the new charset
chars_ptr = original_value : REM restore ROM value to use normal charset font
PRINT PAPER 1; INK 6; " ": REM should print a SPACE now
-------------------------------------
Probably a typo in my code. The Array name is, if you read carefully, graphic_data (without trailing -s). :-)
---
Boriel
Posts: 30
Threads: 9
Joined: Nov 2024
Reputation:
0
hello thanks...
oh..oh...
greeting
|