OSBYTE &A2

From BeebWiki
Revision as of 22:53, 26 August 2024 by Jgharston (talk | contribs) (Corrected and clarified return values.)
Jump to: navigation, search

Enable/Disable GXR

 On entry:
   X=0   Disable GXR (version 1.xx), Enable GXR (version 2.xx)
   X=128 Enable GXR (version 1.xx), Disable GXR (version 2.xx)

The Graphics Extension ROM for the BBC B and BBC B+ can be enabled and disabled with OSBYTE &A2. See also Talk:OSBYTE &A2.

Write non-volatile memory

 On entry:
   X=offset to byte to write
   Y=byte to write
 On exit:
   If unsupported: X=&FF
                   Y=preserved
   If offset within non-volative memory exists:
                   X=absolute offset within memory
                   Y=preserved
   If offset within non-volatile memory does not exist (past last location):
                   X=preserved
                   Y=preserved

OSBYTE &A2 writes a byte to non-volatile memory used to store configuration data. There are typically 50 locations but implementations can have more. The Master 128 uses 50 bytes of non-volatile CMOS RAM, the Master Compact uses a 128-byte or a 256-byte EEPROM, the Master Extension ROM for the BBC B uses a block of memory or a file on disk.

Location zero holds the local station number and is protected from being written with OSBYTE &A2. It can only be changed with a utility such as *SetStation.

Some implementations of non-volatile memory have a limited write-cycle time, so it is best to only write a value if it is not already the same. The following code will write a block of configuration data:

 REM max%=number of locations -1
 REM mem%=block of configuration data
 FOR X%=1 TO max%
 A%=161:Y%=((USR&FFF4)AND&FF0000)DIV65536
 IF mem%?X%<>Y% THEN Y%=mem%?X%:A%=162:CALL &FFF4
 NEXT X%

See Also

Jgharston 16:06, 31 October 2010 (UTC)