; 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.
;
; > Sources.MsgTrans

MsgTrans_FileName
        DCB     "DisplayManager:Messages",0
                ALIGN

;---------------------------------------------------------------------------
; MsgTrans_OpenFile
;
;       Out:    r0 -> message file block
;
;       Open our messages file.
;
MsgTrans_OpenFile
        ENTRY   "r1-r2"

        Debug   msg,"MsgTrans_OpenFile"

        ADR     r0, message_file_block
        LDRB    lr, flags
        TST     lr, #f_messagesopen
        EXIT    NE

        Debug   msg," opening file"

        ADR     r1, MsgTrans_FileName
        MOV     r2, #0
        SWI     XMessageTrans_OpenFile
        LDRVCB  lr, flags
        ORRVC   lr, lr, #f_messagesopen
        STRVCB  lr, flags

        EXIT


;---------------------------------------------------------------------------
; MsgTrans_ErrorLookup
;
;       In:     r0 -> token error block
;               r4-r7 -> optional parameters
;       Out:    r0 -> translated error block
;
;       Lookup an error in our messages file.
;
MsgTrans_ErrorLookup
        ENTRY   "r0-r2"

        Debug   msg,"MsgTrans_ErrorLookup"

        CLRV
        BL      MsgTrans_OpenFile

        MOVVC   r1, r0
        LDRVC   r0, [sp]
        MOVVC   r2, #0
        SWIVC   XMessageTrans_ErrorLookup
        STR     r0, [sp]

        EXIT


;---------------------------------------------------------------------------
; MsgTrans_Lookup
;
;       In:     r1 -> token
;               r2 -> buffer (or 0)
;               r3 = size of buffer (if r2 non-zero)
;               r4-r7 = parameters
;       Out:    r2 -> translated string
;               r3 = size of result before terminator
;
;       Look up the given token in our messages file.
;
MsgTrans_Lookup
        ENTRY   "r0,r1"

        Debug   msg,"MsgTrans_Lookup"

        CLRV
        BL      MsgTrans_OpenFile

        SWIVC   XMessageTrans_Lookup
        STRVS   r0, [sp]

        EXIT


        END