Difference between revisions of "VDU 25"

From BeebWiki
Jump to: navigation, search
m (1 revision)
m (Added link to VDUV.)
 
(5 intermediate revisions by 2 users not shown)
Line 9: Line 9:
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
 
| Character stream (hex)
 
| Character stream (hex)
| <code>19</code> <command> <Xlow> <Xhigh> <Ylow> <Yhigh>
+
| <code>&amp;19</code> <command> <Xlow> <Xhigh> <Ylow> <Yhigh>
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
 
| Description
 
| Description
Line 15: Line 15:
 
|}
 
|}
  
<pre>
+
==Coordinates==
Plot Numbers
+
The X and Y coordinates specify [[Logical pixels|logical points]] in a
------------
+
logical screen that is the same size in all screen modes with the same
b0-b1: 00 move
+
aspect ratio regardless of the number of physical pixels. The usual BBC
      01 plot in current foreground colour
+
screen size is 1280 horizontal logical pixels by 1024 vertical logical
      10 plot in logical inverse colour
+
pixels.
      11 plot in current background colour
 
b2  : 0  relative coords
 
      1  absolute coords
 
  
b6-b7=00 - draw line:
+
==Plot commands==
b3  : 0  last point not omitted
+
The plot command is a bitmap indicating what action to perform. Unsupported
      1  last point omitted
+
or unimplemented actions are passed to [[VDUV]].
b4  : 0  solid line
 
      1  dot-dash line
 
b5  : 0  first point not omitted
 
      1  first point omitted
 
  
b6-b7<>00:
+
  +---+---+---+---+---+---+---+---+
40 Plot point
+
  | 7 | 6 | 5 | 4 | 3 | 2 | 1  0 |      Draw line
48 Fill to non-background
+
  +---+---+---+---+---+---+---+---+
50 Fill triangle
+
    |  |  |  |  |  |  |  |
58 Fill to background
+
    |  |  |  |  |  |  +---+---00    Move
60 Fill rectangle
+
    |  |  |  |  |  |          01    Plot with foreground GCOL action and colour
68 Fill to foreground
+
    |  |  |  |  |  |          10    Plot in inverse colour as though GCOL 4
70 Fill parallelogram
+
    |  |  |  |  |  |          11    Plot with background GCOL action and colour
78 Fill to non-foreground
+
    |  |  |  |  |  +----------- 0    Relative coordinates
 +
    |  |  |  |  |                1    Absolute coordinates
 +
    |  |  |  |  +--------------- 0    Last point not omitted
 +
    |  |  |  |                    1    Last point omitted
 +
    |  |  |  +------------------- 0    Solid line
 +
    |  |  |                        1    Dot-dash line
 +
    |  |  +----------------------- 0    First point not omitted
 +
    |  |                            1    First point omitted
 +
    +---+---------------------------00    Draw line
 +
 
 +
  +---+---+---+---+---+---+---+---+
 +
  | 7 | 6 | 5 | 4 | 3 | 2 | 1  0 |      Plot points
 +
  +---+---+---+---+---+---+---+---+
 +
    |  |  |  |  |  |  |  |
 +
    |  |  |  |  |  |  +---+---00   Move
 +
    |  |  |  |  |  |          01    Plot with foreground GCOL action and colour
 +
    |  |  |  |  |  |          10    Plot in inverse colour as though GCOL 4
 +
    |  |  |  |  |  |          11    Plot with background GCOL action and colour
 +
    |  |  |  |  |  +----------- 0    Relative coordinates
 +
    |  |  |  |  |                1    Absolute coordinates
 +
    +---+---+---+---+---------------&40+n Plot point
 +
                                    &48+n Fill to non-background
 +
                                    &50+n Fill triangle
 +
                                    &58+n Fill to background
 +
                                    &60+n Fill rectangle
 +
                                    &68+n Fill to foreground
 +
                                    &70+n Fill parallelogram
 +
                                    &78+n Fill to non-foreground
 +
 
 +
  +---+---+---+---+---+---+---+---+
 +
  | 7 | 6 | 5 | 4 | 3 | 2 | 1  0 |      Fill area and other actions
 +
  +---+---+---+---+---+---+---+---+
 +
    |  |  |  |  |  |  |  |
 +
    |  |  |  |  |  |  +---+---00    Move
 +
    |  |  |  |  |  |          01    Plot with foreground GCOL action and colour
 +
    |  |  |  |  |  |          10    Plot in inverse colour as though GCOL 4
 +
    |  |  |  |  |  |          11    Plot with background GCOL action and colour
 +
    |  |  |  |  |  +----------- 0    Relative coordinates
 +
    |  |  |  |  |                1    Absolute coordinates
 +
    +---+---+---+---+---------------&80+n Flood to non-background
 +
                                    &88+n Flood to foreground
 +
                                    &90+n Circle outline
 +
                                    &98+n Circle fill
 +
                                    &A0+n Circle arc
 +
                                    &A8+n Circle segment
 +
                                    &B0+n Circle sector
 +
                                    &B8+n Block copy/move/swap:
 +
                                          b0-b1: 00 no action
 +
                                                01 copy
 +
                                                10 move
 +
                                                11 swap (copy and move)
 +
                                    &C0+n Ellipse outline
 +
                                    &C8+n Ellipse fill
 +
                                    &D0+n Font plot
 +
                                    &D8+n Reserved
 +
                                    &E0+n Reserved
 +
                                    &E8+n Sprite plot (BBFW: block swap)
 +
                                    &F0+n User plot, always passed to [[VDUV]]
 +
                                    &F8+n User plot, always passed to [[VDUV]]
  
80 Flood to non-background
+
==Calling from BBC BASIC==
88 Flood to foreground
+
  PLOT k,x,y                        sends  VDU 25,k,x;y;
90 Circle outline
+
  MOVE x,y                          sends  PLOT 4,x,y
98 Circle fill
+
  DRAW x,y                          sends  PLOT 5,x,y
A0 Circle arc
+
 
A8 Circle segment
+
On BASICs that support the commands:
B0 Circle sector
+
  MOVE BY x,y                        sends  PLOT 0,x,y
B8 Block copy/move/swap:
+
  DRAW BY x,y                        sends  PLOT 1,x,y
    b0-b1: 00 no action
+
  PLOT BY x,y                        sends  PLOT 65,x,y
          01 copy
+
  PLOT x,y                          sends  PLOT 69,x,y
          10 move
+
  FILL BY x,y                        sends  PLOT 129,x,y
          11 swap (copy and move)
+
  FILL x,y                          sends  PLOT 133,x,y
 +
  LINE x1,y1,x2,y2                  sends  MOVE x1,y1:DRAW x2,y2
 +
  CIRCLE x,y,r                      sends  MOVE x,y:PLOT 145,r,0
 +
  CIRCLE FILL x,y,r                  sends  MOVE x,y:PLOT 153,r,0
 +
  ELLIPSE x,y,a,b                    sends  MOVE x,y:MOVE a,0:PLOT 193,0,b
 +
  ELLIPSE FILL x,y,a,b              sends  MOVE x,y:MOVE a,0:PLOT 201,0,b
 +
  RECTANGLE FILL x,y,w,h            sends  MOVE x,y:PLOT 101,x+w,y+h
 +
  RECTANGLE FILL x1,y1,w,h TO x2,y2  sends  MOVE x1,y1:MOVE x1+w,y1+h:PLOT 189,x2,y2
 +
  RECTANGLE x1,y1,w,h TO x2,y2      sends  MOVE x1,y1:MOVE x1+w,y1+h:PLOT 190,x2,y2
 +
  RECTANGLE SWAP x1,y1,w,h TO x2,y2  sends  MOVE x1,y1:MOVE x1+w,y1+h:PLOT 191,x2,y2
 +
  RECTANGLE x,y,w,h                  sends  MOVE x,y:PLOT 13,x+w,y:PLOT 13,x+w,y+h:PLOT 13,x,y+h:PLOT 13,x,y
  
C0 Ellipse outline
+
==Implementation==
C8 Ellipse fill
+
{| class="wikitable"
D0 Font plot
+
| PLOT &00-&3F || Draw line              || All platforms
D8 Reserved
+
|-
E0 Reserved
+
| PLOT &40+n  || Plot point              || All platforms
E8 Sprite plot (BBFW: block swap)
+
|-
F0 User plot
+
| PLOT &48+n  || Fill to non-background  || All platforms
F8 User plot
+
|-
 
+
| PLOT &50+n  || Draw trangle            || All platforms
PLOT k,x,y                        -> VDU 25,k,x;y;
+
|-
 
+
| PLOT &58+n  || Fill to background      ||
MOVE x,y                          -> PLOT 4,x,y
+
|-  
DRAW x,y                          -> PLOT 5,x,y
+
| PLOT &60+n  || Fill rectangle          ||
 
+
|-  
CIRCLE x,y,r                      -> MOVE x,y:PLOT 145,r,0
+
| PLOT &68+n  || Fill to foreground      ||
CIRCLE FILL x,y,r                -> MOVE x,y:PLOT 153,r,0
+
|-  
DRAW BY x,y                      -> PLOT 1,x,y
+
| PLOT &70+n  || Fill parallelogram      ||
ELLIPSE x,y,a,b                  -> MOVE x,y:PLOT 0,a,0:PLOT 193,0,b
+
|-
ELLIPSE FILL x,y,a,b              -> MOVE x,y:PLOT 0,a,0:PLOT 201,0,b
+
| PLOT &78+n  || Fill to non-foreground  ||
FILL x,y                          -> PLOT 133,x,y
+
|-  
FILL BY x,y                      -> PLOT 129,x,y
+
| PLOT &80+n  || Flood to non-background ||
LINE x1,y1,x2,y2                  -> MOVE x1,y1:DRAW x2,y2
+
|-  
MOVE BY x,y                      -> PLOT 0,x,y
+
| PLOT &88+n  || Flood to foreground    ||
PLOT x,y                          -> PLOT 69,x,y
+
|-  
PLOT BY x,y                      -> PLOT 65,x,y
+
| PLOT &90+n  || Circle outline          ||
RECTANGLE x,y,w,h                -> MOVE x,y:PLOT 13,x+w,y:PLOT 13,x+w,y+h:PLOT 13,x,y+h:PLOT 13,x,y
+
|-  
RECTANGLE FILL x,y,w,h            -> MOVE x,y:PLOT 101,x+w,y+h
+
| PLOT &98+n  || Circle fill            ||
RECTANGLE FILL x1,y1,w,h TO x2,y2 -> MOVE x1,y1:MOVE x1+w,y1+h:PLOT 189,x2,y2
+
|-  
RECTANGLE SWAP x1,y1,w,h TO x2,y2 -> MOVE x1,y1:MOVE x1+w,y1+h:PLOT 191,x2,y2
+
| PLOT &A0+n  || Circle arc              ||
RECTANGLE x1,y1,w,h TO x2,y2      -> MOVE x1,y1:MOVE x1+w,y1+h:PLOT 190,x2,y2
+
|-  
</pre>
+
| PLOT &A8+n  || Circle segment          ||
 +
|-  
 +
| PLOT &B0+n  || Circle sector          ||
 +
|-  
 +
| PLOT &B8+n  || Block copy/move/swap    ||
 +
|-  
 +
| PLOT &C0+n  || Ellipse outline        ||
 +
|-  
 +
| PLOT &C8+n  || Ellipse fill            ||
 +
|-
 +
| PLOT &D0+n  || Font plot              ||
 +
|-
 +
| PLOT &D8+n  || Reserved                ||
 +
|-  
 +
| PLOT &E0+n  || Reserved                ||
 +
|-  
 +
| PLOT &E8+n  || Sprite plot            ||
 +
|-  
 +
| PLOT &F0+n  || User                    || All platforms
 +
|-  
 +
| PLOT &F8+n  || User                    || All platforms
 +
|}

Latest revision as of 15:03, 26 September 2024

PLOT commands

VDU 25
Syntax VDU 25,<numeric>,<numeric>;<numeric>;
Character stream (hex) &19 <command> <Xlow> <Xhigh> <Ylow> <Yhigh>
Description Performs a vector graphics operation.

Coordinates

The X and Y coordinates specify logical points in a logical screen that is the same size in all screen modes with the same aspect ratio regardless of the number of physical pixels. The usual BBC screen size is 1280 horizontal logical pixels by 1024 vertical logical pixels.

Plot commands

The plot command is a bitmap indicating what action to perform. Unsupported or unimplemented actions are passed to VDUV.

 +---+---+---+---+---+---+---+---+
 | 7 | 6 | 5 | 4 | 3 | 2 | 1   0 |       Draw line
 +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |
   |   |   |   |   |   |   +---+---00    Move
   |   |   |   |   |   |           01    Plot with foreground GCOL action and colour
   |   |   |   |   |   |           10    Plot in inverse colour as though GCOL 4
   |   |   |   |   |   |           11    Plot with background GCOL action and colour
   |   |   |   |   |   +----------- 0    Relative coordinates
   |   |   |   |   |                1    Absolute coordinates
   |   |   |   |   +--------------- 0    Last point not omitted
   |   |   |   |                    1    Last point omitted
   |   |   |   +------------------- 0    Solid line
   |   |   |                        1    Dot-dash line
   |   |   +----------------------- 0    First point not omitted
   |   |                            1    First point omitted
   +---+---------------------------00    Draw line
 
 +---+---+---+---+---+---+---+---+
 | 7 | 6 | 5 | 4 | 3 | 2 | 1   0 |       Plot points
 +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |
   |   |   |   |   |   |   +---+---00    Move
   |   |   |   |   |   |           01    Plot with foreground GCOL action and colour
   |   |   |   |   |   |           10    Plot in inverse colour as though GCOL 4
   |   |   |   |   |   |           11    Plot with background GCOL action and colour
   |   |   |   |   |   +----------- 0    Relative coordinates
   |   |   |   |   |                1    Absolute coordinates
   +---+---+---+---+---------------&40+n Plot point
                                   &48+n Fill to non-background
                                   &50+n Fill triangle
                                   &58+n Fill to background
                                   &60+n Fill rectangle
                                   &68+n Fill to foreground
                                   &70+n Fill parallelogram
                                   &78+n Fill to non-foreground
 
 +---+---+---+---+---+---+---+---+
 | 7 | 6 | 5 | 4 | 3 | 2 | 1   0 |       Fill area and other actions
 +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |
   |   |   |   |   |   |   +---+---00    Move
   |   |   |   |   |   |           01    Plot with foreground GCOL action and colour
   |   |   |   |   |   |           10    Plot in inverse colour as though GCOL 4
   |   |   |   |   |   |           11    Plot with background GCOL action and colour
   |   |   |   |   |   +----------- 0    Relative coordinates
   |   |   |   |   |                1    Absolute coordinates
   +---+---+---+---+---------------&80+n Flood to non-background
                                   &88+n Flood to foreground
                                   &90+n Circle outline
                                   &98+n Circle fill
                                   &A0+n Circle arc
                                   &A8+n Circle segment
                                   &B0+n Circle sector
                                   &B8+n Block copy/move/swap:
                                         b0-b1: 00 no action
                                                01 copy
                                                10 move
                                                11 swap (copy and move)
                                   &C0+n Ellipse outline
                                   &C8+n Ellipse fill
                                   &D0+n Font plot
                                   &D8+n Reserved
                                   &E0+n Reserved
                                   &E8+n Sprite plot (BBFW: block swap)
                                   &F0+n User plot, always passed to VDUV
                                   &F8+n User plot, always passed to VDUV

Calling from BBC BASIC

 PLOT k,x,y                         sends  VDU 25,k,x;y;
 MOVE x,y                           sends  PLOT 4,x,y
 DRAW x,y                           sends  PLOT 5,x,y
 
On BASICs that support the commands:
 MOVE BY x,y                        sends  PLOT 0,x,y
 DRAW BY x,y                        sends  PLOT 1,x,y
 PLOT BY x,y                        sends  PLOT 65,x,y
 PLOT x,y                           sends  PLOT 69,x,y
 FILL BY x,y                        sends  PLOT 129,x,y
 FILL x,y                           sends  PLOT 133,x,y
 LINE x1,y1,x2,y2                   sends  MOVE x1,y1:DRAW x2,y2
 CIRCLE x,y,r                       sends  MOVE x,y:PLOT 145,r,0
 CIRCLE FILL x,y,r                  sends  MOVE x,y:PLOT 153,r,0
 ELLIPSE x,y,a,b                    sends  MOVE x,y:MOVE a,0:PLOT 193,0,b
 ELLIPSE FILL x,y,a,b               sends  MOVE x,y:MOVE a,0:PLOT 201,0,b
 RECTANGLE FILL x,y,w,h             sends  MOVE x,y:PLOT 101,x+w,y+h
 RECTANGLE FILL x1,y1,w,h TO x2,y2  sends  MOVE x1,y1:MOVE x1+w,y1+h:PLOT 189,x2,y2
 RECTANGLE x1,y1,w,h TO x2,y2       sends  MOVE x1,y1:MOVE x1+w,y1+h:PLOT 190,x2,y2
 RECTANGLE SWAP x1,y1,w,h TO x2,y2  sends  MOVE x1,y1:MOVE x1+w,y1+h:PLOT 191,x2,y2
 RECTANGLE x,y,w,h                  sends  MOVE x,y:PLOT 13,x+w,y:PLOT 13,x+w,y+h:PLOT 13,x,y+h:PLOT 13,x,y

Implementation

PLOT &00-&3F Draw line All platforms
PLOT &40+n Plot point All platforms
PLOT &48+n Fill to non-background All platforms
PLOT &50+n Draw trangle All platforms
PLOT &58+n Fill to background
PLOT &60+n Fill rectangle
PLOT &68+n Fill to foreground
PLOT &70+n Fill parallelogram
PLOT &78+n Fill to non-foreground
PLOT &80+n Flood to non-background
PLOT &88+n Flood to foreground
PLOT &90+n Circle outline
PLOT &98+n Circle fill
PLOT &A0+n Circle arc
PLOT &A8+n Circle segment
PLOT &B0+n Circle sector
PLOT &B8+n Block copy/move/swap
PLOT &C0+n Ellipse outline
PLOT &C8+n Ellipse fill
PLOT &D0+n Font plot
PLOT &D8+n Reserved
PLOT &E0+n Reserved
PLOT &E8+n Sprite plot
PLOT &F0+n User All platforms
PLOT &F8+n User All platforms