Difference between revisions of "OSBYTE &87"

From BeebWiki
Jump to: navigation, search
m (1 revision)
(faster call)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:OSBYTE]]
 
[[Category:OSBYTE]]
OSBYTE &87 (135) - Character at text cursor and screen MODE. Called by BASIC's =MODE function.
+
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)
 
     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)
 
             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==
 
==See Also==
 +
* [[MODE]]
 +
* [[OSBYTE &75]]
 +
* [[OSBYTE &A0]]
 +
* [[Reading screen mode]]
 +
* [[Paging in video memory]]
 
* http://mdfs.net/Docs/Comp/BBC/Osbyte80
 
* http://mdfs.net/Docs/Comp/BBC/Osbyte80
  
 
[[User:Jgharston|Jgharston]] 22:01, 26 May 2009 (UTC)
 
[[User:Jgharston|Jgharston]] 22:01, 26 May 2009 (UTC)
 +
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 08:08, 28 December 2016 (UTC)
 +
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 23:39, 4 February 2017 (UTC)

Latest revision as of 11:17, 31 March 2021

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)