Yesterday I was trying to figure ouut some obscure input things in CobraPy such as "detecting the Enter key" and ran into a lovely package in PyPI: Pymput
What does it do? It lets you inject and read input events.
And by input events I mean mouse andkeyboard.
And it does so in your whole session.
And you wouldn't notice if it was doing that.
And it does this in 20 lines of friendly python code. Here, have a keyboard sniffer:
This is one of the reasons why Wayland (or Mir, I remember Mir!) needs to happen. It's trivial for any desktop app to monitor everything you do. Of course nowadays you also will see software advertising this, as a "feature" where it's used to "monitor employee productivity".
Because remember, often things are only illegal when individuals do them, if you are a company and are charging for it, then Bob's your uncle.
When I started playing with the idea of doing a sort-of-retro-80s-programming-environment called CobraPy
I suspected one of the problems would be finding a graphics library that did what I wanted and had good performance.
I have used PyGame a little in the past but never liked it too much, so I tried Pyglet and it was working great ...
until I tried to add something as simple as a widget to enter text. It doesn't really do widgets, for that you apparently use glooey
But glooey is ... I don't like it. And then I ran into a bug where you can either clean the contents of an EditableLabeland set it to
focused without it crashing deep in its bowels. I worked around it by using fake mouse events to focus. And then noticed you can't type a
double quote in one of those widgets. So, I got pissed.
It literally took me less time to find a nice C game library, read a tutorial on CFFI, do minimal edits to its header file, learn how to use invoke and write my first program using it than I wasted chasing that glooey bug.
I may have hated pyglet + glooey so much I just went and looked for a nice C game library and did a wrapper in 10 minutes using cffi. pic.twitter.com/fEamIs5zQz
Some context: I am doing a sort of modern retro-programming environment-thingie.
So ... I caved. I caved and started typing.
It's still just exploratory, fooling around, but I wanted to see whether the vague
ideas I had about how this could, maybe work were right, and hey, they are!
Text Mode
I wanted a text mode. Something with N rows and M columns where you could just say "put this text there".
Done. In the most basic possible way that works.
Implemented a print_at function that takes row, column and text, and does what it says in the label.
Immediate Graphics Mode
In these old computers you could just draw in the graphics memory. In 2020 ... not so much. So, I implemented
a sort of offscreen buffer. You draw there, and it gets blitted a lot to screen. Ends up working like a flicker-free double-buffered screen! Nice!
Implemented ellipse which ... draws an ellipse. I know, surprising.
Now that was interesting. you see, nowadays you are supposed to have an event loop. The computer is there, idling
and when something happens, then it does something. So, you clicked? It reacts. 10 milliseconds passed? It does its thing.
In the 80s it was not like that. Your program started and it owned the machine. It went through your code, running it as fast as it could with its little two-megaherz-heart until it ran out of code and then it was done.
So, how to make it act like that?
Start the event loop.
Start a second thread with a prompt.
Have the user interact with the prompt.
When the user presses Enter ... send the command to the event loop via a queue.
When the event arrives, do the thing.
And yes, it works! It's probably horrible for performance, but it does work just fine, and it's much,
much easier to make a working program fast than it is to make a fast program work.
So, what's next?
The Future
I may try to integrate the prompt and the window where the text and such is displayed (right now it's in a
terminal) ... maybe sprites.
After that:
Make the API nice and useful (a few weeks of work)
Make the thing run well (a few days of work)
Do the janitorial work to make it usable by someone else (a couple days of work)
Support it, document it, etc (8 to 30 years of work)
I have not started a real serious open source project in a while. Ok, that's a lie.
I have started a number of things and abandoned them, but the last software project
I started that had lasting power was Nikola and that was
in 2012!
I turned 7**2 a couple weeks ago, so I am officially old (it's the law!) and us olds
get bored because we don't get all the tiktok and whatever you youn'uns do.
So, I am getting itchy, and have been thinking of starting something. After seeing
a number of retrocomputing videos, it turns out the ZX-81 of my childhood is
vintage enough that they are actually older than ENIAC was when I got it.
And it got me thinking ... was there anything in that kind of computers that is
worth saving for something other than nostalgia's sake? Sure, playing Monty on
The Run is as fun as always and people still release software for C64 and
similar ancient computers.
However ... well, that sort of reeks of masochism, because developing for those
system was absurdly painful. You can get the same level of pain coding for pico8 and people can play your games
much easier.
There's also the retro-hardware thing but ... honestly, I like modern hardware much better!
For example, a Color Maximite looks much more fun
that a C64 to develop in.
But still.
There is this feeling that current computers are missing something.
Why not explore it a little? I have a theory.
The Theory
Modern computers are made to run things, old computers were not.
Getting someone else's software into your computer in 1984 was absurdly difficult.
Get a computer (try doing that while living in Argentina in 1984)
Now what? There's no Internet
Read the manual and start coding (yes, the manual for the computer explained how)
Fail
Find someone else who had a computer and had actual software for it
Get copies. That often involved copying audio tapes. That would take between 10 and 20 minutes.
Try out the copy on your computer. Loading it into the computer would also take between 10 and 20 minutes.
And after that you had ... a port of Manic Miner to C64 with crappy sound.
So, some of us, we stuck a little to the other side of those remarkable machines. That they booted
into a development environment. That you could make them do shit.
And that's what current computers don't do. They don't do shit. They don't invite you to
start doing your own shit. Which is perfectly and aggressively fine, I don't mind. But I do.
The Plan in My Head
What would the evolution of an 80s computer look like nowadays?
It should invite you to code and do shit
It should run on cheap, commodity hardware that is cheap and easy to find and buy
It should not do much out of the box. It's a box to do shit not to run shit.
Therefore, how about ...
A disk image that you can pop into a raspberry Pi and...
Boots to a limited environment
Where you can do shit
With fixed APIs and a provided software suite so that:
You can do some graphics, easily
You can do some sound, easily
You can edit a program, easily
You can share it somehow, easily
Why the Pi?
It's fixed, known, cheap, supported hardware.
You have IO pins to do extra shit
It's cheap
Also, inexpensive
What APIs?
Direct-address text mode (fake)
One or two graphics modes. 720p and 1080p?
Graphic primitives
Sprites! (hey, it's not the 80s without sprites)
Basic mod playing
Some beeping thingie
What language?
Python. Sorry. I am playing with it, it's not going to be BASIC.
Any weird thing?
Oh yes.
No import. You get the APIs you get.
Programs are one file. You can use packages in your bigboy box over there that has chrome in it.
No internet (no web browsing at least) just use your phone.
Included sprite enditor
Included Music tracker
Are you really going to write this?
Well, I'm going to give it a try and see if it's fun to do. If it's not I won't.
Are you looking for collaborators?
Nope. I want to do this solo at least for the first few months. My coding at early project stages is way too erratic and would make everyone hate me.
What's it called.
It's nostalgic. It's 80s. It has snakes in it. It should be Cobra Kai.
But because copyright exists, it's Cobra Py. Or maybe Cobra Pie, because there's also other python things called Cobra.
h/t to Guido de Caso for figuring out the name.
Perdón por el sonido, moví el micrófono de lugar, quedó más cerca y el sonido clipea, lamentablemente soy demasiado haragán como para grabarlo de nuevo.
Links:
Entrevistas de trabajo: https://youtu.be/ICndfSG1Or4