1 line
12 KiB
ArmAsm
1 line
12 KiB
ArmAsm
|
load 'macros.dump'
include 'driver.equ'
include 'pl.equ'
;-----------------------------------------------
;
; Imported addresses
;
;-----------------------------------------------
IMPORT D_BeachBall
IMPORT D_GetStats
IMPORT D_GetWdth
IMPORT D_GrowLHandle
IMPORT D_MustHandle
IMPORT D_SelectFont
IMPORT T_CurColor
IMPORT T_CurFont
IMPORT T_CurIndent
IMPORT T_CurRulBits
IMPORT T_CurRulPtr
IMPORT T_CurStyle
IMPORT T_CurStyleSize
IMPORT T_GetParPtr
IMPORT T_GetSpacing
IMPORT T_LockRuler
IMPORT T_MaxAscent
IMPORT T_MaxDescent
IMPORT T_MulLine
IMPORT T_UnlockRuler
;------------------------------------------------------------------------------
;
; T_CountSpaces (TextPtr:l,Offset:w,MaxOffset:w) : TabStop:w,Spaces:w
;
T_CountSpaces PROC EXPORT
;Using T_TextEqu
INPUT TextPtr:l,Offset:w,MaxOffset:w
OUTPUT TabStop:w,Spaces:w
BEGIN
stz Spaces
stz TabStop
ldy Offset
CharLoop cpy MaxOffset
bge Exit
lda [TextPtr],y
iny
and #$ff
cmp #SPACE+1
bge CharLoop
cmp #5
bge ChkTab
asl a
tax
jmp (JumpTable,x)
ChkTab
cmp #9
beq DoTab
cmp #13
beq Exit
cmp #32
beq DoSpace
bra Charloop
DoSpace inc Spaces
bra CharLoop
DoTab bra CharLoop
Skip2 iny
Skip1 iny
bra CharLoop
Exit dey
lda [TextPtr],y
and #$ff
cmp #SPACE
bne No
dec Spaces
No RETURN
JumpTable DC.W Exit ; 0
DC.W Skip2 ; 1
DC.W Skip1 ; 2
DC.W Skip1 ; 3
DC.W Skip1 ; 4
ENDP
;-------------------------------------------------------------------------------
;
; T_UseTab (TextPtr:l,Offset:w,CurH:w,MaxH:w,FontId:l,Color:w) : NextH
;
; TextPtr -- Ptr to Q_Text
; Offset -- Offet into Q_Text after tab.
; CurH -- Where Q_Text up to TextPtr ends horiz.
; MaxH -- The right margin
;
; NextH -- -1 -- Try tab on next Q_Line.
; >= 0 -- Where to start putting Q_Text
;
T_UseTab PROC EXPORT
;Using P_Data
;Using T_TextEqu
;Using T_Data
INPUT TextPtr:l,Offset:w,CurH:w,MaxH:w,FontId:l,Color:w
OUTPUT NextH:w
LOCAL RulerPtr:l,FontChanged:w,TabCount:w
LOCAL CurTab:l,TextWidth:w,Room:w,TheChar:w
BEGIN
moveword #-1,NextH
; D_Save these to be restored later
pushword FontId
pushword FontId+2
pushword Color
stz FontChanged
lda T_CurRulBits
and #T_Full+T_left
jeq TreatSpace
movelong T_CurRulPtr,RulerPtr
cmpw CurH,[RulerPtr]:#T_Indent
bge NotIndent
moveword [RulerPtr]:y,CurTab
stz CurTab+2
bra DoTab
NotIndent
; If there are no tab stops, treat as a space
moveword [RulerPtr]:#T_TabCount,TabCount
jeq TreatSpace
; If the first tab stop is greater than MaxH, treat as a space
addwl #T_TabArray,RulerPtr
cmpw [RulerPtr],MaxH
jge TreatSpace
ldx #0
LookTab
cmpw CurH,[RulerPtr]
blt FoundTab
addwl #4,RulerPtr
inx
cpx TabCount
blt LookTab
brl Exit ;Past all tabs, try next Q_Line.
FoundTab
movelong [RulerPtr],CurTab
DoTab
cmpw CurTab,MaxH
bge Exit
sta NextH
lda CurTab+2
beq Exit ;left tab just move over
subword CurTab,CurH,Room
stz TextWidth
CharLoop
moveword [TextPtr]:Offset,a
inc Offset
and #$ff
sta TheChar
cmp #'.'
bne noPer
lda CurTab+2
bpl NormalChar
brl AdjustTab
NoPer
cmp #sp
bcs NormalChar
SpecChar
asl a
tax
jmp (JumpTable,x)
NormalChar
lda FontChanged
beq NoChange
rcall D_SelectFont,in=(FontId:a,FontId+2:x,#0:y)
stz FontChanged
NoChange rcall D_GetWdth,in=(TheChar:a),out=(a:a)
addword a,TextWidth,TextWidth
GotTW
cmp Room
bge MakeCurH
brl CharLoop
AdjustTab
subword Room,TextWidth,a
bpl Okay
lda #0
Okay addword a,CurH,NextH
bra Exit
TreatSpace
rcall D_GetWdth,in=(#SPACE:a),out=(a:a)
addword a,CurH,CurH
cmp MaxH
bge Exit
MakeCurH moveword CurH,NextH
Exit ply
plx
pla
jsl D_SelectFont
RETURN
FChange
moveword [TextPtr]:Offset,FontId
inc Offset
bra ChangeExit
SizeChange
movebyte [TextPtr]:Offset,FontId+3
bra ChangeExit
StyleChange
movebyte [TextPtr]:Offset,FontId+2
bra ChangeExit
ChangeExit
inc Offset
inc FontChanged
brl CharLoop
JumpTable DC.W 0,FChange ;0,1
DC.W StyleChang
|