public function EINT_1AH as boolean

//DEBUG.ON 'uncomment to enable debug messages (can be slow for hi-freq events)

 ?? "INT 1AH AH=";Hex(cpu.AH);"h"

select case cpu.AH

'*****************************************************************************
'* INT 1AH AH=00h (BIOS) GET SYSTEM TIME
'* Params: -
'* Result: CX:DX = timer ticks count since midnight
'*         AL = counter of days
'* TODO:   Rewrite in asm to speedup some sofware
'*****************************************************************************

case 0 //AH=0

 'Read timer counter from BIOS data area (40h:6Ch..6Fh)
 cpu.DX=mem.Word(0x46C) : cpu.CX=mem.Word(0x46C+2)

 'Read counter of days from BIOS data area (40h:70h)
 cpu.AL=mem.Byte(0x470) : result=true

'*****************************************************************************
'* INT 1AH AH=01h (BIOS) SET SYSTEM TIME
'* Params: CX:DX = timer ticks count since midnight
'* Result: CF flag
'*****************************************************************************

case 1 //AH=1

 'Check value and clear/set carry flag as result
 dim i as integer : i=shl(cpu.CX,16) or cpu.DX 
 cpu.FLAGS.CF=(i>=0x1800B0) 
 if cpu.FLAGS.CF then exit 'incorrect param

 'Write timer counter to BIOS data area (40h:6Ch..6Fh)
 mem.Word(0x46C)=cpu.DX : mem.Word(0x46C+2)=cpu.CX

 'Clear counter of days in BIOS data area (40h:70h)
 mem.Byte(0x470)=0 : result=true

end select : end function