Developing comlynx support for Atari Lynx homebrew could seems a difficult task, but I discovered that it's easy.
I think that the real reasons for so few homebrew with comlynx support are that there aren't so many examples of code available, and comlynx is not well suported on emulators, making difficoult to test the code.
Sage's version of handy should support comlynx emulation over UDP, but using two PC is not the best solution while testing, and on my PCs I wasn't able to make it work (it crashes trying to connect).
Since I'm developig a game that uses a 2 players mode, and I have to wait long time before to have an SD cart or an EEPROM cart programmer PI hat, I decided to modify Sage's version of the emulator to run two instances of the emulator core in the same application, than crosslinked the TX and RX comlynx interfaces of the two cores to have a comlynx test enviroment that can run on a single PC and without relying on network protocols.
I made a quick and dirty tweak of the code, so don't expect an advanced version of handy. It's buggy, plays sound from both emulators core (so better disable sound) and can't emulate commercial games comlynx connection. But it works very well as a testing tools for developers.
It's possible to swap betwen the two cores with CTRL+N or from the emulator menu. The active core outputs to the screen and gets the keyboard input, the other one runs silently in background. This means that it's not possible to use the two cores at the same time.
Attached you can find a build for windows and a zip with the modified sources. When I have time I'll add the sources to my github and post the link here.
To encourage other developers to start using the comlynx feature in their games (this can give more chances to win in the atarigamers game competition of this summer ) I'm sharing here two code examples of comlynx use.
The first one is a simple piece of code from karri already posted on the forum (http://atariage.com/...r/#entry1888745) that doesn't seem to have attracted the attention of the other developers. I slightly modified karri's code and attached it here (testcon.zip).
In this example some sample text is sent over the comlynx connection at the A key press and printed on the screen of the other endpoint. The B key clears the buffer. The direction keys move an Hello world text, so that placing it in different position can help to identify the two running instances.
The second example is a simple but complete game, an implementation of Tic Tac Toe using a 2 player mode over comlynx.
The game uses a simple handshake protocol to start the connection that defines the two players ID (I took the handshake protocol from the comlynx code example of Championship Rally posted here http://atariage.com/...pionship-rally/) and a simple communication protocol derived from a more complex one I'm developing for another game of mine.
Here are some screeshots of the game:
The game code is mine (wrote it in an hour), this means two things:
- It's public domain (do whatever you want with it, you can also develop from it a full game with muisic, gfx and and AI for 1P mode, but hurry up before I do it first)
- It can contain bugs.
I really hope to see a lot of new homebrew games with comlynx support in the next future.
Note: The code axamples posted here aren't tested on real lynx yet. Please let me know if they work as expected.
Edited by Nop90, Sat May 11, 2019 4:03 PM.