NEW PREFIX /A2OSX.BUILD AUTO 4,1 .LIST OFF .OP 65C02 .OR $2000 .TF BIN/MORE *-------------------------------------- .INB INC/MACROS.I .INB INC/A2OSX.I .INB INC/MLI.I .INB INC/MLI.E.I *-------------------------------------- ZPPTR1 .EQ ZPBIN ZPBufPtr .EQ ZPBIN+2 *-------------------------------------- * File Header (16 Bytes) *-------------------------------------- CS.START cld jmp (.1,x) .DA #$61 6502,Level 1 (65c02) .DA #1 BIN Layout Version 1 .DA #0 S.PS.F .DA #0 .DA CS.END-CS.START CS .DA DS.END-DS.START DS .DA #16 SS .DA #4 ZP .DA 0 *-------------------------------------- * Relocation Table *-------------------------------------- .1 .DA CS.INIT .DA CS.RUN .DA CS.DOEVENT .DA CS.QUIT L.MSG.USAGE .DA MSG.USAGE L.MSG.CR .DA MSG.CR L.MSG.LINENUM .DA MSG.LINENUM L.MSG.Pause .DA MSG.Pause .DA 0 *-------------------------------------- CS.INIT clc rts *-------------------------------------- CS.RUN .1 >INC.G ArgCount >SYSCALL ArgV bcs .7 >STYA ZPPtr1 lda (ZPPtr1) cmp #'-' bne .4 ldy #1 lda (ZPPtr1),y ldx OptionList .2 cmp OptionList,x beq .3 dex bne .2 .99 >PUSHBI 0 >LDYA L.MSG.USAGE >SYSCALL printf lda #E.SYN sec .9 rts .3 ldy OptionVars-1,x lda #$80 sta (pData),y bra .1 .4 >LDA.G hFile bne .99 >LDYA ZPPtr1 jsr CS.RUN.OPEN bcs .9 bra .1 scan for any other args .7 >LDA.G bHelp beq .8 jsr .99 lda #0 rts .8 >LDYAI 256 >SYSCALL GetMem bcs .9 >STYA ZPBufPtr txa >STA.G hBuf CS.RUN.LOOP >SLEEP >LDA.G hFILE bne .1 ldy #S.PS.hStdErr lda (pPS),y >SYSCALL GetC bra .2 .1 >SYSCALL GetChar .2 bcs .10 no char cmp #$03 Ctrl-C bne .3 sec Abort.... rts .3 cmp #C.SPACE bne .10 >LDA.G bPause eor #$ff sta (pData),y bne .8 .10 >LDA.G bPause bne .8 Pause... >LDA.G hFile bra .12 .11 ldy #S.PS.hStdIn lda (pPS),y bra .12 .12 pha >PUSHWI 256 >PUSHW ZPBufPtr pla >SYSCALL fgets bcs .13 >INCW.G LineNum >LDA.G LineCount bne .22 >LDA.G bPage beq .22 lda #C.FF >SYSCALL putchar .22 jsr CS.RUN.PRINT >INC.G LineCount cmp #23 bne .8 lda #0 sta (pData),y dec >STA.G bPause >PUSHBI 0 >LDYA L.MSG.Pause >SYSCALL printf .8 jmp CS.RUN.LOOP .13 cmp #MLI.E.EOF bne .9 lda #0 Exit with no Error .9 sec rts *-------------------------------------- CS.RUN.OPEN pha >PUSHWI 0 Aux type >PUSHBI S.FI.T.TXT >PUSHBI O.RDONLY+O.TEXT pla >SYSCALL FOpen bcs .9 >STA.G hFile .9 rts *-------------------------------------- CS.RUN.PRINT clc >LDA.G bLineNum bpl .1 >PUSHW.G LineNum >PUSHBI 2 >LDYA L.MSG.LINENUM >SYSCALL printf bcs .9 .1 >PUSHBI 0 >LDYA ZPBufPtr >SYSCALL printf bcs .9 >PUSHBI 0 >LDYA L.MSG.CR >SYSCALL printf .9 rts *-------------------------------------- CS.QUIT >LDA.G hBuf beq .1 >SYSCALL FreeMem .1 >LDA.G hFILE beq .2 >SYSCALL FClose .2 .8 clc rts *-------------------------------------- CS.DOEVENT sec rts *-------------------------------------- CS.END *-------------------------------------- OptionList >PSTR "NnHhPp" OptionVars .DA #bLineNum,#bLineNum,#bHelp,#bHelp,#bPage,#bPage *-------------------------------------- MSG.USAGE .AS "Usage : MORE \r\n" .AS " -H : This help screen\r\n" .AS " -N : Number all output lines\r\n" .AS " -P : Page mode, no scroll" MSG.CR .AZ "\r\n" MSG.LINENUM .AZ "%5D:" MSG.Pause .AZ "\e[7m --- More --- \e[0m\r" *-------------------------------------- .DUMMY .OR 0 DS.START ArgCount .BS 1 hFile .BS 1 LineCount .BS 1 LineNum .BS 2 bPause .BS 1 bLineNum .BS 1 bPage .BS 1 bHelp .BS 1 ArgIndex .BS 1 hBuf .BS 1 DS.END .ED *-------------------------------------- MAN SAVE /A2OSX.SRC/BIN/MORE.S ASM