![]() |
char pointer bend to another address - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13) +---- Thread: char pointer bend to another address (/showthread.php?tid=2579) |
char pointer bend to another address - funkheld - 11-29-2024 hello, good day. how can you change the character pointer to another address to create new characters? I want to change all characters. greetings RE: char pointer bend to another address - boriel - 12-06-2024 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 RE: char pointer bend to another address - funkheld - 12-07-2024 hello, thanks for the help. what do I have to write now so that I can change the character "K"? thanks. greetings RE: char pointer bend to another address - boriel - 12-07-2024 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 Please read here about using UDGs: https://zxbasic.readthedocs.io/en/docs/syntax/ RE: char pointer bend to another address - funkheld - 12-08-2024 hello, good day. why is the letter "Y" not ok? number_y: DATA 129,129,129,129,129,129,129,129 greetings Code: cls RE: char pointer bend to another address - boriel - 12-11-2024 funkheld Wrote:hello, good day. 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. RE: char pointer bend to another address - funkheld - 12-12-2024 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 RE: char pointer bend to another address - boriel - 12-12-2024 funkheld Wrote:hello, thanks for the help. 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 RE: char pointer bend to another address - funkheld - 12-12-2024 hello thanks for help. greeting RE: char pointer bend to another address - funkheld - 12-13-2024 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 ------------------------------------- RE: char pointer bend to another address - boriel - 12-13-2024 funkheld Wrote:hello, her is one error : Probably a typo in my code. The Array name is, if you read carefully, graphic_data (without trailing -s). :-) RE: char pointer bend to another address - funkheld - 12-13-2024 hello thanks... oh..oh... greeting |