1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-24 20:31:12 +00:00

Add game port library and sandbox example (ex.17)

This commit is contained in:
David Schmenk 2016-08-01 13:33:52 -07:00
parent c5d9fc8568
commit a1aa849d60
3 changed files with 59 additions and 1 deletions

Binary file not shown.

53
src/libsrc/portio.pla Normal file
View File

@ -0,0 +1,53 @@
//
// Game port I/O library based on the wiring library
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
const ANN0 = $C058
const ANN1 = $C05A
const ANN2 = $C05C
const ANN3 = $C05E
const OFF = 0
const ON = 1
const STROBE = $C040
const FLAG0 = $C060
const FLAG1 = $C061
const FLAG2 = $C062
const FLAG3 = $C063
const PREAD = $FB1E
const WAIT = $FCA8
export def digitalRead(pin)
return FLAG0[pin&3] > 127
end
export def portRead
return (^FLAG0>>7)&1|(^FLAG1>>6)&2|(^FLAG2>>5)&4|(^FLAG3>>4)&8
end
def digitalWrite(pin, val)
return ^ANN0[pin&3+val&1]
end
export def portWrite(val)
^ANN0[val&1]
^ANN1[(val>>1)&1]
^ANN2[(val>>2)&1]
return ^ANN3[(val>>3)&1]
end
export def analogRead(pin)
return call(PREAD,0,pin&3,0,0).2
end
export def delay(time)
return call(WAIT,time,0,0,0)
end
done

View File

@ -18,6 +18,7 @@ DHCP = DHCP\#FE1000
HTTPD = HTTPD\#FE1000
DGR = DGR\#FE1000
TONE = TONE\#FE1000
PORTIO = PORTIO\#FE1000
ROGUE = ROGUE\#FE1000
ROGUEIO = ROGUEIO\#FE1000
ROGUEMAP= ROGUEMAP\#FE1000
@ -52,7 +53,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST)
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST) $(PORTIO)
clean:
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
@ -161,6 +162,10 @@ $(TONE): libsrc/tone.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < libsrc/tone.pla > libsrc/tone.a
acme --setpc 4094 -o $(TONE) libsrc/tone.a
$(PORTIO): libsrc/portio.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < libsrc/portio.pla > libsrc/portio.a
acme --setpc 4094 -o $(PORTIO) libsrc/portio.a
$(DGR): libsrc/dgr.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < libsrc/dgr.pla > libsrc/dgr.a
acme --setpc 4094 -o $(DGR) libsrc/dgr.a