ZapRedraw and LineEditor

Christian Ludlam chris at recoil.org
Fri May 10 19:49:19 BST 2002


On 9 May Tom Hughes wrote:

> I have actually got a partial definition for ZapRedraw that I did ages ago
> but I never submitted it as it is very incomplete. It would certainly be
> nice to have that in anyway.

If that's the one in the current source distribution, then this is based on
it; it completes the definitions and adds the new 0.40 SWIs and font hanle
support.

SWIs which are problematic or not supported:

  ZapRedraw_RedrawRaster
      R6 b0:15 is fg colour, 16:31 bg colour; not supported by DefMod
      
  
  ZapRedraw_AddCursor, AddCursorSmart
      R7 has 4 parameters in each byte; ideally DefMod would be able to
      combine these, otherwise needs something like
      
      struct add_cursor_r7
      {
          unsigned int high_byte    : 8;
          unsigned int control_code : 8;
          unsigned int fg           : 8;
          unsigned int bg           : 8;
       };
       
       such structures are (AFAIK) not creatable with DefMod.
       
   
  ZapRedraw_PlotRectangle
       corrupts so many registers it causes a parse error. I'm not sure how
       true this is, or whether the kernel implicitly preserves some of 
       these for the SWI routine.
     
  
Other issues:

  Initial colours in the redraw block are Int instead of ZapRedraw_Colour
  which is more usefully defined as Byte.
  
  No provision for extension routines (which aren't APCS compliant)
  
  No definition of ZapRedaraw's Service calls.


Still, all other calls are fully supported, and it's been tested and works!

LineEditor works fine, I'm not aware of any problems.

HTH,

-- 
Christian Ludlam
chris at recoil.org
-------------- next part --------------
TITLE LineEd;
AUTHOR "Christian Ludlam, <chris at recoil.org> 13-Feb-02 13:26";

NEEDS Wimp;

//LineEd chunk number: &83880

TYPE LineEd_H;


TYPE LineEd_Length = .Int;
CONST LineEd_Unknown = LineEd_Length: 0xfffffffe;
CONST LineEd_NoEdit  = LineEd_Length: 0xffffffff;


TYPE LineEd_Pos = .Int;
CONST LineEd_End            = LineEd_Pos: 0x7FFFFFFF;
CONST LineEd_PreviousWrap   = LineEd_Pos: 0x80000000;
CONST LineEd_PreviousNoWrap = LineEd_Pos: 0x80000001;
CONST LineEd_NextNoWrap     = LineEd_Pos: 0x80000002;
CONST LineEd_NextWrap       = LineEd_Pos: 0x80000003;


TYPE LineEd_Cursors = .Int;
CONST LineEd_Block          = LineEdCursors: %0;
CONST LineEd_Underline      = LineEdCursors: %1;
CONST LineEd_Steady         = LineEdCursors: %00;
CONST LineEd_Flashing       = LineEdCursors: %10;

CONST LineEd_NormalShift    = .Int: 0; // shift
CONST LineEd_OvertypeShift  = .Int: 8; // shift

TYPE LineEdSetOptions_Flags = .Bits;
CONST LineEd_LocalTaskwindows    = LineEdSetOptions_Flags: %1;
CONST LineEd_LocalAppendDots     = LineEdSetOptions_Flags: %10;
CONST LineEd_LocalOvertype       = LineEdSetOptions_Flags: %100;
CONST LineEd_LocalKeepDuplicates = LineEdSetOptions_Flags: %1000;
CONST LineEd_LocalNoTilde        = LineEdSetOptions_Flags: %10000;
CONST LineEd_LocalNoEvents       = LineEdSetOptions_Flags: %100000;
CONST LineEd_LocalNoCircumflex   = LineEdSetOptions_Flags: %1000000;


TYPE LineEd_Pos = .Int;
CONST LineEd_End            = LineEd_Pos: 0x7FFFFFFF;
CONST LineEd_PreviousWrap   = LineEd_Pos: 0x80000000;
CONST LineEd_PreviousNoWrap = LineEd_Pos: 0x80000001;
CONST LineEd_NextWrap       = LineEd_Pos: 0x80000002;
CONST LineEd_NextNoWrap     = LineEd_Pos: 0x80000003;


SWI LineEd_SetOptions =
   (  NUMBER 0x83880 "Sets the options used by LineEditor",
      ENTRY
      ( R0  =  .Int: size,
        R1  =  LineEdSetOptions_Flags: flags,
        R2  =  .Int: min,
        R3  =  .Int: max,
        R4  =  LineEd_Cursors: cursors
      )
   );
   

SWI LineEd_GetOptions =
   (  NUMBER 0x83881 "Reads the options used by LineEditor",
      EXIT
      ( R0  =  .Int: size,
        R1  =  LineEdSetOptions_Flags: flags,
        R2  =  .Int: min,
        R3  =  .Int: max,
        R4  =  LineEd_Cursors: cursors
      )
   );


SWI LineEd_CreateBuffer =
   (  NUMBER 0x83882 "Creates a new private history buffer",
      ENTRY
      ( R0  =  .Int: size,
        R1  =  Wimp_T: handle,
        R2  =  .Bits: expansion
      ),
      EXIT
      ( R0! =  LineEd_H: handle
      )
   );
     

SWI LineEd_DeleteBuffer =
   (  NUMBER 0x83883 "Releases a private history buffer",
      ENTRY
      ( R0  = LineEd_H: handle
      )
   );
     
     
SWI LineEd_SetPos =
   (  NUMBER 0x83884 "Sets the position in the private history buffer",
      ENTRY
      ( R0  = LineEd_H: handle,
        R1  = LineEd_Pos: position
      )
   );
   

SWI LineEd_GetPos =
   (  NUMBER 0x83885 "Reads the current position in the history buffer",
      ENTRY
      ( R0  =  LineEd_H: handle
      ),
      EXIT
      ( R0! =  LineEd_Pos: position
      )
   );
   

SWI LineEd_GetLine =
   (  NUMBER 0x83886 "Reads a line from the history buffer",
      ENTRY
      ( R0  =  LineEd_H: handle,
        R1  =  .Ref .Char: buffer,
        R2  =  .Int: length
      ),
      EXIT
      ( R2! =  .Int: used
      )
   );
   

SWI LineEd_AppendLine =
   (  NUMBER 0x83887 "Adds a line to the history buffer",
      ENTRY
      ( R0  =  LineEd_H: handle,
        R1  -> .Char: line
      )
   );
   

SWI LineEd_DeleteLine = 
   (  NUMBER 0x83888 "Removes the last line from the history buffer",
      ENTRY
      ( R0  =  LineEd_H: handle
      )     
   );
   

SWI LineEd_ReadInfo = 
   (  NUMBER 0x83889 "Reads information about current LineEditor edits",
      ENTRY
      ( R0  =  Wimp_T: task_handle
      ),
      EXIT
      ( R0  =  LineEd_Length: length,
        R1! =  .Int: pos
      )
   );
   
   

SWI LineEd_ReadLine = 
   (  NUMBER 0x8388a "Reads a line of input with history",
      ENTRY
      ( R0  =  .Ref .Char: buffer,
        R1  =  .Int: size,
        R2  =  .Char: min_char,
        R3  =  .Char: max_char,
        R5  #  0,
        R6  =  LineEd_H: handle
      ),
      EXIT
      ( 
        FLAGS!,
        R0?,
        R1  =  .Int: used
      )
   );
   

SWI LineEd_ReadLineGivenEcho = 
   (  NUMBER 0x8388a "Reads a line of input with history, using the given 
                      echo character",
      ENTRY
      ( R0  =  .Ref .Char: buffer,
        R1  =  .Int: size,
        R2  =  .Char: min_char,
        R3  =  .Char: max_char,
        R4  =  .Char: echo,
        R5  #  1,
        R6  =  LineEd_H: handle
      ),
      EXIT
      ( 
        FLAGS!,
        R0?,
        R1  =  .Int: used
      )
   );
   

SWI LineEd_ReadLineSuppressInvalid = 
   (  NUMBER 0x8388a "Reads a line of input with history, not echoing 
                      invalid characters",
      ENTRY
      ( R0  =  .Ref .Char: buffer,
        R1  =  .Int: size,
        R2  =  .Char: min_char,
        R3  =  .Char: max_char,
        R5  #  2,
        R6  =  LineEd_H: handle
      ),
      EXIT
      ( 
        FLAGS!,
        R0?,
        R1  =  .Int: used
      )
   );
   

SWI LineEd_ReadLineGivenEchoSuppressInvalid = 
   (  NUMBER 0x8388a "Reads a line of input with history, using the given 
                      echo character and not echoing invalid characters",
      ENTRY
      ( R0  =  .Ref .Char: buffer,
        R1  =  .Int: size,
        R2  =  .Char: min_char,
        R3  =  .Char: max_char,
        R4  =  .Char: echo,
        R5  #  3,
        R6  =  LineEd_H: handle
      ),
      EXIT
      ( 
        FLAGS!,
        R0?,
        R1  =  .Int: used
      )
   )
-------------- next part --------------
TITLE ZapRedraw;
AUTHOR "Christian Ludlam, <chris at recoil.org> 09-Feb-02 23:39";

NEEDS OS, Wimp;

//ZapRedraw chunk number: &48480

TYPE ZapRedraw_Flags = .Bits;

CONST 
   ZapRedraw_DSA                   = ZapRedraw_Flags: %0,
   ZapRedraw_VDU                   = ZapRedraw_Flags: %1,
   ZapRedraw_DoubleHeight          = ZapRedraw_Flags: %10 "(DSA mode)",
   ZapRedraw_GivenExtensionRoutine = ZapRedraw_Flags: %100 "(DSA mode)",
   ZapRedraw_Substyles             = ZapRedraw_Flags: %1000,
   ZapRedraw_FastRectangles        = ZapRedraw_Flags: %10000 "(DSA mode)",
   ZapRedraw_AutoScale             = ZapRedraw_Flags: %100000,
   ZapRedraw_Extend                = ZapRedraw_Flags: %1000000,
   ZapRedraw_RtoL                  = ZapRedraw_Flags: %10000000 "(VDU mode)",
   ZapRedraw_Transparent           = ZapRedraw_Flags: %100000000 "(VDU mode)",
   ZapRedraw_AASuppress            = ZapRedraw_Flags: %1000000000 "(DSAVDU mode)";


TYPE ZapRedraw_CharCache = .Ref .Byte;
TYPE ZapRedraw_Colour = .Byte;
TYPE ZapRedraw_F;
TYPE ZapRedraw_Substyle = .Char;

CONST ZapRedraw_Normal        = ZapRedraw_Substyle: %0;
CONST ZapRedraw_Strikethrough = ZapRedraw_Substyle: %1;
CONST ZapRedraw_Inverse       = ZapRedraw_Substyle: %1000;
CONST ZapRedraw_Bold          = ZapRedraw_Substyle: %100000;
CONST ZapRedraw_Italic        = ZapRedraw_Substyle: %1000000;
CONST ZapRedraw_Underlined    = ZapRedraw_Substyle: %10000000;

TYPE ZapRedraw_DSABlock =
   .Struct
   (  ZapRedraw_Flags: flags,
      OS_Box: box "redraw box (pixels)",
      .Ref .Byte: screen,
      .Int: bpl "bits per raster line of screen",
      .Int: log2_bpp,
      .Int: charw "(in pixels)",
      .Int: charh "(in pixels)",
      .Ref ZapRedraw_CharCache: caddr,
      .Int: cbpl "bytes per cached character line",
      .Int: cbpc "bytes per cached character",
      .Int: linesp "line spacing (pixels)",
      .Ref .Ref .Char: data,
      .Int: scrollx "horizontal scroll offset in 'data' of top left of
            redraw rectangle (pixels)",
      .Int: scrolly "vertical scroll offset in 'data' of top left of
            redraw rectangle (pixels)",
      .Ref ZapRedraw_Palette: palette,
      .Int: fg "index of foreground colour",
      .Int: bg "index of background colour",
      .Ref Void: workarea "word-aligned workspace (SWI-dependent)",
      .Int: magx "log2 of x pixel size (O S units)",
      .Int: magy "log2 of y pixel size (O S units)",
      .Int: xsize "x screen size (pixels)",
      .Int: ysize "y screen size (pixels)",
      OS_Mode: mode,
      .Int: length  "offset of last entry in the redraw block (optional)",
      .Int: lmargin "width of left margin (pixels)",
      .Int: tmargin "height of top margin (pixels)"
   );

TYPE ZapRedraw_VDUBlock =
   .Struct
   (  ZapRedraw_Flags: flags,
      OS_Box: box "redraw box (pixels)",
      .Ref .Byte: reserved0,
      .Int: reserved1,
      .Int: log2_bpp,
      .Int: charw "(in pixels)",
      .Int: charh "(in pixels)",
      .Ref .Char: caddr "font name",
      .Int: offsetx "x offset of character in bbox",
      .Int: offsety "y offset of character in bbox",
      .Int: linesp "line spacing (pixels)",
      .Ref .Ref .Char: data,
      .Int: scrollx "x scroll offset of redraw rectangle (pixels)",
      .Int: scrolly "y scroll offset of redraw rectangle (pixels)",
      .Ref ZapRedraw_Palette: palette,
      .Int: fg "index of foreground colour",
      .Int: bg "index of background colour",
      .Ref Void: workarea "word-aligned workspace (SWI-dependent)",
      .Int: magx "log2 of x pixel size (O S units)",
      .Int: magy "log2 of y pixel size (O S units)",
      .Int: xsize "x screen size (pixels)",
      .Int: ysize "y screen size (pixels)",
      OS_Mode: mode,
      .Int: length  "offset of last entry in the redraw block (optional)",
      .Int: lmargin "width of left margin (pixels)",
      .Int: tmargin "height of top margin (pixels)"
   );

TYPE ZapRedraw_FontBlock =
   .Struct
   (  ZapRedraw_Flags: flags,
      OS_Box: box "redraw box (pixels)",
      .Ref .Byte: screen,
      .Int: bpl "bits per raster line of screen",
      .Int: log2_bpp,
      .Int: charw "unused",
      .Int: charh "unused",
      ZapRedraw_F: font,
      .Int: cbpl "unused",
      .Int: cbpc "unused",
      .Int: linesp "line spacing (pixels)",
      .Ref .Ref .Char: data,
      .Int: scrollx "horizontal scroll offset in 'data' of top left of
                     redraw rectangle (pixels)",
      .Int: scrolly "vertical scroll offset in 'data' of top left of
                     redraw rectangle (pixels)",
      .Ref ZapRedraw_Palette: palette,
      .Int: fg "index of foreground colour",
      .Int: bg "index of background colour",
      .Ref Void: workarea "Should be set to 0",
      .Int: magx "log2 of x pixel size (OS units)",
      .Int: magy "log2 of y pixel size (OS units)",
      .Int: xsize "x screen size (pixels)",
      .Int: ysize "y screen size (pixels)",
      OS_Mode: mode,
      .Int: length  "offset of last entry in the redraw block (optional)",
      .Int: lmargin "width of left margin (pixels)",
      .Int: tmargin "height of top margin (pixels)"
   );

TYPE ZapRedraw_Block =
   .Union
   ( ZapRedraw_VDUBlock:  vdu,
     ZapRedraw_DSABlock:  dsa,
     ZapRedraw_FontBlock: font
   );

CONST
   ZapRedraw_Command            = .Char: 0 "followed by 'cc'",
   ZapRedraw_CommandNull        = .Char: 0 "followed by 'c'",
   ZapRedraw_CommandSetColours  = .Char: 1 "followed by 'f', 'b'",
   ZapRedraw_CommandEOL         = .Char: 2,
   ZapRedraw_CommandUnichar     = .Char: 3 "followed by 'l', 'h'",
   ZapRedraw_CommandMerge       = .Char: 4 "followed by 'f', 'b', 'c0', 'c1'",
   ZapRedraw_CommandReserved    = .Char: 5 "reserved",
   ZapRedraw_CommandSetFG       = .Char: 6 "followed by 'f'",
   ZapRedraw_CommandSetBG       = .Char: 7 "followed by 'b'",
   ZapRedraw_CommandCursorMerge = .Char: 8 "followed by 'f', 'b', 'x', 'y'",
   ZapRedraw_CommandSetStyle    = .Char: 9 "followed by 's'",
   ZapRedraw_CommandSetStyleCol = .Char: 10 "followed by 'f', 'b', 's'",
   ZapRedraw_CommandDelete      = .Char: 0x7F,
   ZapRedraw_CommandTBL         = .Int:  0x100,
   ZapRedraw_CommandTB          = .Int:  0x101,
   ZapRedraw_CommandTBR         = .Int:  0x102,
   ZapRedraw_CommandTBLR        = .Int:  0x103,
   ZapRedraw_CommandB           = .Int:  0x104,
   ZapRedraw_CommandL           = .Int:  0x105;

TYPE ZapRedraw_DSAPalette = .Struct (.Bits: dup_colour ...);
TYPE ZapRedraw_VDUPalette = .Struct (OS_Colour: colour ...);
TYPE ZapRedraw_Palette    = .Union (ZapRedraw_VDUPalette: vdu,
                                    ZapRedraw_DSAPalette: dsa);


SWI ZapRedraw_RedrawArea =
   (  NUMBER &48480 "Redraws a rectangle of characters on the screen
                     (bytes needed: 64 + cbpl)",
      ENTRY
      (  R1 -> ZapRedraw_Block: redraw_block,
         R2 -> .Asm: extension_fn,
         R3 =  .Ref Void: extension_handle
      ),
      EXIT (R0?)
   );

TYPE ZapRedraw_Reason = .Int;
CONST ZapRedraw_NewRaster       = ZapRedraw_Reason: 0;
CONST ZapRedraw_SetColours      = ZapRedraw_Reason: 1;
CONST ZapRedraw_Merge           = ZapRedraw_Reason: 4;
CONST ZapRedraw_SetFG           = ZapRedraw_Reason: 6;
CONST ZapRedraw_SetBG           = ZapRedraw_Reason: 7;
CONST ZapRedraw_CursorMerge     = ZapRedraw_Reason: 8;
CONST ZapRedraw_SetStyle        = ZapRedraw_Reason: 9;
CONST ZapRedraw_SetStyleColours = ZapRedraw_Reason: 10;

SWI ZapRedraw_GetPaletteEntry =
   (  NUMBER &48481 "Takes a colour bitmap and duplicates it to create
                     a DSA colour mask",
      ENTRY
      (  R0 = OS_ColourNumber: colour_number,
         R1 = .Int: bpp
      ),
      EXIT (R0! = .Int: dup_colour)
   );

//ZapRedraw_RedrawRaster =
//   (  NUMBER 0x48482 "Redraws a single raster line (DSA mode)"
//      ENTRY (R1 -> .Ref ZapRedraw_Block: redraw_block,
// R3=address of text to use for this line starting at the first
//    visible character.
//           R4 -> ZapRedraw_CharCache: bitmaps,
//           R5 ->
// R5=screen address of the start of the raster line.
// R6=b0-b15 = start foreground colour to use (eg r_for value)
//    b16-b31 = start background colour to use (eg r_bac value)
//      EXIT (R0?, FLAGS?)
//   ),


SWI ZapRedraw_ConvertBitmap =
   (  NUMBER 0x48483 "Converts a 1bpp bitmap for use by
                      ZapRedraw_RedrawArea",
      ENTRY
      ( R1 -> ZapRedraw_Block: redraw_block,
        R2 =  .Int: first,
        R3 =  .Int: last,
        R4 =  ZapRedraw_CharCache: bitmaps
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_PrepareDataLine =
   (  NUMBER 0x48484 "Helps prepare the 'r_data' field of the redraw block",
      ENTRY
      ( R0  =  ZapRedraw_Colour: ctrl_colour,
        R1  -> ZapRedraw_Block: redraw_block,
        R2  -> .String: input,
        R3  -> ZapRedraw_Colour: fg,
        R4  -> ZapRedraw_Colour: bg,
        R5  =  .Int: length,
        R6  =  .Ref .String: output,
        R7  -> ZapRedraw_Substyle: substyles
      ),
      EXIT
      ( R0  =  .Int: highest,
        R5! =  .Int: length_out
      )
   );


//ZapRedraw_AddCursor =
//   (  NUMBER 0x48485 "Adds in the codes to place 'cursors' over some of
//                      the text"
//      ENTRY
//      ( R0 =  .Ref .String: dest,
//        R1 ->  ZapRedraw_Block: redraw_block,
//        R2 =  .Int: offset,
//        R3 =  .Int: length,
//        R4 -> .String cursors,
//        R5 -> .String source,
//        R6 =  swap colour/-1 if none. If the character having the cursor placed
//    over it has this foreground colour then the cursor bac/foreground
//    cols are swapped over (eg in a selected region).
// R7=b0-b7   high byte to use for cursor characters in R4 string
//    b8-b15  control code to use when merging ie 4 or 8.
//    b16-b23 foreground colour of the cursor
//    b24-b31 background colour of the cursor
// Room should be reserved for the string to grow by 8*R3
// characters. (eg 0,4,f,b,old,0,3,l,h) If the indicated offset (R2)
// is off the end of the string then it will be lengthened with spaces
// (&20) so you should ensure R2+9*R3 characters extra are reserved.),
//      EXIT (R0=end of new destination string (after 0,2 terminator))
//   ),


SWI ZapRedraw_FindCharacter =
   (  NUMBER 0x48486 "Finds the (n + 1)th printable character within
                      a line",
      ENTRY
      ( R0  =  .Int:               count,
        R1  -> .String:            input,
        R2  =  ZapRedraw_Colour:   fg,
        R3  =  ZapRedraw_Colour:   bg,
        R4  =  ZapRedraw_Substyle: style
      ),
      EXIT
      ( R0  -> .String:            something,
        R1! -> .String:            next_char,
        R2  =  ZapRedraw_Colour:   fg_out,
        R3  =  ZapRedraw_Colour:   bg_out,
        R4  =  ZapRedraw_Substyle: style_out
      )
   );


SWI ZapRedraw_MoveBytes =
   (  NUMBER 0x48487 "Fast byte shifting",
      ENTRY
      ( R1 -> .Byte:     source,
        R2 =  .Ref Byte: dest,
        R3 =  .Int:      length
      ),
      EXIT
      ( R0?,
        R1?,
        R2?,
        R3?
      )
   );


SWI ZapRedraw_CachedCharSize =
   (  NUMBER 0x48488 "Calculates cbpl, cbpc from charw, charh, bpp",
      ENTRY
      ( R0 =  .Int: bpp,
        R2 =  .Int: charw,
        R3 =  .Int: charh
      ),
      EXIT
      ( R0?,
        R2 =  .Int: cbpl,
        R3 =  .Int: cbpc
      )
   );


SWI ZapRedraw_ConvBitmapChar =
   (  NUMBER 0x48489 "Performs the bitmap conversion for one character",
      ENTRY
      ( R1 -> ZapRedraw_Block: redraw_block,
        R2 =  .Int:                  source_bpl,
        R3 =  .Int:                  dest_bpl,
        R4 =  ZapRedraw_CharCache:   source_bitmap,
        R5 =  ZapRedraw_CharCache:   dest_bitmap,
        R6 =  .Bits:                 bit_mask,
        R7 =  .Int:                  bpp
      ),
      EXIT
      ( R0?,
        R4  =  ZapRedraw_CharCache: next_source,
        R5! =  ZapRedraw_CharCache: next_dest
      )
   );


TYPE ZapRedrawCreatePalette_Flags = .Bits;
CONST ZapRedrawCreatePalette_WimpToVDU = ZapRedrawCreatePalette_Flags: %1;
CONST ZapRedrawCreatePalette_VDUToDSA  = ZapRedrawCreatePalette_Flags: %10;

SWI ZapRedraw_CreatePalette =
   (  NUMBER 0x4848A "Performs various operations on palette data",
      ENTRY
      ( R0 =  ZapRedrawCreatePalette_Flags: flags,
        R1 -> ZapRedraw_Block: redraw_block,
        R2 -> ZapRedraw_Palette: in,
        R3 =  .Ref ZapRedraw_Palette: out,
        R4 =  .Int: number
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_InsertChar =
   (  NUMBER 0x4848B "Inserts a single character into a string of 'data'
                      format",
      ENTRY
      ( R0 =  .Int:         c,
        R1 =  .Ref .String: address
      ),
      EXIT
      ( R0?,
        R1! -> .String: address_out
      )
   );


SWI ZapRedraw_ReadSystemChars =
   (  NUMBER 0x4848C "Converts the system characters to a form usable
                      for ZapRedraw_RedrawArea",
      ENTRY
      ( R0 =  ZapRedraw_CharCache:  buffer,
        R1 -> ZapRedraw_Block: redraw_block
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_ReverseBitmaps =
   (  NUMBER 0x4848D "Reverses the bits of each byte",
      ENTRY
      ( R1 =  ZapRedraw_CharCache: source,
        R2 =  ZapRedraw_CharCache: dest,
        R3 =  .Int:                number
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_ReadVduVars =
   (  NUMBER 0x4848E "Fills in bpl, bpp, magx, magy, xsize, ysize, mode",
      ENTRY (R1 = .Ref ZapRedraw_Block: redraw_block),
      EXIT  (R0?)
   );


SWI ZapRedraw_GetRectangle =
   (  NUMBER 0x4848F "Takes the redraw rectangle block as returned by
                      Wimp_RedrawWindow or Wimp_GetRectangle and uses it to fill
                      in the ZapRedraw block",
      ENTRY
      ( R0 -> Wimp_Draw:            wimp_block,
        R1 =  .Ref ZapRedraw_Block: redraw_block
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_AddVduBitmaps =
   (  NUMBER 0x48490 "Creates bitmaps for extra characters from a
                      standard bitmap of the normal characters",
      ENTRY
      ( R1 -> ZapRedraw_Block: redraw_block,
        R2 =  .Int:                  first,
        R3 =  .Int:                  last,
        R4 =  ZapRedraw_CharCache:   address
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_CacheFontChars =
   (  NUMBER 0x48491 "Caches a range of characters as bitmaps - see
                      individual reason codes",
      ABSENT
   );

SWI ZapRedrawCacheFontChars_CurrentMode =
   (  NUMBER 0x48491,
      ENTRY
      ( R0 #  1 "Caches a range of characters as bitmaps in the curent mode",
        R1 -> ZapRedraw_Block: redraw_block,
        R2 -> .String: font_name,
        R3 =  .Int:    size,
        R4 =  .Int:    xoff,
        R5 =  .Int:    yoff,
        R6 =  .Int:    first,
        R7 =  .Int:    last
      ),
      EXIT (R0?)
   );

SWI ZapRedrawCacheFontChars_1bpp =
   (  NUMBER 0x48491,
      ENTRY
      ( R0 #  2 "Caches a range of characters as bitmaps in 1bpp",
        R1 -> ZapRedraw_Block: redraw_block,
        R2 -> .String: font_name,
        R3 =  .Int:    size,
        R4 =  .Int:    xoff,
        R5 =  .Int:    yoff,
        R6 =  .Int:    first,
        R7 =  .Int:    last
      ),
      EXIT (R0?)
   );


TYPE  ZapRedrawSpriteSize_Reason = .Bits;
CONST ZapRedrawSpriteSizeReason_PassOne = ZapRedrawSpriteSize_Reason: 0;
CONST ZapRedrawSpriteSizeReason_PassTwo = ZapRedrawSpriteSize_Reason: %10000000;

SWI ZapRedraw_SpriteSize =
   (  NUMBER 0x48492 "Returns the size required for a sprite area the
                      size of a single character",
      ABSENT
   );

SWI ZapRedrawSpriteSize_CurrentMode =
   (  NUMBER 0x48492,
      ENTRY
      ( R0  #  1 "Returns the size required for the sprite area in the current mode",
      	R0  |  ZapRedrawSpriteSize_Reason: pass,
      	R1  -> ZapRedraw_Block: redraw_block
      ),
      EXIT
      ( R0! =  .Int: size
      )
   );

SWI ZapRedrawSpriteSize_1bpp =
   (  NUMBER 0x48492,
      ENTRY
      ( R0  #  2 "Returns the size required for the sprite area in a 1bpp mode",
      	R0  |  ZapRedrawSpriteSize_Reason: pass,
      	R1  -> ZapRedraw_Block: redraw_block
      ),
      EXIT
      ( R0! =  .Int: size
      )
   );


SWI ZapRedraw_RedrawWindow =
   (  NUMBER 0x48493 "The whole Wimp_RedrawWindowRequest event handler",
      ENTRY
      ( R0 -> Wimp_Draw: wimp_block,
      	R1 -> ZapRedraw_Block: redraw_block
      ),
      EXIT (R0?)
   );


SWI ZapRedraw_Divide =
   (  NUMBER 0x48494 "Fast unsigned integer division / modulus",
      ENTRY
      ( R0  =  .Bits: numerator,
        R1  =  .Bits: denominator
      ),
      EXIT
      ( R0! =  .Bits: div,
        R1?,
        R2  =  .Bits: mod,
        R3?
      )
    );


// The fact that this corrupts R10-R12 renders it completely incompatible with the
// APCS - so much so that this is even a parse error :)
//SWI ZapRedraw_PlotRectangle =
//    (  NUMBER 0x48495 "Fast rectangle fill routine using DSA",
//       ENTRY
//       ( R0  =  .Int: x0,
//         R1  =  .Int: y0,
//         R2  =  .Int: x1,
//         R3  =  .Int: y1,
//         R4  =  OS_ColourNumber: colour
//       ),
//       EXIT (R0?, R1?, R2?, R3?, R4?, R5?, R6?, R7?, R8?, R9?, R10?, R11?, R12?)
//    );


//SWI ZapRedraw_AddCursorSmart

TYPE ZapRedrawFindFont_Flags = .Bits;
CONST ZapRedrawFindFont_DSA            = ZapRedrawFindFont_Flags: %0;
CONST ZapRedrawFindFont_VDU            = ZapRedrawFindFont_Flags: %1;
CONST ZapRedrawFindFont_ReductionBlock = ZapRedrawFindFont_Flags: %10;

TYPE ZapRedraw_ReductionBlock = OS_Box;
SWI ZapRedraw_FindFont =
   ( NUMBER 0x48497 "Opens a font and returns a font handle",
     ENTRY
     ( R0  -> .String:                  name,
       R1  =  ZapRedrawFindFont_Flags:  flags,
       R2  =  .Int:                     size,
       R3  =  .Int:                     aspect,
       R4  -> ZapRedraw_ReductionBlock: block
     ),
     EXIT
     ( R0! =  ZapRedraw_F: handle
     )
   );


SWI ZapRedraw_LoseFont =
   (  NUMBER 0x48498 "Closes a font",
      ENTRY
      ( R0  =  ZapRedraw_F: handle
      ),
      EXIT (R0?)
   );


TYPE ZapRedrawReadCharSize_Flags = .Bits;
CONST ZapRedrawReadCharSize_Pixels = ZapRedrawReadCharSize_Flags: %0;
CONST ZapRedrawReadCharSize_OS     = ZapRedrawReadCharSize_Flags: %1;
CONST ZapRedrawReadCharSize_Linesp = ZapRedrawReadCharSize_Flags: %10;
CONST ZapRedrawReadCharSize_Scale  = ZapRedrawReadCharSize_Flags: %100;

SWI ZapRedraw_ReadCharSize =
   (  NUMBER 0x48499 "Reads the character size of an opened font",
      ENTRY
      ( R0  =  ZapRedraw_F:                 handle,
        R1  -> ZapRedraw_Block:             redraw_block,
        R2  =  ZapRedrawReadCharSize_Flags: flags
      ),
      EXIT
      ( R0?,
        R2  =  .Int: charw,
        R3  =  .Int: charh
      )
    );


SWI ZapRedraw_Version =
   (  NUMBER 0x4849a "Reads the version of ZapRedraw",
      EXIT
      ( R0! =  .Int: Version,
        R1?, // div_mod not APCS compliant
        R2?  // move_bytes not APCS compliant (actually, it's almost APCS32 compliant, 
             //                                but fairly usless in a C context)
      )
   );


SWI ZapRedraw_ListFonts =
   (  NUMBER 0x4849b "Lists the fonts installed on the system (NYI)",
      ABSENT
   );



SWI ZapRedraw_UpdateWindow =
   (  NUMBER 0x4849c "Updates a wimpdow by calling Wimp_UpdateWindow and
                      ZapRedraw_RedrawWindow",
      ENTRY
      ( R0  ->  Wimp_Draw: update,
        R1  ->  ZapRedraw_Block: redraw_block
      ),
      EXIT (R0?)
    );


SWI ZapRedraw_ReadFontInfo =
   (  NUMBER 0x4849d "Read information about an open font - see individual subreasons",
      ABSENT
   );

SWI ZapRedraw_ReadFontName =
   (  NUMBER 0x4849d,
      ENTRY
      ( R0  #  0 "Read the font name of an open font",
        R1  =  ZapRedraw_F: handle
      ),
      EXIT
      ( R0! -> .String: name
      )
   );


SWI ZapRedraw_ReadModeBPP =
   (  NUMBER 0x4849e "Read the Log2 BPP for the current mode, adjusted for ViewFinder",
      EXIT (R0! = .Int: bpp)
   )



More information about the oslib-user mailing list