Disable /RAM, fix Viewport call in both VM

This commit is contained in:
David Schmenk 2014-05-13 22:03:09 -07:00
parent f98e7944f6
commit 816399dcdc
4 changed files with 67 additions and 49 deletions

View File

@ -26,7 +26,7 @@ const resxhgr2 = $0020
predef home, gotoxy, viewport, crout, cout, prstr, cin, rdstr predef home, gotoxy, viewport, crout, cout, prstr, cin, rdstr
predef syscall, romcall predef syscall, romcall
predef markheap, allocheap, allocalignheap, releaseheap, availheap predef markheap, allocheap, allocalignheap, releaseheap, availheap
predef memclr, memset, memcpy, xmemcpy, memxcpy predef memset, memcpy, xmemcpy, memxcpy
predef uword_isgt, uword_isge, uword_islt, uword_isle predef uword_isgt, uword_isge, uword_islt, uword_isle
predef getpfx, setpfx, newline, online, open, close, read, write, create, destroy predef getpfx, setpfx, newline, online, open, close, read, write, create, destroy
; ;
@ -57,7 +57,6 @@ byte hpalignstr[] = "HEAPALLOCALIGN"
byte hpallocstr[] = "HEAPALLOC" byte hpallocstr[] = "HEAPALLOC"
byte hprelstr[] = "HEAPRELEASE" byte hprelstr[] = "HEAPRELEASE"
byte hpavailstr[] = "HEAPAVAIL" byte hpavailstr[] = "HEAPAVAIL"
;byte memclrstr[] = "MEMCLR"
byte memsetstr[] = "MEMSET" byte memsetstr[] = "MEMSET"
byte memcpystr[] = "MEMCPY" byte memcpystr[] = "MEMCPY"
byte uisgtstr[] = "ISUGT" byte uisgtstr[] = "ISUGT"
@ -78,7 +77,6 @@ word = @hpmarkstr, @markheap
word = @hpallocstr,@allocheap word = @hpallocstr,@allocheap
word = @hpalignstr,@allocalignheap word = @hpalignstr,@allocalignheap
word = @hprelstr, @releaseheap word = @hprelstr, @releaseheap
;word = @memclrstr, @memclr
word = @memsetstr, @memset word = @memsetstr, @memset
word = @memcpystr, @memcpy word = @memcpystr, @memcpy
word = @uisgtstr, @uword_isgt word = @uisgtstr, @uword_isgt
@ -203,31 +201,6 @@ asm reboot
JMP ($FFFC) ; RESET JMP ($FFFC) ; RESET
end end
; ;
; SET MEMORY TO 0
; MEMCLR(ADDR, SIZE)
;
;asm memclr
; LDY #$00
; LDA ESTKL+1,X
; STA DSTL
; LDA ESTKH+1,X
; STA DSTH
; INC ESTKL,X
; INC ESTKH,X
; TYA
;CLRMLP DEC ESTKL,X
; BNE +
; DEC ESTKH,X
; BEQ ++
;+ STA (DST),Y
; INY
; BNE CLRMLP
; INC DSTH
; BNE CLRMLP
;++ INX
; RTS
;end
;
; SET MEMORY TO VALUE ; SET MEMORY TO VALUE
; MEMSET(ADDR, SIZE, VALUE) ; MEMSET(ADDR, SIZE, VALUE)
; ;
@ -420,18 +393,16 @@ end
asm viewport asm viewport
LDA ESTKL+3,X LDA ESTKL+3,X
STA $20 STA $20
LDA ESTKL+2,X
STA $22
LDA ESTKL+1,X LDA ESTKL+1,X
STA $21 STA $21
LDA ESTKL,X LDA ESTKL+2,X
STA $22
CLC CLC
ADC $22 ADC ESTKL,X
STA $23 STA $23
STA $25 LDY #$00
DEC $25 STY $24
LDA #$00 LDA $22
STA $24
STX ESP STX ESP
BIT ROMEN BIT ROMEN
JSR $FB5B JSR $FB5B
@ -1162,7 +1133,7 @@ def loadmod(mod)
; ;
; Locate bytecode defs in appropriate bank. ; Locate bytecode defs in appropriate bank.
; ;
if ^MACHID & $30 if ^MACHID & $30 == $30
defbank = 1 defbank = 1
defaddr = allocxheap(rld - bytecode) defaddr = allocxheap(rld - bytecode)
else else

View File

@ -346,8 +346,7 @@ int load_mod(byte *mod)
{ {
if (show_state) printf("BYTE"); if (show_state) printf("BYTE");
mem_data[addr] = fixup; mem_data[addr] = fixup;
} }
} }
if (show_state) printf("@$%04X\n", addr); if (show_state) printf("@$%04X\n", addr);
rld += 4; rld += 4;
@ -411,7 +410,8 @@ void call(uword pc)
interp(mem_data + (mem_data[pc] + (mem_data[pc + 1] << 8))); interp(mem_data + (mem_data[pc] + (mem_data[pc + 1] << 8)));
break; break;
case 3: // LIBRARY STDLIB::VIEWPORT case 3: // LIBRARY STDLIB::VIEWPORT
printf("Set Window %d, %d, %d, %d/n", POP, POP, POP, POP); printf("Set Viewport %d, %d, %d, %d\n", esp[3], esp[2], esp[1], esp[0]);
esp += 4;
PUSH(0); PUSH(0);
break; break;
case 4: // LIBRARY STDLIB::PUTC case 4: // LIBRARY STDLIB::PUTC
@ -466,6 +466,11 @@ void call(uword pc)
fflush(stdout); fflush(stdout);
PUSH(0); PUSH(0);
break; break;
case 11: // LIBRARY STDLIB::PUTNL
putchar('\n');
fflush(stdout);
PUSH(0);
break;
default: default:
printf("Bad call code\n"); printf("Bad call code\n");
} }
@ -851,7 +856,9 @@ char *stdlib_exp[] = {
"GETC", "GETC",
"GETS", "GETS",
"CLS", "CLS",
"GOTOXY" "GOTOXY",
"PUTNL",
0
}; };
byte stdlib[] = { byte stdlib[] = {
@ -877,7 +884,7 @@ int main(int argc, char **argv)
*/ */
stodci("STDLIB", dci); stodci("STDLIB", dci);
add_mod(dci, 0xFFFF); add_mod(dci, 0xFFFF);
for (i = 0; i < 8; i++) for (i = 0; stdlib_exp[i]; i++)
{ {
mem_data[i] = i + 3; mem_data[i] = i + 3;
stodci(stdlib_exp[i], dci); stodci(stdlib_exp[i], dci);

View File

@ -4,13 +4,20 @@
;* ;*
;********************************************************** ;**********************************************************
;* ;*
;* MONITOR SPECIAL LOCATIONS AND PRODOS MLI ;* MONITOR SPECIAL LOCATIONS
;* ;*
CSWL = $36 CSWL = $36
CSWH = $37 CSWH = $37
PROMPT = $33 PROMPT = $33
;*
;* PRODOS
;*
PRODOS = $BF00 PRODOS = $BF00
MACHID = $BF98 DEVCNT = $BF31 ; GLOBAL PAGE DEVICE COUNT
DEVLST = $BF32 ; GLOBAL PAGE DEVICE LIST
MACHID = $BF98 ; GLOBAL PAGE MACHINE ID BYTE
RAMSLOT = $BF26 ; SLOT 3, DRIVE 2 IS /RAM'S DRIVER VECTOR
NODEV = $BF10
;* ;*
;* HARDWARE ADDRESSES ;* HARDWARE ADDRESSES
;* ;*
@ -50,6 +57,39 @@ ESP = DST+2
LDX #$FF LDX #$FF
TXS TXS
;* ;*
;* DISCONNECT /RAM
;*
SEI ; DISABLE /RAM
LDA MACHID
AND #$30
CMP #$30
BNE RAMDONE
LDA RAMSLOT
CMP NODEV
BNE RAMCONT
LDA RAMSLOT+1
CMP NODEV+1
BEQ RAMDONE
RAMCONT LDY DEVCNT
RAMLOOP LDA DEVLST,Y
AND #$F3
CMP #$B3
BEQ GETLOOP
DEY
BPL RAMLOOP
BMI RAMDONE
GETLOOP LDA DEVLST+1,Y
STA DEVLST,Y
BEQ RAMEXIT
INY
BNE GETLOOP
RAMEXIT LDA NODEV
STA RAMSLOT
LDA NODEV+1
STA RAMSLOT+1
DEC DEVCNT
RAMDONE CLI
;*
;* INSTALL PAGE 3 VECTORS ;* INSTALL PAGE 3 VECTORS
;* ;*
LDY #$20 LDY #$20

View File

@ -2,7 +2,7 @@
; Declare all imported modules and their data/functions. ; Declare all imported modules and their data/functions.
; ;
import stdlib import stdlib
predef cls, gotoxy, puts, putc, putnl, getc predef cls, gotoxy, viewport, puts, putc, putnl, getc
end end
import testlib import testlib
@ -15,7 +15,7 @@ predef main
; ;
; Declare all global variables for this module. ; Declare all global variables for this module.
; ;
byte hello[] = "Hello, world.\n\n" byte hello[] = "Hello, world.\n"
word defptr = main word defptr = main
; ;
; Define functions. ; Define functions.
@ -31,14 +31,16 @@ def nums
word i word i
for i = -10 to 10 for i = -10 to 10
puti(i) puti(i)
putc('\n') putnl
next next
end end
export def main export def main
cls cls
nums nums
viewport(12, 12, 16, 8)
ascii ascii
viewport(0, 0, 40, 24)
gotoxy(15,5) gotoxy(15,5)
puts(@hello) puts(@hello)
end end
@ -50,6 +52,4 @@ export def indirect
end end
indirect indirect
putc(getc)
putnl
done done