! Source code for ECP8 in ORCA/M for the IIgs format ! (though it will probably compile under the 8-bit version ! of the software as well. ! ! This is still a copyrighted program with all commercial rights ! reserved but I am no longer requiring a shareware payment for ! use of the program though I'll certainly accept any $$ people ! feel like sending for it. The source code is being released ! because when I was writing this code there was precious little ! decent source code to real-life applications available for me ! to learn from. Perhaps this code, while written years ago, will ! help teach the next great VisiCalc programmer a trick or two that ! we might all benefit from some day. ! ! Feel free to modify the program to suit your tastes. I'd like ! to ask though that if you give away copies that you modify that ! you not remove any of the credits of where the code came from and ! of course you cannot sell derivative works based on this product ! but you're free to give them away. ! ! Also, to avoid confusion, if you should distribute modified code, ! be sure to distribute it with the source code and call your finished ! program ECP-JONES or ECP-SMITH etc so we can keep the derivations ! straight. ! ! This was really the first serious Apple II program I ever tried ! writing in assembly language. I do lots of things better than I ! did back in 1984 or so when I was writing this thing. Some of the ! code is probably obscure so if there are questions don't hesitate ! to contact me via email to ask about stuff. I'll try to answer ! what I can. ! ! Don Elton ! Carolina System Software ! 3207 Berkeley Forest Drive ! Columbia, SC 29209-4111 ! ! Compuserve 72010,37 ! The Source SIG048 ! GEnie delton ! ProLine (any site) delton@pro-carolina ! UUCP/UNIX crash!delton%pro-carolina@nosc.mil ! MCI MAIL 351-9930 ! ! Pro-Carolina 300-2400 baud, 803-776-3936 ! !-------------------------------------------------------------------- ! Modification History !-------------------------------------------------------------------- ! Version 5.00 ! ------------ ! 1-14-89 Communications routines removed from program and status ! changed to freeware with source code release ! ! Version 5.01 ! ------------ ! 1-24-89 Failure to print bug fixed -- stupid addressing error in Macro ! argument. ! ! !==================================================================== list off symbol off keep obj/ecp8 mcopy ecp8.macs org $2000 msb on 65c02 off 65816 off longa off longi off absaddr on ********* * * main * ********* * main start using globals lastdev gequ $bf30 pddate gequ $bf90 pdtime gequ $bf92 pfxflag gequ $bf9a amperv gequ $3f5 usradr gequ $3f8 break gequ $3f0 inbuf gequ $200 stack gequ $100 mon gequ $ff69 init gequ $fb2f setwnd gequ $fb4b prhex gequ $fde3 mli gequ $bf00 basic gequ $be00 finf gequ $20 fzero gequ $40 ludp gequ 10 lpdp gequ 8 lufp gequ 7 lpfp gequ 4 ferr1 gequ 1 ferr2 gequ 2 ferr3 gequ 4 ferr4 gequ 8 ferr5 gequ 16 sysestmin gequ $94 sysestmax gequ $96 syseste gequ $98 syscstmin gequ $9a syscstmax gequ $9c syspstmin gequ $9e syspstmax gequ $a0 syseol gequ $a2 syseof gequ $a3 wr0 gequ $c0 wr1 gequ $c1 wr2 gequ $c2 wr3 gequ $c3 wr4 gequ $c4 wr5 gequ $c5 wr6 gequ $c6 wr7 gequ $c7 mr0 gequ $c8 mr1 gequ $c9 mr2 gequ $ca mr3 gequ $cb mr4 gequ $cc mr5 gequ $cd mr6 gequ $ce mr7 gequ $cf syss1 gequ $d0 syse1 gequ $d1 sysm1 gequ $d3 sign gequ $e0 syss2 gequ $e1 syse2 gequ $e2 sysm2 gequ $e4 sysferr gequ $eb str gequ $ec prbyte gequ $fdda vtab gequ $fc22 clreos gequ $f442 clreol gequ $fc9c home gequ $fc58 prerr gequ $ff2d key gequ $c000 clrkey gequ $c010 spkr gequ $c030 pb2 gequ $c062 oapple gequ $c060 capple gequ $c061 jmp cold ;$2000 dc a'$0501' ;release number dc h'00' dc h'00 00' external entry ;external entry $2008 jmp extcont dc h'00' ;reserved $200b dc a'getkey' ;key input address $200c ds 1 dc a'cout' ;char output address $200f dc h'ff' ;default startup flag $2011 dc a'cmdtable' ;command table address $2012 dc a'types' ;file type table $2014 dc a'pdprefix' ;pointer to prefix $2016 dc h'00' ;execflag $2018 dc h'00' ;inhibit ctrlc $2019 dc h'00' ;lower case restrict $201a dc h'00' ;skm present $201b dc a'initstr' ;printer init string $201c dc h'ff' ;echo restrict flag $201e dc h'01' ;printer slot $201f dc h'00' ;ctrl available $2020 dc h'00' ;last control char $2021 dc h'00' ;click duration $2022 ds 23 dc c':' ;prompt $203a dc a'inline' ;inline pointer $203b dc a'args' ;args pointer $203d dc a'path1' ;path1 pointer $203f dc a'path2' ;path2 pointer $2041 dc a'scrsize' ;scrsize ptr $2043 dc a'rootpfx' ;rootpfx ptr $2045 dc a'cmdpath' ;cmdpath ptr $2047 dc a'helppath' ;helppath ptr $2049 dc a'arg1' ;arg1 ptr $204b dc a'arg2' ;arg2 ptr $204d dc a'arg3' ;arg3 ptr $204f dc a'epath' ;epath ptr $2051 dc a'cpath' ;cpath ptr $2053 dc a'cref' ;cref ptr $2055 dc a'eref' ;eref ptr $2057 dc a'kbuffer' ;input buffers start $2059 dc h'5e' ;control char token '^'$205b dc a'0000' ;value $205c dc h'00' ;ioresult $205e dc a'$0000' ;pseudo-irq vector $205f ds 2 dc h'00' ;ASK byte $2063 dc a'$5eff' ;top memory size $2064 dc h'00' ;debug mode $2066 dc h'60' ;rts op code $2067 dc a'0000' ;extgetcmd address $2068 dc h'00' ;maxlen for getcmd $206A dc h'00' ;inpmode for getcmd $206B dc a'0000' ;inpbuffer $206C extcont cld sta trick1+1 ;stash a txa asl a tax dex lda table,x ;msb pha dex lda table,x pha trick1 lda #0 ;restore a rts table dc a'boot-1' ;1 dc a'buzz-1' ;2 dc a'calltime-1' ;3 dc a'catalog-1' 4 dc a'close-1' 5 dc a'fakeirq-1' 6 dc a'copypath-1' 7 dc a'cout-1' 8 dc a'cout1-1' 9 dc a'match-1' 10 * new dc a'deblank-1' 11 dc a'dspcurs-1' 12 dc a'dsptime-1' 13 dc a'exit-1' 14 dc a'findpfx-1' 15 dc a'getargs-1' 16 dc a'getcmd-1' 17 dc a'getkey-1' 18 dc a'gomon-1' 19 dc a'home-1' 20 dc a'extcopy-1' 21 dc a'moveln-1' 22 dc a'online-1' 23 dc a'parse-1' 24 dc a'extappend-1' 25 dc a'prefix-1' 26 dc a'input-1' 27 * new dc a'ask-1' 28 * new dc a'putpath-1' 29 dc a'doquit-1' 30 dc a'showtyp-1' 31 dc a'time-1' 32 dc a'title-1' 33 dc a'getargs1-1' 34 * new dc a'delete-1' 35 dc a'rename-1' 36 dc a'copy-1' 37 dc a'readln-1' 38 * new dc a'lock-1' 39 dc a'unlock-1' 40 dc a'type-1' 41 dc a'dump-1' 42 dc a'pderr-1' 43 dc a'fkey-1' 44 dc a'col40-1' 45 dc a'col80-1' 46 dc a'store-1' 47 * new dc a'noargs-1' dc a'backpfx-1' 49 dc a'prefix2-1' 50 dc a'execfl-1' 51 dc a'execln-1' 52 dc a'prttog-1' 53 dc a'docmd-1' 54 dc a'stopexec-1' 55 dc a'cold-1' 56 dc a'home2-1' 57 dc a'pinit-1' 58 dc a'zaplin-1' 59 dc a'writefl-1' 60 dc a'printon-1' 61 dc a'fileon-1' 62 dc a'upcase-1' 63 dc a'noargs-1' 64 ;the real noargs here dc a'ifshell-1' 65 dc a'moncmd-1' 66 dc a'chkkey-1' 67 dc a'chkbuf-1' 68 dc a'getctrl-1' 69 dc a'noargs-1' dc a'noargs-1' dc a'noargs-1' dc a'noargs-1' dc a'noargs-1' dc a'noargs-1' dc a'noargs-1' dc a'noargs-1' 77 * dc a'noargs-1' dc a'coldsu-1' 79 dc a'initparm-1' 80 dc a'noargs-1' dc a'eightoff-1' 82 dc a'if-1' 83 dc a'ifnot-1' 84 dc a'ifyes-1' 85 dc a'xdump-1' 86 dc a'path-1' 87 dc a'exit2-1' 88 dc a'goto-1' 89 dc a'call-1' 90 dc a'erts-1' 91 dc a'ifeq-1' 92 dc a'noargs-1' 93 ########## dc a'noargs-1' dc a'dolines-1' 95 dc a'noargs-1' 96 ########## dc a'noargs-1' 97 ########## dc a'arginterp-1' 98 dc a'rootarg-1' 99 dc a'argpath1-1' 100 dc a'argpath2-1' 101 dc a'ifbyte-1' 102 dc a'hexbin-1' 103 dc a'exists-1' 104 end ********* * * cold - cold start the system * ********* * cold start using globals cld jsr initparm lm echoflag,#$ff lda #0 sta prflag printer not active sta key0 fkey buffers sta key1 sta key2 sta key3 sta key4 sta key5 sta key6 sta key7 sta key8 sta key9 sta level file level sta kbufstart keyboard type-ahead buffer sta kbufend sta callpath 1 level stack for execs sta callmark sta callmark+1 sta callmark+2 jsr chkkey ;get first keypress if there move #0,keys,#10 ;clear fkey flags lda $fbb3 ;id byte cmp #$06 beq skip2 lm $c0b0,#$0a ;reset videx cursor lm $c0b0,#$60 ;on II+ only to avoid SwiftCard skip2 ldx #$ff ;fix stack txs jsr eightoff jsr resetvec jsr clrmem jsr chkkey jsr close jsr stopexec lda #begin reset and BRK handler sta $3f2 lda #begin/256 sta $3f3 lda #fatal sta $3f0 lda #fatal/256 sta $3f1 lda $3f3 ;fix reset eor #$a5 ;power-up byte sta $3f4 la usradr+1,ctrly ;fix ctrly la ($1,$b2),begin lm usradr,#$4c lm $b1,#$20 lm idbyte,#0 ;//e here lda $fbb3 cmp #$06 bne twoehere sec ;identify IIgs port jsr $fe1f ;special id subroutine bcs twoehere dec idbyte ;//gs here twoehere anop jsr chkkey jsr volname ;set pfx jsr chkkey ;get second key press here jsr hidequit lm interpsu,#0 ident lda #$08 bit machid beq oldsys bpl oldsys bvc ceor3 oldsys bmi ceor3 lm lcflag,#$ff ;lower case restrict mode ceor3 lm scrsize,#40 lda machid ;got 80 col? and #%00000010 beq done1 lm scrsize,#80 done1 jmp begin end ******** * * clrmem * ******** * clrmem start using globals lm $bf58,#$cf release #$800,#$1800 reserve #$2000,#$4000 release #$6000,topsize ;clear bitmap rts end ********* * * dolines ********* * dolines start using globals lm entsu,startup inc entsu doline jsr getcmd lda startup cmp entsu beq donexe lda execflag beq notexe lda echoflag bne p1 notexe cout #' ' jsr crout p1 jsr parse jsr docmd lda inline cmp #$8d beq atend lm inline,#' ' bne p1 ;always atend lda execflag bne doline donexe rts entsu ds 1 end ********* * * begin - main code here * ********* * begin start using globals ldx #$ff txs ;reset stack again jsr clrmem ;fix bitmap jsr chkkey lm (level,prflag),#0 jsr close lm level,#filelev jsr stopexec jsr zaplin jsr chkkey ctrly entry lda scrsize ;fix screen cmp #40 beq got40 jsr col80 jmp skip got40 jsr col40 skip lda startup ;su check needed? cmp #$ff ;cold start? jne getlin ;if no then start prog normal inc startup ;set startup to 0 jsr rootarg ;create path for cp.keys in root dir ldy args ldx #1 fixkey lda cpkey,x sta args+1,y iny inx cpx #8 bne fixkey sty args jsr crout jsr chkkey la pdgetinf+1,args ;look for cp.keys get_info pdgetinf bcs trysu ;try cp.startup if not found jsr chkkey jsr exit2 ;execute cp.keys jsr dolines trysu la pdgetinf+1,su ;check for su file get_info pdgetinf bcs getlin jsr chkkey la ' end **************************************************************** * * OutDec - output acc as decimal * **************************************************************** * OutDec START using globals pha lm high+1,#$ff pla loop inc high+1 sec sbc #10 bpl loop clc adc #10 pha high lda #0 ;self modified code ora #'0' jsr cout pla ora #'0' jmp cout END ******************************* * * gomon - enter apple monitor * ******************************* * gomon start using globals jsr getargs jne moncmd jsr stopexec jsr setkbd jmp $ff69 ;enter monitor end ******************************* * * catalog - catalog current directory (needs update for AppleTalk) ### * * inputs: args * ******************************* * catalog start using globals jsr getctrl ;waste ctrl char jsr getargs docat lm nlines,#0 first ifeq args,usepfx ;see if there is a path here oks la pdopen+1,args argthere la pdgetinf+1,args jsr chkkey get_info pdgetinf ;see if path is available bcs err1 ;error finding path lm unit,lastdev ;stash last dev jsr chkkey lda pdgetinf+4 cmp #$f ;is argument a directory? bne badtyp ;nope --> badtyp lda args+1 cmp #'/'-128 ;is argument a volume name? beq okb ;yes --> skip prefix display la