Remarks: Maze Walker
From Maze
(Difference between revisions)
(→Stabilizing the Maze) | (→Stabilizing the Maze) | ||
| Line 74: | Line 74: | ||
Fortunately, BASIC provides the commands POKE and PEEK to directly write and read physical memory addresses. These commands provide a mechanism for subverting the language abstractions of BASIC, giving the BASIC programmer access to the arbitrary memory manipulation available via assembly language opcodes. If computer memory truly consisted only of data and code, as described by the von Neumann architecture, then POKE and PEEK would have limited utility to the BASIC programmer, merely providing a less convenient mechanism than variables for storing data, as well as the somewhat esoteric ability for a program to modify its own code during execution. But the C64 employs a common computer architecture approach of memory-mapped hardware registers. With memory mapping, in addition to the standard memory space that stores code and data, there are memory addresses for hardware registers that directly control the execution of the machine. These special memory addresses include control for input and output devices, such as screens, keyboards, and printers. On the C64, the BASIC interpreter and operating system code that create abstractions such as PRINT's virtual teletype, perform their lowest level operations by writing and reading these special memory addresses. By providing POKE and PEEK, which were not available in the original Dartmouth BASIC [I don't think memory-mapping was common in 1964, so POKE and PEEK would have had limited utility - further BASIC was operating in a time-sharing environment, so you wouldn't have wanted to provide individual programs access to hardware registers anyway - if we want to go into this, it would be wherever we want to introduce POKE and PEEK], Commodore BASIC provides a backdoor by which BASIC programmers can directly manipulate hardware registers that would typically only be accessible to assembly language programmers. | Fortunately, BASIC provides the commands POKE and PEEK to directly write and read physical memory addresses. These commands provide a mechanism for subverting the language abstractions of BASIC, giving the BASIC programmer access to the arbitrary memory manipulation available via assembly language opcodes. If computer memory truly consisted only of data and code, as described by the von Neumann architecture, then POKE and PEEK would have limited utility to the BASIC programmer, merely providing a less convenient mechanism than variables for storing data, as well as the somewhat esoteric ability for a program to modify its own code during execution. But the C64 employs a common computer architecture approach of memory-mapped hardware registers. With memory mapping, in addition to the standard memory space that stores code and data, there are memory addresses for hardware registers that directly control the execution of the machine. These special memory addresses include control for input and output devices, such as screens, keyboards, and printers. On the C64, the BASIC interpreter and operating system code that create abstractions such as PRINT's virtual teletype, perform their lowest level operations by writing and reading these special memory addresses. By providing POKE and PEEK, which were not available in the original Dartmouth BASIC [I don't think memory-mapping was common in 1964, so POKE and PEEK would have had limited utility - further BASIC was operating in a time-sharing environment, so you wouldn't have wanted to provide individual programs access to hardware registers anyway - if we want to go into this, it would be wherever we want to introduce POKE and PEEK], Commodore BASIC provides a backdoor by which BASIC programmers can directly manipulate hardware registers that would typically only be accessible to assembly language programmers. | ||
| + | |||
| + | The characters displayed on the C64 screen are stored in one of these special regions of memory, called video memory. Display hardware continuously scans video memory, reading character codes, looking up the bitmap describing each character, and drawing each character pixel-by-pixel onto the screen. Thus, even when no user code is executing, and the C64 is just sitting with text visible on the screen, the illusion of stable text is underwritten by frenetic activity, as character codes are accessed, bitmaps looked up, and characters painstakingly drawn, pixel by pixel, over and over again. So even in a one-line program like 10 PRINT, layers of process complexity underwrite the abstractions which provide the visual experience of an endlessly scrolling maze-like pattern. | ||
