Page 1 of 1

Snake revisit.

Posted: Sat Feb 04, 2023 7:08 pm
by Whitey
So it's been an interesting journey to this point. My new to me physical zx81 needs an adjustment to the composite video mod as it's currently showing both a grey rather than white screen and the text is distorted so I'm still on the emulator currently whilst I wait on a new composite video mod board.

After 40 years away I'm rediscovering sinclair basic but have also found mcoder2 which is a game changer albeit with it's idiosyncrasies around random number generation!
I never understood machine code as a kid and that is a project for later.

My initial project has been a snake style clone written in basic adapted for and then compiled with mcoder 2
This is week one.
Currently produces a game play area, moving snake, four direction control, both snake and walls have crash detection. Each move increase the score and every 50 points the snake grows by two segments.
Hopefully the youtube link works

Next will be random placed food item to grow the snake by one segments and 'hazard' mushrooms to avoid.
If I can get that far then I'll 'pretty it up'😂

https://youtu.be/HYnEcKUBkPM

Re: Snake revisit.

Posted: Sun Feb 05, 2023 5:01 pm
by dr beep
Hello,

my suggestion after 40 years:

Skip MCODER2 and start machinecode. Your code will not only be shorter, but it will be faster as well.

If you think it is too hard, start simple.
Make it BASIC first and then convert it step by step into machinecode.

Enough knowledge here to help you out when you get stuck.

Re: Snake revisit.

Posted: Sun Feb 05, 2023 5:54 pm
by Whitey
Thanks for the advice. It's certainly something I'd like to learn. I was very Concious that other than messing around with an arduino and c++ a couple of years ago I hadn't done any programming since I was a kid so baby steps are going to be needed. 🤦‍♂️😂

Re: Snake revisit.

Posted: Wed Feb 08, 2023 7:16 pm
by Whitey
Thanks to the help with mcoder2 random number generation my snake clone now sports poisonous mushrooms that kill you on contact and sporadically increase in number and food to make your tail grow.
it's far from pretty or efficient programming but it's mine and the first one I've produced in fourty years 😂

https://youtu.be/wbb29PZ3EDc

Re: Snake revisit.

Posted: Wed Feb 08, 2023 8:22 pm
by mrtinb
dr beep wrote: Sun Feb 05, 2023 5:01 pm Skip MCODER2 and start machinecode. Your code will not only be shorter, but it will be faster as well.

If you think it is too hard, start simple.
Make it BASIC first and then convert it step by step into machinecode.
Another approach is to make small sub-routines in machine code. The idea is to break down the problem, and test the small routines, before they are combined with the rest of the code. Then combine the program with

Code: Select all

CALL subrutine1
CALL subrutine2
CALL subrutine3
If you then need to add an IF-statement to your code, it could be

Code: Select all

CALL subrutine4
CALL testConditionForIFandSetZflag
CALL Z subrutineIFflagZisSet
CALL subrutine7
A good idea is also to have a subrutine, that displays the current status of registers and program counter, and stack pointer - without modifying them.

Then you can add

Code: Select all

CALL showregisters
multiple times in your code, when you are trying to find an error.

Re: Snake revisit.

Posted: Wed Feb 08, 2023 9:44 pm
by dr beep
mrtinb wrote: Wed Feb 08, 2023 8:22 pm
A good idea is also to have a subrutine, that displays the current status of registers and program counter, and stack pointer - without modifying them.

Then you can add

Code: Select all

CALL showregisters
multiple times in your code, when you are trying to find an error.
Even easier is setting a breakpoint in EughtyOne and do step execution.
It will give all the info Mrtinnb mentioned.

Re: Snake revisit.

Posted: Wed Feb 08, 2023 10:29 pm
by Whitey
Thanks guys. I'm definitely going to look to progress the machine code thing.
Now that I know I can sort of remember how to program in basic I figure I'll probably look to try the machine code subroutine thing first.
I may use snake as my test bed or I might try some thing a bit simpler to start with.

I've got a small bouncing ball thing I wrote to test out using mcoder a couple of weeks back that might make a useful test project.

Re: Snake revisit.

Posted: Mon Feb 27, 2023 5:15 pm
by Whitey
Whilst waiting for my interface parts to arrive i spent a bit of time on this.

Dr Beep will be horrified that it's compiled with mcoder 2 but I'm still at the point of crashing my machine just trying to print simple characters on the screen in machine code 🙄😂
D7CFD77E-FFD1-43FA-96AA-A9E98AF1EDEB.jpeg
The video of it running is here
https://youtu.be/Sk3UDBQXuio

Even compiled from basic it needs significantly slowing down to be playable.
I'm looking forward to being able to code this sort of thing myself without the need of a compiler.

Re: Snake revisit.

Posted: Mon Mar 27, 2023 11:45 pm
by salvacam
I just saw this contest, in case you are interested in presenting the game
https://itch.io/jam/retro-snake-game-jam

Re: Snake revisit.

Posted: Wed Jul 26, 2023 8:16 pm
by JohnsBargs
Whitey wrote: Mon Feb 27, 2023 5:15 pm Whilst waiting for my interface parts to arrive i spent a bit of time on this.

Dr Beep will be horrified that it's compiled with mcoder 2 but I'm still at the point of crashing my machine just trying to print simple characters on the screen in machine code 🙄😂
D7CFD77E-FFD1-43FA-96AA-A9E98AF1EDEB.jpeg

The video of it running is here
https://youtu.be/Sk3UDBQXuio

Even compiled from basic it needs significantly slowing down to be playable.
I'm looking forward to being able to code this sort of thing myself without the need of a compiler.

I love the look of this! Any news on it?