Reading screen mode

From BeebWiki
Revision as of 21:39, 3 April 2015 by Jgharston (talk | contribs) (Initial page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

OSBYTE &87 returns the current screen mode, and the VDU status byte returned by OSBYTE &75 has a bit which is set if the current display is a shadow screen mode. However, OSBYTE &87 only returns the base screen mode 0 to 7, it does not add &80 if a shadow screen mode is selected. Also, the VDU status byte shadow bit is only set by Master series computers. Shadow screen systems on the BBC use a different memory location. So, neither the current screen mode or the VDU status byte can consistantly tell you if you are using a shadow screen mode.

Running on I/O processor

If a shadow screen is selected the top of user memory, read with OSBYTE &84 and returned to BASIC to set HIMEM, will be &8000 or higher. There are some systems that overlay RAM over the BASIC ROM so HIMEM could even be at &C000 even on the I/O processor. So, the address should be checked to be &8000 or higher, not just exactly &8000. This can be done easily by testing bit 15 of the address.

 \ Test for shadow screen selected:
 LDA #&84:JSR OSBYTE   :\ Read top of user memory/bottom of screen
 TYA                   :\ Set flags from address
 BMI ShadowSelected
 BPL ShadowNotSelected
 \ Read current screen mode, including shadow bit:
 LDA #&87:JSR OSBYTE   :\ Read current screen MODE
 STY tmp
 LDA #&84:JSR OSBYTE   :\ Read top of user memory/bottom of screen
 TYA:AND #&80          :\ Keep bit 15 of address
 ORA tmp               :\ Copy into bit 7 of MODE number

Running on a second processor

If the program is running on a second processor, OSBYTE &84 returns the top of user memory, not the bottom of screen memory, as the user memory and screen memory are in different memory areas.


See Also

Jgharston (talk) 20:39, 3 April 2015 (UTC)