import STDLIB predef syscall, call, memset, getc, putc, puts, modaddr byte MACHID end // // Handy constants. // const FALSE = 0 const TRUE = !FALSE const FULLMODE = 0 const MIXMODE = 1 // // Apple II hardware constants. // const speaker = $C030 const showgraphics = $C050 const showtext = $C051 const showfull = $C052 const showmix = $C053 const showpage1 = $C054 const showpage2 = $C055 const showlores = $C056 const showhires = $C057 const keyboard = $C000 const keystrobe = $C010 const hgr1 = $2000 const hgr2 = $4000 const page1 = 0 const page2 = 1 // // Predefined functions. // predef a2reset,a2keypressed,a2home,a2gotoxy,a2viewport,a2texttype predef a2textmode,a2writeint,a2writeln predef a2grmode,grcolor,grplot // // String pool. // byte stdlib[] = "STDLIB" // // Screen row address arrays. // word txt1scrn[] = $0400,$0480,$0500,$0580,$0600,$0680,$0700,$0780 word = $0428,$04A8,$0528,$05A8,$0628,$06A8,$0728,$07A8 word = $0450,$04D0,$0550,$05D0,$0650,$06D0,$0750,$07D0 word txt2scrn[] = $0800,$0880,$0900,$0980,$0A00,$0A80,$0B00,$0B80 word = $0828,$08A8,$0928,$09A8,$0A28,$0AA8,$0B28,$0BA8 word = $0850,$08D0,$0950,$09D0,$0A50,$0AD0,$0B50,$0BD0 // // Text screen parameters. // byte textcols = 40 byte curshpos = 0 byte cursvpos = 0 // // Apple 3 console codes. // byte textbwmode[] = 2, 16, 0 byte textclrmode[] = 2, 16, 1 byte grcharset[] = 1, 0, $7F, $7F, $7F, $7F, $00, $00, $00, $00 byte devcons // // Exported function table. // export word conio[] // // Function pointers. // word = @a2reset word = @a2keypressed word = @a2home word = @a2gotoxy word = @a2viewport word = @a2texttype word = @a2textmode word = @a2grmode word = @grcolor word = @grplot // // Native routines. // asm equates !SOURCE "vmsrc/plvmzp.inc" end // // def grscrn(rowaddrs) // asm grscrn GRSCRN = $26 GRSCRNL = GRSCRN GRSCRNH = GRSCRNL+1 LDA ESTKL,X STA GRSCRNL LDA ESTKH,X STA GRSCRNH RTS end // // def grcolor(color) // asm grcolor GRCLR = $30 LDA #$0F AND ESTKL,X STA GRCLR ASL ASL ASL ASL ORA GRCLR STA GRCLR RTS end // // def grplot(x, y) // asm grplot STY IPY LDA ESTKL,X AND #$FE CMP ESTKL,X TAY LDA (GRSCRN),Y STA DSTL INY LDA (GRSCRN),Y STA DSTH LDA #$FF ADC #$00 EOR #$0F TAY AND GRCLR STA TMPL TYA EOR #$FF LDY ESTKL+1,X AND (DST),Y ORA TMPL STA (DST),Y LDY IPY INX RTS end // // Apple 1 routines. // def a1keypressed return ^$D011 >= 128 end def a1gotoxy(x, y) curshpos = x cursvpos = y putln while x putc(' ') x = x - 1 loop end def a1viewport(left, top, width, height) end def a1texttype(type) end def a1textmode(columns) end def a1grmode(mix) return 0 // not supported end // // Apple II routines. // def a2keypressed return ^keyboard >= 128 end def a2home curshpos = 0 cursypos = 0 return call($FC58, 0, 0, 0, 0) // home() end def a2gotoxy(x, y) curshpos = x cursvpos = y ^$24 = x + ^$20 return call($FB5B, y + ^$22, 0, 0, 0) end def a2viewport(left, top, width, height) if !width or !height left = 0 top = 0 width = 40 height = 24 fin ^$20 = left ^$21 = width ^$22 = top ^$23 = height + top - 1 return a2gotoxy(0, 0) end def a2texttype(type) end def a2writeln(string, start, fill) end def a2textmode(columns) call($FB39, 0, 0, 0, 0) // textmode() return a2home end def a2grmode(mix) call($FB2F, 0, 0, 0, 0) // initmode() call($FB40, 0, 0, 0, 0) // grmode() if !mix ^showfull fin a2home return grscrn(@txt1scrn) // point to lo-res screen end // // Apple III routines. // def dev_control(devnum, code, list) byte params[5] params.0 = 3 params.1 = devnum params.2 = code params:3 = list return syscall($83, @params) end def dev_status(devnum, code, list) byte params[5] params.0 = 3 params.1 = devnum params.2 = code params:3 = list return syscall($82, @params) end def a3keypressed byte count dev_status(devcons, 5, @count) return count end def a3home curshpos = 0 cursvpos = 0 return cout(28) end def a3gotoxy(x, y) curshpos = x cursvpos = y putc(24) putc(x) putc(25) return putc(y) end def a3viewport(left, top, width, height) if !width or !height // // Reset the full-screen viewport // left = 0 top = 0 width = textwidth height = 24 fin putc(1) // Reset viewport putc(26) putc(left) putc(top) putc(2) putc(26) putc(left + width - 1) putc(top + height - 1) putc(3) return a3gotoxy(0, 0) end def a3texttype(type) end def a3textmode(columns) puts(@textbwmode) if columns > 40 a3viewport(0, 0, 80, 24) else a3viewport(0, 0, 40, 24) fin return putc(28) end def a3grmode(mix) byte i if mix mix = 19 else mix = 23 fin puts(@textclrmode) dev_control(devcons, 17, @grcharset) a3viewport(0, 20, 40, 4) for i = 0 to mix memset(txt1scrn[i], 40, $0000) // text screen memset(txt2scrn[i], 40, $0000) // color screen next return grscrn(@txt2scrn) // point to color screen end // // Machine specific initialization. // when MACHID & $C8 is $08 // Apple 1 conio:reset = @a1reset conio:keypressed = @a1keypressed conio:home = @a1home conio:gotoxy = @a1gotoxy conio:viewport = @a1viewport conio:texttype = @a1texttype conio:textmode = @a1textmode conio:grmixmode = @a1grmixmode is $C0 // Apple /// conio:reset = @a3reset conio:keypressed = @a3keypressed conio:home = @a3home conio:gotoxy = @a3gotoxy conio:viewport = @a3viewport conio:texttype = @a3texttype conio:textmode = @a3textmode conio:grmixmode = @a3grmixmode devcons = modaddr(@stdlib).5 // devcons variable from STDLIB otherwise // Apple ][ wend