C64 Burrow.BAS

原始链接: https://basic-code.bearblog.dev/c64-burrow/

This short Commodore 64 BASIC program, adapted from a 1985 *Run* magazine listing, creates a visual “burrowing” effect using an asterisk. It’s a demonstration of the C64’s capabilities, not a game. The program utilizes `POKE` commands to directly manipulate memory addresses 53280 and 53281, changing the screen frame and background colors respectively. A random direction (up, down, left, or right) is chosen for the asterisk with each iteration, making it appear to dig randomly across the screen. Special C64 control codes, denoted by curly brackets (e.g., `{yellow}`, `{up}`), are used to control color and cursor movement – conventions needed as these aren’t easily represented in text. The program efficiently packs this visual effect into just two lines of BASIC code.

相关文章

原文
c64 Burrow.BAS | BASIC Code

After a long search I've finally figured out how to embed Commodore 64 BASIC listings into blog posts.

This isn't a game, just a visual demo showing off some of the C64's capabilities. It's taken from two one-line programs in the 1985 Special Issue of Run magazine, posted by L.F.S. and Glenn Zuch. I've combined them.

The Listing

1 poke53280,6:poke53281,6:?"{yellow}":fori=1to19:?:next
2 a$="{up}{down}{left}{right}":? mid$(a$,rnd(.5)*4+1,1)"*{left}";:fori=1to30:next:?"{reverse on} {left}";:goto2

Okay, a few notes here. First off, the Commodore 64 keyboard had special keys for setting and changing color. These are hard to convey in printed listings, so the convention is to use {} brackets and indicate what keys should be pressed.

c64-vic20-keyboard

{yellow} is a special character on the 8 key accessed by hitting control+8; this turns the following output yellow. {up}{down}{left} and {right} are the cursor keys. You get them by hitting those keys. They move the on-screen cursor, changing where the next character will print. {reverse on} is control+9, and that basically reverses the color of the next printed character; a space will be a full color "block", etc.

Peek and Poke show up as commands in a few different 8-bit BASICs... what they do is let you look at (peek) or change (poke) memory addresses directly. This is different for every computer model, of course, and it isn't obvious what exactly they do without a memory reference chart.

Poke 53280 lets us directly change the color of the "frame" around our graphics window, and 53281 lets us change the color of the background itself.

The ? mid$ line chooses one of the cursor direction codes we have at random, making the asterisk appear to burrow in a random direction each update.

So, a simple program that crams a lot into two lines. The original was line 2; I adapted line 1 (changing the colors) from another one-liner to make the colors pop a bit more.

#C64

联系我们 contact @ memedata.com