QDOS Internals

Anything you never knew you wanted to know about the Sinclair QL.

User Tools

Site Tools



These traps draw lines and curves in a window using a graphical system of Cartesian coordinates defined by three values, X, Y and S. The point X,Y in graphical coordinates is the bottom left corner of the window and S is the height of the window. The default values are 0, 0 and 100 which set the graphical origin at the bottom left of the window and the graphical point (0,100) at the top left of the window.

TrapValue of D0.BAction
SD_POINT/IOG_DOT$30Draw a point
SD_LINE/IOG_LINE$31Draw a line
SD_ARC/IOG_ARC$32Draw an arc
SD_ELIPS/IOG_ELIP$33Draw an ellipse
SD_SCALE/IOG_SCAL$34Set the graphics scale
SD_GCUR/IOG_SGCR$36Position the cursor
Call ParametersReturn Parameters
D0.BSee aboveD0.LCorrupted?
D1.L D1.LCorrupted.
D3.WTimeout D3.LPreserved.
A0.LChannel ID A0.LPreserved.
A1.LArithmetic stack pointerA1.LCorrupted.


ERR_NCNot complete.
ERR_NOChannel not open.


  • All registers not shown above are not used on entry and are preserved on exit.
  • A1.L points to a stack. Note that this is an absolute address and not relative to A6. At entry to each trap this stack must contain various floating point parameters as detailed below. Also there must be at least 240 bytes available on the stack.
  • Parameters which are angles must be in radians.
  • The Trap SD_GCUR/IOG_SGCR sets the cursor in the window at a position relative to a point in graphical coordinates. The parameters required are those of the graphical point (X,Y) and the offset from that in pixels. This allows text to be added to graphical figures.

Stack Parameters

SD_LINE/IOG_LINE$00(A1)Y-coord of line finish
$06(A1)X-coord of line finish
$0C(A1)Y-coord of line start
$12(A1)X-coord of line start
SD_AEC/IOG_ARC$00(A1)angle subtended by arc
$06(A1)Y-coord of line finish
$0C(A1)X-coord of line finish
$12(A1)Y-coord of line start
$18(A1)X-coord of line start
SD_ELIPS/IOG_ELIP$00(A1)Rotation angle
$06(A1)Radius of ellipse
$0C(A1)Eccentricity of ellipse
$12(A1)Y-coord of center
$18(A1)X-coord of center
SD_SCALE/IOG_SCAL$00(A1)Y-coord of bottom of window
$06(A1)X-coord of left of window
$0C(A1)Height of window
$0C(A1)Pixel offset to right
$12(A1)Pixel offset down


The example below shows how to draw an ellipse. It is assumed that the graphical scale has the default values, that A0 contains the channel ID and that A1 points to a large enough area (relative to A6).

ellipse lea     arith,a3        ; Point to maths code
        movea.w ri_execb,a2     ; Prepare to do the operations
        jsr     (a2)            ; Put the parameters on the stack
        moveq   #sd_elips,d0    ; $33
        moveq   #-1,d3          ; Timeout
        trap    #4              ; Arrange for A6 to be added to A1
        trap    #3              ; Draw the ellipse
        tst.l   d0              ; OK? . .
        bne     error           ; . . no!

; Arithmetic operations
; Note that the extended set of codes in SMSQE are used here

arith   dc.b    qa_n,50         ; X-coord of centre = 50
        dc.b    qa_n,48         ; Y-coord of centre = 48
        dc.b    qa_one          ; Put 1 on stack . .
        dc.b    qa_halve        ; . . Set eccentricity = 1/2
        dc.b    qa_n,25         ; Radius = 25
        dc.b    qa_k,qa_pi2     ; Rotation angle = pi/2     
qdosmsq/traps/trap_3/dot.txt · Last modified: 2011/02/12 09:59 by george.gwilt