Author Topic: Read Charset from BASIC  (Read 1331 times)

0 Members and 1 Guest are viewing this topic.

Offline logiker

  • CPC464
  • **
  • Posts: 33
  • Country: sc
  • Liked: 23
  • Likes Given: 4
Read Charset from BASIC
« on: 18:47, 10 March 19 »
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

Offline TomEtJerry

  • CPC6128
  • ****
  • Posts: 185
  • Country: fr
  • Liked: 123
  • Likes Given: 0
Re: Read Charset from BASIC
« Reply #1 on: 20:06, 10 March 19 »
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.

Offline logiker

  • CPC464
  • **
  • Posts: 33
  • Country: sc
  • Liked: 23
  • Likes Given: 4
Re: Read Charset from BASIC
« Reply #2 on: 20:23, 10 March 19 »
Thank you very much. That is exactly what I was looking for!

Offline logiker

  • CPC464
  • **
  • Posts: 33
  • Country: sc
  • Liked: 23
  • Likes Given: 4
Re: Read Charset from BASIC
« Reply #3 on: 21:17, 10 March 19 »
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?

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: Read Charset from BASIC
« Reply #4 on: 23:28, 10 March 19 »
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

Offline logiker

  • CPC464
  • **
  • Posts: 33
  • Country: sc
  • Liked: 23
  • Likes Given: 4
Re: Read Charset from BASIC
« Reply #5 on: 23:41, 10 March 19 »
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?

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: Read Charset from BASIC
« Reply #6 on: 00:17, 11 March 19 »
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

Offline logiker

  • CPC464
  • **
  • Posts: 33
  • Country: sc
  • Liked: 23
  • Likes Given: 4
Re: Read Charset from BASIC
« Reply #7 on: 12:42, 11 March 19 »
Thank you all for explanations and the code!