1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-27 09:33:21 +00:00

Fix predef paramaters, multiple per line, and asm defs with parameters

This commit is contained in:
Dave Schmenk 2017-06-07 19:26:03 -07:00
parent 92535477ff
commit 0b95baaefc
4 changed files with 54 additions and 47 deletions

Binary file not shown.

View File

@ -140,7 +140,7 @@ $(MON): samplesrc/mon.pla $(PLVM02) $(PLASM)
acme --setpc 4094 -o $(MON) samplesrc/mon.a acme --setpc 4094 -o $(MON) samplesrc/mon.a
$(ROD): samplesrc/rod.pla $(PLVM02) $(PLASM) $(ROD): samplesrc/rod.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMO < samplesrc/rod.pla > samplesrc/rod.a ./$(PLASM) -AMOW < samplesrc/rod.pla > samplesrc/rod.a
acme --setpc 4094 -o $(ROD) samplesrc/rod.a acme --setpc 4094 -o $(ROD) samplesrc/rod.a
$(SIEVE): samplesrc/sieve.pla $(PLVM02) $(PLASM) $(SIEVE): samplesrc/sieve.pla $(PLVM02) $(PLASM)
@ -220,19 +220,19 @@ $(DGRTEST): samplesrc/dgrtest.pla $(PLVM02) $(PLASM)
acme --setpc 4094 -o $(DGRTEST) samplesrc/dgrtest.a acme --setpc 4094 -o $(DGRTEST) samplesrc/dgrtest.a
$(ROGUE): samplesrc/rogue.pla $(PLVM02) $(PLASM) $(ROGUE): samplesrc/rogue.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMO < samplesrc/rogue.pla > samplesrc/rogue.a ./$(PLASM) -AM < samplesrc/rogue.pla > samplesrc/rogue.a
acme --setpc 4094 -o $(ROGUE) samplesrc/rogue.a acme --setpc 4094 -o $(ROGUE) samplesrc/rogue.a
$(ROGUEIO): samplesrc/rogue.io.pla $(PLVM02) $(PLASM) $(ROGUEIO): samplesrc/rogue.io.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMO < samplesrc/rogue.io.pla > samplesrc/rogue.io.a ./$(PLASM) -AM < samplesrc/rogue.io.pla > samplesrc/rogue.io.a
acme --setpc 4094 -o $(ROGUEIO) samplesrc/rogue.io.a acme --setpc 4094 -o $(ROGUEIO) samplesrc/rogue.io.a
$(ROGUECOMBAT): samplesrc/rogue.combat.pla $(PLVM02) $(PLASM) $(ROGUECOMBAT): samplesrc/rogue.combat.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMO < samplesrc/rogue.combat.pla > samplesrc/rogue.combat.a ./$(PLASM) -AM < samplesrc/rogue.combat.pla > samplesrc/rogue.combat.a
acme --setpc 4094 -o $(ROGUECOMBAT) samplesrc/rogue.combat.a acme --setpc 4094 -o $(ROGUECOMBAT) samplesrc/rogue.combat.a
$(ROGUEMAP): samplesrc/rogue.map.pla $(PLVM02) $(PLASM) $(ROGUEMAP): samplesrc/rogue.map.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMO < samplesrc/rogue.map.pla > samplesrc/rogue.map.a ./$(PLASM) -AM < samplesrc/rogue.map.pla > samplesrc/rogue.map.a
acme --setpc 4094 -o $(ROGUEMAP) samplesrc/rogue.map.a acme --setpc 4094 -o $(ROGUEMAP) samplesrc/rogue.map.a
$(HGR1): samplesrc/hgr1.pla samplesrc/hgr1test.pla $(PLVM02) $(PLASM) $(HGR1): samplesrc/hgr1.pla samplesrc/hgr1test.pla $(PLVM02) $(PLASM)

View File

@ -1,5 +1,5 @@
import cmdsys import cmdsys
predef syscall, call, memset, getc, putc, puts, modaddr predef syscall(f,p)#1, call(adr,a,x,y,p)#1, memset(d,s,l)#1, getc#1, putc(c)#1, puts(s)#1, modaddr(a)#1
byte MACHID byte MACHID
end end
// //
@ -30,7 +30,7 @@ const page2 = 1
// //
// Predefined functions. // Predefined functions.
// //
predef a2keypressed, a2gotoxy, a2grmode, a2textmode predef a2keypressed#1, a2gotoxy(x,y)#0, a2grmode(m)#0, a2textmode#0
// //
// String data. // String data.
// //
@ -71,7 +71,7 @@ end
// //
// def grscrn(rowaddrs) // def grscrn(rowaddrs)
// //
asm grscrn asm grscrn(rowaddrs)#0
GRSCRN = $26 GRSCRN = $26
GRSCRNL = GRSCRN GRSCRNL = GRSCRN
GRSCRNH = GRSCRNL+1 GRSCRNH = GRSCRNL+1
@ -79,12 +79,13 @@ GRSCRNH = GRSCRNL+1
STA GRSCRNL STA GRSCRNL
LDA ESTKH,X LDA ESTKH,X
STA GRSCRNH STA GRSCRNH
INX
RTS RTS
end end
// //
// def grcolor(color) // def grcolor(color)
// //
asm grcolor asm grcolor(color)#0
GRCLR = $30 GRCLR = $30
LDA #$0F LDA #$0F
AND ESTKL,X AND ESTKL,X
@ -95,12 +96,13 @@ GRCLR = $30
ASL ASL
ORA GRCLR ORA GRCLR
STA GRCLR STA GRCLR
INX
RTS RTS
end end
// //
// def grplot(x, y) // def grplot(x, y)
// //
asm grplot asm grplot(x, y)#0
STY IPY STY IPY
LDA ESTKL,X LDA ESTKL,X
AND #$FE AND #$FE
@ -125,56 +127,57 @@ asm grplot
STA (DST),Y STA (DST),Y
LDY IPY LDY IPY
INX INX
INX
RTS RTS
end end
// //
// Apple II routines. // Apple II routines.
// //
def a2keypressed def a2keypressed#1
if ^keyboard >= 128 if ^keyboard >= 128
return ^keystrobe return ^keystrobe
fin fin
return FALSE return FALSE
end end
def a2gotoxy(x, y) def a2gotoxy(x, y)#0
^$24 = x + ^$20 ^$24 = x + ^$20
return call($FB5B, y + ^$22, 0, 0, 0) call($FB5B, y + ^$22, 0, 0, 0)
end end
def a2grmode(mix) def a2grmode(mix)#0
call($FB2F, 0, 0, 0, 0) // initmode() call($FB2F, 0, 0, 0, 0) // initmode()
call($FB40, 0, 0, 0, 0) // grmode() call($FB40, 0, 0, 0, 0) // grmode()
if !mix if !mix
^showfull ^showfull
fin fin
call($FC58, 0, 0, 0, 0) // home() call($FC58, 0, 0, 0, 0) // home()
return grscrn(@txt1scrn) // point to lo-res screen grscrn(@txt1scrn) // point to lo-res screen
end end
def a2textmode def a2textmode#0
call($FB39, 0, 0, 0, 0) // textmode() call($FB39, 0, 0, 0, 0) // textmode()
return call($FC58, 0, 0, 0, 0) // home() call($FC58, 0, 0, 0, 0) // home()
end end
// //
// Apple III routines. // Apple III routines.
// //
def dev_control(devnum, code, list) def dev_control(devnum, code, list)#1
byte params[5] byte params[5]
params.0 = 3 params.0 = 3
params.1 = devnum params.1 = devnum
params.2 = code params.2 = code
params:3 = list params:3 = list
return syscall($83, @params) return syscall($83, @params)
end end
def dev_status(devnum, code, list) def dev_status(devnum, code, list)#1
byte params[5] byte params[5]
params.0 = 3 params.0 = 3
params.1 = devnum params.1 = devnum
params.2 = code params.2 = code
params:3 = list params:3 = list
return syscall($82, @params) return syscall($82, @params)
end end
def a3keypressed def a3keypressed#1
byte count byte count
dev_status(devcons, 5, @count) dev_status(devcons, 5, @count)
if count if count
@ -182,13 +185,13 @@ def a3keypressed
fin fin
return FALSE return FALSE
end end
def a3gotoxy(x, y) def a3gotoxy(x, y)#0
putc(24) putc(24)
putc(x) putc(x)
putc(25) putc(25)
return putc(y) putc(y)
end end
def a3viewport(left, top, width, height) def a3viewport(left, top, width, height)#0
putc(1) // Reset viewport putc(1) // Reset viewport
putc(26) putc(26)
putc(left) putc(left)
@ -198,9 +201,9 @@ def a3viewport(left, top, width, height)
putc(left + width - 1) putc(left + width - 1)
putc(top + height - 1) putc(top + height - 1)
putc(3) putc(3)
return a3gotoxy(0, 0) a3gotoxy(0, 0)
end end
def a3grmode(mix) def a3grmode(mix)#0
byte i byte i
if mix if mix
mix = 19 mix = 19
@ -214,17 +217,17 @@ def a3grmode(mix)
memset(txt1scrn[i], $0000, 40) // text screen memset(txt1scrn[i], $0000, 40) // text screen
memset(txt2scrn[i], $0000, 40) // color screen memset(txt2scrn[i], $0000, 40) // color screen
next next
return grscrn(@txt2scrn) // point to color screen grscrn(@txt2scrn) // point to color screen
end end
def a3textmode def a3textmode#0
puts(@textbwmode) puts(@textbwmode)
a3viewport(0, 0, 40, 24) a3viewport(0, 0, 40, 24)
return putc(28) putc(28)
end end
// //
// Rod's Colors. // Rod's Colors.
// //
def rod def rod#0
byte i, j, k, w, fmi, fmk, color byte i, j, k, w, fmi, fmk, color
while TRUE while TRUE
for w = 3 to 50 for w = 3 to 50
@ -234,16 +237,16 @@ def rod
color = (j * 3) / (i + 3) + i * w / 12 color = (j * 3) / (i + 3) + i * w / 12
fmi = 40 - i fmi = 40 - i
fmk = 40 - k fmk = 40 - k
grcolor(color) grcolor(color)#0
grplot(i, k) grplot(i, k)#0
grplot(k, i) grplot(k, i)#0
grplot(fmi, fmk) grplot(fmi, fmk)#0
grplot(fmk, fmi) grplot(fmk, fmi)#0
grplot(k, fmi) grplot(k, fmi)#0
grplot(fmi, k) grplot(fmi, k)#0
grplot(i, fmk) grplot(i, fmk)#0
grplot(fmk, i) grplot(fmk, i)#0
if keypressed() if keypressed()#1
return return
fin fin
next next
@ -271,10 +274,10 @@ when MACHID & $C8
fin fin
otherwise // Apple ][ otherwise // Apple ][
wend wend
grmode(MIXMODE) grmode(MIXMODE)#0
gotoxy(11, 1) gotoxy(11, 1)#0
puts(@exitmsg) puts(@exitmsg)
rod rod
textmode() textmode()#0
puts(@goodbye) puts(@goodbye)
done done

View File

@ -1353,6 +1353,7 @@ int parse_vars(int type)
parse_error("Invalid def return value count"); parse_error("Invalid def return value count");
return (0); return (0);
} }
scan();
} }
type |= funcparms_type(cfnparms) | funcvals_type(cfnvals); type |= funcparms_type(cfnparms) | funcvals_type(cfnvals);
idfunc_add(idstr, idlen, type, tag_new(type)); idfunc_add(idstr, idlen, type, tag_new(type));
@ -1362,6 +1363,7 @@ int parse_vars(int type)
{ {
idstr = tokenstr; idstr = tokenstr;
idlen = tokenlen; idlen = tokenlen;
type &= ~FUNC_PARMVALS;
cfnparms = 0; cfnparms = 0;
cfnvals = 1; // Default to one return value for compatibility cfnvals = 1; // Default to one return value for compatibility
if (scan() == OPEN_PAREN_TOKEN) if (scan() == OPEN_PAREN_TOKEN)
@ -1388,6 +1390,7 @@ int parse_vars(int type)
parse_error("Invalid def return value count"); parse_error("Invalid def return value count");
return (0); return (0);
} }
scan();
} }
type |= funcparms_type(cfnparms) | funcvals_type(cfnvals); type |= funcparms_type(cfnparms) | funcvals_type(cfnvals);
idfunc_add(idstr, idlen, type, tag_new(type)); idfunc_add(idstr, idlen, type, tag_new(type));
@ -1597,6 +1600,7 @@ int parse_defs(void)
parse_error("Invalid def return value count"); parse_error("Invalid def return value count");
return (0); return (0);
} }
scan();
} }
type |= funcparms_type(cfnparms) | funcvals_type(infuncvals); type |= funcparms_type(cfnparms) | funcvals_type(infuncvals);
if (idglobal_lookup(idstr, idlen) >= 0) if (idglobal_lookup(idstr, idlen) >= 0)
@ -1618,8 +1622,8 @@ int parse_defs(void)
func_tag = tag_new(type); func_tag = tag_new(type);
idfunc_add(idstr, idlen, type, func_tag); idfunc_add(idstr, idlen, type, func_tag);
} }
c = tokenstr[idlen]; c = idstr[idlen];
tokenstr[idlen] = '\0'; idstr[idlen] = '\0';
emit_idfunc(func_tag, type, idstr, 0); emit_idfunc(func_tag, type, idstr, 0);
idstr[idlen] = c; idstr[idlen] = c;
do do