How to use UDG 4 ZXpand / ZXBlast
Posted: Fri Aug 25, 2017 2:20 pm
okay over in the sales thread.... a disscusion has broken out how to use UDG in your own programs....
first we need an alternate character set to use, this could be one from the DK'tronics ROM or one that you create your self using the UDG designer or some other 3rd party tool, either way you should end up with a file on your storage device containing your chosen charcater set 512 bytes long for each 64 charset, or 1024 bytes long for each 128 charset.
once you have your charset file you now need to choose an address hwere you want to load it too, for a 64 charset this address MUST be on a 512 byte boundary, i.e 8192, 8704, 9216 ect... for 128 charsets the address MUST be on a 1024 byte boundary i.e 8192, 9216, 10240 ect... this is our Base ADDress
and we must also calculate the corresponding value for the I register that is used to point the zx81 hardware at our character set. we do this by dividing our Base ADDress by 256 ( please not that if using eightyone emulator with CHR$16 selected in hardware you will need to add 1 to this result only if using 128 charsets) so for Base ADDress 8192 you would get 32 and Base ADDress 10240 you would get 40. this is the number you need for the I register.
Changing the I register in Basic is not difficult but does require a little 5 byte MC routine. in the following example the small 5 byte long mc program is poked into line 1 by lines 2 thru 6, the value poked at address 16515 is the value used for the I register and can be changed to match our chosen Base ADDress. we then load our user defined characters at our chosen memory adress the USR 16514 call at line 10 chages the I register and now the zeddy is using our characters, the rest of our program executes normally until we reach the end where is may be preferable to switch back to the standard ROM characters we do this by poking a value of 30 ( the default value ) at address 16515 and again calling the short USR 16514 to change the I register for us.
HTH Andy
first we need an alternate character set to use, this could be one from the DK'tronics ROM or one that you create your self using the UDG designer or some other 3rd party tool, either way you should end up with a file on your storage device containing your chosen charcater set 512 bytes long for each 64 charset, or 1024 bytes long for each 128 charset.
once you have your charset file you now need to choose an address hwere you want to load it too, for a 64 charset this address MUST be on a 512 byte boundary, i.e 8192, 8704, 9216 ect... for 128 charsets the address MUST be on a 1024 byte boundary i.e 8192, 9216, 10240 ect... this is our Base ADDress
and we must also calculate the corresponding value for the I register that is used to point the zx81 hardware at our character set. we do this by dividing our Base ADDress by 256 ( please not that if using eightyone emulator with CHR$16 selected in hardware you will need to add 1 to this result only if using 128 charsets) so for Base ADDress 8192 you would get 32 and Base ADDress 10240 you would get 40. this is the number you need for the I register.
Changing the I register in Basic is not difficult but does require a little 5 byte MC routine. in the following example the small 5 byte long mc program is poked into line 1 by lines 2 thru 6, the value poked at address 16515 is the value used for the I register and can be changed to match our chosen Base ADDress. we then load our user defined characters at our chosen memory adress the USR 16514 call at line 10 chages the I register and now the zeddy is using our characters, the rest of our program executes normally until we reach the end where is may be preferable to switch back to the standard ROM characters we do this by poking a value of 30 ( the default value ) at address 16515 and again calling the short USR 16514 to change the I register for us.
Code: Select all
1 REM XXXXX
2 POKE 16514,62
3 POKE 16515,32
4 POKE 16516,237
5 POKE 16517,71
6 POKE 16518,201
7 LOAD "MYCHARS;8192"
10 RAND USR 16514
20 REM REST OF THE PROGRAM USING UDG
30
40
...
9989 REM 30 IS THE I REGISTER VALUE FOR STANDARD ROM CHARACTERS
9990 POKE 16515,30
9995 REM SWITCH BACK TO ROM CHARS
9996 RAND USR 16514
9999 STOP