News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_logiker

Read Charset from BASIC

Started by logiker, 17:47, 10 March 19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

logiker

Hi!


Is there an easy way to read (e.g. with peek) the values of the charset in BASIC?
For example I would like to get the 8 byte values of a certain character or symbol.
I know I can create my own ones with SYMBOL, but I want to read the given ones.


Thanks


Logiker

TomEtJerry

Hum, I am not quite sure of what you really want to do. If it's the ability to read system chars, it's easy to do in Basic. You just have to set a SYMBOL AFTER 32 command to put in RAM the font. Then you can read it. Little example :

10 SYMBOL AFTER 32
11 d=HIMEM+1
20 INPUT "Char to read ";c
30 PRINT
40 PRINT "Char values : ";
50 FOR i=0 TO 7:PRINT HEX$(PEEK(d+(c-32)*8+i));",";:NEXT
60 b=8:PRINT CHR$(b);" ";

The only possible "problem" is to know where is the font in memory. You need to get the HIMEM value immediatly after having set the SYMBOL buffer with SYMBOL AFTER command.

logiker

Thank you very much. That is exactly what I was looking for!

logiker

Now I am really currious how this memory stuff works. Can the address of the system chars change? Why is it so? Are the system chars just at the border after the "normal" BASIC memory?

AMSDOS

It's all to do with how HIMEM is set when the Computer is powered up. On a Disk Based system PRINT HIMEM may return a value of 42619, that's with AMSDOS in play, I'm not sure if the same is true with ParaDOS. By default though BASIC allocates a little bit of memory to Redefine the Character set, so Characters 240 to 255 can be Redefined.
If you specified that you don't want any characters to be redefined, you can type SYMBOL AFTER 256, and if you PRINT HIMEM again you will see that value is now 42747.
The problem in BASIC and the SYMBOL AFTER statement is you cannot specify where you want your Redefined Character set, unlike the Firmware equivalent, which gives you the control of where to have your Redefined Character set.
Another problem occurs when using MEMORY followed by an address, which is used to Protect any M/C routines from being overwritten by BASIC. Once MEMORY has been set, the HIMEM is set to that value, though trying to use SYMBOL AFTER will return the Improper Argument Error, the reason for this is SYMBOL AFTER places the Character Set what appears to be above HIMEM and once MEMORY has been set, HIMEM is adjusted to the value and nothing above it can be written there from BASIC.

I hope that makes sense.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

logiker

Thanks for your detailed answere! It makes sense to me.
I have one further question:
As I only want to read, I do still have to do whole procedure with SYMBOL AFTER and HIMEM, right?
That's because I can't read from the ROM but only from the copied RAM, isn't it?

AMSDOS

To my knowledge, I've only seen the ROM from inside an Disassembler written in Assembly (unless somebody else knows otherwise). The SYMBOL AFTER statement as TomEtJerry explains does place the contents of the font in RAM and has correctly assigned the variable 'd' in line 11 to point to the start of the Font in RAM.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

logiker

Thank you all for explanations and the code!

Powered by SMFPacks Menu Editor Mod