OSBYTE &14

From BeebWiki
Jump to: navigation, search
OSBYTE &14 (20): Explode and reset font
 On entry:
    X=0:     characters &80 to &9F only are redefineable (default without Tube)
    X=1:     characters &80 to &BF are redefineable
    X=2:     characters &80 to &DF are redefineable
    X=3:     characters &80 to &FF are redefineable
    X=4:     characters &20 to &3F, &80 to &FF are redefineable
    X=5:     characters &20 to &5F, &80 to &FF are redefineable
    X=6:     characters &20 to &FF are redefineable (default with Tube)
    X>6:     as with X=6, all characters redefineable
  Extension:
    X=7..&BF set font RAM to pages X..X+6
    X=&C0+n  set maximum font explosion level to n
 On exit:
    X=&00:   font permanently exploded (MOS 3 and later)
    X=&FF:   font explodable/implodable (before MOS 3, ie Electron, BBC, BBC B+)
   
 BBC:     X=return value from Service Call &11, &FF if call unclaimed
 Master:  X=&00
 RISC OS: X=&01 (first font bank reset)
 BB4W:    X=&20 (character under cursor)

In the "imploded" state (X=0) only 32 characters can be defined as only 256 bytes is permanently allocated for font definitions. All calls reset the font for CHR$32-CHR$127 by setting them as "hard", and they are read from ROM, and set CHR$128-CHR$255 as "soft". The default and "imploded" state is that all soft font groups use the same 256-byte font RAM.

Each group of 32 characters is a font group. Defining any character results in that definition being repeated for all soft font groups. For example, defining CHR$&80 results in that definition being used for CHR$A0, CHR$&C0 and CHR$E0. If you redefine a "hard" character the default font is copied for that font group and the character redefined. For example, in the "imploded" state, if you redefine CHR$21 its font group (CHR$&20-CHR$&3F) becomes soft and its definition will also be used for all the other soft font groups.

Exploding the font allocates a separate page of memory for the specified number of font groups, so each font group can be uniquely defined. For example, exploding with X=1 allocates a page of memory for CHR$&A0-CHR$BF allowing those to be uniquely defined. Again, the unallocated font groups will share the initial default font memory.

Exploding the font allocates 1 to 6 pages of font RAM underneath the default OSHWM, allowing more characters to be defined, pushing up the host's OSHWM - which is read by BASIC to set PAGE.

This OSBYTE must be used with care within a language, as it can reduce the language's memory allocation. Service call &11 is issued to notify ROMs of the change in OSHWM. BASIC does not respond to this, so if OSHWM changes the *BASIC command needs to be issued to get it to reset PAGE.

When a Tube coprocessor is fitted, the font is fully exploded by default, as this does not take up language memory, but it can be imploded if desired.

OSBYTE &14 with any value of X also resets characters &20-&7F to the ROM font. Characters &80-&FF are not altered, contrary to some manuals.

MOS 3 and later ignores the input value of X. The font is always fully exploded, and the definitions do not take up user memory. The only effect of OSBYTE &14 is to reset characters &20-&7F. Characters &80-&FF are not altered, contrary to some manuals. To reset all characters, OSBYTE &19 should be used.

You should not examine the returned Y value, as OSBYTE calls <128 are defined to only return information in the X register, and only the X register is returned to the user in some environments (such as across the Tube).

Extension

 On entry:
   X=7..&BF

The font memory is fully imploded, the maximum font explosion level is set to 0, characters 32 to 127 are assigned to the OS ROM, and pages of memory from X upwards are assigned to character groups 1 to 7. X should be at least &0E (14) to avoid collision with OS reserved memory areas. If X is in the range &7A to &BF (122 to 191) inclusive, the sideways RAM slot number must first be set with OSBYTE 163,129,n.

 On entry:
   X=&C0+n

The maximum font explosion level is set to n; if the current font explosion level is higher, it is imploded to the new maximum level. The maximum may be lowered or raised.

Subsequent calls with X < 7 implode or explode the main memory allocation between 0 and the maximum level, inclusive. If X is greater than the maximum, the maximum is used. These calls also reassign characters 32 to 127 to the OS ROM. Memory assignments of font explosion groups at or above the maximum level are not disturbed. Characters 128 to 159 are treated as font explosion group 6 and are protected from relocation when the maximum is less than 7, otherwise they are reassigned to page &0C (this group cannot be exploded.)

 On exit:
   X,Y undefined

See Also

Jgharston (talk) 00:00, 24 November 2022 (CET) Jgharston (talk) 14:13, 31 August 2015 (UTC) Jgharston 21:30, 26 May 2009 (UTC)
KJBracey 15:04, 5 December 2009 (UTC)