Skip to content

Commit

Permalink
Implemented DECSTBM (scrolling region top/bottom margins)
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Oct 12, 2020
1 parent 974b24a commit 6d8eddd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
44 changes: 41 additions & 3 deletions vt100.spin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6d8eddd

Please sign in to comment.