Home
CBM
  ASCII-X
  BASIC
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
A nice thing about the CBM 8-bit computers is they have a full-screen text editor.  If you "upgraded" from CBM to a 16/32-bit DOS machine, you were probably shocked by the primitive text editing on those "better" machines.  Like many text editors, the CBMs have several control codes for things like cursor movement and font changes (color, underline, flash, reverse, font selection).  These codes are identical in both ASCII-X and PETSCII character sets because they are "non-printing" characters.  Importantly, those are each one character (byte) and except for a few features, like color and flash, they are supported in all the CBM models.  Most of them are entered by pressing two keys simulatiously (for example, hold down Control and press R).
 
Some of the later machines (CBM-II series, TED series, C128) offer more advanced text editing, but since virtually all of the 8-bit control codes were used, these machines used a two character (two-byte) escape sequences for the new features.  They're called ESC codes for short.  They almost always begin with the ESC key and end with a letter of the alphabet.  Unlike control-codes, the escape codes need to be entered by pressing each of the two keys seperately in sequence.  The ESC codes are fairly compatible between machines that actually support ESC codes at all.  They're listed below with differences noted.
 
Key Sequence
Code Bytes
Machines
FunctionNote(s)
Dec.Hex.CBM-IITEDC128
HOME HOME19 1913 13+++Disable window (access full-screen) 
ESC ESC27 271B 1B++Clear quote and (manual) insert modes
ESC @27 641B 40+Clear to end of screen 
ESC A27 651B 41+++Enable Auto-Insert mode
ESC B27 661B 42+++Set Bottom-right corner of window
ESC C27 671B 43+++Cancel Auto-Insert mode
ESC D27 681B 44+++Delete logical line (lines below move up)Logical line may span multiple physical lines
ESC E27 691B 45++Disable cursor flashing
ESC F27 701B 46++Enable cursor Flashing
ESC G27 711B 47++Enable ASCII Bell (Control-G)
ESC H27 721B 48++Disable ASCII Bell
ESC I27 731B 49+++Insert a blank line (others move down)
ESC J27 741B 4A+++Move to start of line
ESC K27 751B 4B+++Move to end of lineOn C128, moves past last character; others onto last
ESC L27 761B 4C+++Enable screen scrolling
ESC M27 771B 4D+++Disable screen scrollingCursor will move to top row if trying to go past last row
ESC N27 781B 4E++Normal (non-reverse) video modeOn C128, only applies to 80-column (VDC) screen
ESC N27 781B 4E + Normal window (access full-screen) Normal 40x25 window (also clears the screen)
ESC O27 791B 4F+++Clear quote, reverse, (manual) insert modesOn CBM-II series, it also prints an O (bug)
ESC P27 801B 50+++Clear to start of line
ESC Q27 811B 51+++Clear to end of line
ESC R27 821B 52+ +Reverse video mode On C128, only applies to 80-column (VDC) screen 
ESC R27 821B 52 + Reduced window (for smooth scrolling?) 38x23 window (also clears the screen)
ESC S27 831B 53++Solid (block) cursorNormal (the alternate is underline cursor)
ESC T27 841B 54+++Set Top-left corner of window
ESC U27 851B 55++Underline cursornormal is solid block
ESC V27 861B 56+++Scroll window contents up 1 linePhysical line; may chop a logical line
ESC W27 871B 57+++Scroll window contents down 1 linePhysical line; may chop a logical line
ESC X27 881B 58+Exchange editorSwitch between 40 and 80 column screens
ESC Y27 891B 59+Set default tab stopsOne every 8 characters
ESC Z27 901B 5A+Clear all tab stops
 
Some interesting things you might notice, or be curious about.  The editor has two forms of insert mode.  Manual insert is when you press Shift+Del (INS) to manually open space for text; this is needed because the editor is (by default) in "overwrite" mode.  Other CBM machines (those without ESC codes) only support manual insert mode.  This mode can be convient for BASIC programmers because it allows control characters (like Control+S to HOME the cursor) to be inserted into text strings.  That is, manual insert mode works very similar to quote mode: most control codes will print a special character in reverse-font video.  However, this also means cursor keys will not function (they print special reverse-characters too).  Manual insert mode can be canceled in a few ways: type enough characters to fill up all the inserted spaces, press (Shift) Return to go to the next line, or (where available) ESC O or ESC ESC.
 
The codes ESC O and ESC ESC perform almost the same action.  They both cancel the pesky quote and manual insert modes.  However ESC O also disables reverse font.  Neither cancels Auto-insert mode.
 
Auto-insert mode is the default for most modern text editors.  It is not the default for any CBM machine.  This is probably because it can be slow.  It works fast when editing inside a line because the editor will look for a "next character" on the same line which is usually only 1 character away (very quick test).  But when the computer wants to print on a blank line (or at the end of line already containing text) it has to check all remaining character on the line to be sure nothing needs to be shifted.  So the first character on a blank line requires 79 tests (most video displays), the second character on a line needs 78 tests, etc.  Thus several hundred tests can be performed to print a single line.  This becomes obviously slow when the computer needs to display many lines (like listing a program or disk directory).  Anyway, the only way the editor can cancel auto-insert mode is ESC C (note that BASIC clears auto-insert mode when you RUN a program).
 
On all CBM machines, the editor can be placed into reverse-text mode with Control+R (or sometimes Control+9).  This makes only the following characters appear in reverse font.  The video chip in the CBM-II series (6548?) and the 80-column display chip of the C128 (8563/8 VDC) feature a reverse screen mode activated with ESC R.  This reverses all characters on the screen; it will even re-reverse characters that were formerly in reverse-font (so they appear 'normal').  I don't know what use this would have on the CBM-II series which lack color, but on the C128 this allows each character to have a different background color (however, all text will now have the same foreground color).  This special reverse-video mode is canceled with ESC N.
 
On the TED series, ESC R and ESC N perform an operation completely incompatible with the CBM-II series and C128.  ESC R sets up a 38x23 text window (one character of padding on all four sides); I'm guessing this is to help with smooth scrolling?  ESC N sets the editor for normal full-screen 40x25 text window.  This action is almost the same as HOME HOME.  The difference is that ESC N (also ESC R) erase all text on the screen.
 
HOME HOME clears any active window and allows full-screen editing.  Yes, CBM does windows!  ESC T will mark the current cursor position as the top-left corner of a window, and ESC B will mark the current cursor position as the bottom-right corner.  This can be useful when editing to keep important information from scrolling off-screen as new lines are entered.  It can also be useful in a program to implement, umm, windows.  The only issue there is you would probably want some way to "memorize" the old/current screen contents before rendering a new window and then some method to restore the screen when you want to "close" the window.
 
Interestingly, the TED series does not support the ASCII Bell (Control-G) even though it has a sound chip.  Not suprisingly, the related ESC G and ESC H do nothing on these machines.

© H2Obsession, 2014