6502 Math and Strings

How To Create Guessing Game using 6502 assembler

Introduction

I thought it would be great to code a guessing game using assembly language and the 6502 emulators. During the implementation, I have used the code to place a graphic on the screen from the CDOT wiki website. Also, I have used hex to decimal conversion code from the Bet Eater video. He has a great channel related to 6502 and breadboards builds, I highly recommend subscribing to his channel.

As the code is 400 lines long, I have created a repository on my GitHub and pasted the implementation there. Feel free to check it out!




In the screenshot above, you can see the winning sprite that is shown when you find the guessed number. Also, there is a guess counter and a message giving hints.

Enhancements

The only thing that I would add is to improve the random number generation process as it currently uses the "lsr" and "and" instructions to ensure that the number is between 0 and 99. Such an approach throws a lot of information of the byte generated at $fe and the possible variety is small and very repetitive. The best way would be to somehow map the range 0-255 to 0-99 which will preserve all bits.

Conclusion

The process of coding was really engaging and spent two straight days creating this little game. I have a lot of new things and I am pretty confident now working with this assembly. Finally, the process of problem solving and research are the best part of this journey.


Author: Iurii Kondrakov 
GitHub: github.com

p.s this blog post is created for the SPO600 Lab 3

Comments