; > Sources.Main

; ***** BEGIN LICENSE BLOCK *****
; Version: MPL 1.1
;
; The contents of this file are subject to the Mozilla Public License Version
; 1.1 (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.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS" basis,
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
; for the specific language governing rights and limitations under the
; License.
;
; The Original Code is the Printers+ front-end.
;
; The Initial Developer of the Printers front-end is Acorn Computers Ltd.
; The Initial Developer of the Printers+ extensions is RISCOS Ltd.
;
; Portions created by the Initial Developers are Copyright (C) 2003
; the Initial Developers. All Rights Reserved.
;
; Contributor(s):
;
; ***** END LICENSE BLOCK ***** */


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

; Date       Description
; ----       -----------
; 19-Feb-90     0.01    File created
;

Module_BaseAddr

        GET     s.AppName         ; read ApplicationName

        GET     Hdr:ListOpts
        GET     Hdr:Macros
        GET     Hdr:System
        GET     Hdr:ModHand
        GET     Hdr:Services
        GET     Hdr:Proc
        GET     Hdr:ResourceFS
        GET     s.Version

        LEADR   Module_LoadAddr


; **************** Module code starts here **********************

        ASSERT  (.-Module_BaseAddr) = 0

        DCD     0 ; App_Start    - Module_BaseAddr
        DCD     App_Init     - Module_BaseAddr
        DCD     App_Die      - Module_BaseAddr
        DCD     App_Service  - Module_BaseAddr
        DCD     App_Title    - Module_BaseAddr
        DCD     App_HelpStr  - Module_BaseAddr
        DCD     0
        DCD     0
        DCD     0
        DCD     0
        DCD     0

App_Title     DCB     "$ApplicationName", 0
App_HelpStr   DCB   "$ApplicationName", 9, "$VString $Date", 0
                ALIGN

; *****************************************************************************
;
;       App_Init - Initialisation entry
;

App_Init ENTRY "r0"

        ADR     R0, resourcefsfiles
        SWI     XResourceFS_RegisterFiles   ; ignore errors (starts on Service_ResourceFSStarting)

        EXITS

; *****************************************************************************
;
;       App_Die - Die entry
;

App_Die ENTRY "r0"

        ADR     R0, resourcefsfiles
        SWI     XResourceFS_DeregisterFiles

        EXITS                   ; ignore errors (ResourceFS might be dead)

; *****************************************************************************
;
;       App_Service - Main entry point for services
;

App_Service ROUT

        TEQ     R1, #Service_ResourceFSStarting
        MOVNE   PC, LR

; In    R2 -> address inside ResourceFS module to call
;       R3 = workspace pointer for module
; Out   R2 called with R0 -> files, R3 -> workspace

svc_resourcefsstarting ENTRY "R0-R3"

        ADR     R0, resourcefsfiles
        MOV     LR, PC                          ; get return address
        MOV     PC, R2                          ; R2 = address to call

        EXITS

resourcefsfiles
        GET     s.ResFiles
        DCD     0

        END
