MEGA65 / mega65-rom-public

MEGA65 ROM public issue reporting
4 stars 0 forks source link

Escape sequence to disable/enable line pushing #108

Closed dansanderson closed 7 months ago

dansanderson commented 9 months ago

Is your feature request related to a problem? Please describe. When PRINT writes to the rightmost column, it pushes the lines below it downward. This is undesirable in cases where PRINT is being used to update text in a layout, such as in a BASIC full-screen game. It would be better in these cases to have a mode that treats the text screen more as a canvas than a terminal.

Commodore introduces the line pushing behavior in BASIC 3.5. It is not present on the C64.

As a workaround, this can currently be disabled by poking an undocumented KERNAL variable: SETBIT $F8,6 There is not yet a published API for affecting this flag.

Describe the solution you'd like Add printable escape sequences that set and unset this flag. We're almost out of available letters, but it looks like N and R are available, or we can use some punctuation characters like , and ..

Escape sequences are used to affect other editor feature bits, so this is consistent with those. For example, ESC M disables scrolling with cursor movement in the last row; ESC L enables it.

Describe alternatives you've considered

In general, BASIC 10/65 does a good job of minimizing the need for PEEK/POKE tricks, and we need to continue to protect KERNAL internals while the system is still in development.

Additional context See this discussion.

dansanderson commented 7 months ago

I did some experiments with the existing ESC M / ESC L feature to disable "scrolling" (scroll bit 7) along with a new feature to disable "line pushing" (scroll bit 6). I believe this is the right design. Enabling both of these allows PRINT to paint anywhere on the screen without pushing any text.

If we could redesign this from scratch, I'd just have ESC M / ESC L disable/enable both scrolling and line pushing together. I can't imagine wanting one and not the other. But I want this to be a backwards compatible change.

Note that PRINTing in the bottom right corner does not wrap the cursor to the top of the screen. It causes all subsequent printed characters to write to the bottom right corner. I believe this is fine: all that is needed here is predictable defined behavior, and an actual program will just locate the cursor wherever it wants to print something.