Skip to content

Commit

Permalink
implement WaitForChar
Browse files Browse the repository at this point in the history
  • Loading branch information
bebbo committed Mar 24, 2024
1 parent cfef841 commit cc165a4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions amitools/vamos/lib/DosLibrary.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import ctypes
import re
import os
import select

from amitools.vamos.machine.regs import *
from amitools.vamos.libcore import LibImpl
@@ -594,6 +595,22 @@ def Close(self, ctx):
self.setioerr(ctx, 0)
return self.DOSTRUE

def WaitForChar(self, ctx):
# file,timeout)(d1/d2)
fh_b_addr = ctx.cpu.r_reg(REG_D1)
fh = self.file_mgr.get_by_b_addr(fh_b_addr, False)
if select.select([fh.obj], [], [], 0.)[0]:
return self.DOSTRUE

ms = ctx.cpu.r_reg(REG_D2)
if ms > 0:
time.sleep(ms * 1e-3)

if select.select([fh.obj], [], [], 0.)[0]:
return self.DOSTRUE

return self.DOSFALSE

def Read(self, ctx):
fh_b_addr = ctx.cpu.r_reg(REG_D1)
buf_ptr = ctx.cpu.r_reg(REG_D2)

0 comments on commit cc165a4

Please sign in to comment.