;R11 - pointer to VARS

.os_byte_handler			;OS_BYTE
 #if No_Frame_Pacing == 0
   CMP     R0, #13
   BLO     vector_handler_forward	;not one of ours
   TEQNE   R0, #14			;OS_Byte 13 / 14
   BEQ     os_byte_13_or_14
 #endif

 TEQ     R0, #253			;is it OS_Byte 253?
 BEQ     os_byte_253			;YES

 CMP     R0, #201			;is it OS_Byte 201?  PRM1-912
 BHI     vector_handler_forward		;not one of ours
 EXITSWIEQ ""				;prevent keyboard being disabled

 TEQ     R0, #19			;is it OS_Byte 19?
 BEQ     os_byte_19			;YES

 CMP     R0, #113			;is it OS_Byte 113?
 BLO     vector_handler_forward		;not one of ours
 BEQ     os_byte_113			;YES

 #if compile_RO > 311
   TEQ     R0, #129			;key scan
   BEQ     os_byte_129
 #endif

 #if No_Frame_Pacing == 0
   TEQ     R0, #176			;is it OS_Byte 176?
   BEQ     os_byte_176			;YES
 #endif

 #if compile_RO >= 450
   TEQ     R0, #166			;is it OS_Byte 166?
   BEQ     _os_byte_166			;YES, return OS_Byte vars ptr
 #endif

 TEQ     R0, #161
 TEQEQ   R1, #16			;could be a game checking boot
 BEQ     _os_byte_161

 TEQ     R0, #162			;is it OS_Byte 162?
 BNE     vector_handler_forward		;NO, hand back to OS

 LDRB    R14, [R11, #prevent_CMOSchanges - VARS]
 TEQ     R14, #0			;should we prevent CMOS writes?
 BNE     vector_handler_trap		;YES, trap the SWI
B       vector_handler_forward		;hand back to OS


._os_byte_161				;checked by Arcade 3
 LDR     R14, [R11, #JFD_tmp - VARS + JFD_Bit_Flags]
 TST     R14, #JFD_BF_ShiftBreak	;is floppy flagged as needing Shift-Break?
 BEQ     vector_handler_forward		;NO
 BL      pre_SWI_veneer			;call SWI that follows
 SWI     XOS_Byte
 ORR     R2, R2, #1<<4			;set BOOT
B       exit_SWI_veneer


#if compile_RO >= 450
; used by !65Host.!RunImage @ 3B10 - Zalaga
;         !game @ 819C             - Adventures Classic Collection
._os_byte_166
 BL      check_JIT_and_taskID		;is the task supported?
 BNE     vector_handler_forward		;NO

 MOV     R1, #&FA
 MOV     R2, #&8
 ADD     R2, R2, #jit_code_start >> 8	;redirect to JIT appspace
EXITSWI ""
; MOV     R0, #6
; MOV     R1, #0
; MOV     R2, #71			;read OS_Byte vars pointer
; BL      pre_SWI_veneer			;call SWI that follows
; SWI     XOS_ReadSysInfo		;see ROOL wiki
;
; AND     R1, R2, #&FF			;lower 8 bits of address
; MOV     R2, R2, LSR #8			;upper bits of address
; MOV     R0, #166
;B       exit_SWI_veneer
#endif