Character editor

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
User avatar
LordVaderUK
Posts: 208
Joined: Thu Jan 31, 2019 12:26 am
Location: Hampshire
Contact:

Character editor

Post by LordVaderUK » Wed Jun 03, 2020 2:56 pm

Can anyone direct me to a simple character editor to allow redefinition of ASCII chars 224 to 255? I have tried googling, and searching here, but haven't found anything that works yet.

Failing that, I may have to write my own, in which case, how does one read the current 8 byte make up of one of the redefinable characters? :?
Loving my BBC Master 128

User avatar
jgharston
Posts: 4116
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Character editor

Post by jgharston » Wed Jun 03, 2020 3:14 pm

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
LordVaderUK
Posts: 208
Joined: Thu Jan 31, 2019 12:26 am
Location: Hampshire
Contact:

Re: Character editor

Post by LordVaderUK » Wed Jun 03, 2020 5:30 pm

jgharston wrote:
Wed Jun 03, 2020 3:14 pm
http://mdfs.net/Apps/Font/ : DefChar
Thank you - exactly what I needed! Looks like you wrote it (very impressed) - can you tell me how to extract the resultant VDU statements so I can include them in my BASIC code?
Loving my BBC Master 128

User avatar
jgharston
Posts: 4116
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Character editor

Post by jgharston » Wed Jun 03, 2020 6:46 pm

LordVaderUK wrote:
Wed Jun 03, 2020 5:30 pm
jgharston wrote:
Wed Jun 03, 2020 3:14 pm
http://mdfs.net/Apps/Font/ : DefChar
Thank you - exactly what I needed! Looks like you wrote it (very impressed) - can you tell me how to extract the resultant VDU statements so I can include them in my BASIC code?
The editor window shows the values of each line of the bitmap, the parameters to a VDU 23,n sequence.

Code: Select all

           there---\
                   |
+-+-+-+-+-+-+-+-+
| | | | | | | |#| 001
+-+-+-+-+-+-+-+-+
| | | | | | |#| | 002
+-+-+-+-+-+-+-+-+
| | | | | |#| | | 004
+-+-+-+-+-+-+-+-+
| | | | |#| | | | 008
+-+-+-+-+-+-+-+-+
| | | |#| | | | | 016
+-+-+-+-+-+-+-+-+
| | |#| | | | | | 032
+-+-+-+-+-+-+-+-+
| |#| | | | | | | 064
+-+-+-+-+-+-+-+-+
|#| | | | | | | | 128
+-+-+-+-+-+-+-+-+

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
LordVaderUK
Posts: 208
Joined: Thu Jan 31, 2019 12:26 am
Location: Hampshire
Contact:

Re: Character editor

Post by LordVaderUK » Wed Jun 03, 2020 6:53 pm

jgharston wrote: The editor window shows the values of each line of the bitmap, the parameters to a VDU 23,n sequence.
Ah yes, sorry I knew that, should have made myself clearer. When I save the characters to a file, there’s an option to save in VDU format. I assumed this would be a text file full of VDU 23, statements but when I *TYPE it nothing appears.
Loving my BBC Master 128

User avatar
jgharston
Posts: 4116
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Character editor

Post by jgharston » Wed Jun 03, 2020 6:54 pm

A saved VDU font file can be "loaded" by just OPENIN'ing it and VDU'ing it. A saved binary font file can be loaded with a loop that goes through each character and VDU's the eight parameters, both can be done with the BFont_Load() procedure in the BFont library:

Code: Select all

   80 REM BFont_Load - Load bitmap font
   90 REM -----------------------------
  100 REM A$ - filename to load
  110 REM S% - start character to load to 0 for VDU file
  120 :
  130 DEFPROCBFont_Load(A$,S%):LOCALin%,A%:in%=OPENIN(A$):IFin%=0:ENDPROC
  140 REPEAT:IFA%=0:IFS%:VDU23,S%:S%=S%+1
  150 VDUBGET#in%:A%=(A%+1)AND7:UNTILEOF#in%:CLOSE#in%:ENDPROC
The same functionality is done by the *CLOAD command supplied with DefChar and in the CharROM.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
jgharston
Posts: 4116
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Character editor

Post by jgharston » Wed Jun 03, 2020 6:59 pm

LordVaderUK wrote:
Wed Jun 03, 2020 6:53 pm
jgharston wrote: The editor window shows the values of each line of the bitmap, the parameters to a VDU 23,n sequence.
Ah yes, sorry I knew that, should have made myself clearer. When I save the characters to a file, there’s an option to save in VDU format. I assumed this would be a text file full of VDU 23, statements but when I *TYPE it nothing appears.
That's normal. All the VDU 23 sequences will have gone to the VDU driver, VDU 23 does not display anything on the screen, it defines a character.

Note that *TYPE on MOS 3+ interprets the contents as printable text, so VDU 23 sequences will end up displayed as |S |Y76|q,,, etc, whereas *TYPE on DFS UTILS on pre-Master MOSes send the entire contents to the VDU driver. The "old" functionality of *TYPE is implemented by *PRINT on the Master series.

The best method is to use *CLOAD (Character LOAD) or a program function such as BFont_Load(), both of which also have the advantage of being agnostic about where the font lives, which attempting to *LOAD it isn't. BFont_Load() has the additional advantange of being completely platform agnostic, will run on BBC BASIC on any platform that has a VDU driver that implements VDU 23. BBC, DPS, ZX Spectrum, Commodore 64......

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
Richard Russell
Posts: 1668
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Character editor

Post by Richard Russell » Wed Jun 03, 2020 9:13 pm

In case it's of interest, here's another character designer. It needs BBC BASIC for Windows or BBC BASIC for SDL 2.0 because it uses a structure.

User avatar
LordVaderUK
Posts: 208
Joined: Thu Jan 31, 2019 12:26 am
Location: Hampshire
Contact:

Re: Character editor

Post by LordVaderUK » Thu Jun 11, 2020 9:55 am

jgharston wrote:
Wed Jun 03, 2020 6:54 pm
A saved VDU font file can be "loaded" by just OPENIN'ing it and VDU'ing it. A saved binary font file can be loaded with a loop that goes through each character and VDU's the eight parameters, both can be done with the BFont_Load() procedure in the BFont library
Thanks for this, I'm trying to use the BFont library but ... well, is it me, or is there a bug in this code?!

Code: Select all

  180 REM BFont_Save - Save bitmap font
  190 REM -----------------------------
  200 REM A$ - filename to save to
  210 REM S% - start character to save
  220 REM E% - end character to save
  230 REM R% - <>0 save as raw bitmap, 0 save as VDU file
  240 :
  250 DEFPROCBFont_Save(A$,S%,E%,R%):LOCALout%,L%,X%,Y%,A%:out%=OPENOUT(A$):IFout%=0:ENDPROC
  260 DIMX%-1:Y%=X%DIV256:A%=10:REPEAT:?X%=S%:CALL&FFF1:IFR%=0:BPUT#out%,23:BPUT#out%,S%
  270   FORL%=1TO8:REPEAT:BPUT#out%,X%?L%:NEXT:S%=S%+1:UNTILS%>E%:CLOSE#out%:ENDPROC
...specifically, a rogue extra 'REPEAT' statement in line 270??

Certainly, the code doesn't seem to work unless I remove it :shock:
Loving my BBC Master 128

User avatar
jgharston
Posts: 4116
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Character editor

Post by jgharston » Thu Jun 11, 2020 12:22 pm

LordVaderUK wrote:
Thu Jun 11, 2020 9:55 am
Thanks for this, I'm trying to use the BFont library but ... well, is it me, or is there a bug in this code?!
...specifically, a rogue extra 'REPEAT' statement in line 270??

Certainly, the code doesn't seem to work unless I remove it :shock:
You're right! Have a banana! :)

I'll update the library.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
LordVaderUK
Posts: 208
Joined: Thu Jan 31, 2019 12:26 am
Location: Hampshire
Contact:

Re: Character editor

Post by LordVaderUK » Thu Jun 11, 2020 5:54 pm

jgharston wrote:
Thu Jun 11, 2020 12:22 pm
LordVaderUK wrote:
Thu Jun 11, 2020 9:55 am
Thanks for this, I'm trying to use the BFont library but ... well, is it me, or is there a bug in this code?!
...specifically, a rogue extra 'REPEAT' statement in line 270??

Certainly, the code doesn't seem to work unless I remove it :shock:
You're right! Have a banana! :)

I'll update the library.
Wooot! I found a 30 year old bug :p
Loving my BBC Master 128

Post Reply

Return to “programming”