96 lines
3.4 KiB
Plaintext
96 lines
3.4 KiB
Plaintext
|
''This file is an excerpt of tv.spin. Copyright and license are from tv.spin.
|
||
|
''***************************************
|
||
|
''* TV Driver v1.1 *
|
||
|
''* Author: Chip Gracey *
|
||
|
''* Copyright (c) 2004 Parallax, Inc. *
|
||
|
''* See end of file for terms of use. *
|
||
|
''***************************************
|
||
|
|
||
|
'' Modified for Sphinx by Michael Park
|
||
|
|
||
|
|
||
|
SXTVRENDEZVOUS = $8000 - 4
|
||
|
|
||
|
PUB GetBasepin
|
||
|
repeat while long[SXTVRENDEZVOUS]
|
||
|
long[SXTVRENDEZVOUS]~~ ' ping the sxtv cog (send -1)
|
||
|
repeat while long[SXTVRENDEZVOUS] == -1
|
||
|
return long[SXTVRENDEZVOUS]~ >> 8
|
||
|
|
||
|
PUB str(stringptr)
|
||
|
|
||
|
'' Print a zero-terminated string
|
||
|
|
||
|
repeat strsize(stringptr)
|
||
|
out(byte[stringptr++])
|
||
|
|
||
|
|
||
|
PUB dec(value) | i
|
||
|
|
||
|
'' Print a decimal number
|
||
|
|
||
|
if value < 0
|
||
|
-value
|
||
|
out("-")
|
||
|
|
||
|
i := 1_000_000_000
|
||
|
|
||
|
repeat 10
|
||
|
if value => i
|
||
|
out(value / i + "0")
|
||
|
value //= i
|
||
|
result~~
|
||
|
elseif result or i == 1
|
||
|
out("0")
|
||
|
i /= 10
|
||
|
|
||
|
|
||
|
PUB hex(value, digits)
|
||
|
|
||
|
'' Print a hexadecimal number
|
||
|
|
||
|
value <<= (8 - digits) << 2
|
||
|
repeat digits
|
||
|
out(lookupz((value <-= 4) & $F : "0".."9", "A".."F"))
|
||
|
|
||
|
|
||
|
PUB bin(value, digits)
|
||
|
|
||
|
'' Print a binary number
|
||
|
|
||
|
value <<= 32 - digits
|
||
|
repeat digits
|
||
|
out((value <-= 1) & 1 + "0")
|
||
|
|
||
|
|
||
|
pub out(ch)
|
||
|
repeat while long[SXTVRENDEZVOUS]
|
||
|
long[SXTVRENDEZVOUS] := ch
|
||
|
|
||
|
pub Ping
|
||
|
out( -1 )
|
||
|
|
||
|
pub Enable
|
||
|
out( "E"<<8 )
|
||
|
|
||
|
pub Disable
|
||
|
out( "D"<<8 )
|
||
|
|
||
|
{{
|
||
|
+------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| TERMS OF USE: MIT License |
|
||
|
+------------------------------------------------------------------------------------------------------------------------------+
|
||
|
|Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation |
|
||
|
|files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, |
|
||
|
|modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software|
|
||
|
|is furnished to do so, subject to the following conditions: |
|
||
|
| |
|
||
|
|The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.|
|
||
|
| |
|
||
|
|THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
|
||
|
|WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
||
|
|COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
|
||
|
|ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||
|
+------------------------------------------------------------------------------------------------------------------------------+
|
||
|
}}
|
||
|
|