Remarks: One-Liners

From Maze

(Difference between revisions)
Jump to: navigation, search
Line 1:Line 1:
−
One-liners such as 10 PRINT are curt, minimal BASIC programs written to illustrate, represent, and express ideas. These remarks examine three one-liners which make use of the RND function in BASIC on the Commodore 64.
+
One-liners such as 10 Print are curt, minimal BASIC programs written to illustrate and express ideas. 10 Print, a one-liner, draws a maze. Other one-liners help the programmer stage practical jokes. A number of one-liners make use of a command found in BASIC called RND. The following programs, Icicle Storm and Windy Day in Chicago demonstrate why the RND command is so important in one-liners such as 10 Print.
−
Due to their brevity, one-liners must often exploit resources existing in the underlying platform. For example, 10 PRINT relies on graphical images called PETSCII contained in the ROMs of the Commodore computers. The single line of code itself contains no data pertaining to the curves or pixels comprising the / and \ images. 10 PRINT uses merely the numbers 205.5 and 0.5 to refer to characters number 205 and 206. Those two numbers are indexes into the "block graphics set" which the 8-bit home computers used to draw simple graphics. This feature, common to the Commodore video display hardware and many other platforms, but not the original Dartmouth BASIC system, helps keep the program very short.
+
Due to their brevity, one-liners must often exploit resources existing in the underlying platform. There is no space in the single line to include extensive data about specific movements, such as a 3-D character animation. 10 Print relies on graphical images called PETSCII contained in the ROMs of the Commodore computers. The single line of code itself contains no information pertaining to the curves or pixels comprising the / and \ images. It uses merely the numbers 205.5 and 0.5 to refer to characters number 205 and 206. Those two numbers are indexes into the "block graphics set" which 8-bit home computers used to draw simple graphics. The block graphics set uses more data to encode the image: 8 bytes each versus. approximately two.
 +
 +
Block graphics sets, common to the Commodore video display hardware and many other platforms, although strikingly not the original Dartmouth BASIC system, help keep 10 Print very short. Those symbols can be used expressively with the RND command in other ways, too.
*Icicle Storm
*Icicle Storm
Line 7:Line 9:
Block graphics sets - such as the non-typographic / and \ symbols used in 10Print - have collectively allowed a non-alphabetic visual vocabulary to flourish, one capable of representing emotions, stick-figures, space travel, balance sheets, and graphical window systems. In 10 PRINT, block graphics characters more firmly represent the notion of a maze than the typographic / and \ symbols. A maze constructed of / and \ would have leaks at every junction. In contrast, the block graphics symbols form tight edges, accurate to the pixel.
Block graphics sets - such as the non-typographic / and \ symbols used in 10Print - have collectively allowed a non-alphabetic visual vocabulary to flourish, one capable of representing emotions, stick-figures, space travel, balance sheets, and graphical window systems. In 10 PRINT, block graphics characters more firmly represent the notion of a maze than the typographic / and \ symbols. A maze constructed of / and \ would have leaks at every junction. In contrast, the block graphics symbols form tight edges, accurate to the pixel.
−
For example, in the one-liner variation on 10 PRINT below, one of the same diagonal symbols that 10 PRINT uses can be reinvoked as an icicle:
+
For example, the variation on 10 Print found below reinvokes one of the same diagonal graphics characters that 10 PRINT uses as an icicle:
10 poke 1024+rnd(1)*1000,78: goto 10
10 poke 1024+rnd(1)*1000,78: goto 10
−
 
−
In that program, part of the impression of movement and space-filling are features inherent to the medium of BASIC on the Commodore 64. Specifically, the slow, ruthless instantiation of icicles mimics the dynamics of a mounting storm because the computer can not draw them fast enough to fill the screen instantly. For narrative purposes, it would be possible to <em>slow down</em> the drawing, but not to speed it up (without resorting to extra-BASIC code execution or upgraded hardware). In a similar way to Icicle Storm's window gradually filling with frozen snow, 10 PRINT presents a cinematic representation of an experience. The pace of that experience is limited to the slow and steady synthesis of their final output images.
 
This one-line simulation may represent the accumulating energy of a storm, but it will never, like a real storm, die out and warm up. After completely filling the screen, the action ceases, so the one-liner can only tell one part of a story.
This one-line simulation may represent the accumulating energy of a storm, but it will never, like a real storm, die out and warm up. After completely filling the screen, the action ceases, so the one-liner can only tell one part of a story.
Line 18:Line 18:
Icicle Storm relies on the RND command as well as "screen memory," the grid-shaped arrangement of memory locations which corresponds to the PETSCII graphics as they appear on a monitor.
Icicle Storm relies on the RND command as well as "screen memory," the grid-shaped arrangement of memory locations which corresponds to the PETSCII graphics as they appear on a monitor.
−
+
In that program, part of the impression of movement and space-filling are features inherent to the medium of BASIC on the Commodore 64. Specifically, the slow, ruthless instantiation of icicles mimics the dynamics of a mounting storm because the computer can not draw them fast enough to fill the screen instantly. For narrative purposes, it would be possible to <em>slow down</em> the drawing, but not to speed it up (without resorting to extra-BASIC code execution or upgraded hardware). In a similar way to Icicle Storm's window gradually filling with frozen snow, 10 PRINT presents a cinematic representation of an experience. The pace of that experience is CPU-limited to the slow and steady rendering of their final output images.
−
 
−
 
−
 
*Windy Day in Chicago
*Windy Day in Chicago
−
In addition to using external graphics to maintain brevity, BASIC one-liners tend to rely on the random number generator command RND. In Icicle Storm, the unpredictable nature of the random number generator emulates the natural physical process of precipitation.
+
In Icicle Storm, the unpredictable nature of the random number generator emulated the natural physical process of precipitation. This random nature can be combined with another hardware feature of the Commodore 64, the VIC-2 chip. Together they create the following example which exploits the video chip inside the Commodore 64:
−
 
−
This random nature can be combined with another hardware feature of the Commodore 64, the VIC-2 chip. Together they create the following example which exploits the side-scrolling video chip inside the Commodore 64:
 
10 poke 53248+22,int(192+4+3*sin((time*3.456+rnd(1)*.5))): goto 10
10 poke 53248+22,int(192+4+3*sin((time*3.456+rnd(1)*.5))): goto 10
 +
It is a good example of one-liner program which exists not only to express a thought about weather, but also demonstrates the simplicity of working with the side-scrolling register in the video chip, an advanced topic which is never taught explicitly in the Commodore 64 manuals.
*Random SID Tones
*Random SID Tones
−
The BASIC included with the Commodore 64 included no specific commands such as PLOT and SOUND for controlling the video and sound hardware. As a result, simple sound programs are generally longer than one line. For example, the program below is an audio equivalent of 10 PRINT which plays a juxtaposition of alternating tones balanced evenly between two opposing piano notes.
+
The BASIC included with the Commodore 64 included no specific commands such as PLOT and SOUND for controlling the video and sound hardware. As a result, simple sound programs are generally longer than one line. For example, the program below is an audio equivalent of 10 Print. It plays a string of alternating tones balanced evenly between two opposing piano notes using the same pseudorandom pattern as 10 Print.
5 s=54272
5 s=54272
Line 50:Line 46:
−
This program can not be squished into one line for for many reasons. For example, as seen in line 20, the program must supply or perform its own calculations to create the descriptive data pertaining to the desired note. It is not possible, as in the case of 10 PRINT, and other one-liners like Icicle Storm, to supply an index into a reserve of information.
+
This program can not be squished into one line for for many reasons. For example, as seen in line 20, the program must supply or perform its own calculations to create the descriptive data pertaining to the desired note. It is not possible, as in the case of 10 Print, and other one-liners like Icicle Storm, to supply an index into a reserve of information because that information does not naturally exist in the Commodore 64. For example, the original Commodore 64 BASIC did not have a command to produce a tone simply by specifying an index into a note table. These tables had to be included in programs. Furthermore, the sound chip required two POKE commands to change the note frequency. Although this is because the chip is extremely accurate in this pitch control, it makes the the computer difficult to write one-liner sound programs for.
−
+
Another way to go about probing the capabilities of complex chips like the Commodore 64's VIC-II and SID registers is to simply write random values to them. IN THE CASE OF THE VIDEO CHIP THIS MAY BE UNSAFE. According to the Programmer's Reference Manual certain values must not be altered, but you may safely try this program in an emulator:
−
Another way to go about probing the capabilities of complex chips like the Commodore 64's VIC-II and SID registers is to simply write random values to them. IN THE CASE OF THE VIDEO CHIP THIS MAY BE UNSAFE. According to the Programmer's Reference Manual certain values must not be altered, but you may safely try it in an emulator.
 
Randomize VIC-II (video chip)
Randomize VIC-II (video chip)
10 poke 53248+rnd(0)*46,rnd(0)*256: goto 10
10 poke 53248+rnd(0)*46,rnd(0)*256: goto 10
−
Random SID (sound chip)
+
Random SID Music (sound chip)
10 poke 54272 + (0*ti+(rnd(1)*25)),(rnd(1)*256)and255:goto 10
10 poke 54272 + (0*ti+(rnd(1)*25)),(rnd(1)*256)and255:goto 10

Revision as of 13:26, 19 July 2011

View this revision of Remarks: One-Liners.

Personal tools