1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-10-18 22:24:28 +00:00

Extend Console I/O so Rogue I/O disappears

This commit is contained in:
David Schmenk 2018-02-03 09:26:27 -08:00
parent 39385d79a4
commit d59a54d8fd
9 changed files with 136 additions and 159 deletions

View File

@ -4,6 +4,7 @@ import conio
const FLASH = $7F
struc t_conio
word keypressed
word getkey
word home
word gotoxy
word viewport
@ -12,5 +13,7 @@ import conio
word grmode
word grcolor
word grplot
word tone
word rnd
end
end

View File

@ -1,4 +1,5 @@
import sndseq
word musicSequence // musicSequence(yield, backgroundProc)#0
predef spkrTone(pitch, duration)#0, spkrPWM(sample, speed, len)#0
predef musicPlay(track, rept)#0, musicStop#0, musicGetKey(yield,backgroundProc)#1
predef musicPlay(track, rept)#0, musicStop#0, musicGetKey(yield, backgroundProc)#1
end

View File

@ -5,6 +5,12 @@ include "inc/cmdsys.plh"
const FULLMODE = 0
const MIXMODE = 1
//
// Apple II ZP locations.
//
const a2rndnum = $4E // ZP location of RND
const a2rndl = $4E
const a2rndh = $4F
//
// Apple II hardware constants.
//
const speaker = $C030
@ -23,10 +29,15 @@ const hgr2 = $4000
const page1 = 0
const page2 = 1
//
// External interface
// Apple III hardware constants.
//
const ENV_REG = $FFDF
//
// External interface.
//
struc t_conio
word keypressed
word getkey
word home
word gotoxy
word viewport
@ -35,12 +46,14 @@ struc t_conio
word grmode
word grcolor
word grplot
word tone
word rnd
end
//
// Predefined functions.
//
predef a2keypressed,a2home,a2gotoxy(x,y),a2viewport(left, top, width, height),a2texttype(type)
predef a2textmode(cols),a2grmode(mix),a2grcolor(color),a2grplot(x,y)
predef a2textmode(cols),a2grmode(mix),a2grcolor(color),a2grplot(x,y),a2tone(duration, delay),a2rnd
//
// Exported function table.
//
@ -49,6 +62,7 @@ word conio[]
// Function pointers.
//
word = @a2keypressed
word = @getc
word = @a2home
word = @a2gotoxy
word = @a2viewport
@ -57,6 +71,8 @@ word = @a2textmode
word = @a2grmode
word = @a2grcolor
word = @a2grplot
word = @a2tone
word = @a2rnd
//
// Screen row address arrays.
//
@ -79,6 +95,10 @@ byte textbwmode[] = 2, 16, 0
byte textclrmode[] = 2, 16, 1
byte grcharset[] = 1, 0, $7F, $7F, $7F, $7F, $00, $00, $00, $00
//
// Random number for Apple 1 and III.
//
word randnum = 12345
//
// Native routines.
//
asm equates
@ -176,6 +196,15 @@ end
def a1grmode(mix)
return 0 // not supported
end
def a1tone(duration, delay)
byte i
while duration
for i = delay downto 0; next
duration--
loop
return 0
end
//
// Apple II routines.
//
@ -223,6 +252,20 @@ def a2grmode(mix)
a2home
return a2grscrn(@txt1scrn) // point to lo-res screen
end
def a2tone(duration, delay)
byte i
while duration
^speaker // toggle speaker
for i = delay downto 0; next
duration--
loop
return 0
end
def a2rnd
*a2rndnum = (*a2rndnum << 1) + *a2rndnum + 123
return *a2rndnum & $7FFF
end
//
// Apple III routines.
//
@ -314,27 +357,56 @@ def a3grmode(mix)
next
return a2grscrn(@txt2scrn) // point to color screen
end
def a3tone(duration, pitch)
byte env
env = ^ENV_REG
^ENV_REG = env | $C0
a2tone(duration, pitch)
^ENV_REG = env
return 0
end
//
// Apple 1 and III combined routines.
//
def a13getkey
while not conio:keypressed()
randnum = randnum + 123
loop
return getc()
end
def a13rnd
randnum = (randnum << 1) + randnum + 123
return randnum & $7FFF
end
//
// Machine specific initialization.
//
when MACHID & MACHID_MODEL
is MACHID_I
conio:keypressed = @a1keypressed
conio:getkey = @a13getkey
conio:home = @a1home
conio:gotoxy = @a1gotoxy
conio:viewport = @a1viewport
conio:texttype = @a1texttype
conio:textmode = @a1textmode
conio:grmode = @a1grmode
conio:tone = @a1tone
conio:rnd = @a13rnd
break
is MACHID_III
conio:keypressed = @a3keypressed
conio:getkey = @a13getkey
conio:home = @a3home
conio:gotoxy = @a3gotoxy
conio:viewport = @a3viewport
conio:texttype = @a3texttype
conio:textmode = @a3textmode
conio:grmode = @a3grmode
conio:tone = @a3tone
conio:rnd = @a13rnd
break
//otherwise // MACHID_II
wend

View File

@ -38,7 +38,6 @@ DGR = DGR\#FE1000
TONE = TONE\#FE1000
PORTIO = PORTIO\#FE1000
ROGUE = ROGUE\#FE1000
ROGUEIO = ROGUEIO\#FE1000
ROGUEMAP= ROGUEMAP\#FE1000
ROGUECOMBAT= ROGUECOMBAT\#FE1000
HELLO = HELLO\#FE1000
@ -73,7 +72,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM802) $(PLVM03) $(CMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(TONE) $(DGR) $(DGRTEST) $(FILEIO) $(CONIO) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM802) $(PLVM03) $(CMD) $(PLASMAPLASM) $(CODEOPT) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(TONE) $(DGR) $(DGRTEST) $(FILEIO) $(CONIO) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
clean:
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
@ -285,10 +284,6 @@ $(ROGUE): samplesrc/rogue.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rogue.pla > samplesrc/rogue.a
acme --setpc 4094 -o $(ROGUE) samplesrc/rogue.a
$(ROGUEIO): samplesrc/rogue.io.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rogue.io.pla > samplesrc/rogue.io.a
acme --setpc 4094 -o $(ROGUEIO) samplesrc/rogue.io.a
$(ROGUECOMBAT): samplesrc/rogue.combat.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rogue.combat.pla > samplesrc/rogue.combat.a
acme --setpc 4094 -o $(ROGUECOMBAT) samplesrc/rogue.combat.a

View File

@ -38,7 +38,6 @@ cp ROD#FE1000 prodos/demos/ROD.REL
mkdir prodos/demos/rogue
cp ROGUE#FE1000 prodos/demos/rogue/ROGUE.REL
cp ROGUECOMBAT#FE1000 prodos/demos/rogue/ROGUECOMBAT.REL
cp ROGUEIO#FE1000 prodos/demos/rogue/ROGUEIO.REL
cp ROGUEMAP#FE1000 prodos/demos/rogue/ROGUEMAP.REL
cp samplesrc/LEVEL0#040000 prodos/demos/rogue/LEVEL0.TXT
cp samplesrc/LEVEL1#040000 prodos/demos/rogue/LEVEL1.TXT
@ -77,6 +76,9 @@ cp samplesrc/playseq.pla prodos/bld/PLAYSEQ.PLA.TXT
cp samplesrc/rpncalc.pla prodos/bld/RPNCALC.PLA.TXT
cp samplesrc/httpd.pla prodos/bld/HTTPD.PLA.TXT
cp samplesrc/fatcat.pla prodos/bld/FATCAT.PLA.TXT
cp samplesrc/rogue.pla prodos/bld/ROGUE.PLA.TXT
cp samplesrc/rogue.map.pla prodos/bld/ROGUE.MAP.PLA.TXT
cp samplesrc/rogue.combat.pla prodos/bld/ROGUE.COMBAT.PLA.TXT
mkdir prodos/bld/inc
cp inc/args.plh prodos/bld/inc/ARGS.PLH.TXT

View File

@ -1,9 +1,6 @@
include "inc/cmdsys.plh"
include "inc/conio.plh"
import rogueio
word rnd, getkb, tone
end
import roguemap
predef moveplayer
end
@ -129,10 +126,10 @@ export word entities = 0
//
def win#0
tone(30, 15)
tone(5, 15)
tone(5, 15)
tone(30, 5)
conio:tone(30, 15)
conio:tone(5, 15)
conio:tone(5, 15)
conio:tone(30, 5)
end
export def fight(player, enemy)
@ -161,18 +158,18 @@ export def fight(player, enemy)
puts(ascii_entity[enemy->kind] + e_atck * 11)
next
conio:gotoxy(12, 8); puts("F)ight or R)un?")
if toupper(getkb()) == 'R'
if toupper(conio:getkey()) == 'R'
return 1
else
//
// Turn player in random direction
//
player->angle = rnd() & 7
player->angle = conio:rnd() & 7
//
// Calculate attack (with a little random variation)
//
p_atck = player->skill + player->energy / 10 - enemy->power / 25 + (rnd() & 7)
e_atck = enemy->power - player->skill / 5 - player->energy / 20 + (rnd() & 7)
p_atck = player->skill + player->energy / 10 - enemy->power / 25 + (conio:rnd() & 7)
e_atck = enemy->power - player->skill / 5 - player->energy / 20 + (conio:rnd() & 7)
if enemy->life > p_atck
enemy->life = enemy->life - p_atck
else

View File

@ -1,111 +0,0 @@
include "inc/cmdsys.plh"
include "inc/conio.plh"
byte[] initstr
byte = " ( )\n"
byte = " )\\ ) ( /( (\n"
byte = "(()/( )\\()) )\\ ) ( (\n"
byte = " /(_))((_)\\ (()/( )\\ )\\\n"
byte = "(_)) ((_) /(_))_ _ ((_)((_)\n"
byte = "| _ \\ / _ \\(_)) __|| | | || __|\n"
byte = "| / | (_) | | (_ || |_| || _|\n"
byte = "|_|_\\ \\___/ \\___| \\___/ |___|\n"
byte = "\n"
byte = " By Resman\n"
byte = " Artwork by Seth Sternberger\n"
byte = ""
word titlestr = @initstr
//
// Machine specific routines
//
export word rnd, getkb, tone
const ENV_REG = $FFDF
const SPEAKER = $C030
const a2rndnum = $4E // ZP location of RND
const a2rndl = $4E
const a2rndh = $4F
word a3rndnum = 12345
def a3rnd
a3rndnum = (a3rndnum << 1) + a3rndnum + 123
return *a3rndnum & $7FFF
end
def a2rnd
*a2rndnum = (*a2rndnum << 1) + *a2rndnum + 123
return *a2rndnum & $7FFF
end
def a2getkb
return getc()
end
def a2tone(duration, delay)
byte i
while duration
^SPEAKER
for i = 0 to delay
next
duration--
loop
return 0
end
def a3tone(duration, pitch)
byte env
env = ^ENV_REG
^ENV_REG = env | $C0
a2tone(duration, pitch)
^ENV_REG = env
return 0
end
//
// Apple /// console routines
//
def a3getkb
while not conio:keypressed()
a3rndnum = a3rndnum + 123
loop
return getc()
end
//
// Set machine specific routines
//
when MACHID & $C8
is $08 // Apple 1
puts("APPLE 1 NOT SUPPORTED.")
return -1
is $C0 // Apple ///
rnd = @a3rnd
getkb = @a3getkb
tone = @a3tone
break
otherwise // Apple ][
rnd = @a2rnd
getkb = @a2getkb
tone = @a2tone
wend
//
// Print title page
//
conio:home()
while ^titlestr
puts(titlestr)
titlestr = titlestr + ^titlestr + 1
loop
done

View File

@ -5,13 +5,24 @@ include "inc/cmdsys.plh"
include "inc/conio.plh"
include "inc/fileio.plh"
import rogueio
const O_READ = 1
const O_WRITE = 2
const O_READ_WRITE = 3
//
// Title page
//
word rnd, getkb, tone
end
byte[] initstr
byte = " ( )\n"
byte = " )\\ ) ( /( (\n"
byte = "(()/( )\\()) )\\ ) ( (\n"
byte = " /(_))((_)\\ (()/( )\\ )\\\n"
byte = "(_)) ((_) /(_))_ _ ((_)((_)\n"
byte = "| _ \\ / _ \\(_)) __|| | | || __|\n"
byte = "| / | (_) | | (_ || |_| || _|\n"
byte = "|_|_\\ \\___/ \\___| \\___/ |___|\n"
byte = "\n"
byte = " By Resman\n"
byte = " Artwork by Seth Sternberger\n"
byte = ""
word titlestr = @initstr
//
// Octant beam parameters
@ -760,4 +771,14 @@ export def drawvisentity(xofst, yofst, tile)#0
fin
end
//
// Print title page
//
conio:home()
while ^titlestr
puts(titlestr)
titlestr = titlestr + ^titlestr + 1
loop
done

View File

@ -41,10 +41,6 @@ import roguecombat
word entity, entities
end
import rogueio
word rnd, getkb, tone
end
const maxlight = 10
const maxview = 19
@ -54,6 +50,7 @@ byte vplayer = '^', '\\', '>', '/', 'v', '\\', '<', '/'
byte totaldarkness = 0
byte level = 0
word free_entities
//
// Power-ups
//
@ -157,42 +154,42 @@ end
//
def ouch#0
tone(128,5)
conio:tone(128,5)
end
def gotit#0
tone(10,8)
tone(80,2)
conio:tone(10,8)
conio:tone(80,2)
end
def fall#0
byte i
for i = 0 to 10
tone(50, i)
conio:tone(50, i)
next
end
def drown#0
word i
tone(10,20)
tone(10,1)
conio:tone(10,20)
conio:tone(10,1)
for i = 0 to 1000
next
tone(10,25)
tone(10,2)
conio:tone(10,25)
conio:tone(10,2)
for i = 0 to 1000
next
tone(10,30)
tone(10,3)
conio:tone(10,30)
conio:tone(10,3)
end
def groan#0
byte i
for i = 0 to 5
tone(5, 40 + i)
conio:tone(5, 40 + i)
next
end
@ -463,10 +460,10 @@ def play
return FALSE
fin
conio:gotoxy(xcentr, ycentr)
when toupper(getkb())
when toupper(conio:getkey())
is 'I'
if totaldarkness
player.angle = rnd() & 7
player.angle = conio:rnd() & 7
else
player.angle = 0
fin
@ -474,7 +471,7 @@ def play
break
is 'J'
if totaldarkness
player.angle = rnd() & 7
player.angle = conio:rnd() & 7
else
player.angle = 6
fin
@ -482,7 +479,7 @@ def play
break
is 'K'
if totaldarkness
player.angle = rnd() & 7
player.angle = conio:rnd() & 7
else
player.angle = 2
fin
@ -490,7 +487,7 @@ def play
break
is 'M'
if totaldarkness
player.angle = rnd() & 7
player.angle = conio:rnd() & 7
else
player.angle = 4
fin
@ -601,7 +598,7 @@ def play
clearstatus
conio:gotoxy(0, statusline)
puts(@quitstr)
if toupper(getkb()) == 'Y'
if toupper(conio:getkey()) == 'Y'
player.health = 0
return FALSE
fin