VDU settings not initialised by MODE

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
User avatar
Richard Russell
Posts: 1246
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

VDU settings not initialised by MODE

Post by Richard Russell » Fri Feb 21, 2020 5:30 pm

The MODE statement, reasonably enough, initialises most VDU settings (colours, viewports, origin etc.) but there are notable exceptions. For example MODE does not affect the current VDU 23,16... (cursor movement control) setting, so if you have previously selected right-to-left printing it will remain that way after a MODE change. Is there a list somewhere of precisely what is and what is not initialised by MODE?

RobC
Posts: 2804
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: VDU settings not initialised by MODE

Post by RobC » Fri Feb 21, 2020 5:49 pm

The OS 1.2 disassembly might be a good starting point. VDU 22 ends up at CB33.

Here are the lines where it's setting or doing stuff:

Code: Select all

CB3D STX &0355   ; Save current screen MODE
CB43	STA &0360   ; Set current number of logical colours less 1
CB49	STA &034F   ; Set bytes per character
CB4F	STA &0361   ; Set pixels per byte
CB5B	STA &0363   ;colour mask left
CB61	STA &0362   ;colour mask right
CB67	STY &0356   ;memory map type
CB73	JSR &E9F8   ;set hardware scrolling to VIA
CB79	STA &0354   ;screen RAM size hi byte
CB7F	STA &034E   ;hi byte of screen RAM address
CB89	LDA &C466,X ;row multiplication table pointer
CB8C STA &E0     ;store it
CB90	STA &E1     ;store it (&E0) now points to C3B5 or C375
CB92	LDA &C463,X ;get nuber of bytes per row from table
CB95	STA &0352   ;store as bytes per character row
CB98	STX &0353   ;bytes per character row
CB9D JSR &C5A8   ;A=A and &D0:&D0=A
CBA6 JSR &EA00   ;set video ULA using osbyte 154 code
CBB3	JSR &C95E   ;set register Y
CBBB JSR &C839   ;set default colours
CBBE JSR &C9BD   ;set default windows
CBC6 STX &0350   ;window area start address lo
CBC9 STA &0351   ;window area start address hi
CBCC JSR &C9F6   ;use X and Y to set new cursor address
CBD1 JSR &CA2B   ;set registers 12 and 13 in CRTC
CBDA LDY &C454,X ;get section control number
CBDD STY &035D   ;set it in jump vector lo
CBE0	LDY #&CC    ;Y=&CC
CBE2	STY &035E   ;upper byte of link address
CBE5	LDX #&00    ;X=0
CBE7	STX &0269   ;paged mode counter
CBEA STX &0318   ;text column
CBED STX &0319   ;current text line
CBF0	JMP (&035D) ; clear screen memory

User avatar
jgharston
Posts: 3927
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: VDU settings not initialised by MODE

Post by jgharston » Sat Feb 22, 2020 9:37 am

The RISC OS manual states that MODE initialises:

* Cursor editing is terminated if currently in use
* VDU 4 mode is entered
* The text and graphics windows are restored to their default values
* The text cursor is moved to its home position
* The graphics cursor is moved to (0,0)
* The graphics origin is moved to (0,0)
* Paged mode is terminated if currently in use
* The logical-physical colour map is set to the new mode's default
* The text and graphics foreground colours are set to white
* The text and graphics background colours are set to black (colour 0)
* The colour patterns are set to their defaults for the new mode
* The ECF origin is set to (0,0)
* The dot pattern for dotted lines is reset to &AAAAAAAA
* The dot pattern repeat length is reset to 8
* The screen is cleared to the current text background colour (ie black).

I think what's also missing is:
* graphics plot mode set to 0 (ie GCOL 0,maxcolour and GCOL 0,128)
* (edited) visible text cursor, ie VDU 23,1,1|, as a result of cursor editing terminated; set to flashing ie VDU 23,1,3|
* default cursor shape, reversing any VDU 23,0,10/11 - implicit on the BBC where all CRTC registers are re-written
* default character size (VDU 23,17,7)

So the stuff that isn't reset includes:
* Extended Colour Fill patterns (just as the soft font isn't changed by MODE)
* Flash space/period (VDU 23,9/10 and *FX8/10)
* Cursor movement (VDU 23,16)
* Colour pattern types (VDU 23,17,4)

When I've implemented a VDU driver, the MODE code is something like this:

Code: Select all

.vduMODE
\ set up hardware
CALL vduCursor0   :\ normal cursor
CALL vdu20        :\ default colours
CALL vdu26        :\ default windows
CALL vduCLGcoords :\ set graph=(0,0)
CALL vdu29coords  :\ set origin=(0,0)
CALL vduGCOL0
CALL vdu15
.vduCLS
\ clear screen
.vdu30
\ set text=(0,0)
Edit: The Master Reference Manual also states the above, but states the Extended Colour Fill patterns are reset (so does a VDU 23,11). That needs testing and reporting back.

Second edit: fixed VDU 23,1 notes.
Last edited by jgharston on Sat Feb 22, 2020 11:08 am, edited 1 time in total.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
Richard Russell
Posts: 1246
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: VDU settings not initialised by MODE

Post by Richard Russell » Sat Feb 22, 2020 10:14 am

jgharston wrote:
Sat Feb 22, 2020 9:37 am
The RISC OS manual states that MODE initialises:
Thank you for that very comprehensive reply! The only thing that immediately strikes me as suspicious is:
* default text flashing cursor, ie VDU 23,1,0|, as a result of cursor editing terminated
Shouldn't that be VDU 23,1,1| ?

User avatar
jgharston
Posts: 3927
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: VDU settings not initialised by MODE

Post by jgharston » Sat Feb 22, 2020 11:05 am

Richard Russell wrote:
Sat Feb 22, 2020 10:14 am
jgharston wrote:
Sat Feb 22, 2020 9:37 am
The RISC OS manual states that MODE initialises:
Thank you for that very comprehensive reply! The only thing that immediately strikes me as suspicious is:
* default text flashing cursor, ie VDU 23,1,0|, as a result of cursor editing terminated
Shouldn't that be VDU 23,1,1| ?
D'oh!. 1=on, 0=off.

Also, MODE effectively does:
VDU 23,1,1| :REM Cursor on
VDU 23,1,3| :REM Cursor flashing
0/1 and 2/3 operate independently. Also, a quick test shows that 'terminate editing cursor' turns the cursor on (ie VDU 23,1,1|) but does not change the flash state. ie:
MODE 7
cursor flashing
VDU 23,1,0|
cursor disappears
press cursor up, then press RETURN
flashing cursor comes back
VDU 23,1,2|
cursor stops flashing
press cursor up, then press RETURN
cursor still non-flashing

So, "default text cursor when cursor editing terminated" is just "turns cursor on".

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Post Reply

Return to “programming”