QDOS Internals

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

User Tools

Site Tools


Table of Contents


These SMSQ/E traps set the GD2 colour of paper, strip and ink.

TrapValue in D0Action
IOW_PAPP$50Set paper colour using palette
IOW_STRP$51Set strip colour using palette
IOW_INKP$52Set ink colour using palette
IOW_PAPT$54Set true colour paper
IOW_STRT$55Set true colour strip
IOW_INKT$56Set true colour ink
IOW_PAPN$58Set native colour paper
IOW_STRN$59Set native colour strip
IOW_INKN$5ASet native colour ink
Call ParametersReturn Parameters
D0.BSee aboveD0.LError return
D1.LColour D1.LCorrupted?
D2.LStipple D2.LPreserved?
A0.LChannel ID A0.LPreserved.


ERR_NCNot complete.
ERR_NOChannel not open.


  • All registers not shown above are not used on entry and are probably preserved on exit.
  • The standard colour definitions are:
    • QL colour : a value from 0 to 7.
    • Palette colour: a value from 0 to 255.
    • True colour: 8 bit red, 8 bit green, 8 bit blue.
  • Native colour can be one of these or may be different, such as mode 32 or 33.
  • The value in D1.L must be right justified except for true colour when it must be left justified.
  • The value in D2.L determines the stipple. If D1 is -1 then the colour is solid. If the value is 0, 1, 2 or 3 then the colour in D1 is the stipple colour applied to the the existing solid colour. Thus, stipples require two calls, the first to set the solid colour and the second to apply the stipple.


The example below shows a window being opened and coloured using these traps.

wind    bsr     ope             ; Open the window
        moveq   #-1,d3          ; Timeout
        moveq   #-1,d2          ; Solid colour
        moveq   #2,d1           ; Palette red
        moveq   #iow_papp,d0    ; Palette paper colour
        bsr     tp3             ; Do trap
        moveq   #0,d2           ; Stipple
        move.l  #$00FF0000,d1   ; True colour green
        moveq   #iow_papt,d0    ; You can mix colour types!
        bsr     tp3             ; 2nd call for stipple
        moveq   #1,d1           ; Palette white
        moveq   #-1,d2          ; Solid colour
        moveq   #iow_strp       ; White strip
        moveq   #0,d1           ; Palette black
        moveq   #-1,d2          ; Solid colour
        moveq   #iow_inkp       ; Black ink
        moveq   #-1,d2          ; Solid colour
        moveq   #4,d1           ; Blue
        moveq   #iow_blkp,d0    ; First call for border
        bsr     tp3
        move.l  #$30002,d2      ; Stipple 3 and border width 2
        moveq   #6,d1           ; Palette yellow
        moveq   #iow_blkp,d0    ; Second call for border
        bsr     tp3
        moveq   #sd_clear,d0    ; Clear the window
        bsr     tp3

tp3     trap    #3
tp3_1   tst.l   d0              ; OK? . .
        bne     error           ; . . no!
        rts                     ; return OK

ope     moveq   #-1,d1          ; This job
        moveq   #0,d3           ; Type of open
        lea     con,a0          ; The window
        trap    #2              ; Open the window
        bra     tp3_1           ; Test for errors and return

con     dc.w    3
        dc.b    "con"           
qdosmsq/traps/trap_3/papp.txt · Last modified: 2009/05/17 10:26 by george.gwilt