mirror of
https://github.com/antoinevignau/source.git
synced 2025-01-23 05:30:29 +00:00
1 line
17 KiB
Plaintext
1 line
17 KiB
Plaintext
|
LOAD 'Macros.dump'
INCLUDE 'SS.equ'
INCLUDE 'Driver.equ'
INCLUDE 'Heap.aii.i'
INCLUDE 'Eval.aii.i'
;-----------------------------------------------
;
; Imported addresses
;
;-----------------------------------------------
IMPORT S_AddCellToChangedList
IMPORT S_DeltaMove
IMPORT S_FixFormula
IMPORT S_FixFormula2
IMPORT S_FixFormula3
IMPORT S_FixFormulaFlag
IMPORT S_GetCellTableEntry
IMPORT S_InsertLeftPadCells
IMPORT S_InsertRightPadCells
IMPORT S_MergeDependLists
IMPORT S_MoveDestBR
IMPORT S_MoveDestTL
IMPORT S_MoveNewCell
IMPORT S_MoveOldCell
IMPORT S_MoveSrcBR
IMPORT S_MoveSrcTL
IMPORT S_RearrangePadCells
IMPORT S_RemoveCellFromChangedList
IMPORT S_ResetCircularity
IMPORT S_SetCellTableEntry
IMPORT S_SetCircularBits
IMPORT S_SplitDependList
IMPORT S_TraverseDependFormulas
;-----------------------------------------------
;
; Forward addresses and entries
;
;-----------------------------------------------
ENTRY S_ClearChangedBits
ENTRY S_ClearChangedBits2
;--------------------------------------------------------------------------
; S_SwapCell
;
; For the purposes of the comments in this routine, the following
; terminology will be used. User cell's are those cells that the user
; thinks of as cells. (These include labels, values, and 2 types of formulas.
; The cell type of user cells are always positive, and of non-user cells are
; always negative.) Pad cells are those cell structures in the cell table, used
; to indicate space for overlapping labels. Real cells will be the union of
; User and Pad cells. (This name is used because real cell structures exist.)
; Fake cells are cell table entries that consist of dependency lists.
; (Dependency lists always have some of the high 2 bits of the cell table entry
; non-zero for detection.) Empty cells are blank cell table entries. (For the
; purposes of this routine, empty cells treated as Fake cells because the
; code works.)
S_SwapCell PROC EXPORT
;Using S_CurrentData
;Using S_MoveData
;Using S_SwapCellFixData
input SrcCell:l
local SrcCellTableEntry:l,SrcFakeFlag:w
local SrcFormat:l,SrcCellType:w
local SrcFormulaIndex:l,SrcDependIndex:l
local SrcSingDepList:l,SrcRngDepList:l
local NewSrcEntry:l,NewSrcDepList:l
local DestCell:l,DestCellTableEntry:l,DestFakeFlag:w
local DestFormat:l,DestCellType:w
local DestFormulaIndex:l,DestDependIndex:l
local DestSingDepList:l,DestRngDepList:l
local NewDestEntry:l,NewDestDepList:l
local CellPtr:l,PreviousCell:l,NextCell:l,ClrChangedBits:w
error ErrorFlag
BEGIN
; Initialize flag variables
stz ErrorFlag
stz SrcFakeFlag
stz DestFakeFlag
stz ClrChangedBits
; Determine the other cell to swap with
AddWord SrcCell,S_DeltaMove,DestCell
AddWord SrcCell+2,S_DeltaMove+2,DestCell+2
; ;
; Adjust the src cell ;
; ;
in SrcCell:l
out SrcCellTableEntry:l
XCall S_GetCellTableEntry
ora SrcCellTableEntry
beq fakeSrc1 ; branch empty cell
lda SrcCellTableEntry+2
and #S_CellTableFlags
beq realSrc1 ; branch real cell
; The following works for both fake and empty src cells.
fakeSrc1
inc SrcFakeFlag
MoveWord #S_CellTypeEmpty,SrcCellType
MoveWord #0,SrcFormat+2
MoveLong SrcCellTableEntry,SrcDependIndex
brl adjustDestCell
realSrc1
H_GetBlockPtr SrcCellTableEntry,CellPtr
MoveLong [CellPtr]:#S_CellContent,SrcFormulaIndex
MoveLong [CellPtr]:#S_CellDependOnMe,SrcDependIndex
MoveLong [CellPtr]:#S_CellFormat,SrcFormat
MoveLong [CellPtr]:#S_CellNext,NextCell
MoveLong [CellPtr]:#S_CellPrevious,PreviousCell
lda SrcFormat+2
and #$FFFF-S_CellCircular
MoveWord a,[CellPtr]:#S_CellFormat+2
lda SrcFormat
and #S_CellType
sta SrcCellType
bmi chkChangedSrc ; branch pad cell
; Clear any circularity, we'll reset them at the end ;
userSrc1
lda SrcFormat+2
and #S_CellCircular
beq chkChangedSrc
Call S_ResetCircularity,in=(SrcCell:l)
; Remove SrcCell from changed list if it is already
|