; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
        SUBT    Creation of swis.h ==> Hdr:makehswis

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name       Description
; ----       ----       -----------
; 07-Feb-94  TMD        Created file
; 20-Jul-94  AMcC       Made compatible with Hdr file changes:
;                       - GETs Hdr:PublicWS rather than defining SoundWorkSpace.
;                       - Hdr:File has been split into Hdr:FSNumbers and Hdr:HighFSI
;                         GETs Hdr:FSNumbers (needed by NewErrors) (was GET Hdr:File).
;                       - FilerAction hdr file is now called FilerAct (was Filer).
;                       - Filter hdr file is now called Filter (was Filters).
;                       - Squash hdr file is now called Squash (was Compress).
;                       - Removed GET  Hdr:DBox
;                       - Removed GET  Hdr:ROMCache
; 22-Sep-94  AMcC       #ifdef __cplusplus lines included in derived file (from IJohnson)
; 22-Sep-94  AMcC       Generates SWI name defs for all SWIs listed in PRM (3.50 version)
; 12-Oct-94  AMcC       Added SWIs for DDT (HLLDebugger) and HostFS (Tube)
; 03-Jan-95  AMcC       Added CDROM and SCSI SWIs (as requested by SPalmer)
; 09-Jan-95  AMcC       Added #defines for INR(..) and OUTR(..)
;                       Added usage comment (for Aquarius Toolbox)
;                       Updated version and date for header of output file
;

; AAsm source file to make h.swis file from Hdr:SWIs and other headers

        GET     Hdr:ListOpts
        GET     Hdr:Machine.<Machine>
        $GetIO

        GBLS    SWIClass

; Now the special version of the AddSWI macro that outputs the #defines

        MACRO
        AddSWI  $SWIName,$value
        LCLA    val2
  [     "$value" = ""
$SWIClass._$SWIName # 1
  |
$SWIClass._$SWIName * $value
  ]
val2    SETA    $SWIClass._$SWIName
X$SWIClass._$SWIName * $SWIClass._$SWIName + Auto_Error_SWI_bit
        =       "#undef $SWIClass._$SWIName", 10
        =       "#define $SWIClass._$SWIName 0x$val2", 10
        MEND

        MACRO
$label  AddError $name,$text,$value
$label
   [    "$value" = ""
ErrorNumber_$name # 1
   |
ErrorNumber_$name * $value
   ]
        GBLS ErrorString_$name
ErrorString_$name SETS "$text"
        MEND

        MACRO
$label  AddError2 $name,$text,$value
$label
   [    "$value" = ""
ErrorNumber_$name # 1
   |
ErrorNumber_$name * $value
   ]
        GBLS ErrorString_$name
ErrorString_$name SETS "$text"
        MEND

        MACRO
$label  AddFSError      $class, $baseerr, $fsname, $fsnumber
$label
        LCLA    value
value   SETA    &10000 + $fsnumber*&100 + ErrorNumber_$baseerr._Pre
        LCLS    string
string  SETS    ErrorString_$baseerr._Pre :CC: "$fsname" :CC: ErrorString_$baseerr._Post
        LCLS    string2
string2 SETS    "&":CC:(:STR:value)
        AddError        $class$baseerr, "$string", $string2
        MEND

; Needed to GET Hdr:Sound without Hdr:VickySpace -> Hdr:Macros

;SoundWorkSpace * &01F04000
        GET     Hdr:PublicWS

        AREA    |Text$Data|, DATA

; First output the file header
	BIN	h.swisheader

; Now output all the SWI symbols we can access

        GET     Hdr:FSNumbers
        GET     Hdr:NewErrors
        GET     Hdr:SWIs
        GET     Hdr:CPU.Generic26
        GET     Hdr:IO.GenericIO
        GET     Hdr:ModHand

        GET     s.swioptions

; And finally the trailing bits

        =       10
        =       "#endif", 10

        END