OSBYTE &87

From BeebWiki
Jump to: navigation, search

OSBYTE &87 (135) - Character at text cursor and screen MODE. Called by BASIC's =MODE function.

   On exit X=character at current cursor position (or 0 if unreadable)
           Y=current mode number (shadow modes DO NOT return with bit 7 set)

The returned value does not give the shadow MODE bit. The following code will return the full MODE number that can be used with the MODE command to re-select the same mode:

   mode%=(FNfx(&87,0)DIV256) OR ((FNfx(&75,0)AND&10)*8)
   ...
   DEFFNfx(A%,X%):LOCAL Y%:Y%=X%DIV256:=((USR&FFF4)AND&FFFF00)DIV256
   LDA #&75:JSR OSBYTE   :\ Read VDU status
   TXA:AND #&10:CMP #&10 :\ Test shadow flag in bit 4
   PHP                   :\ Save shadow flag in Carry
   LDA #&87:JSR OSBYTE   :\ Read current MODE
   TYA:ASL A:PLP:ROR A   :\ Move shadow flag into bit 7

According to the B+ User Guide, the call typically takes 120 microseconds. To save time, the base mode number can be obtained without character recognition by calling OSBYTE &A0 with X=&55.

See Also

Jgharston 22:01, 26 May 2009 (UTC) Jgharston (talk) 08:08, 28 December 2016 (UTC) Jgharston (talk) 23:39, 4 February 2017 (UTC)