Hacker News new | past | comments | ask | show | jobs | submit login
C64 Basic Tutorial: Using String Manipulation to Write a Text Adventure (retrogamecoders.com)
47 points by rbanffy 48 days ago | hide | past | favorite | 12 comments



People of a certain age (and geographic location) will remember the Usborne Write Your Own Adventure Programs[0] book that taught kids the intricacies of string parsing and data driven programming in basic. I used that book to write several adventures of increasing complexity during my early teens.

[0] https://sheep.horse/2017/2/usborne_computer_books.html (self link)


Your link to the Usborne books is dead—this works:

https://usborne.com/us/books/computer-and-coding-books


My grandmother had the foresight in the 80s to buy me a C64 while I was still in elementary school. She was the only one in the family who would've done it.

I'm grateful I was able to show off a very simplistic 'choose your own adventure' type program to her before she died. It was mostly ASCII art, more of a proof of concept and less than 10 screens, but still.


Well done granny. I lacked your imagination and thumped in loads of machine code listings from a series of books to do basic graphics and sounds. Mind you I did discover about attack/decay/sustain/release and a few other things so all good.

I still have my C64. It now has a USB interface and I don't use it much these days sigh

I suspect you made your granny very proud and quite rightly so. A couple of little girls call me grandad these days ...


Ben Heckendorn has a few YouTube videos where he revisited and improved some text adventures he wrote ages ago:

Adventure Island https://www.youtube.com/watch?v=C9qSw3BZ5n4

Adventure Island Rebirth https://www.youtube.com/watch?v=wZZzcRhFuXk / Source code: https://github.com/benheck/AdventureIslandAtari800

More Atari BASIC Games https://www.youtube.com/watch?v=c2W1THaLqhk


I wrote a Zork-style text game in high school as an end-of-year project on a TRS80 model III, using its built-in BASIC. There were three stages of the game, and all was going well until I ran out of RAM. :( Stage 1 was complete, though. For being an elective, I put a lot of work into that game. The teacher even let me lug the giant beast home once or twice.


Curious how the author first spends words to explain that concatenating strings can be wasteful of precious memory, and then does exactly that in the program, by repeatedly printing constructed strings (with "+") instead of merely printing them side by side (with ";").


I’m feeling like next year I want to try advent of code in either Apple II, Atari, or C64 BASIC…


That might be rather more difficult than you might expect. Advent of Code uses quite a lot of 64-bit numbers. A bit of googling tells me C64 BASIC only supports 16-bit integers and 32-bit floats. I imagine the other BASICs have similar limitations.

I did 2023 Advent of Code with my own compiler and this was the biggest challenge I ran into. I only had 32-bit integers at the time so I had to manually implement 64-bit math and number formatting within the language to be able to do the puzzles. You would probably have to do the same in BASIC.


Commodore BASIC, derived from Microsoft's 6502 BASIC, actually has 40-bit floats, with a 32-bit mantissa and 8-bit exponent, not that it would help much, if any, with 64-bit maths.

There are Microsoft BASICs that have 64-bit floats, such as built into ROM on the TRS-80 Model I, III and 4 w/Level 2 BASIC, TRS-80 Model 100/102, TI-99/4(a), Apple III, and MSX systems, or on cartridge such as Microsoft BASIC for the Atari 8-bit computers.


Ah that book, I have found an old friend!

That book series was my first take into role playing and adventure games, have quite a bunch, at least those that happened to be translated into Portuguese.


so was it common bitd to write adventure games or rather adventure engines? i certainly did so. i think because the premiere games of the age were adventure games, not because of a special attraction to rudimentary role playing. so we were all aspiring to that greatness which we found inspiring.

honestly this and the few comments so far are a surprise to me. i thought i was a rare breed that spent all my time on this kind of programming




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: