antoine-source/appleworksgs/WP/Src/Copy.aii

1 line
8.3 KiB
Plaintext
Raw Normal View History

2023-03-04 02:45:20 +00:00
load 'macros.dump' include 'driver.equ' include 'wp.equ' include 'scrap.equ' ;----------------------------------------------- ; ; Imported addresses ; ;----------------------------------------------- IMPORT D_BeachBall IMPORT W_CalcFBytes IMPORT W_FindFont IMPORT W_FindFont2 IMPORT W_GetAddr IMPORT W_GetEndPar IMPORT W_Getparrec IMPORT W_LessRoom IMPORT W_MakeRoom IMPORT D_NeedHandle IMPORT W_WriteFBytes IMPORT W_addr import W_RulBytes import X_MassageWPScrap import D_NeedHand import D_Deref import D_GrowHandle import X_DisposeWPScrap **************************************************************** * * W_WpCopy(startp,startl,starto,endp,endl,endo):wpscrap * **************************************************************** W_WpCopy PROC EXPORT BlockSize equ $c00 ;3K input Startp:w,Startl:w,Starto:w input Endp:w,Endl:w,Endo:w local Pars:w,Par:w,Block:l,ParPtr:l,Sptr:l,ParRec:l,Type:w local Length:w,Offset:w,Bptr:l,NewOffset:l,CurrentBlock:l local CBPtr:l,NewRuler:l,NRPtr:l,Ruler:l,OldRuler:l,BlockUsed:w local ScrapSize:l,NextBlock:l,NewSize:l,Soff:l output Scrap:l error err begin +b stz err SubWord Endp,Startp,Pars inc Pars tool _Multiply,in=(Pars:w,#W_pBytes:w),out=(:l) AddLong s,#2,ScrapSize call D_NeedHand,in=ScrapSize:l,out=Scrap:l,err=err jcs exit MoveLong [Scrap],Sptr MoveWord #0,[Sptr] MoveLong #2,Soff MoveWord Startp,Par Stzl Block Stzl OldRuler parloop jsl D_BeachBall jsr GetParInfo ;ParRec will have pointer to ;paragraph,Type will be set,returns ;length of paragraph Length, and offset ;to first character in Offset. jsr GrowBlock ;Will allocate a new block if there jcs memoryerror ;is none. Will make space if there ;would still be less than 3K. Will ;make new text block if not. Sets ;up the variables Block,Bptr,NewOffset. ;Uses Length variable. Does NOT lock ;the block. MoveLong [ParRec],CurrentBlock MoveLong [CurrentBlock],CBPtr Addwl Offset,CBPtr Cmpw Par,StartP bne nofont ;Get font info for the first paragraph call W_FindFont,in=(Startp:w,Startl:w,Starto:w),out=(:l,:w) PullWord [Bptr]:#4 ;Color PullLong [Bptr] ;Font ID Addwl #7,Bptr bra docopy nofont lda [CBPtr] sta [Bptr] ldy #2 lda [CBptr],y sta [Bptr],y iny iny lda [CBptr],y sta [Bptr],y Addwl #7,CBptr Addwl #7,Bptr Subwl #7,Length docopy ;Now set up the copying of text. jsr CopyText ;Copy the ruler if necessary. lda Type bne noruler MoveLong [ParRec]:#W_pRulerHand,Ruler Cmpl Ruler,OldRuler bne getnewruler MoveLong [NewRuler],NRPtr lda [NRPtr] inc a sta [NRPtr] bra noruler getnewruler call D_NeedHand,in=(#W_RulBytes:l),out=(NewRuler:l),err=err bcc @1 jsr DisposeCurrentBlock ;Only disposes if nothing else has used it. brl memoryerror @1 MoveLong [NewRuler],NRPtr tool _BlockMove,in=([Ruler]:l,NRPtr:l,#W_RulBytes:l) MoveWord #1,[NRPtr] MoveLong Ruler,OldRuler bra update noruler Stzl Ruler update ;Update the paragraph array. This is used for all paragraphs MoveLong [Scrap],Sptr AddLong Sptr,Soff,ParPtr Addwl #W_pBytes,Soff MoveLong Block,[ParPtr] MoveWord NewOffset,[ParPtr]:#W_pOffset MoveWord Type,[ParPtr]:#W_pAttr MoveLong NewRuler,[ParPtr]:#W_pRulerHand MoveWord #0,[ParPtr]:#W_PRulerHand+4 MoveWord a,[ParPtr]:#W_PRulerHand+6 MoveWord a,[ParPtr]:#W_PRulerHand+8 MoveWord a,[ParPtr]:#W_PRulerHand+10 lda [Sptr] inc a sta [Sptr] Cmpw Par,Endp bge massage inc Par brl parloop massage call X_MassageWPScrap,in=(Scrap:l) bra exit memoryerror call X_DisposeWPScrap,in=Scrap:l exit return ;This sets up several variables about the paragraph in Par. Length will be the size ;of the text. ParRec wil be the pointer to the paragraph record. OldTextPtr will ;point to the first character of text past the paragraph header. Offset will be ;the offset into the block for this character. Type will be the type of paragraph. ;Length includes the carraige return. GetParInfo rcall W_GetParRec,in=(Par:a),out=(ParRec:ax) ;input paragraph in Par stz Length MoveWord [ParRec]:#W_pAttr,Type MoveWord