summaryrefslogtreecommitdiffstats
path: root/Demo/sgi
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-06-10 13:32:32 (GMT)
committerGuido van Rossum <guido@python.org>1993-06-10 13:32:32 (GMT)
commitfa04170682a1b361d874937a541e57dbc16115a5 (patch)
treedbf5014bf68912417d2d48dc45a4cd425f090434 /Demo/sgi
parent672754a4880eb204ad4351b3f3b473bacf78651e (diff)
downloadcpython-fa04170682a1b361d874937a541e57dbc16115a5.zip
cpython-fa04170682a1b361d874937a541e57dbc16115a5.tar.gz
cpython-fa04170682a1b361d874937a541e57dbc16115a5.tar.bz2
VCR.py: Use unix files instead of stdio files for tty communication,
because of buffering. Also added several new commands (Jack). VFile.py: Made setting of RGB or colormap mode separate methods, so they can be overridden (e.g. when using the Glx.draw widget the way to change the mode is totally different).
Diffstat (limited to 'Demo/sgi')
-rwxr-xr-xDemo/sgi/video/VCR.py143
-rwxr-xr-xDemo/sgi/video/VFile.py18
2 files changed, 151 insertions, 10 deletions
diff --git a/Demo/sgi/video/VCR.py b/Demo/sgi/video/VCR.py
index ea123cb..d99fce6 100755
--- a/Demo/sgi/video/VCR.py
+++ b/Demo/sgi/video/VCR.py
@@ -4,9 +4,30 @@ from IOCTL import *
import sys
import struct
import select
+import posix
DEVICE='/dev/ttyd2'
+class UnixFile:
+ def open(self, name, mode):
+ self.fd = posix.open(name, mode)
+ return self
+
+ def read(self, len):
+ return posix.read(self.fd, len)
+
+ def write(self, data):
+ dummy = posix.write(self.fd, data)
+
+ def flush(self):
+ pass
+
+ def fileno(self):
+ return self.fd
+
+ def close(self):
+ dummy = posix.close(self.fd)
+
def packttyargs(*args):
if type(args) <> type(()):
raise 'Incorrect argtype for packttyargs'
@@ -39,8 +60,8 @@ def unpackttyargs(str):
return (iflag, oflag, cflag, lflag, line, chars)
def initline(name):
- fp = open(name, 'r')
- ofp = open(name, 'w')
+ fp = UnixFile().open(name, 2)
+ ofp = fp
fd = fp.fileno()
rv = fcntl.ioctl(fd, IOCTL.TCGETA, nullttyargs())
iflag, oflag, cflag, lflag, line, chars = unpackttyargs(rv)
@@ -92,13 +113,31 @@ EJECT='\x2a'
FF ='\xab'
REW ='\xac'
STILL='\x4f'
-STEP_FWD ='\xad'
+STEP_FWD ='\x2b' # Was: '\xad'
FM_SELECT=EXP_8 + '\xc8'
FM_STILL=EXP_8 + '\xcd'
DM_OFF=EXP_8 + '\xc9'
DM_SET=EXP_8 + '\xc4'
FWD_SHUTTLE='\xb5'
REV_SHUTTLE='\xb6'
+EM_SELECT=EXP_8 + '\xc0'
+N_FRAME_REC=EXP_8 + '\x92'
+
+IN_ENTRY=EXP_7 + '\x90'
+IN_ENTRY_RESET=EXP_7 + '\x91'
+IN_ENTRY_SET=EXP_7 + '\x98'
+IN_ENTRY_INC=EXP_7 + '\x94'
+IN_ENTRY_DEC=EXP_7 + '\x95'
+IN_ENTRY_SENSE=EXP_7 + '\x9a'
+
+OUT_ENTRY=EXP_7 + '\x92'
+OUT_ENTRY_RESET=EXP_7 + '\x93'
+OUT_ENTRY_SET=EXP_7 + '\x99'
+OUT_ENTRY_INC=EXP_7 + '\x96'
+OUT_ENTRY_DEC=EXP_7 + '\x98'
+OUT_ENTRY_SENSE=EXP_7 + '\x9b'
+
+DEBUG=0
class VCR:
def init(self):
@@ -106,7 +145,8 @@ class VCR:
return self
def _cmd(self, cmd):
-## print '>>>',`cmd`
+ if DEBUG:
+ print '>>>',`cmd`
self.ofp.write(cmd)
self.ofp.flush()
@@ -118,8 +158,10 @@ class VCR:
## if rep:
## print 'FLUSHED:', `rep`
return None
+ # XXXX Niet goed: er is meer gebufferd!
data = self.ifp.read(1)
-## print '<<<',`data`
+ if DEBUG:
+ print '<<<',`data`
if data == NAK:
return NAK
rep = rep + data
@@ -143,11 +185,12 @@ class VCR:
return number
def _iflush(self):
- dummy = self._waitdata(10000, 1)
+ dummy = self._waitdata(10000, 0)
## if dummy:
## print 'IFLUSH:', dummy
def simplecmd(self,cmd):
+ self._iflush()
for ch in cmd:
self._cmd(ch)
rep = self._reply(1)
@@ -157,6 +200,11 @@ class VCR:
raise error, 'Unexpected reply:' + `rep`
return 1
+ def replycmd(self, cmd):
+ if not self.simplecmd(cmd[:-1]):
+ return 0
+ self._cmd(cmd[-1])
+
def _number(self, number, digits):
if number < 0:
raise error, 'Unexpected negative number:'+ `number`
@@ -258,6 +306,41 @@ class VCR:
return 0
return 1
+ def editmode(self, mode):
+ if mode == 'off':
+ a0 = a1 = a2 = 0
+ elif mode == 'format':
+ a0 = 4
+ a1 = 7
+ a2 = 4
+ elif mode == 'asmbl':
+ a0 = 1
+ a1 = 7
+ a2 = 4
+ elif mode == 'insert-video':
+ a0 = 2
+ a1 = 4
+ a2 = 0
+ else:
+ raise 'editmode should be off,format,asmbl or insert-video'
+ if not self.simplecmd(EM_SELECT):
+ return 0
+ self._number(a0, 1)
+ self._number(a1, 1)
+ self._number(a2, 1)
+ if not self.simplecmd(ENTER):
+ return 0
+ return 1
+
+ def nframerec(self, num):
+ if not self.simplecmd(N_FRAME_REC):
+ return 0
+ self._number(num, 4)
+ if not self.simplecmd(ENTER):
+ return 0
+ self.waitready()
+ return 1
+
def fmstill(self):
if not self.simplecmd(FM_STILL):
return 0
@@ -295,3 +378,51 @@ class VCR:
return 0
self._number(num, 1)
return 1
+
+ def getentry(self, which):
+ if which == 'in':
+ cmd = IN_ENTRY_SENSE
+ elif which == 'out':
+ cmd = OUT_ENTRY_SENSE
+ self.replycmd(cmd)
+ h = self._getnumber(2)
+ print 'h=',h
+ m = self._getnumber(2)
+ print 'm=',m
+ s = self._getnumber(2)
+ print 's=',s
+ f = self._getnumber(2)
+ print 'f=',f
+ return (h, m, s, f)
+
+ def inentry(self, arg):
+ return self.ioentry(arg, (IN_ENTRY, IN_ENTRY_RESET, \
+ IN_ENTRY_SET, IN_ENTRY_INC, IN_ENTRY_DEC))
+
+ def outentry(self, arg):
+ return self.ioentry(arg, (OUT_ENTRY, OUT_ENTRY_RESET, \
+ OUT_ENTRY_SET, OUT_ENTRY_INC, OUT_ENTRY_DEC))
+
+ def ioentry(self, arg, (Load, Clear, Set, Inc, Dec)):
+ if type(arg) == type(()):
+ h, m, s, f = arg
+ if not self.simplecmd(Set):
+ return 0
+ self._number(h,2)
+ self._number(m,2)
+ self._number(s,2)
+ self._number(f,2)
+ if not self.simplecmd(ENTER):
+ return 0
+ return 1
+ elif arg == 'reset':
+ cmd = Clear
+ elif arg == 'load':
+ cmd = Load
+ elif arg == '+':
+ cmd = Inc
+ elif arg == '-':
+ cmd = Dec
+ else:
+ raise error, 'Arg should be +,-,reset,load or (h,m,s,f)'
+ return self.simplecmd(cmd)
diff --git a/Demo/sgi/video/VFile.py b/Demo/sgi/video/VFile.py
index 016115a..f04d93b 100755
--- a/Demo/sgi/video/VFile.py
+++ b/Demo/sgi/video/VFile.py
@@ -442,8 +442,7 @@ class Displayer(VideoParams):
self.color0 = None
self.fixcolor0 = 0
if self.format in ('rgb', 'jpeg', 'compress'):
- gl.RGBmode()
- gl.gconfig()
+ self.set_rgbmode()
gl.RGBcolor(200, 200, 200) # XXX rather light grey
gl.clear()
return
@@ -456,8 +455,7 @@ class Displayer(VideoParams):
gl.clear()
gl.pixmode(GL.PM_SIZE, 8)
return
- gl.cmode()
- gl.gconfig()
+ self.set_cmode()
self.skipchrom = 0
if self.offset == 0:
self.mask = 0x7ff
@@ -470,6 +468,18 @@ class Displayer(VideoParams):
if not self.quiet:
sys.stderr.write(' Done.\n')
+ # Set the window in RGB mode (may be overridden for Glx window)
+
+ def set_rgbmode(self):
+ gl.RGBmode()
+ gl.gconfig()
+
+ # Set the window in colormap mode (may be overridden for Glx window)
+
+ def set_cmode(self):
+ gl.cmode()
+ gl.gconfig()
+
# Clear the window to a default color
def clear(self):