diff --git a/README.md b/README.md index 3e7b1de..80ddf1b 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ The following escape sequences can be used to control the terminal behaviour Clear entire screen. * **`\ESC[{ROW];{COLUMN}f`** Same as `\ESC[{ROW];{COLUMN}H`. + * **`\ESC[{TOP};{BOTTOM}r`** + Selects top and bottom margins, defining the scrolling region. If TOP and BOTTOM are not selected, the complete screen is used (no margins). * **`\ESC[{NUM1};...;{NUMn}m`** Sets multiple display attribute settings. The following lists supported attributes: **`0`** - Reset all attributes @@ -136,7 +138,8 @@ The following escape sequences can be used to control the terminal behaviour Disable National Replacement Character Set. Where `\ESC` is the binary character `1Bh (or 27)` and `{NUM}`, `{COUNT}`, -`{ROW}`, `{COLUMN}` is any sequence of numeric characters like `123`. +`{ROW}`, `{COLUMN}`, `{TOP}`, `{BOTTOM}` is any sequence of numeric characters +like `123`. ### Usage from BASIC diff --git a/vt100.spin b/vt100.spin index cd86732..339dd69 100644 --- a/vt100.spin +++ b/vt100.spin @@ -543,6 +543,11 @@ DAT org 0 vt100_entry mov DIRA, bell_mask + + mov scroll_top, txt_scrn + mov scroll_count, txt_bcnt + sub scroll_count, #scrn_columns + jmp #_bell _loop call #charIn @@ -667,12 +672,11 @@ charIn rdlong t1, rx_head wrlong t2, rx_tail charIn_ret ret -scroll mov t1, txt_scrn +scroll mov t1, scroll_top sub t1, #4 mov t2, t1 sub t2, #scrn_columns << 1 - mov t3, txt_bcnt - sub t3, #scrn_columns + mov t3, scroll_count shr t3, #1 :l1 rdlong a, t2 sub t2, #4 @@ -693,6 +697,9 @@ scroll mov t1, txt_scrn scroll_ret ret +scroll_top long 0 +scroll_count long 0 + ' initialised data and/or presets incdst long 1 << 9 @@ -832,6 +839,8 @@ _esc mov argc, #0 if_z jmp #_cup cmp ch, #"f" wz if_z jmp #_cup + cmp ch, #"r" wz + if_z jmp #_stbm cmp ch, #"m" wz if_z mov overlay_par, attr_overlay_par if_z jmp #overlay_load @@ -875,6 +884,35 @@ _cup mov y, args cmpsub x, #1 jmp #_done +_stbm cmp argc, #0 wz + if_z jmp #:stbm1 + cmp args, #1 wc,wz + if_c jmp #_done + cmp args, #25-1 wc,wz + if_nc jmp #_done + cmp args + 1, #25+1 wc,wz + if_nc jmp #_done + cmp args + 1, args wc,wz + if_c_or_z jmp #_done + +:stbm1 mov scroll_top, txt_scrn + mov scroll_count, txt_bcnt + sub scroll_count, #scrn_columns + cmp argc, #0 wz + if_z jmp #_done + + mov y, args + sub y, #1 wc,wz + if_nz sub scroll_top, #scrn_columns << 1 + if_nz sub scroll_count, #scrn_columns + if_nz djnz y, #$-2 + + mov y, #25 + sub y, args + 1 wc,wz + if_nz sub scroll_count, #scrn_columns + if_nz djnz y, #$-1 + jmp #_done + long $0[($ - overlay_start) // 2] _esc_end fit $1F0