   10REM SAVE"$.Arabic.Test.INSDIAG"
   20REM Simple OSBYTE intercept
   30DIM Code &100
   40OsByte = &FFF4
   50InsV = &22A
   60FOR Pass=4 TO 6 STEP 2
   70P%=&2F00:O%=Code
   80[OPT Pass
   90.Entry
  100  Lda InsV:Sta MyInsV
  110  Lda InsV+1:Sta MyInsV+1
  120  Lda #MyIns MOD 256:Sta InsV
  130  Lda #MyIns DIV 256:Sta InsV+1
  140  Rts
  150.MyInsV NOP:NOP
  160.MyIns
  170  PHP:PHY:PHA:PHX
  180  Cpx #0:Bne notkybd
  190  Cmp #&8B:Bne notswap \ Needs soft-key test, split cursor test
  200  Lda flipbyte:Cmp #0:Bne other
  210  Lda #70:Ldx #21:Ldy #3:Jsr OsByte \ Screenflip uk
  220  Lda #70:Ldx #21:Ldy #6:Jsr OsByte \ Fontflip uk
  230  Ldx #ukkey MOD 256:Ldy #ukkey DIV 256
  240  Bra both
  250.other
  260  Lda #70:Ldx #21:Ldy #2:Jsr OsByte \ Screenflip arabic
  270  Lda #70:Ldx #21:Ldy #5:Jsr OsByte \ Fontflip arabic
  280  Ldx #arabkey MOD 256:Ldy #arabkey DIV 256
  290.both
  300  Jsr &FFF7
  301  Lda flipbyte:Eor #1:Sta flipbyte
  310  PLX:PLA:PLY:PLP
  320  Rts
  330.notswap
  340.notkybd
  350  PLX:PLA:PLY:PLP
  360  Jmp (MyInsV)
  370.flipbyte EQUB 0
  380.arabkey EQUS "*KEYBOARD ARABIC":EQUB 13
  390.ukkey EQUS "*KEYBOARD UK":EQUB 13
  400]
  410NEXT Pass
  420OSCLI("SAVE $.Library.InstTest "+STR$~(Code)+" +100 FFFF2F00 FFFF2F00")
