ORCA-C/ObjOut.macros
2017-10-21 18:40:19 -05:00

254 lines
3.0 KiB
Plaintext

MACRO
&LAB LONG &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB REP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA ON
.B
AIF .NOT.&I,.C
LONGI ON
.C
MEND
MACRO
&LAB PH4 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDY #2
LDA (&N1),Y
PHA
LDA (&N1)
PHA
AGO .E
.B
AIF "&C"<>"[",.C
LDY #2
LDA &N1,Y
PHA
LDA &N1
PHA
AGO .E
.C
LDA &N1+2
PHA
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA +(&N1)|-16
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB SHORT &A,&B
LCLB &I
LCLB &M
&A AMID &A,1,1
&M SETB ("&A"="M").OR.("&A"="m")
&I SETB ("&A"="I").OR.("&A"="i")
AIF C:&B=0,.A
&B AMID &B,1,1
&M SETB ("&B"="M").OR.("&B"="m").OR.&M
&I SETB ("&B"="I").OR.("&B"="i").OR.&I
.A
&LAB SEP #&M*32+&I*16
AIF .NOT.&M,.B
LONGA OFF
.B
AIF .NOT.&I,.C
LONGI OFF
.C
MEND
MACRO
&LAB INC4 &A
&LAB ~SETM
INC &A
BNE ~&SYSCNT
INC 2+&A
~&SYSCNT ~RESTM
MEND
MACRO
&LAB ~SETM
&LAB ANOP
AIF C:&~LA,.B
GBLB &~LA
GBLB &~LI
.B
&~LA SETB S:LONGA
&~LI SETB S:LONGI
AIF S:LONGA.AND.S:LONGI,.A
REP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
LONGA ON
LONGI ON
.A
MEND
MACRO
&LAB ~RESTM
&LAB ANOP
AIF (&~LA+&~LI)=2,.I
SEP #32*(.NOT.&~LA)+16*(.NOT.&~LI)
AIF &~LA,.H
LONGA OFF
.H
AIF &~LI,.I
LONGI OFF
.I
MEND
MACRO
&LAB PUT2 &N1,&F1,&CR,&ERROUT
AIF C:&F1,.A
LCLC &F1
&F1 SETC #0
.A
&LAB ~SETM
PH2 &N1
PH2 &F1
PH2 #C:&CR
PH2 #C:&ERROUT
JSL ~PUT2
~RESTM
MEND
MACRO
&LAB PUT4 &N1,&F1,&CR,&ERROUT
AIF C:&F1,.A
LCLC &F1
&F1 SETC #0
.A
&LAB ~SETM
PH4 &N1
PH2 &F1
PH2 #C:&CR
PH2 #C:&ERROUT
JSL ~PUT4
~RESTM
MEND
MACRO
&LAB PUTS &N1,&F1,&CR,&ERROUT
&LAB ~SETM
LCLC &C
&C AMID "&N1",1,1
AIF "&C"<>"#",.C
AIF L:&N1>127,.A
BRA ~&SYSCNT
AGO .B
.A
BRL ~&SYSCNT
.B
&N1 AMID "&N1",2,L:&N1-1
~L&SYSCNT DC I1"L:~S&SYSCNT"
~S&SYSCNT DC C&N1
~&SYSCNT ANOP
&N1 SETC ~L&SYSCNT-1
AIF C:&F1=0,.D
.C
~PUSHA &N1
AIF C:&F1,.C1
PEA 0
AGO .C2
.C1
PH2 &F1
.C2
PH2 #C:&CR
PH2 #C:&ERROUT
JSL ~PUTS
~RESTM
MEXIT
.D
PEA ~L&SYSCNT|-16
PEA ~L&SYSCNT
LDX #$1C0C+(C:&ERROUT*256)-(512*C:&CR)
JSL $E10000
~RESTM
MEND
MACRO
&LAB ~PUSHA &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
SEP #$20
LONGA OFF
LDA #0
PHA
REP #$20
LONGA ON
PHK
LDA &N1
PHA
MEXIT
.B
AIF "&C"<>"[",.C
&N1 AMID &N1,2,L:&N1-2
LDA &N1+2
PHA
LDA &N1
PHA
MEXIT
.C
PEA +(&N1)|-16
PEA &N1
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PH2 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDA (&N1)
PHA
AGO .E
.B
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND