2024-07-03 22:02:00 +02:00

2068 lines
46 KiB
ArmAsm

*
* Ensemble de sous-Programmes
*
IconSub START
USING IconVar
USING GlobalData
USING ProdosData
USING FontData
*
* Test si l'evenement est un caractere ...
*
IsItACar ENTRY
lda CmdsMode
cmp #LettreMode
bne IsItACarExit
lda LettreEnab
beq IsItACarExit
lda >EventWhat
cmp #3
beq itsaKeyDown
cmp #5
beq itsaKeyDown
bra IsItACarExit
ItsAKeyDown jsr ManageCar
IsItACarExit rts
*
* Gestion de l'affichage de caracteres
*
ManageCar ENTRY
lda #$FFFF
sta >IcModified
jsr SetNewClip
jsr KillCurret
PushWord #4 ; laisse le background inchange
_SetTextMode
PushWord ColorNum
_SetForeColor
PushLong >FontID
PushWord #0
_InstallFont
lda >EventMessage
cmp #$7F
beq BackSpace
lda NbrCar
cmp #9
bcs ManageCarExit
ldx NbrCar
lda ColorNum
sta LettreColor,x
lda >EventMessage
and #$00FF
sta LeMot,x
pha
_DrawChar
inc NbrCar
bra RedrawCar
BackSpace lda NbrCar
beq ManageCarExit
dec NbrCar
jsr CopyUndoToSc
PushWord BitMcX
PushWord BitMcY
_MoveTo
lda NbrCar
beq RedrawCar
ldx #0
NextDCar phx
lda LettreColor,x
and #$00FF
pha
_SetForeColor
plx
phx
lda LeMot,x
and #$00FF
pha
_DrawChar
plx
inx
cpx NbrCar
bcc NextDcar
PushWord ColorNum
_SetForeColor
RedrawCar jsr RedrawLoupe
ManageCarExit jsr ReSetOldClip
PushLong #0
PushWord #0
_InstallFont
rts
*
* change curseur etc...
*
WithNoEvent ENTRY
lda CmdsMode
cmp #SelectMode
bne HdlNextChange1
PushWord #0
PushLong #SelectionRect
_EmptyRect
pla
beq HdlNextChange1
dec InvertPPause
lda InvertPPause
bne HdlNextChange1
jsr SetNewClip
lda #PauseInvert
sta InvertPPause
jsr InvertPatNR ; invert pat without redraw
lda SelecPat
eor #1
sta SelecPat
jsr InvertSelPat
jsr ReSetOldClip
HdlNextChange1 lda CmdsMode
cmp #LettreMode
bne HdlNextChange2
lda LettreEnab
beq HdlNextChange2
dec CurretPPause
lda CurretPPause
bne HdlNextChange2
jsr SetNewClip
lda #PauseCurret
sta CurretPPause
lda TopCurret
eor #1
sta TopCurret
jsl Eor_Flash1
jsr ReSetOldClip
jsr RedrawLoupe
HdlNextChange2 anop
rts
*
*
*
KillCurret ENTRY
lda TopCurret
beq KillCurrExit
jsl Eor_Flash1
stz TopCurret
jsr RedrawLoupe
KillCurrExit rts
*
* Set Clip Region To bitmap rect
*
SetNewClip ENTRY
PushLong #0
_NewRgn
pla
sta ClipRHdl
pla
sta ClipRhdl+2
PushLong ClipRHdl
_GetClip
PushLong #BMDessRect
_ClipRect
rts
*
* Reset old clip region
*
ResetOldClip ENTRY
PushLong ClipRHdl
_SetClip
PushLong ClipRHdl
_DisposeRgn
rts
*
* Set Clip Region To AllScreen
*
SetAllSClip ENTRY
PushLong #0
_NewRgn
pla
sta AllSHdl
pla
sta AllSHdl+2
PushLong AllSHdl
_GetClip
PushLong #DialFull
_ClipRect
rts
*
* Reset clip region
*
ReSetASClip ENTRY
PushLong AllSHdl
_SetClip
PushLong AllSHdl
_DisposeRgn
rts
*
* Dessine cadre bitmap et titre
*
DrawIcTitre ENTRY
jsr SetAllSClip
PushLong DlgIconPtr
_SetPort
PushWord #0
_SetPenMode
PushWord #0 ; couleur 0 = noir
_SetSolidPenPat
PushLong #BitMapRect
_FrameRect
PushLong #IcLiseRect
_FrameRect
* cadre
PushWord #0 ; couleur 0 = noir
_SetSolidPenPat
PushLong #IcOmbreRect
_PaintRect
PushWord #1 ; couleur 1 = gris
_SetSolidPenPat
PushLong #IcTitRect
_PaintRect
PushWord #0 ; couleur 0 = noir
_SetSolidPenPat
PushLong #IcTitRect
_FrameRect
PushWord #4 ; mode transparent
_SetTextMode
PushWord #IcTitOmbreX
PushWord #IcTitOmbreY
_MoveTo
PushWord #0 ; couleur 0 = noir
_SetForeColor
PushLong #IconTitle
_DrawString
PushWord #IcTitleX
PushWord #IcTitleY
_MoveTo
PushWord #9 ; couleur 9 = jaune
_SetForeColor
PushLong #IconTitle
_DrawString
PushWord #0 ; couleur 0 = noir
_SetForeColor
jsr ReSetASClip
rts
*
* Copy le scrap sur l'icon
*
ScrapToPort ENTRY
lda ScrapBufHdl
ldx ScrapBufHdl+2
jsr IcDeref
sta ScrapIcon
stx ScrapIcon+2
PushLong #ScrapBlock
PushLong #ScrapCRect
PushWord SelectionRect+2
PushWord SelectionRect
PushWord #0
_PPToPort
lda ScrapBufHdl
ldx ScrapBufHdl+2
jsr IcUnLock
rts
*
* Teste les boutons cut,copy paste et selectionne si besoin est
*
SetCutCopy ENTRY
PushWord #0
PushLong #SelectionRect
_EmptyRect
pla
beq DisabCutC
lda CutEnab
beq EnableCut
brl SetCCExit
EnableCut lda #Enabled
sta CutEnab
jsr SetAllSClip
PushWord #actif
PushLong #0 ; Output handle
PushLong DlgIconPtr
PushWord ICut ; ICut contient Item ID
_GetControlDItem
_HiliteControl ; les parametres arrivent de _Get...
PushWord #actif
PushLong #0 ; Output handle
PushLong DlgIconPtr
PushWord ICopy ; ICopy contient Item ID
_GetControlDItem
_HiliteControl ; les parametres arrivent de _Get...
jsr ReSetASClip
bra SetCCExit
DisabCutC jsr EndCutCopy
SetCCExit rts
*
* Met Paste actif
*
SetPaste ENTRY
jsr SetAllSClip
PushWord #actif
PushLong #0 ; Output handle
PushLong DlgIconPtr
PushWord IPaste ; IPaste contient Item ID
_GetControlDItem
_HiliteControl ; les parametres arrivent de _Get...
jsr ReSetASClip
rts
*
* Met Paste inactif
*
UnSetPaste ENTRY
jsr SetAllSClip
PushWord #inactif
PushLong #0 ; Output handle
PushLong DlgIconPtr
PushWord IPaste ; IPaste contient Item ID
_GetControlDItem
_HiliteControl ; les parametres arrivent de _Get...
jsr ReSetASClip
rts
*
* Disable cut et copy
*
EndCutCopy ENTRY
lda CutEnab
beq EndCutCExit
lda #Disabled
sta CutEnab
jsr SetAllSClip
PushWord #inactif
PushLong #0 ; Output handle
PushLong DlgIconPtr
PushWord ICut ; ICut contient Item ID
_GetControlDItem
_HiliteControl ; les parametres arrivent de _Get...
PushWord #inactif
PushLong #0 ; Output handle
PushLong DlgIconPtr
PushWord ICopy ; ICopy contient Item ID
_GetControlDItem
_HiliteControl ; les parametres arrivent de _Get...
jsr ReSetASClip
EndCutCExit rts
*
* Deplace le rectangle de selection
*
TestSelectIn ENTRY
TestY1PDy lda SelectionRect
clc
adc DeltaY
cmp BMDessRect
bcs TestX1PDx
lda BMDessRect
sec
sbc SelectionRect
sta DeltaY
TestX1PDx lda SelectionRect+2
clc
adc DeltaX
cmp BMDessRect+2
bcs TestY2PDy
lda BMDessRect+2
sec
sbc SelectionRect+2
sta DeltaX
TestY2PDy lda SelectionRect+4
clc
adc DeltaY
cmp BMDessRect+4
bcc TestX2PDx
lda BMDessRect+4
sec
sbc SelectionRect+4
sta DeltaY
TestX2PDx lda SelectionRect+6
clc
adc DeltaX
cmp BMDessRect+6
bcc TestOffset
lda BMDessRect+6
sec
sbc SelectionRect+6
sta DeltaX
TestOffset lda DeltaX
bne OffsetSelR
lda DeltaY
bne OffsetSelR
bra TestSelExit
OffsetSelR jsr CopyMvSelToSc
PushLong #SelectionRect
PushWord DeltaX
PushWord DeltaY
_OffsetRect
PushLong #SelecDessRect
lda DeltaX
asl a
asl a
pha
lda DeltaY
asl a
asl a
pha
_OffsetRect
jsr ScrapToPort
jsr RedrawLoupe
TestSelExit rts
*
* Interrompt le mode selection si cmdsmode = SelectMode
*
EndSelect ENTRY
lda #Disabled
sta LettreEnab ; on en proffite
jsr KillCurret
lda CmdsMode
cmp #SelectMode
bne EndSelExit
jsr InvertSelPat
PushLong #SelectionRect
pea $0
pea $0
pea $0
pea $0
_SetRect
PushLong #SelecDessRect
pea $0
pea $0
pea $0
pea $0
_SetRect
jsr EndCutCopy
EndSelExit rts
*
* Draw the frame : ligne, rectangle, ovale
*
PutTheFrame ENTRY
lda CmdsMode
asl a
tax
jsr (PutTheTab,x)
PushLong #SelectionRect
pea 0
pea 0
pea 0
pea 0
_SetRect
jsr ReDrawLoupe
rts
PutTheTab ENTRY
dc i'IcIgnore'
dc i'IcIgnore'
dc i'PutTheLig'
dc i'IcIgnore'
dc i'IcIgnore'
dc i'IcIgnore'
dc i'PutTheRect'
dc i'PutThePlan'
dc i'PutTheRRect'
dc i'PutTheRPlan'
dc i'PutTheCercle'
dc i'PutTheDisque'
* Dessine la ligne dans la couleur
PutTheLig ENTRY
PushWord ColorNum
_SetSolidPenPat
PushWord ODiagX
PushWord ODiagY
_MoveTo
PushWord EDiagX
PushWord EDiagY
_LineTo
rts
* Dessine Rectangle dans la couleur
PutTheRect ENTRY
PushWord ColorNum
_SetSolidPenPat
PushLong #SelectionRect
_FrameRect
rts
* Dessine Plan dans la couleur
PutThePlan ENTRY
PushWord ColorNum
_SetSolidPenPat
PushLong #SelectionRect
_PaintRect
rts
* Dessine RoundRectangle dans la couleur
PutTheRRect ENTRY
PushWord ColorNum
_SetSolidPenPat
PushLong #SelectionRect
PushWord #17
PushWord #17
_FrameRRect
rts
* Dessine RoundPlan dans la couleur
PutTheRPlan ENTRY
PushWord ColorNum
_SetSolidPenPat
PushLong #SelectionRect
PushWord #17
PushWord #17
_PaintRRect
rts
* Dessine Cercle dans la couleur
PutTheCercle ENTRY
PushWord ColorNum
_SetSolidPenPat
PushLong #SelectionRect
_FrameOval
rts
* Dessine Disque dans la couleur
PutTheDisque ENTRY
PushWord ColorNum
_SetSolidPenPat
PushLong #SelectionRect
_PaintOval
rts
*
* Inverse le rectangle de selection avec redraw
*
InvertSelPat ENTRY
jsr InvertPatNR
jsr ReDrawLoupe
rts
*
* Inverse le rectangle de selection sans redraw
*
InvertPatNR ENTRY
lda CmdsMode
asl a
tax
jsr (InvertTab,x)
rts
InvertTab ENTRY
dc i'IcIgnore'
dc i'InvertPSel'
dc i'InvertPLig'
dc i'IcIgnore'
dc i'IcIgnore'
dc i'IcIgnore'
dc i'InvertPRect'
dc i'InvertPRect'
dc i'InvertPRRect'
dc i'InvertPRRect'
dc i'InvertPCercle'
dc i'InvertPCercle'
* Selection pattern
InvertPSel ENTRY
lda SelecPat
bne GetPat2
PushLong #Pat1
bra SetPattern
GetPat2 PushLong #Pat2
SetPattern _SetPenPat
PushWord #0
_GetPenMode
pla
sta LePenMode
PushWord #2 ; Mode XOr
_SetPenMode
PushLong #SelectionRect
_FrameRect
PushWord LePenMode
_SetPenMode
rts
* Ligne pattern
InvertPLig ENTRY
PushWord #15
_SetSolidPenPat
PushWord #0
_GetPenMode
pla
sta LePenMode
PushWord #2 ; Mode XOr
_SetPenMode
PushWord ODiagX
PushWord ODiagY
_MoveTo
PushWord EDiagX
PushWord EDiagY
_LineTo
PushWord LePenMode
_SetPenMode
rts
* Rectangle pattern
InvertPRect ENTRY
PushWord #15
_SetSolidPenPat
PushWord #0
_GetPenMode
pla
sta LePenMode
PushWord #2 ; Mode XOr
_SetPenMode
PushLong #SelectionRect
_FrameRect
PushWord LePenMode
_SetPenMode
rts
* RoundRectangle pattern
InvertPRRect ENTRY
PushWord #15
_SetSolidPenPat
PushWord #0
_GetPenMode
pla
sta LePenMode
PushWord #2 ; Mode XOr
_SetPenMode
PushLong #SelectionRect
PushWord #17
PushWord #17
_FrameRRect
PushWord LePenMode
_SetPenMode
rts
* Ovale pattern
InvertPCercle ENTRY
PushWord #15
_SetSolidPenPat
PushWord #0
_GetPenMode
pla
sta LePenMode
PushWord #2 ; Mode XOr
_SetPenMode
PushLong #SelectionRect
_FrameOval
PushWord LePenMode
_SetPenMode
rts
*
* Obtient les coordonnees, dans le dessin, de la souris
*
GetDessCoord ENTRY
lda #true
sta MouseNotMv
lda >MouseX
sec
sbc Dessrect+2
dec a
dec a
bpl GetDess1
lda #0
GetDess1 lsr a
lsr a
cmp #44
bcc NotTooRight
lda #44
NotTooRight cmp KMouseX
beq NotXMvd
stz MouseNotMv
NotXMvd sta CoordX
sec
sbc KMouseX
sta DeltaX
lda CoordX
sta KmouseX
clc
adc BMDessRect+2
sta BitMCX
lda >MouseY
sec
sbc Dessrect
dec a
dec a
bpl GetDess2
lda #0
GetDess2 lsr a
lsr a
cmp #34
bcc NotTooBot
lda #34
NotTooBot cmp KMouseY
beq NotYMvd
stz MouseNotMv
NotYMvd sta CoordY
sec
sbc KMouseY
sta DeltaY
lda CoordY
sta KmouseY
clc
adc BMDessRect
sta BitMCY
rts
*
* Obtient la couleur du point aux coordonnees Coordx et CoordY
*
GetColCoord ENTRY
lda CoordY
asl a
tax
lda BitMapAdr,x
sta <Ptr_ScIcon
lda #$00E1
sta <Ptr_ScIcon+2
lda CoordX
ror a
tay
lda [<Ptr_ScIcon],y
bcs ColImPair
lsr a
lsr a
lsr a
lsr a
ColImpair and #$000F
sta CouleurDuPt
rts
*
* Dessine dans l'icone, le buffer... aux coordonnees
* avec CouleurDuPt
*
SetColCoord ENTRY
lda CoordX
cmp #44
bcc SetColS1
brl SetColExit
SetColS1 lda CoordY
cmp #34
bcc SetColS2
brl SetColExit
* Dessine un point dans le petit icone
SetColS2 PushWord BitMCX
PushWord BitMCY
_MoveTo
PushWord CouleurDuPt
_SetSolidPenPat
pea $0
pea $0
_Line
jsr ReDrawLoupe
SetColExit rts
*
* Dessine une ligne dans l'icone, le buffer... aux coordonnees
* avec CouleurDuPt
*
SetColLigne ENTRY
lda CoordX
cmp #44
bcc SetLig1
lda #43
sta CoordX
SetLig1 lda CoordY
cmp #34
bcc SetLig2
lda #33
sta CoordY
* Dessine le trait dans le petit icone
SetLig2 PushWord CouleurDuPt
_SetSolidPenPat
lda BMDessRect+2
clc
adc CoordX
pha
lda BMDessRect
clc
adc CoordY
pha
_LineTo
jsr ReDrawLoupe
SetLigExit rts
*
* Dessine une frame dans l'icone le pattern a deja ete
* selectionne
*
SetPatRect ENTRY
lda CoordX
cmp #44
bcc SetPatR1
lda #44
sta CoordX
SetPatR1 lda CoordY
cmp #34
bcc SetPatR2
lda #34
sta CoordY
* Dessine le Rectangle dans le petit icone
SetPatR2 jsr InvertPatNR
PushLong #SelectionRect
lda BMDessRect+2
clc
adc CoordX
sta TempX
cmp OrigineX
bcs SetNormR1
PushWord TempX
lda OrigineX
inc a
sta TempX
bra TestRectY
SetNormR1 PushWord OrigineX
TestRectY lda BMDessRect
clc
adc CoordY
sta TempY
cmp OrigineY
bcs SetNormR2
PushWord TempY
lda OrigineY
inc a
sta TempY
bra SetNormXY
SetNormR2 PushWord OrigineY
SetNormXY PushWord TempX
PushWord TempY
_SetRect
lda OrigineX
sta ODiagX
lda OrigineY
sta ODiagY
lda BMDessRect+2
clc
adc CoordX
sta EDiagX
lda BMDessRect
clc
adc CoordY
sta EDiagY
jsr InvertSelPat
SetPatRExit rts
*
* Redessine l'icone dans la loupe
*
ReDrawLoupe ENTRY
_HideCursor
lda DessBitMap
ldx DessBitMap+2
jsr IcDeref
sta <Ptr_Icon
stx <Ptr_Icon+2
lda BitMapAdr
sta <Ptr_ScIcon
lda #$00E1
sta <Ptr_ScIcon+2
ldx #0 ; numero octet dans la ligne
ldy #0 ; numero octet dans le buffer
sty TempY
;--------------------------------------
ComReD lda Flag_Loupe
bne ComReD_F
;--
ComReD_N phy |Normal Avec Test
txy
lda [<Ptr_ScIcon],y
ply
cmp [<Ptr_Icon],y
beq ReDr1
sta [<Ptr_Icon],y
jsr Draw4Carre
bra ReDr1
;--
ComReD_F phy |FORCER au 1er PASSAGE
txy
lda [<Ptr_ScIcon],y
ply
sta [<Ptr_Icon],y
jsr Draw4Carre
;--------------------------------------
ReDr1 iny
iny
inx
inx
cpx #22
bcc ComReD
ldx #0
lda <Ptr_ScIcon
clc
adc #160
sta <Ptr_ScIcon
inc TempY
cpy #748
bcc ComReD
lda DessBitMap
ldx DessBitMap+2
jsr IcUnLock
_ShowCursor
rts
*
* Dessine 4 carres consecutifs
* CoordX est dans X
*
Draw4Carre ENTRY
pha ; sauve les couleurs des 4 points
phx
phy
stz Coul3
rol a
rol Coul3
rol a
rol Coul3
rol a
rol Coul3
rol a
rol Coul3
stz Coul4
rol a
rol Coul4
rol a
rol Coul4
rol a
rol Coul4
rol a
rol Coul4
stz Coul1
rol a
rol Coul1
rol a
rol Coul1
rol a
rol Coul1
rol a
rol Coul1
stz Coul2
rol a
rol Coul2
rol a
rol Coul2
rol a
rol Coul2
rol a
rol Coul2
txa
asl a ; x 4 points
asl a
sta TempX
lda Coul1
asl a
tax
lda CoulToPat,x
sta Coul1
lda Coul2
asl a
tax
lda CoulToPat,x
sta Coul2
lda Coul3
asl a
tax
lda CoulToPat,x
sta Coul3
lda Coul4
asl a
tax
lda CoulToPat,x
sta Coul4
lda #$00E1
sta <Ptr_DsIcon+2
lda TempY
asl a
tax
lda LoupeAdr,x
clc
adc TempX
sta <Ptr_DsIcon
ldy #0
Next4Lig lda Coul1
sta [<Ptr_DsIcon]
inc <Ptr_dsIcon
inc <Ptr_dsIcon
lda Coul2
sta [<Ptr_DsIcon]
inc <Ptr_dsIcon
inc <Ptr_dsIcon
lda Coul3
sta [<Ptr_DsIcon]
inc <Ptr_dsIcon
inc <Ptr_dsIcon
lda Coul4
sta [<Ptr_DsIcon]
iny
lda <Ptr_DsIcon
clc
adc #160-6
sta <Ptr_DsIcon
cpy #3
bcc Next4Lig
ply
plx
pla
rts
*
* Met le Pattern a la couleur CouleurDuPt
*
SetDessPat ENTRY
lda CouleurDuPt ; ex : $0007
asl a ; -> $000E
asl a ; -> $001C
asl a ; -> $0038
asl a ; -> $0070
ora CouleurDuPt ; -> $0077
sta CoordCouleur
xba ; -> $7700
ora CoordCouleur ; -> $7777
sta FillColor
and #$0FFF ; -> $0777
ora #$F000 ; met un point blanc a gauche -> $F777
ldy #4
SetNextP1 sta DessPat,y
iny
iny
cpy #16
bcc SetNextP1
ldy #20
SetNextP2 sta DessPat,y
iny
iny
cpy #32
bcc SetNextP2
rts
*
* Rempli le buffer avec la Couleur FillColor
*
FillBuff ENTRY
ldy #0
lda FillColor ; mis a jour par SetDessPat
FillNext sta [<Ptr_Icon],y
iny
iny
cpy #748
bcc FillNext
rts
*
* Rempli l'icone avec la couleur CouleurDuPt
*
FillIcon ENTRY
jsr SetAllSClip
jsr SetDessPat ; avec couleur dans CouleurDuPt
_HideCursor
PushWord CouleurDuPt
_SetSolidPenPat
PushLong #BMDessRect
_PaintRect
PushLong #DDessRect
PushLong #DessPat
_FillRect
lda DessBitMap
ldx DessBitMap+2
jsr IcDeref
sta <Ptr_Icon
stx <Ptr_Icon+2
jsr FillBuff
lda DessBitMap
ldx DessBitMap+2
jsr IcUnlock
_ShowCursor
jsr ReSetASClip
rts
*
* Cree le rectangle du scrap
*
SetScrapRect ENTRY
PushLong #ScrapCRect
lda SelectionRect+2
sec
sbc BMDessRect+2
pha
lda SelectionRect
sec
sbc BMDessRect
pha
lda SelectionRect+6
sec
sbc BMDessRect+2
pha
lda SelectionRect+4
sec
sbc BMDessRect
pha
_SetRect
rts
*
* cree le rectangle SelecDessRect
* utilise pour deplacer une selection
*
ScrapToSelDR ENTRY
PushLong #SelecDessRect
lda ScrapCRect+2
asl a
asl a
clc
adc DDessRect+2
pha
lda ScrapCRect
asl a
asl a
clc
adc DDessRect
pha
lda ScrapCRect+6
asl a
asl a
clc
adc DDessRect+2
pha
lda ScrapCRect+4
asl a
asl a
clc
adc DDessRect
pha
_SetRect
rts
*
* Copy une ligne pour scroll et flipH
*
CopyLigne ENTRY
lda ODiagX
sta CoordX
sta TempX
NextColC jsr FlipPoint
lda CoordX
inc a
sta CoordX
sta TempX
cmp EDiagX
bcc NextColC
rts
*
* Copy une colonne pour scroll
*
CopyColonne ENTRY
NextLigneC jsr FlipPoint
lda CoordY
inc a
sta CoordY
cmp EDiagY
bcs CopycolExit
lda <Ptr_DsIcon
clc
adc #640
sta <Ptr_DsIcon
lda <Ptr_ScIcon
clc
adc #160
sta <Ptr_ScIcon
bra NextligneC
CopyColExit rts
*
* Flip un rectangle
*
ChangeRect ENTRY
jsr ReSetOldClip ; la clip region etait le bitmap
PushLong #lastcmds
_InvertRect
lda RectNum
asl a
asl a
asl a
tax
lda CmdsRect,x
sta lastcmds
lda CmdsRect+2,x
sta lastcmds+2
lda CmdsRect+4,x
sta lastcmds+4
lda CmdsRect+6,x
sta lastcmds+6
lda #^CmdsRect
pha
txa
clc
adc #CmdsRect
pha
_InvertRect
jsr SetNewClip ; la clip region redevient le bitmap
rts
ShouldICopySc ENTRY
PushWord #0
PushLong #SelectionRect
_EmptyRect
pla
beq ShouldICExit
jsr CopyScToScrap
jsr SetScrapRect
ShouldICExit rts
TestForFlip ENTRY
PushWord #0
PushLong #SelectionRect
_EmptyRect
pla
beq AllScreenFlip
stz DeltaX
stz DeltaY
jsr TestSelectIn
lda SelectionRect+6
sec
sbc BMDessRect+2
sta EDiagX
lda SelectionRect+4
sec
sbc BMDessRect
sta EDiagY
lda SelectionRect+2
sec
sbc BMDessRect+2
sta ODiagX
lda SelectionRect
sec
sbc BMDessRect
sta ODiagY
jsr UnSetPaste
bra TestFlipExit
AllScreenFlip stz ODiagX
stz OdiagY
lda #44
sta EDiagX
lda #34
sta EdiagY
TestFlipExit rts
*
* Flip le point CoordX, CoordY en TempX,TempY
*
FlipPoint ENTRY
lda CoordX
asl a
tay
lda [<Ptr_DsIcon],y
xba
sta CouleurDuPt
lda TempX
lsr a
tay
bcs flipImpair
lda CouleurDuPt
and #$00F0
sta CouleurDuPt
lda [<Ptr_ScIcon],y
and #$FF0F
ora CouleurDuPt
sta [<Ptr_ScIcon],y
rts
FlipImpair lda CouleurDuPt
and #$000F
sta CouleurDuPt
lda [<Ptr_ScIcon],y
and #$FFF0
ora CouleurDuPt
sta [<Ptr_ScIcon],y
rts
*
* Copy undo buffer to screen
*
CopyUndoToSc ENTRY
lda >UndoBufHdl+2
tax
lda >UndoBufHdl
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
jsr CopyBuffToSc
lda >UndoBufHdl+2
tax
lda >UndoBufHdl
jsr IcUnLock
rts
*
* Copy screen to undo buffer
*
CopyScToUndo ENTRY
lda >UndoBufHdl+2
tax
lda >UndoBufHdl
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
jsr CopyScToBuff
lda >UndoBufHdl+2
tax
lda >UndoBufHdl
jsr IcUnLock
rts
*
* Copy MvSelect buffer to screen
*
CopyMvSelToSc ENTRY
lda MvSelectHdl
ldx MvSelectHdl+2
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
jsr CopyBuffToSc
lda MvSelectHdl
ldx MvSelectHdl+2
jsr IcUnLock
rts
*
* Copy screen to MvSelect buffer
*
CopyScToMvSel ENTRY
lda MvSelectHdl
ldx MvSelectHdl+2
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
jsr CopyScToBuff
lda MvSelectHdl
ldx MvSelectHdl+2
jsr IcUnLock
rts
*
* Copy Revert buffer to screen
*
CopyRevertToSc ENTRY
lda RevertBufHdl
ldx RevertBufHdl+2
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
jsr CopyBuffToSc
lda RevertBufHdl
ldx RevertBufHdl+2
jsr IcUnLock
rts
*
* Copy screen to Revert buffer
*
CopyScToRevert ENTRY
lda RevertBufHdl
ldx RevertBufHdl+2
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
jsr CopyScToBuff
lda RevertBufHdl
ldx RevertBufHdl+2
jsr IcUnLock
rts
*
* Copy buffer1 to screen
*
CopyBuffToSc ENTRY
_HideCursor
lda BitMapAdr
sta <Ptr_ScIcon
lda #$00E1
sta <Ptr_ScIcon+2
ldx #0 ; numero octet dans la ligne
ldy #0 ; numero octet dans le buffer
sty TempY
CopyBuffToSD lda [<Ptr_Buffer1],y
phy
txy
sta [<Ptr_ScIcon],y
ply
iny
iny
inx
inx
cpx #22
bcc CopyBuffToSD
ldx #0
lda <Ptr_ScIcon
clc
adc #160
sta <Ptr_ScIcon
inc TempY
cpy #748
bcc CopyBuffToSD
_ShowCursor
rts
*
* Copy screen to buffer1
*
CopyScToBuff ENTRY
_HideCursor
lda BitMapAdr
sta <Ptr_ScIcon
lda #$00E1
sta <Ptr_ScIcon+2
ldx #0 ; numero octet dans la ligne
ldy #0 ; numero octet dans le buffer
sty TempY
CopyScToBufD phy
txy
lda [<Ptr_ScIcon],y
ply
sta [<Ptr_Buffer1],y
iny
iny
inx
inx
cpx #22
bcc CopyScToBufD
ldx #0
lda <Ptr_ScIcon
clc
adc #160
sta <Ptr_ScIcon
inc TempY
cpy #748
bcc CopyScToBufD
_ShowCursor
rts
*
* Copy screen to scrap buffer
*
CopyScToScrap ENTRY
_HideCursor
lda ScrapBufHdl
ldx ScrapBufHdl+2
jsr IcDeref
sta <Ptr_Buffer1
stx <Ptr_Buffer1+2
lda BitMapAdr
sta <Ptr_ScIcon
lda #$00E1
sta <Ptr_ScIcon+2
ldx #0 ; numero octet dans la ligne
ldy #0 ; numero octet dans le buffer
sty TempY
CopyScToScrD phy
txy
lda [<Ptr_ScIcon],y
ply
sta [<Ptr_Buffer1],y
iny
iny
inx
inx
cpx #24
bcc CopyScToScrD
ldx #0
lda <Ptr_ScIcon
clc
adc #160
sta <Ptr_ScIcon
inc TempY
cpy #816
bcc CopyScToScrD
lda ScrapBufHdl
ldx ScrapBufHdl+2
jsr IcUnLock
_ShowCursor
rts
*
* Echange le contenu de Buffer 1 et du bit map a l'ecran
*
SwitchBuffer ENTRY
_HideCursor
lda BitMapAdr
sta <Ptr_ScIcon
lda #$00E1
sta <Ptr_ScIcon+2
ldx #0 ; numero octet dans la ligne
ldy #0 ; numero octet dans le buffer
sty TempY
SwitchComReD lda [<Ptr_Buffer1],y
pha
phy
txy
lda [<Ptr_ScIcon],y
ply
sta [<Ptr_Buffer1],y
pla
phy
txy
sta [<Ptr_ScIcon],y
ply
iny
iny
inx
inx
cpx #22
bcc SwitchComReD
ldx #0
lda <Ptr_ScIcon
clc
adc #160
sta <Ptr_ScIcon
inc TempY
cpy #748
bcc SwitchComReD
_ShowCursor
rts
IcDeref ENTRY
sta 0
stx 2
ldy #4
lda [0],y
ora #$8000
sta [0],y
dey
dey
lda [0],y
tax
lda [0]
rts
IcUnlock ENTRY
sta 0
stx 2
ldy #4
lda [0],y
and #$7FFF
sta [0],y
rts
DessProc ENTRY
phb ; sauve registres
phd
phk
plb ; met Data Bank
jsr SetAllSClip
PushWord #0
_SetSolidPenPat
PushLong #DessRect
_FrameRect
jsr ReSetASClip
pld ; remet a jour direct bank
plb ; data bank
lda 0,s
sta 6,s
lda 2,s
sta 8,s
tsc
clc
adc #6
tcs
rtl
CmdsProc ENTRY
phb ; sauve registres
phd
phk
plb ; met Data Bank
jsr SetAllSClip
lda CmdsIconHdl
ldx CmdsIconHdl+2
jsr IcDeref
sta CmdsIcon
stx CmdsIcon+2
PushLong #IconBlock
PushLong #IconCRect
PushWord CmdsDisp+2 ; DestX
PushWord CmdsDisp ; DestY
PushWord #0
_PPToPort
lda CmdsIconHdl
ldx CmdsIconHdl+2
jsr IcUnLock
jsr SetNewClip ; necessaire pour ChangeRect et InColor
*
* Selectionne Cmds et Color
*
stz LastCmds
stz LastCmds+2
stz LastCmds+4
stz LastCmds+6
stz LastColor
stz LastColor+2
stz LastColor+4
stz LastColor+6
lda CmdsMode
sta RectNum
jsr ChangeRect
lda #NbrCmds
sec
sbc ColorNum
dec a
sta RectNum
jsr InColor
jsr ReSetOldClip
jsr ReSetASClip
pld ; remet a jour direct bank
plb ; data bank
lda 0,s
sta 6,s
lda 2,s
sta 8,s
tsc
clc
adc #6
tcs
rtl
END