glcc: some simple c source as play ground

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

Hi.

ok. My mistake. You are right. Youre version works.
In the original version from me, the snake starts immediadly. In your version, you have to press a movement key first, otherwise it waits in the middle.
And I was using cursor keys in KBD mode, not wasd keys. Therefore, I thought, it is not working.

Thanks again, for the explanation. So snake might now be an very simple example of using conio.h and game movement without waiting for key input.
(Working source attached again)

best, Peter
Attachments
snake.c
(2.63 KiB) Downloaded 172 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: glcc: some simple c source as play ground

Post by lb3361 »

petersieg wrote: 01 Aug 2023, 20:26 My mistake. You are right. Youre version works.
I did not understand the lastkey logic. But I realize now that my version stops the snake whenever you press a key that is not an arrow.
Is this why lastkey was necessary?
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

Yes. lastkey logic was required.
Here is an updated snake.c with lastkey logic.

best, Peter
Attachments
snake.c
(2.6 KiB) Downloaded 161 times
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

So here is another game 'Atom / Chain Reaction' using conio with a quick fix to make it work under glcc+Gigatron.

Game Play: https://learncgames.com/tutorials/atoms ... -tutorial/
Original Source: https://github.com/David-H-Bolton/LearnCCode/tree/main
Conio used for linux/macos: https://github.com/casualsnek/linuxconio/tree/main

In the zip file:
v0 = original source using local conio.h from above side: cc atoms.c -o atoms (Mac OS Ventura)
v1 = working Gigatron version - same as on main directory as a safe place.

Have fun playing, making it better (eg: no scrolling; using colors..) whatsoever ;-)

best, Peter
Attachments
Bildschirmfoto 2023-08-06 um 19.17.51.png
Bildschirmfoto 2023-08-06 um 19.17.51.png (41.59 KiB) Viewed 1560 times
atoms.zip
(30.43 KiB) Downloaded 165 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: glcc: some simple c source as play ground

Post by lb3361 »

One of my GLCC tests is now a rewritten variant of snake.
I also have a good conio emulation for unix (in the unix directory).
Just "make snake" for unix, "make TSTsnake.gt1" for gigatron.
- Leon

https://github.com/lb3361/gigatron-lcc/ ... tuff/conio
Attachments
TSTsnake.gt1
(4.62 KiB) Downloaded 163 times
Last edited by lb3361 on 09 Aug 2023, 05:15, edited 1 time in total.
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

Very nice improvement! Many Thx.

best, Peter
Attachments
TSTsnake.gt1
(6.49 KiB) Downloaded 158 times
Bildschirmfoto 2023-08-08 um 13.55.20.png
Bildschirmfoto 2023-08-08 um 13.55.20.png (39.03 KiB) Viewed 1525 times
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

I apologize upfront - but I could not resist.
I know - nobody needs Eliza - but here it is adapted for Gigatron 64k required. ;-)

Source from here:
https://github.com/mottosso/cs50x/blob/master/eliza.c

(In the Mac Emu, it does NOT run - only black screen?. In gtemuAT67 it runs fine)

best, Peter
Attachments
LICENSE.txt
(1.06 KiB) Downloaded 156 times
Bildschirmfoto 2023-08-09 um 19.57.40.png
Bildschirmfoto 2023-08-09 um 19.57.40.png (47 KiB) Viewed 1505 times
eliza64.gt1
(10.5 KiB) Downloaded 154 times
eliza.c
(12.04 KiB) Downloaded 177 times
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

Simple 2048 game.
Original Source from here: https://gist.github.com/ibaned/41481b2fdddbb61a4291
Now runs on Gigatron ;-) Use wasd for movements.
Lot of improvements possible ;-)

best, Peter
Attachments
Bildschirmfoto 2023-08-10 um 12.50.40.png
Bildschirmfoto 2023-08-10 um 12.50.40.png (38.82 KiB) Viewed 1481 times
2048.zip
(17.06 KiB) Downloaded 167 times
petersieg
Posts: 111
Joined: 28 Jun 2023, 09:06

Re: glcc: some simple c source as play ground

Post by petersieg »

Some more simple c code examples.
This time "Enigma".
The crypto machine used in WW2 by german army.

Links:
https://en.wikipedia.org/wiki/Enigma_machine
https://www.codeproject.com/Articles/831015/ENIGMA
Some simple c code used here and found at:
https://github.com/timlindquist/Enigma/tree/master

Could be improved by showing rotating wheels etc. pp;-)

Have fun, Peter
Attachments
enigma.png
enigma.png (50.36 KiB) Viewed 893 times
enigma.zip
(39.39 KiB) Downloaded 131 times
Post Reply