The Commodore 64
From Maze
(Difference between revisions)
(added a bit of Casey's original introduction back in, in a slightly different spot) | |||
| Line 139: | Line 139: | ||
GOTO 10</blockquote> | GOTO 10</blockquote> | ||
| − | 10-Print is programmed to loop forever, so there must be a contingency available for when the cursor has filled the entire screen grid with characters and cannot move to the next row. In addition to automatically wrapping text, the Commodore 64's text mode also automatically scrolls the contents of the screen when the cursor is on the bottom row and attempts to move down. While it seems intuitive to do this, some programming environments would simply stop the program or return the cursor to the first column and row of the grid, overwriting the characters that had already been printed on the screen. | + | 10-Print is programmed to loop forever, so there must be a contingency available for when the cursor has filled the entire screen grid with characters and cannot move to the next row. In addition to automatically wrapping text, the Commodore 64 BASIC shell also automatically scrolls the contents of the screen when the cursor is on the bottom row and attempts to move down. [tk-check if this uses the VIC-II scroll function or if it's a ROM thing] (Though it appears to scroll the screen up two lines after hitting the last character slot on the screen, from the Commodore 64's perspective only one line is advanced; the Commodore 64's physical screen was 40 characters wide, but its logical screen width was 80 characters.) While it seems intuitive to do this, some programming environments would simply stop the program or return the cursor to the first column and row of the grid, overwriting the characters that had already been printed on the screen. |
| − | Modified version: | + | ''How can the assumption be changed?'' To avoid invoking the automatic text scroll, POKE must again be substituted for PRINT. The output of the example below looks almost the same as the PRINT version because the variable I in the FOR loop takes on a cursor-like function, forcing POKE to create characters in the same order that PRINT would. However, when the fake cursor gets to the end of the screen no scrolling takes place and it simply starts again at the top-left corner of the screen, drawing over the characters that it already put there. |
| + | |||
<pre>10 FOR I=1024 TO 2043: POKE I,205.5+RND(1): NEXT I: GOTO 10</pre> | <pre>10 FOR I=1024 TO 2043: POKE I,205.5+RND(1): NEXT I: GOTO 10</pre> | ||
| + | |||
| + | [[File:10-print-noscroll.gif|600px|thumb|center|10-Print without scrolling]] | ||
| + | |||
| + | [tk-ended editing here for the day] | ||
==Layers of Code== | ==Layers of Code== | ||
