mirror of
https://github.com/antoinevignau/source.git
synced 2025-01-21 08:33:23 +00:00
1 line
11 KiB
Plaintext
1 line
11 KiB
Plaintext
|
LOAD 'Macros.dump'
INCLUDE 'M16.Profile'
INCLUDE 'SS.equ'
; INCLUDE 'Driver.equ'
INCLUDE 'Heap.aii.i'
INCLUDE 'Eval.aii.i'
;-----------------------------------------------
;
; Imported addresses
;
;-----------------------------------------------
IMPORT S_AcceptCell
IMPORT S_AddCellToChangedList
IMPORT S_BuildTrashUndo
IMPORT S_DeltaMove
IMPORT S_DependHomeCell
IMPORT S_FixDependList
IMPORT S_GetCellTableEntry
IMPORT S_GetRealCell
IMPORT S_GetRefCell
IMPORT S_InRange
IMPORT S_MoveCell
IMPORT S_MoveDestBR
IMPORT S_MoveDestTL
IMPORT S_MoveOldCell
IMPORT S_MoveSrcTL
IMPORT S_NormalizeRange
IMPORT S_OrigTransDestBR
IMPORT S_OrigTransDestTL
IMPORT S_RemoveRangeDep
IMPORT S_ResetCircularity
IMPORT S_SetCellTableEntry
IMPORT S_SetCircularBits
IMPORT S_SplitDependList
IMPORT S_SwapCell
IMPORT S_TraverseDependFormulas
IMPORT S_TraverseRange
;-----------------------------------------------
;
; Forward addresses and entries
;
;-----------------------------------------------
ENTRY S_TrashFormula
ENTRY S_TrashFormula2
;-------------------------------------------------------------------------
;
;
S_TrashCell PROC EXPORT
;Using S_CurrentData
;Using S_MoveData
input Cell:l,CellTableEntry:l
local DependList:l,DependPtr:l
local CellPtr:l,FakeCellFlag:w
local SingleList:l,RangeList:l
local RangeStart:l,RangeSize:l
error ErrFlag
BEGIN
ProfileIn 1
stz ErrFlag
; We know that there is something at this location. If it is only
; a depend list, we can skip the first part of this routine.
lda CellTableEntry+2
and #S_CellTableFlags
sta FakeCellFlag
bne doTrashTraverse
; If a user-cell exists, we will first remove the cell (as if with
; a delete key). This will clean up any depend ptrs to this cell as
; well as fix up any pad cells.
ldx #S_CellTypeEmpty
in Cell:l,x:w,x:w,x:w,x:w
out :l,:l
XCall S_AcceptCell,err=ErrFlag
pla
plx
cpx S_MoveDestBR+2
blt chkLeft1
stx S_MoveDestBR+2
chkLeft1
pla
plx
cpx S_MoveDestTL+2
bge getIndex
stx S_MoveDestTL+2
getIndex
lda ErrFlag
jne Exit
; Now if there are any depend ptrs left at this location, we need to
; 'trash' the formulas that refer to this cell. First get the depend list.
;
Call S_GetCellTableEntry,in=(Cell:l),out=(CellTableEntry:l)
ora CellTableEntry
jeq Exit
lda CellTableEntry+2
and #S_CellTableFlags
sta FakeCellFlag
; This will traverse the depend list and trash any cells that refer
; to this cell.
doTrashTraverse
MoveLong Cell,S_MoveOldCell
in Cell:l,CellTableEntry:l,#S_TrashFormula:l,#S_TrashFormula2:l
XCall S_TraverseDependFormulas,err=ErrFlag
jcs Exit
; Get the DependList again. It could have changed, because trashing an
; endpt of a range will modify depend lists.
lda FakeCellFlag
beq doRealCell
Call S_GetCellTableEntry,in=(Cell:l),out=(DependList:l)
bra gotDepList
doRealCell
H_GetBlockPtr CellTableEntry,CellPtr
MoveWord [CellPtr]:#S_CellDependOnMe,DependList
MoveWord [CellPtr]:#S_CellDependOnMe+2,DependList+2
; If nothing left, quit.
gotDepList
ora DependList
bne gotDepList2
bra Exit
; Else, keep only the range part of the list. To do this we need
; to split up the list and Save the range part at the cell. We'll
; throw away the single part.
gotDepList2
in DependList:l
out SingleList:l,RangeList:l
XCall S_SplitDependList,err=ErrFlag
bcs Exit
; Save the range part.
lda FakeCellFlag
beq doPadCell2
Call S_SetCellTableEntry,in=(Cell:l,RangeList:l)
bra depListSet
doPadCell2
H_GetBlockPtr CellTableEntry,CellPtr
MoveWord RangeList,[CellPtr]:#S_CellDependOnMe
MoveWord RangeList+2,[CellPtr]:#S_CellDependOnMe+2
; Throw away the single part.
depListSet
lda SingleList+2
bmi Exit
and #$FFFF-S_CellTableFlags
sta SingleList+2
ora SingleList
beq Exit
H_DisposeBlock SingleList
Exit
ProfileOut 1
RETURN
ENDP
;---------
|