The territory manager provides the following SWIs:


Territory_Number Entry:
-
Exit:

        R0 = Configured territory's number.

This SWI returns the territory number of the currently configured territory.

                     

Territory_Register Entry:
R0 - Territory Number
R1 -> Buffer containing list of entry points for SWIs
R2 - Value of R12 on entry to territory.
Exit:

        Registers preserved.
                               
        The list of entry points is in the same order as the territory SWIs
detailed below under 'SWIs provided by the territory modules'
        The SWI adds the territory to the list of known territories kept by
the territory manager and makes it available for application programs. This SWI should be called by a territory module, when it is initialised, and whenever it gets Service_TerritoryManagerLoaded

Territory_Deregister Entry:

        R0 - Territory Number
Exit:
        Registers preserved.
        This SWI removes the territory from the list of active territories,
it should be called from the die entry point of the territory module when it is killed.

Territory_NumberToName Entry:
R0 - Territory number.
R1 - Pointer to buffer
R2 - Length of buffer
Exit:

       [R1] - Name of territory in current territory.
       This SWI returns the name of a territory in the currently configured
territory's language.

Territory_NameToNumber Entry:
R0 - Territory number or -1 to use configured territory.
R1 - Pointer to 0 terminated containing a territory name in the
provided territory's alphabet
Exit:

       R0 - 0 if territory unknown, else territory number for given territory.

Territory_Exists

Entry:

       R0 - Territory number.
Exit:
R0 - Preserved.
       Z set if territory is currently loaded.
        This call allows you to check if the specified territory is
currently present in the machine, and can be used by applications.

Territory_AlphabetNumberToName Entry:
R0 - Alphabet number.
R1 - Pointer to buffer
R2 - Length of buffer
Exit:

       [R1] - Name of alphabet in current territory.
        This SWI reads the name of the specified alphabet in the current
territory's language and alphabet.
             

Territory_SelectAlphabet Entry:
R0 - Territory number or -1 for configured territory.
Exit:
      Registers preserved, correct alphabet for territory selected.
       
        This call selects the correct alphabet for the specified or
configured territory and defines the system font appropriately           

Territory_SetTime
Entry:
R0 = Pointer to 5 byte UTC time block
Exit:
R0 preserved.

      Clock set to given UTC time.
        This SWI allows you to set the clock to a given UTC time.

Territory_ReadCurrentTimeZone Entry:
-
Exit:
R0 -> Name of current time zone

       R1 = Offset from UTC to current time zone in centiseconds.
           
        This SWI returns the time zone currently in effect and the offset
from UTC to the current time zone. R1 on exit is a signed 32 bit offset in centiseconds.

Territory_ConvertTimeToUTCOrdinals
Entry:
R1 = Pointer to 5 byte UTC time block
R2 -> Word alligned buffer to hold data
Exit:
R1 Preserved
R2 Preserved
[R2] = CS. ; all values are for UTC.
[R2+4] = Second
[R2+8] = Minute
[R2+12] = Hour (out of 24)
[R2+16] = Day number in month.
[R2+20] = Month number in year.
[R2+24] = Year number.

       [R2+28] = Day of week.
        This SWI calculates the time ordinals for the GMT time zone from a given 5 byte UTC time.
                                                                                                       


The following SWIs are provided by the individual territories by means of the entry points passed to the territory manager when calling Territory_Register.

For all of the following SWIs R0 on entry is the territory for which the operation should be performed, or -1 if the operation should be performed using the default configured territory.


Territory_ReadTimeZones Entry:
R0 - Territory number or -1 for configured territory
Exit:
R0 - Pointer to name of standard time zone for given territory.
R1 - Pointer to name of summer for given territory.
R2 - Offser from UTC to standard time

       R3 - Offset from UTC to summer time.
                                 

Territory_ConvertDateAndTime Entry:

      R0 = Territory number or -1 for configured territory.
      R1 = Pointer to 5 byte UTC time block
      R2 = Pointer to buffer for resulting string
      R3 = Size of buffer
      R4 = Pointer to format string (null terminated)
Exit:
R0 = Pointer to buffer (R2 on entry)
R1 = Pointer to terminating 0 in buffer.
R2 = Number of bytes free in buffer.
R3 = R4 on entry.
      R4 - Preserved.

This call is equivalent to the OS_ConvertDateAndTime call, and should be used in preferance to that call, which just calls this SWI.

The resulting string for both calls is in local time for the given territory, and in the it's local language and alphabet.

The fields allowed in the format string are:

                       
CS - Centi-seconds
SE - Seconds
MI - Minutes
12 - Hours in 12 hour format
24 - Hours in 24 hour format
AM - AM or PM indicator in local language (may NOT be 2 characters) PM - AM or PM indicator in local language (may NOT be 2 characters)

WE - Weekday in full in local language. W3 - Short form of weekday name (May not be 3 characters) WN - Weekday as a number

DY - Day of the month (may not be 2 characters, and may not even be

                         numeric)
ST - Ordinal pre/suffix in local language (may be null) MO - Month name in full
M3 - Short form of month name (May not be 3 characters) MN - Month number.
CE - Century
YR - Year within century
WK - Week of the year (As calculated in the territory, may not be Mon to
       Sun)
DN - Day of the year.
TZ - Name of the time zone currently in effect. (I.E. GMT or BST in the U.K.) 0 Insert an ASCII 0 byte
  %    Insert a '%'        

Territory_ConvertStandardDateAndTime Entry:

      R0 = Territory number or -1 for configured territory.
      R1 = Pointer to 5 byte UTC time block
      R2 = Pointer to buffer for resulting string
      R3 = Size of buffer
Exit:
R0 = Pointer to buffer (R2 on entry)
R1 = Pointer to terminating 0 in buffer.
R2 = Number of bytes free in buffer.
      R3,R4 Preserved.

This SWI is equivalent to OS_ConvertStandardDateAndTime, but uses a territory specific default format.


Territory_ConvertStandardDate Entry:

      R0 = Territory number or -1 for configured territory.
      R1 = Pointer to 5 byte UTC time block
      R2 = Pointer to buffer for resulting string
      R3 = Size of buffer
Exit:
R0 = Pointer to buffer (R2 on entry)
R1 = Pointer to terminating 0 in buffer.
R2 = Number of bytes free in buffer.
      R3,R4 Preserved.

This SWI is equivalent to OS_ConvertStandardDateAndTime, but uses a territory specific default date only format.


Territory_ConvertStandardTime Entry:

      R0 = Territory number or -1 for configured territory.
      R1 = Pointer to 5 byte UTC time block
      R2 = Pointer to buffer for resulting string
      R3 = Size of buffer
Exit:
R0 = Pointer to buffer (R2 on entry)
R1 = Pointer to terminating 0 in buffer.
R2 = Number of bytes free in buffer.
      R3,R4 Preserved.

This SWI is equivalent to OS_ConvertStandardDateAndTime, but uses a territory specific default time only format.


Territory_ConvertTimeToOrdinals Entry:

      R0 = Territory number or -1 for configured territory.
      R1 = Pointer to 5 byte UTC time block
      R2 -> Word alligned buffer to hold data
Exit:
R1 Preserved
R2 Preserved
[R2] = CS. ; All values are for LOCAL time
[R2+4] = Second
[R2+8] = Minute
[R2+12] = Hour (out of 24)
[R2+16] = Day number in month.
[R2+20] = Month number in year.
[R2+24] = Year number.
      [R2+28] = Day of week.
                                          
        This SWI coverts a 5 byte UTC time to time ordinals for the local time in the given territory.

Territory_ConvertTimeStringToOrdinals Entry:

      R0 = Territory number or -1 for configured territory.
      R1 = Reason code:
             1   - String is %24:%MI:%SE
             2   - String is %W3, %DY-%M3-%CE%YR
             3   - String is %W3, %DY-%M3-%CE%YR.%24:%MI:%SE
      R2 -> String
      R3 -> Word aligned buffer to contain result.
Exit:    
     R1-R3  Preserved.
     [R3]    = CS                        ; All values are for LOCAL time
     [R3+4]  = Seconds                   ; Values that are not present in the string are set to -1
     [R3+8]  = Minutes
     [R3+12] = Hours (out of 24)
     [R3+16] = Day number in month.
     [R3+20] = Month number in year.
     [R3+24] = Year number.
        This SWI allows conversion between a time string and time ordinals.
        
        NOTE THAT THE TIME STRING IS EXPECTED TO BE IN THE LOCAL LANGUAGE
AND ALPHABET FOR THE SPECIFIED TERRITORY AS OBTAINED FROM Territory_ConvertDateAndTime WITH THE APPROPRIATE FORMAT STRING.

Territory_ConvertOrdinalsToTime Entry:

      R0 = Territory number or -1 for configured territory.
      R1 -> Block to contain 5 byte time.
      R2 -> Block containing:
      [R2]    = CS.                     ; All values are for LOCAL time
      [R2+4]  = Second
      [R2+8]  = Minute
      [R2+12] = Hour (out of 24)
      [R2+16] = Day number in month.
      [R2+20] = Month number in year.
      [R2+24] = Year number.
Exit:
R1,R2 preserved.
      [R1] 5 byte UTC time for given time.
        This call allows conversion from local time ordinals for the given
territory to a 5 byte UTC time value.

Territory_Alphabet Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 = The alphabet number used by the specified territory

            (E.G. 101 =Latin1, 102 = Latin2 ... )
        This SWI reads the alphabet number that will be selected if
Territory_SelectAlphabet is issued for the given territory.

Territory_AlphabetIdentifier Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> Identifier string for the alphabet that is used by the given

             territory.
        This SWI will return and identifier string for the alphabet that
will be used if Territory_SelectAlphabet is issued for the given territory. (E.G. "Latin1" for the Latin 1 alphabet ) The identifier is guaranteed to be made of ASCII characters only. (I.E 7 bit characters).
                                         

Territory_SelectKeyboardHandler Entry:
R0 = Territory number or -1 for configured territory
Exit:

       Keyboard handler used by the specified territory is selected.
        This call is used to activate the keyboard handler for the specified
territory.

Territory_WriteDirection Entry:
R0 = erritory number or -1 for configured territory
Exit:

        R0 = The write direction used by the specified territory.
        The value in R0 is a set of bits as follows:
        Bit 0 = WriteDirection_LeftToRight      0 = Left to right        1 = Right to left
        Bit 1 = WriteDirection_UpToDown         0 = Up to down           1 = Down to up
        Bit 2 = WriteDirection_HorizontalLines  0 = Linez are horizontal 1 = Lines are vertical.
        Bits 3-31 Are reserved, and at the moment always returned as 0.

Terrirtory_CharacterPropertyTable Entry:
R0 = erritory number or -1 for configured territory
R1 = Property table pointer required:
Property_Control 0 (1 = Is a control code)
Property_Uppercase 1 (1 = Is uppercase)
Property_Lowercase 2 (1 = Is lowercase)
Property_Alpha 3 (1 = Is alphabetic character)
Property_Punctuation 4 (1 = Is a punctuation character)
Property_Space 5 (1 = Is a space character)
Property_Digit 6 (1 = Is a digit)
Property_XDigit 7 (1 = Is a hex digit)
Property_Accented 8 (1 = Has an accent).
Property_ForwardFlow 9 (1 = Character flows in the same
direction as the write
direction for territory )
Property_BackwardFlow 10 (1 = Character flows in the
reverse direction from the

                                                 territory's write dirction)
                                          
Exit:
R0 -> 256 bit table indicating for each character in the territory's
              alphabet if it has the specified property.
        A character which doesn't have properties 9 ann 10 is a nutral
character which flows in the same direction as the surrownding text.
        A character can't have both property 9 and property 10.

Territory_LowerCaseTable Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> 256 byte table indexed by character giving the lowercase

             version of the character in the given territory's alphabet.

Territory_UpperCaseTable Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> 256 byte table indexed by character giving the uppercase

             version of the character in the given territory's alphabet.

Territory_ControlTable Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> 256 byte table indexed by character giving the value for

             CTRL-<character> in the given territory's alphabet.

Territory_PlainTable Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> 256 byte table indexed by character giving the unaccented

             version of the character in the given territory's alphabet.

Territory_ValueTable Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> 256 byte table indexed by character giving the value of the
character when used as a digit (E.G. 9 for '9' and 10 for 'A'

             and 'a' in English) in the given territory's alphabet.

Territory_RepresentationTable Entry:
R0 = Territory number or -1 for configured territory
Exit:
R0 -> 16 byte table indexed by value giving the character
that should be used to represent the given value (E.G. 'A' at

             offset 10 for English)

Territory_Collate Entry:
R0 = Territory number or -1 for configured territory
R1 -> String 1 (0 terminated)
R2 -> String 2 (0 terminated)
R3 = flags
bit 0 - Ignore case.
bit 1 - Ignore accents
bits 2-31 reserved and must be 0.
Exit:
R0 <0 if S1 < S2
=0 if S1 = S2
>0 if S1 > S2
       Other registers preserved.
       Z set if equal (EQ).
       C set and Z clear if S1 > S2 (HI)
       N set and V clear if S1 < S2 (LT)
       V set and R0 -> error block if error.
        This SWI should be used to compare two strings in the given
territory's alphabet.
                                         

Territory_ReadSymbols

In:

       R1 - Reason code:
               0 Return pointer to 0 terminated decimal point string.
               1 Return pointer to 0 terminated thousands separator
               2 Return pointer byte list containing the size of each
                 group of digits in formatted nonmonetary quantities.
                 255   = No further grouping
                   0   = Repeat last grouping for rest of number
                 other = Size of current group, the next byte contains
                         the size of the next group of dogits before the
                          current group.
               3 Return pointer to 0 terminated international currency symbol.
               4 Return pointer to 0 terminated currency symbol in local alphabet.
               5 Return pointer to 0 terminated decimal point used for monetary quantities
               6 Return pointer to 0 terminated thousands separator for monetary quantities
               7 Return pointer byte list containing the size of each
                 group of digits in formatted monetary quantities.
               8 Return pointer to 0 terminated positive sign used for monetary quantities
               9 Return pointer to 0 terminated negative sign used for monetary quantities
              10 Return number of fractional digits to be displayed in an internationally
                 formatted monetay quantity
              11 Return number of fractional digits to be displayed in a formatted monetay
                 quantity
              12 Return 1 If the currency symbol precedes the value for a nonnegative
                          formatted monetary quantity
                        0 If the currency symbol succeeds the value for a nonnegative
                          formatted monetary quantity
              13 Return 1 If the currency symbol is separated by a space from the value for a
                          nonnegative formatted monetary quantity
                        0 If the currency symbol is not separated by a space from the value for a
                          nonnegative formatted monetary quantity
              14 Return 1 If the currency symbol precedes the value for a negative
                          formatted monetary quantity
                        0 If the currency symbol succeeds the value for a negative
                          formatted monetary quantity
              15 Return 1 If the currency symbol is separated by a space from the value for a
                          negative formatted monetary quantity
                        0 If the currency symbol is not separated by a space from the value for a
                          negative formatted monetary quantity
              16 Return for a nonnegative formatted monetary quantity
                        0 If there are parentheses arround the quantity and currency symbol.
                        1 If the sign string precedes the quantity and currency symbol.
                        2 If the sign string succeeds the quantity and currency symbol.
                        3 If the sign string immediately precedes the currency symbol.
                        4 If the sign string immediately succeeds the currency symbol.
              17 Return for a negative formatted monetary quantity
                        0 If there are parentheses arround the quantity and currency symbol.
                        1 If the sign string precedes the quantity and currency symbol.
                        2 If the sign string succeeds the quantity and currency symbol.
                        3 If the sign string immediately precedes the currency symbol.
                        4 If the sign string immediately succeeds the currency symbol.
              18 Return pointer to 0 terminated list separator 
Out:
       R0 - Requested value.

Territory_ReadCalendarInformation In:
R0 = Territory to use (-1 = Configured)
R1 = Pointer to 5 byte UTC time value.
R2 = Pointer to a 44 word buffer

Out:

R0,R1 Preserved.

[R2] = Number of first working day in the week. [R2+4] = Number of last working day in the week. [R2+8] = Number of months in the current year.

                 (current = one in which given time falls)
[R2+12] = Number of days in the current month.

[R2+16] = Max length of AM/PM string. [R2+20] = Max length of WE string.
[R2+24] = Max length of W3 string.
[R2+28] = Max length of DY string.
[R2+32] = Max length of ST string (May be 0). [R2+36] = Max length of MO string.
[R2+40] = Max length of M3 string.
[R2+44] = Max length of TZ string.