Initial import

This commit is contained in:
~d6 2023-11-10 11:44:37 -05:00
commit f0931316ea
7 changed files with 1766 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
# use glob syntax.
syntax: glob
*.pyc
*.pyo
*~
TAGS
*.rom
.theme
.snarf
*.sym
*.log

19
README.md Normal file
View File

@ -0,0 +1,19 @@
# determ
terminal emulator for the uxn system.
(TODO: improve this readme)
## quick start
```
uxnasm term.tal term.rom
python.py term.py term.rom
```
or alternately:
```
gcc term.c -c term
./term term.rom
```

259
cp437.tal Normal file
View File

@ -0,0 +1,259 @@
&nul ( null )
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7e c3 81 a5 81 bd 99 c3 7e 00 00 00 00 00 00
00 7e ff ff db ff c3 e7 ff 7e 00 00 00 00 00 00
00 00 44 ee fe fe fe 7c 38 10 00 00 00 00 00 00
00 10 38 7c fe fe 7c 38 10 00 00 00 00 00 00 00
00 18 3c 3c ff e7 e7 18 18 7e 00 00 00 00 00 00
00 18 3c 7e ff ff 7e 18 18 7e 00 00 00 00 00 00
00 00 00 00 3c 7e 7e 3c 00 00 00 00 00 00 00 00
ff ff ff ff c3 81 81 c3 ff ff ff ff 00 00 00 00
00 00 3c 7e 66 42 42 66 7e 3c 00 00 00 00 00 00
ff ff c3 81 99 bd bd 99 81 c3 ff ff 00 00 00 00
00 3e 0e 3a 72 f8 cc cc cc 78 00 00 00 00 00 00
00 3c 66 66 66 3c 18 7e 18 18 00 00 00 00 00 00
00 1f 19 19 1f 18 18 78 f8 70 00 00 00 00 00 00
00 7f 63 7f 63 63 63 67 e7 e6 c0 00 00 00 00 00
00 00 18 db 7e e7 e7 7e db 18 00 00 00 00 00 00
00 80 c0 e0 f8 fe f8 e0 c0 80 00 00 00 00 00 00
00 02 06 0e 3e fe 3e 0e 06 02 00 00 00 00 00 00
00 18 3c 7e 18 18 18 7e 3c 18 00 00 00 00 00 00
00 66 66 66 66 66 00 00 66 66 00 00 00 00 00 00
00 7f db db db 7b 1b 1b 1b 1b 00 00 00 00 00 00
00 7e 63 30 3c 66 66 3c 0c c6 7e 00 00 00 00 00
00 00 00 00 00 00 00 fe fe fe 00 00 00 00 00 00
00 18 3c 7e 18 18 18 7e 3c 18 7e 00 00 00 00 00
00 18 3c 7e 18 18 18 18 18 18 00 00 00 00 00 00
00 18 18 18 18 18 18 7e 3c 18 00 00 00 00 00 00
00 00 00 18 0c fe 0c 18 00 00 00 00 00 00 00 00
00 00 00 30 60 fe 60 30 00 00 00 00 00 00 00 00
00 00 00 00 c0 c0 c0 fe 00 00 00 00 00 00 00 00
00 00 00 24 66 ff 66 24 00 00 00 00 00 00 00 00
&rs ( record separator )
00 00 10 10 38 38 7c 7c fe fe 00 00 00 00 00 00
00 00 fe fe 7c 7c 38 38 10 10 00 00 00 00 00 00
&space ( space )
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 78 78 78 30 30 00 30 30 00 00 00 00 00 00
00 66 66 66 24 00 00 00 00 00 00 00 00 00 00 00
00 6c 6c fe 6c 6c 6c fe 6c 6c 00 00 00 00 00 00
30 30 7c c0 c0 78 0c 0c f8 30 30 00 00 00 00 00
00 00 00 c4 cc 18 30 60 cc 8c 00 00 00 00 00 00
00 70 d8 d8 70 fa de cc dc 76 00 00 00 00 00 00
00 30 30 30 60 00 00 00 00 00 00 00 00 00 00 00
00 0c 18 30 60 60 60 30 18 0c 00 00 00 00 00 00
00 60 30 18 0c 0c 0c 18 30 60 00 00 00 00 00 00
00 00 00 66 3c ff 3c 66 00 00 00 00 00 00 00 00
00 00 00 18 18 7e 18 18 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 38 38 60 00 00 00 00 00
00 00 00 00 00 fe 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 38 38 00 00 00 00 00 00
00 00 02 06 0c 18 30 60 c0 80 00 00 00 00 00 00
00 7c c6 ce de d6 f6 e6 c6 7c 00 00 00 00 00 00
00 10 30 f0 30 30 30 30 30 fc 00 00 00 00 00 00
00 78 cc cc 0c 18 30 60 cc fc 00 00 00 00 00 00
00 78 cc 0c 0c 38 0c 0c cc 78 00 00 00 00 00 00
00 0c 1c 3c 6c cc fe 0c 0c 1e 00 00 00 00 00 00
00 fc c0 c0 c0 f8 0c 0c cc 78 00 00 00 00 00 00
00 38 60 c0 c0 f8 cc cc cc 78 00 00 00 00 00 00
00 fe c6 c6 06 0c 18 30 30 30 00 00 00 00 00 00
00 78 cc cc cc 78 cc cc cc 78 00 00 00 00 00 00
00 78 cc cc cc 7c 18 18 30 70 00 00 00 00 00 00
00 00 00 38 38 00 00 38 38 00 00 00 00 00 00 00
00 00 00 38 38 00 00 38 38 18 30 00 00 00 00 00
00 0c 18 30 60 c0 60 30 18 0c 00 00 00 00 00 00
00 00 00 00 7e 00 7e 00 00 00 00 00 00 00 00 00
00 60 30 18 0c 06 0c 18 30 60 00 00 00 00 00 00
00 78 cc 0c 18 30 30 00 30 30 00 00 00 00 00 00
00 7c c6 c6 de de de c0 c0 7c 00 00 00 00 00 00
00 30 78 cc cc cc fc cc cc cc 00 00 00 00 00 00
00 fc 66 66 66 7c 66 66 66 fc 00 00 00 00 00 00
00 3c 66 c6 c0 c0 c0 c6 66 3c 00 00 00 00 00 00
00 f8 6c 66 66 66 66 66 6c f8 00 00 00 00 00 00
00 fe 62 60 64 7c 64 60 62 fe 00 00 00 00 00 00
00 fe 66 62 64 7c 64 60 60 f0 00 00 00 00 00 00
00 3c 66 c6 c0 c0 ce c6 66 3e 00 00 00 00 00 00
00 cc cc cc cc fc cc cc cc cc 00 00 00 00 00 00
00 78 30 30 30 30 30 30 30 78 00 00 00 00 00 00
00 1e 0c 0c 0c 0c cc cc cc 78 00 00 00 00 00 00
00 e6 66 6c 6c 78 6c 6c 66 e6 00 00 00 00 00 00
00 f0 60 60 60 60 62 66 66 fe 00 00 00 00 00 00
00 c6 ee fe fe d6 c6 c6 c6 c6 00 00 00 00 00 00
00 c6 c6 e6 f6 fe de ce c6 c6 00 00 00 00 00 00
00 38 6c c6 c6 c6 c6 c6 6c 38 00 00 00 00 00 00
00 fc 66 66 66 7c 60 60 60 f0 00 00 00 00 00 00
00 38 6c c6 c6 c6 ce de 7c 0c 1e 00 00 00 00 00
00 fc 66 66 66 7c 6c 66 66 e6 00 00 00 00 00 00
00 78 cc cc c0 70 18 cc cc 78 00 00 00 00 00 00
00 fc b4 30 30 30 30 30 30 78 00 00 00 00 00 00
00 cc cc cc cc cc cc cc cc 78 00 00 00 00 00 00
00 cc cc cc cc cc cc cc 78 30 00 00 00 00 00 00
00 c6 c6 c6 c6 d6 d6 6c 6c 6c 00 00 00 00 00 00
00 cc cc cc 78 30 78 cc cc cc 00 00 00 00 00 00
00 cc cc cc cc 78 30 30 30 78 00 00 00 00 00 00
00 fe ce 98 18 30 60 62 c6 fe 00 00 00 00 00 00
00 3c 30 30 30 30 30 30 30 3c 00 00 00 00 00 00
00 00 80 c0 60 30 18 0c 06 02 00 00 00 00 00 00
00 3c 0c 0c 0c 0c 0c 0c 0c 3c 00 00 00 00 00 00
10 38 6c c6 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00
30 30 18 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 e0 60 60 7c 66 66 66 66 dc 00 00 00 00 00 00
00 00 00 00 78 cc c0 c0 cc 78 00 00 00 00 00 00
00 1c 0c 0c 7c cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 78 cc fc c0 cc 78 00 00 00 00 00 00
00 38 6c 60 60 f8 60 60 60 f0 00 00 00 00 00 00
00 00 00 00 76 cc cc cc 7c 0c cc 78 00 00 00 00
00 e0 60 60 6c 76 66 66 66 e6 00 00 00 00 00 00
00 18 18 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 0c 0c 00 3c 0c 0c 0c 0c cc cc 78 00 00 00 00
00 e0 60 60 66 6c 78 6c 66 e6 00 00 00 00 00 00
00 78 18 18 18 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 fc d6 d6 d6 d6 c6 00 00 00 00 00 00
00 00 00 00 f8 cc cc cc cc cc 00 00 00 00 00 00
00 00 00 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 dc 66 66 66 66 7c 60 f0 00 00 00 00
00 00 00 00 76 cc cc cc cc 7c 0c 1e 00 00 00 00
00 00 00 00 ec 6e 76 60 60 f0 00 00 00 00 00 00
00 00 00 00 78 cc 60 18 cc 78 00 00 00 00 00 00
00 00 20 60 fc 60 60 60 6c 38 00 00 00 00 00 00
00 00 00 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 cc cc cc cc 78 30 00 00 00 00 00 00
00 00 00 00 c6 c6 d6 d6 6c 6c 00 00 00 00 00 00
00 00 00 00 c6 6c 38 38 6c c6 00 00 00 00 00 00
00 00 00 00 66 66 66 66 3c 0c 18 f0 00 00 00 00
00 00 00 00 fc 8c 18 60 c4 fc 00 00 00 00 00 00
00 1c 30 30 60 c0 60 30 30 1c 00 00 00 00 00 00
00 18 18 18 18 00 18 18 18 18 00 00 00 00 00 00
00 e0 30 30 18 0c 18 30 30 e0 00 00 00 00 00 00
00 73 da ce 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 10 38 6c c6 c6 fe 00 00 00 00 00 00 00
00 78 cc cc c0 c0 c0 cc cc 78 30 60 00 00 00 00
00 cc cc 00 cc cc cc cc cc 76 00 00 00 00 00 00
0c 18 30 00 78 cc fc c0 cc 78 00 00 00 00 00 00
30 78 cc 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 cc cc 00 78 0c 7c cc cc 76 00 00 00 00 00 00
c0 60 30 00 78 0c 7c cc cc 76 00 00 00 00 00 00
38 6c 6c 38 f8 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 78 cc c0 c0 cc 78 30 60 00 00 00 00
30 78 cc 00 78 cc fc c0 c0 7c 00 00 00 00 00 00
00 cc cc 00 78 cc fc c0 c0 7c 00 00 00 00 00 00
c0 60 30 00 78 cc fc c0 c0 7c 00 00 00 00 00 00
00 6c 6c 00 78 18 18 18 18 7e 00 00 00 00 00 00
10 38 6c 00 78 18 18 18 18 7e 00 00 00 00 00 00
60 30 18 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 cc 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
78 cc cc 78 78 cc cc fc cc cc 00 00 00 00 00 00
0c 18 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 00 00 00 fe 1b 7f d8 d8 ef 00 00 00 00 00 00
00 3e 78 d8 d8 fe d8 d8 d8 de 00 00 00 00 00 00
30 78 cc 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 cc cc 00 78 cc cc cc cc 78 00 00 00 00 00 00
c0 60 30 00 78 cc cc cc cc 78 00 00 00 00 00 00
30 78 cc 00 cc cc cc cc cc 76 00 00 00 00 00 00
c0 60 30 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 66 66 00 66 66 66 66 3c 0c 18 f0 00 00 00 00
00 cc 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
cc 00 cc cc cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 78 cc dc ec cc 78 00 00 00 00 00 00
3c 66 60 60 60 fc 60 60 c0 fe 00 00 00 00 00 00
00 3a 6c ce d6 d6 d6 e6 6c b8 00 00 00 00 00 00
00 00 00 00 00 c6 6c 38 6c c6 00 00 00 00 00 00
0e 1b 18 18 7e 18 18 18 d8 70 00 00 00 00 00 00
0c 18 30 00 78 0c 7c cc cc 76 00 00 00 00 00 00
0c 18 30 00 78 18 18 18 18 7e 00 00 00 00 00 00
0c 18 30 00 78 cc cc cc cc 78 00 00 00 00 00 00
0c 18 30 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 76 dc 00 f8 cc cc cc cc cc 00 00 00 00 00 00
76 dc 00 c6 e6 f6 de ce c6 c6 00 00 00 00 00 00
00 78 cc cc 7e 00 fe 00 00 00 00 00 00 00 00 00
00 78 cc cc 78 00 fe 00 00 00 00 00 00 00 00 00
00 30 30 00 30 60 c0 c0 cc 78 00 00 00 00 00 00
00 38 44 ba aa ba b2 aa 44 38 00 00 00 00 00 00
00 00 00 00 00 fc 0c 0c 0c 00 00 00 00 00 00 00
00 62 e6 6c 78 30 6e c3 86 0c 1f 00 00 00 00 00
00 63 e6 6c 78 37 6f db b3 3f 03 00 00 00 00 00
00 30 30 00 30 30 78 78 78 30 00 00 00 00 00 00
00 00 00 00 33 66 cc cc 66 33 00 00 00 00 00 00
00 00 00 00 cc 66 33 33 66 cc 00 00 00 00 00 00
24 92 49 24 92 49 24 92 49 24 92 49 00 00 00 00
55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 00 00 00 00
6d db b6 6d db b6 6d db b6 6d db b6 00 00 00 00
18 18 18 18 18 18 18 18 18 18 18 18 00 00 00 00
18 18 18 18 18 f8 18 18 18 18 18 18 00 00 00 00
0c 18 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
78 cc 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
60 30 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
00 38 44 ba a2 a2 a2 ba 44 38 00 00 00 00 00 00
66 66 66 66 e6 06 06 e6 66 66 66 66 00 00 00 00
66 66 66 66 66 66 66 66 66 66 66 66 00 00 00 00
00 00 00 00 fe 06 06 e6 66 66 66 66 00 00 00 00
66 66 66 66 e6 06 06 fe 00 00 00 00 00 00 00 00
00 30 30 78 cc c0 c0 cc 78 30 30 00 00 00 00 00
cc cc cc cc 78 fc 30 fc 30 30 00 00 00 00 00 00
00 00 00 00 00 f8 18 18 18 18 18 18 00 00 00 00
18 18 18 18 18 1f 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 ff 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 ff 18 18 18 18 18 18 00 00 00 00
18 18 18 18 18 1f 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 ff 18 18 18 18 18 18 00 00 00 00
00 76 dc 00 78 0c 7c cc cc 76 00 00 00 00 00 00
76 dc 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
66 66 66 66 67 60 60 7f 00 00 00 00 00 00 00 00
00 00 00 00 7f 60 60 67 66 66 66 66 00 00 00 00
66 66 66 66 e7 00 00 ff 00 00 00 00 00 00 00 00
00 00 00 00 ff 00 00 e7 66 66 66 66 00 00 00 00
66 66 66 66 67 60 60 67 66 66 66 66 00 00 00 00
00 00 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00
66 66 66 66 e7 00 00 e7 66 66 66 66 00 00 00 00
00 00 00 00 00 c6 7c 6c 7c c6 00 00 00 00 00 00
cc 30 d8 0c 06 7e c6 c6 c6 7c 00 00 00 00 00 00
00 f8 6c 66 66 f6 66 66 6c f8 00 00 00 00 00 00
78 cc 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 cc 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
60 30 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 f0 30 30 30 fc 00 00 00 00 00 00 00 00 00 00
18 30 00 78 30 30 30 30 30 78 00 00 00 00 00 00
78 cc 00 78 30 30 30 30 30 78 00 00 00 00 00 00
00 cc 00 78 30 30 30 30 30 78 00 00 00 00 00 00
18 18 18 18 18 f8 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 1f 18 18 18 18 18 18 00 00 00 00
ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00
00 00 00 00 00 00 ff ff ff ff ff ff 00 00 00 00
00 18 18 18 18 00 18 18 18 18 00 00 00 00 00 00
60 30 00 78 30 30 30 30 30 78 00 00 00 00 00 00
ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00
18 30 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 78 cc cc d8 cc cc cc f8 c0 60 00 00 00 00 00
78 cc 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
60 30 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 76 dc 00 78 cc cc cc cc 78 00 00 00 00 00 00
76 dc 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 66 66 66 66 66 7b 60 c0 00 00 00 00
00 00 e0 60 7c 66 66 7c 60 f0 00 00 00 00 00 00
00 f0 60 7c 66 66 66 7c 60 f0 00 00 00 00 00 00
18 30 00 cc cc cc cc cc cc 78 00 00 00 00 00 00
78 cc 00 cc cc cc cc cc cc 78 00 00 00 00 00 00
60 30 00 cc cc cc cc cc cc 78 00 00 00 00 00 00
06 0c 18 00 66 66 66 66 3c 0c 18 f0 00 00 00 00
18 30 00 cc cc cc 78 30 30 78 00 00 00 00 00 00
00 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 fc 00 00 00 00 00 00 00 00 00 00
00 00 30 30 fc 30 30 00 fc 00 00 00 00 00 00 00
00 00 00 00 00 f8 00 00 f8 00 00 00 00 00 00 00
e0 33 66 3c f8 37 6f db b3 3f 03 00 00 00 00 00
00 7f db db db 7b 1b 1b 1b 1b 00 00 00 00 00 00
00 7e 63 30 3c 66 66 3c 0c c6 7e 00 00 00 00 00
00 00 30 30 00 fc 00 30 30 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 30 70 00 00 00 00
00 3c 66 66 66 3c 00 00 00 00 00 00 00 00 00 00
00 cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00
00 30 70 30 30 78 00 00 00 00 00 00 00 00 00 00
00 78 0c 38 0c 78 00 00 00 00 00 00 00 00 00 00
00 78 0c 18 30 7c 00 00 00 00 00 00 00 00 00 00
00 00 00 fc fc fc fc fc fc 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

23
determ.terminfo Normal file
View File

@ -0,0 +1,23 @@
# based on ansi
determ|quasi-ansi terminal without color,
am, mc5i, mir, msgr, xenl,
cols#80, it#8, lines#24,
acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
cr=\r, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG, ht=\E[I, hts=\EH,
ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n,
indn=\E[%p1%dS, invis=\E[8m, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L,
mc4=\E[4i, mc5=\E[5i, nel=\r\E[S, op=\E[39;49m,
rep=%p1%c\E[%p2%{1}%-%db, rev=\E[7m, rin=\E[%p1%dT,
rmacs=\E[10m, rmpch=\E[10m, rmso=\E[m, rmul=\E[m,
s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B,
setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
sgr0=\E[0;10m, smacs=\E[11m, smpch=\E[11m, smso=\E[7m,
smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd,

57
term.c Normal file
View File

@ -0,0 +1,57 @@
#include <pwd.h>
#ifdef __APPLE__
#include <util.h>
#include <sys/ioctl.h>
#else
#include <pty.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// compile with gcc term.c -lutil
int main(int argc, char **argv) {
if (argc < 2) {
printf("usage: %s ROM [LOGIN]\n", argv[0]);
return 1;
}
char *rom = argv[1]; // find term.rom
int login = argc > 2; // any extra arg signals login shell
// detect the user's shell
char *shell = getenv("SHELL");
if (shell == NULL) {
struct passwd *passwd = getpwuid(getuid());
if (passwd != NULL) {
shell = passwd->pw_shell;
}
}
if (shell == NULL) {
shell = "/bin/sh";
}
// allocate a pty, fork, inititialize file descriptor
int fdm = -1; // allocate file descriptor
pid_t pid = forkpty(&fdm, NULL, NULL, NULL);
if (pid < 0) { // failure
perror("fork failed");
return 1;
} else if (pid == 0) { // child
setenv("TERM", "ansi", 1);
// execute shell
if (login) {
execlp(shell, shell, "-l", "-i", NULL);
} else {
execlp(shell, shell, NULL);
}
perror("exec bash failed");
} else { // parent
struct winsize ws = {23, 80, 8, 12}; // rows, cols, xps, ypx
ioctl(fdm, TIOCSWINSZ, &ws); // set term window size
dup2(fdm, 0); // use fdm for stdin
dup2(fdm, 1); // use fdm for stdout
execlp("uxnemu", "uxnemu", rom, NULL); // exec uxnemu
perror("exec uxnemu failed");
}
}

69
term.py Executable file
View File

@ -0,0 +1,69 @@
#/usr/bin/env python
import fcntl
import os
import pty
import sys
import struct
import termios
# return dimensions (cols x rows)
def load_dimensions():
# default to 80x24
dims = 80, 24
if not os.path.exists('.theme'):
return dims
try:
with open('.theme', 'rb') as f:
data = f.read(8)
if len(data) < 8:
return dims
vals = struct.unpack('HHHBB', data)
x, y = int(vals[3]), int(vals[4])
if x < 80 or y < 24 or x > 200 or y > 100:
print('invalid width/height: %d/%d' % (x, y))
sys.exit(1)
dims = x, y
except Exception(e):
print('error in .theme file: %s' % e)
sys.exit(1)
return dims
def main():
# check usage
args = sys.argv[1:]
if len(args) < 1:
print('usage: %s ROM')
print('')
print(' ROM: the rom file to launch')
sys.exit(1)
# either detect dimensions from theme or use 80x24
cols, rows = load_dimensions()
# path to rom to run
rom = args[0]
# fork with a new pty
pid, fd = pty.fork()
if pid == 0:
# set TERM to something we can (mostly) handle
env = dict(os.environ)
env['TERM'] = 'ansi'
os.execvpe('bash', ['bash'], env)
else:
# set the terminal size
size = struct.pack("HHHH", rows, cols, 8, 12)
fcntl.ioctl(fd, termios.TIOCSWINSZ, size)
# use fd for the terminals stdin/stdout
os.dup2(fd, sys.stdin.fileno())
os.dup2(os.dup(fd), sys.stdout.fileno())
os.execvp('uxnemu', ['uxnemu', rom] + args[1:])
if __name__ == "__main__":
main()

1328
term.tal Normal file

File diff suppressed because it is too large Load Diff