antoine-source/appleworksgs/WP/Src/Docs.aii
2023-03-04 03:45:20 +01:00

1 line
5.9 KiB
Plaintext
Executable File

load 'macros.dump'
include 'driver.equ'
include 'wp.equ'
;-----------------------------------------------
;
; Imported addresses
;
;-----------------------------------------------
IMPORT W_Selected
IMPORT W_CurDoc
IMPORT D_CurrentTime
IMPORT W_DateStr
IMPORT D_DateToStr
IMPORT D_Deref
IMPORT W_DocStuff
IMPORT W_FtrHt
IMPORT W_FtrStuff
IMPORT W_GetParRec
IMPORT D_GetRefCon
IMPORT W_Hand
IMPORT W_HdrHt
IMPORT W_HdrStuff
IMPORT W_InitPars
IMPORT W_InitScreen
IMPORT W_MakeCaret
IMPORT W_MakeCaretNS
IMPORT W_MakePageStr
IMPORT W_PHandle
IMPORT W_PPtr
IMPORT W_PaperSize
IMPORT W_ParRec
IMPORT Q_Pixels
IMPORT W_Ptr
IMPORT W_SetBounds
IMPORT D_SetRefCon
IMPORT W_SizeWinGlobals
IMPORT W_StartSwapStuff
IMPORT W_StartWinGlobals
IMPORT W_Stuff
IMPORT W_StuffSize
IMPORT W_TempRgn
IMPORT W_TimeStr
IMPORT D_TimeToStr
IMPORT D_TodaysDate
IMPORT W_TopPgPixel
IMPORT W_View
IMPORT W_WPFontFlag
IMPORT W_LastP
IMPORT D_NeedHandle
import W_MakingRoom
;-----------------------------------------------
;
; Forward addresses and entries
;
;-----------------------------------------------
ENTRY W_CalcPixels
ENTRY W_GetDoc
ENTRY W_PutData
ENTRY W_SetPtr
ENTRY W_SwitchData
********************************************************************
* INCLUDES
*
* Friday, April 28, 1989 7:25:28 AM
********************************************************************
****************************************************************
* W_InitNew(window)
W_InitNew PROC EXPORT
;Using WpGlobals
input window:l
local W_Ptr:l,W_Hand:l,W_ParRec:l
begin
call D_NeedHandle,in=(#W_SizeWinGlobals:l,#attrfixed:w),out=(W_Hand:l)
movelong [W_Hand],W_Ptr
pushlong W_Ptr
pushlong window
jsl D_SetRefCon
pushlong window
jsl W_GetDoc
stz W_WPFontFlag
stz W_Selected
; normal W_Document
moveword #W_NormalOn,W_View
sta W_Stuff
jsl W_InitPars
pushlong window
jsl W_InitScreen
pushword #W_NormalOn
jsl W_PutData
; for header
jsl W_InitPars
stz W_TopPgPixel
moveword #W_HeaderOn,W_View
jsl W_MakeCaretNS
moveword #W_HdrPixelLimit,W_PaperSize
pushword #W_HeaderOn
jsl W_PutData
; for footer
jsl W_InitPars
moveword #W_FooterOn,W_Stuff
pushword #W_NormalOn
jsl W_SwitchData
moveword #W_NormalOn,W_View
pushword #W_HeaderOn
jsl W_CalcPixels
pushword #W_FooterOn
jsl W_CalcPixels
jsl W_SetBounds
jsl W_MakeCaret
return
ENDP
****************************************************************
* W_PutDoc - copies wpglobals into the current docs structure
W_PutDoc PROC EXPORT
;Using wpglobals
begin
cpzl W_CurDoc
beq NoPut
pushlong #W_StartWinGlobals
spacelong
pushlong W_CurDoc
jsl D_GetRefCon
pushlong #W_SizeWinGlobals
_BlockMove
NoPut
return
ENDP
****************************************************************
* W_GetDoc(window) - gets the globals from the window and puts in wpglobals
* If other globals are current then it puts them in their window
W_GetDoc PROC EXPORT
;Using wpglobals
input window:l
begin
cmpl window,W_CurDoc
beq GDExit
cpzl W_CurDoc
beq NoPut
jsl W_PutDoc
NoPut
cpzl window
beq NoGet
spacelong
pushlong window
jsl D_GetRefCon
pushlong #W_StartWinGlobals
pushlong #W_SizeWinGlobals
_BlockMove
NoGet
movelong window,W_CurDoc
GDExit return
ENDP
****************************************************************
* W_GetRgn
W_GetRgn PROC EXPORT
;Using wpglobals
cpzl W_TempRgn
bne GotIt
pha
pha
_NewRgn
pullLong W_TempRgn
GotIt
movelong W_TempRgn,ax
rtl
ENDP
****************************************************************
* W_SwitchData - swtches the data doc,hdr or ftr into adressable labels
W_SwitchData PROC EXPORT
;Using wpglobals
EXPORT W_SetPtr
input NewData:w ;cannot change unless W_PutData
local W_Ptr:l
begin
pushword W_Stuff
jsl W_PutData
lda NewData
jsr W_SetPtr
pushlong W_Ptr
pushlong #W_StartSwapStuff
pushlong #W_StuffSize
_BlockMove
lda W_MakingRoom
beq @1
MoveLong W_PHandle,W_ptr ;This routine shares locals, so can't put
MoveLong [W_ptr],ax ;a new one in.
MoveLong ax,W_Pptr
bra @2
@1 movelong W_PHandle,ax
jsl D_Deref
movelong ax,W_PPtr
@2 moveword NewData,W_Stuff
SDExit
return
W_SetPtr ;
tay
movelong #W_DocStuff,W_Ptr
tya
beq SPExit
bmi DoFtr
movelong #W_HdrStuff,W_Ptr
bra SPExit
DoFtr
movelong #W_FtrStuff,W_Ptr
SPExit
rts
ENDP
****************************************************************
* W_PutData(data)
W_PutData PROC EXPORT
;Using wpglobals
input NewData:w ;cannot change unless W_SwitchData does
local W_Ptr:l
begin
lda NewData
jsr W_SetPtr
pushlong #W_StartSwapStuff
pushlong W_Ptr
pushlong #W_StuffSize
_BlockMove
return
ENDP
****************************************************************
W_CalcPixels PROC EXPORT
;Using wpglobals
input NewData:w
local W_ParRec:l,par:w,Q_Pixels:w
begin
pushword W_Stuff
pushword #9999
jsl W_MakePageStr
lda NewData
beq Exit
pushword NewData
jsl W_SwitchData
moveword #1,par
stz Q_Pixels
ParLoop
lda par
jsl W_GetParRec
movelong ax,W_ParRec
addword [W_ParRec]:#W_pPixels,Q_Pixels,Q_Pixels
inc par
cmpw Q_Pixels,#W_HdrPixelLimit
bcc NotPast
moveword #W_HdrPixelLimit,Q_Pixels
bra EndLoop
NotPast
cmpw W_LastP,par
bcs ParLoop
EndLoop
lda NewData
bmi putfoot
moveword Q_Pixels,W_HdrHt
bra Exit
PutFoot
moveword Q_Pixels,W_FtrHt
Exit
pushword #1
jsl W_MakePageStr
jsl W_SwitchData
return
ENDP
****************************************************************
* W_FillDateTime
W_FillDateTime PROC EXPORT
;Using wpglobals
begin
pha
pha
jsl D_TodaysDate
pushlong #W_DateStr
pushword #2
pushword #0
jsl D_DateToStr
pha
pha
jsl D_CurrentTime
pushlong #W_TimeStr
pushword #0
jsl D_TimeToStr
return
ENDP
END