mirror of
https://github.com/antoinevignau/source.git
synced 2025-01-20 02:30:40 +00:00
1 line
17 KiB
ArmAsm
1 line
17 KiB
ArmAsm
|
*****************************************************************************************************
; PL I/O Routines
;
; This file contains the routines used by PL to open and save documents.
;
*****************************************************************************************************
load 'macros.dump'
include 'driver.equ'
include 'pl.equ'
IMPORT D_BeachBall
IMPORT D_Deref
IMPORT D_DestroyByRef
IMPORT D_FastMult
IMPORT D_NeedHand
IMPORT D_Read2
IMPORT D_ReadHandle2
IMPORT D_SetCursor
IMPORT D_UnLock
IMPORT D_Write2
IMPORT D_WriteHandle2
IMPORT P_CheckHand
IMPORT P_CurrentWin
IMPORT P_ErrorAlert
IMPORT P_Header
IMPORT P_HeaderSize
IMPORT P_HorizGCount
IMPORT P_HorizGuides
IMPORT P_InitDoc
IMPORT P_KillPage
IMPORT P_LastObj
IMPORT P_LoadPage
IMPORT P_LoadWindowStuff
IMPORT P_MergeGuides
IMPORT P_NotActive
IMPORT P_OBJSIZES
IMPORT P_ObjList
IMPORT P_PInfoSize
IMPORT P_Page
IMPORT P_PageArray
IMPORT P_PageCount
IMPORT P_SavePage
IMPORT P_SaveWindowStuff
IMPORT P_ShowDoc
IMPORT P_UseTemplate
IMPORT P_Version
IMPORT P_VertGCount
IMPORT P_VertGuides
IMPORT T_ReThread
IMPORT X_ReadWPScrap
IMPORT X_WriteWPScrap
IMPORT X_DisposeThread
*****************************************************************************************************
; P_Thread2Pair ( ThreadHdl:long ): PageNo:word, ObjNo:word
;
; This routine is called to determine the page and object number for a given text thread. The page
; and object numbers will be used when saving to disk to replace the handles. These values can be
; used on an Open to correctly relink the new handles in the same way.
P_Thread2Pair PROC EXPORT
;Using P_Data
;Using P_ObjData
input ThreadHdl:l
output PageNo:w,ObjNo:w
local Hdl:l,Ptr:l,ThreadPtr:l,ObjHdl:l,ObjPtr:l,Offset:l
begin
; If thread handle is NIL then blow it off.
cpzl ThreadHdl
beq NoThread
; Get page number from the thread.
movelong [ThreadHdl],ThreadPtr
moveword [ThreadPtr]:#P_PageNo,PageNo
; Get pointer to page entry in the page array.
tool _Multiply,in=(PageNo:w,#P_PInfoSize:w),out=(Offset:l)
movelong P_PageArray,Hdl
movelong [Hdl],Ptr
addlong Ptr,Offset,Ptr
; Scan page object list to see if we can find the thread we are looking for. Get its object number.
movelong [Ptr],ObjHdl
stz ObjNo
loop cmpl ObjHdl,ThreadHdl
beq exit
movelong [ObjHdl],ObjPtr
movelong [ObjPtr],ObjHdl
inc ObjNo
bra loop
; The thread was NIL so return page number and object number of -1.
NoThread moveword #-1,PageNo
sta ObjNo
exit return
ENDP
*****************************************************************************************************
; P_Pair2Thread ( PageNo:word, ObjNo:word ): ThreadHdl:long
;
; This routine is called to determine the text thread corresponding to the given text object for
; the given page.
P_Pair2Thread PROC EXPORT
;Using P_Data
;Using P_ObjData
input PageNo:w,ObjNo:w
output ObjHdl:l
local Hdl:l,Ptr:l,ObjPtr:l,Offset:l
begin
; If page number is -1 then no thread exists for this page object; return NIL.
cmpw PageNo,#-1
beq NoThread
; Get pointer to page entry in the page array.
tool _Multiply,in=(PageNo:w,#P_PInfoSize:w),out=(Offset:l)
movelong P_PageArray,Hdl
movelong [Hdl],Ptr
addlong Ptr,Offset,Ptr
; Scan object array for the given page to find the object handle for the given object number.
movelong [Ptr],ObjHdl
ldx #0
loop cpx ObjNo
beq exit
movelong [ObjHdl],ObjPtr
movelong [ObjPtr],ObjHdl
inx
bra loop
; No thread exists for this page/object return NIL.
NoThread stzl ObjHdl
exit return
ENDP
*****************************************************************************************************
; P_SetParag ( ObjectPtr:long )
;
; This routine is called to put the given objects paragraph handle into all the text threads in
; its linked list.
P_SetParag PROC EXPORT
;Using P_ObjData
input objptr:l
local objhdl:l,paraghdl:l
begin
movelong [objptr]:#P_ParagHdl,paraghdl
objloop cpzl [objptr]:#P_NThread
beq exit
movelong [objptr]:#P_NThread,objhdl
movelong [obj
|