Added error messages

This commit is contained in:
Bill Chatfield 2024-02-05 13:14:58 -05:00
parent d564d8d7dd
commit 903b810f1b
2 changed files with 274 additions and 40 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
MORE
MORE.dsk
_FileInformation.txt
*.swp

308
more.S
View File

@ -31,7 +31,7 @@ FREEBUFR EQU $BEF8 ;FREE BUFFER
* PRODOS ENTRY POINT
PRODOS EQU $BF00 ;MACHINE LANG IFACE (MLI)
PRODOS_MLI EQU $BF00 ;MACHINE LANG IFACE (MLI)
* MEMORY LOCATIONS
*
@ -60,8 +60,8 @@ BUFSIZE .EQ $00FF
SCR.HGHT .EQ 24 ;SCREEN HEIGHT
*
* DEBUGGING
*
TRACE .EQ 0
TRACE EQU 1
********************************
* *
@ -169,30 +169,38 @@ MAIN CLD ;CLEAR DECIMAL FLG, AVOID CRASH
>PUTS PROMPT
JSR GETLN1 ;LENGTH IN X, CR AT END
CPX #0 ;IS THE LENGTH ZERO?
BNE CONT1 ;USER JUST PRESSED RETURN
JMP :END
CONT1 CPIN FILENAME ;COPY "IN" BUF TO FILENAME
BNE :CONT1 ;USER JUST PRESSED RETURN
JMP END
:CONT1 CPIN FILENAME ;COPY "IN" BUF TO FILENAME
DO TRACE
JSR PRSTRBYTES
JSR GETLN
FIN
*
* GET FILE I/O BUFFER FOR OPEN CALL
*
LDA #4 ;FOUR 256 BYTE PAGES = 1KB
JSR GETBUFR ;GET BUF FROM BASIC.SYSTEM
BCC CONT2
JMP :OBUFERR ;CARRY CLEAR MEANS NO ERROR
CONT2 STA OBUFADDR+1 ;GETBUFR RETURNS HIBYTE IN A
BCC :CONT2 ;CARRY CLEAR MEANS NO ERROR
JSR OBUFERR
JMP END
:CONT2 STA OBUFADDR+1 ;GETBUFR RETURNS HIBYTE IN A
LDA #0 ;PREPARE
STA OBUFADDR ;LOBYTE IS 0 B/C ADDR OF PAGE
*
* OPEN FILE
*
JSR PRODOS
JSR PRODOS_MLI
DB OPENCMD
DA OPENPRMS
BNE :OPENERR
BEQ CONT3
JSR OPENERR
JMP :FREEOBUF
*
* COPY FILE NUMBER FROM OPEN PARAMETERS TO READ AND CLOSE
*
LDA OPENFNUM
CONT3 LDA OPENFNUM
STA READFNUM
STA CLOSFNUM
*
@ -200,8 +208,10 @@ CONT2 STA OBUFADDR+1 ;GETBUFR RETURNS HIBYTE IN A
*
LDA #1 ;ONE 256 BYTE BUFFER
JSR GETBUFR ;CALL BASIC.SYSTEM SUB
BCS :RBUFERR ;CARRY SET MEANS ERROR
STA RBADDR+1 ;STORE HI-BYTE
BCC CONT4
JSR RBUFERR ;CARRY SET MEANS ERROR
JMP :CLOSFILE
CONT4 STA RBADDR+1 ;STORE HI-BYTE
STA ZP_A1H ;FOR 0-PAGE INDIRECTION
LDA #0 ;0 FOR LO-BYTE
STA RBADDR ;STORE IT
@ -214,16 +224,30 @@ CONT2 STA OBUFADDR+1 ;GETBUFR RETURNS HIBYTE IN A
* CLEANUP
*
JSR FREEBUFR ;FREE READ BUFFER
JMP :CLOSFILE ;SKIP OVER READ BUF ERR HANDLER
:RBUFERR JSR ERRPROC ;HANDLE ERR GETTING READ BUF
:CLOSFILE JSR PRODOS ;CLOSE THE FILE
:CLOSFILE JSR PRODOS_MLI ;CLOSE THE FILE
DB CLOSCMD
DA CLOSPRMS
BEQ :FREEOBUF
JSR CLOSERR
:OPENERR STA ERRCODE
:FREEOBUF JSR FREEBUFR ;FREE OPEN I/O BUFFER
END NOP
RTS
********************************
* *
* END OF MAIN - PROGRAM EXIT *
* *
********************************
********************************
* *
* HANDLE ERROR WHEN OPENING *
* FILE *
* *
********************************
OPENERR STA ERRCODE
PUTS OERRMSG
PUTS FILENAME
LDA #"'"
@ -232,10 +256,99 @@ CONT2 STA OBUFADDR+1 ;GETBUFR RETURNS HIBYTE IN A
JSR COUT
LDA ERRCODE
JSR ERRPROC
:FREEOBUF JSR FREEBUFR ;FREE OPEN I/O BUFFER
JMP :END
:OBUFERR JSR ERRPROC
:END NOP
RTS
********************************
* *
* HANDLE ERROR WHEN CLOSING *
* FILE *
* *
********************************
CLOSERR STA ERRCODE
PUTS CERRMSG
PUTS FILENAME
LDA #"'"
JSR COUT
LDA #":"
JSR COUT
LDA ERRCODE
JSR ERRPROC
RTS
********************************
* *
* HANDLE ERROR WHEN REQUESTING *
* READ BUFFER *
* *
********************************
RBUFERR STA ERRCODE
PUTS RBERRMSG
LDA #":"
JSR COUT
LDA ERRCODE
JSR ERRPROC
RTS
********************************
* *
* HANDLE ERROR WHEN REQUESTING *
* READ BUFFER *
* *
********************************
OBUFERR STA ERRCODE
PUTS OBERRMSG
LDA #":"
JSR COUT
LDA ERRCODE
JSR ERRPROC
RTS
********************************
* *
* PRINT "IN" BUFFER *
* *
********************************
PRINT_IN
PUSHY
LDA #"X"
JSR COUT
LDA #"="
JSR COUT
TXA
JSR PRBYTE
JSR CROUT
LDY #0
:LOOP CPY #255
BEQ :ENDLOOP
LDA IN,Y
JSR PRBYTE
LDA #" "
JSR COUT
INY
JMP :LOOP
:ENDLOOP JSR CROUT
POPY
RTS
********************************
* *
* PRINT STRING BYTES *
* *
********************************
PRSTRBYTES
PUSHY
LDY #0
:LOOP CPY #255
BEQ :ENDLOOP
LDA FILENAME,Y
JSR PRBYTE
LDA #" "
JSR COUT
INY
JMP :LOOP
:ENDLOOP JSR CROUT
POPY
RTS
********************************
@ -250,7 +363,7 @@ VIEWFILE
FIN
SET1 LINENUM ;INIT LINE NUMBER
:LOOP JSR PRODOS ;CALL PRODOS TO READ FILE
:LOOP JSR PRODOS_MLI ;CALL PRODOS TO READ FILE
DB READCMD ;SPECIFY PRODOS READ COMMAND
DA READPRMS ;READ PARAMETERS
BNE :READERR
@ -298,7 +411,7 @@ WRITEBUF
.3 >POPY
DO TRACE
>PUTS EXVIEW
PUTS EXWRITEBUF
FIN
RTS
@ -393,14 +506,105 @@ ERASEBAR
ERRPROC
STA ERRCODE
CMP #0
BEQ :NOERR
CMP #EOFERR
BEQ :NOERR
PUTS ERRTXT
BNE :EEOF
JMP :END
:EEOF CMP #EOFERR
BNE :E01
JMP :END
:E01 CMP #1
BNE :E04
PUTS E01MSG
:E04 CMP #4
BNE :E25
PUTS E04MSG
:E25 CMP #$25
BNE :E27
PUTS E25MSG
:E27 CMP #$27
BNE :E28
PUTS E27MSG
:E28 CMP #$28
BNE :E2B
PUTS E28MSG
:E2B CMP #$2B
BNE :E2E
PUTS E2BMSG
:E2E CMP #$2E
BNE :E40
PUTS E2EMSG
:E40 CMP #$40
BNE :E42
PUTS E40MSG
:E42 CMP #$42
BNE :E43
PUTS E42MSG
:E43 CMP #$43
BNE :E44
PUTS E43MSG
:E44 CMP #$44
BNE :E45
PUTS E44MSG
:E45 CMP #$45
BNE :E46
PUTS E45MSG
:E46 CMP #$46
BNE :E47
PUTS E46MSG
:E47 CMP #$47
BNE :E48
PUTS E47MSG
:E48 CMP #$48
BNE :E49
PUTS E48MSG
:E49 CMP #$49
BNE :E4A
PUTS E49MSG
:E4A CMP #$4A
BNE :E4B
PUTS E4AMSG
:E4B CMP #$4B
BNE :E4C
PUTS E4BMSG
:E4C CMP #$4C
BNE :E4D
PUTS E4CMSG
:E4D CMP #$4D
BNE :E4E
PUTS E4DMSG
:E4E CMP #$4E
BNE :E50
PUTS E4EMSG
:E50 CMP #$50
BNE :E51
PUTS E50MSG
:E51 CMP #$51
BNE :E52
PUTS E51MSG
:E52 CMP #$52
BNE :E53
PUTS E52MSG
:E53 CMP #$53
BNE :E55
PUTS E53MSG
:E55 CMP #$55
BNE :E56
PUTS E55MSG
:E56 CMP #$56
BNE :E57
PUTS E56MSG
:E57 CMP #$57
BNE :E5A
PUTS E57MSG
:E5A CMP #$5A
BNE :E_UNK
PUTS E5AMSG
JMP :END
:E_UNK PUTS E_UNK_MSG
LDA #":"
JSR COUT
LDA ERRCODE
JSR PRBYTE
JSR CROUT
:NOERR NOP
:END JSR CROUT
RTS
********************************
@ -412,13 +616,7 @@ ERRPROC
PROMPT STR "FILE:"
ERRTXT STR "ERROR:"
FILENAME DS $FF
HERE STR "HERE"
HERE2 STR "HERE2"
READRET STR "READRET="
SREADCNT STR "READCNT="
ERRCODE DS 1
READERR DS 1
CLOSERR DS 1
LINENUM DS 1
BAR STR '[RET] LINE [SPC] PAGE [Q]UIT'
USRQUIT DS 1
@ -426,9 +624,45 @@ BUFCHAR DS 1
USRCHAR DS 1
OERRMSG STR "FAILED TO OPEN FILE '"
CERRMSG STR "FAILED TO CLOSE FILE '"
RBERRMSG STR "REQUEST FOR READ BUFFER FAILED"
OBERRMSG STR "REQUEST FOR OPEN BUFFER FAILED"
E00MSG STR "NO ERROR"
E01MSG STR "BAD SYSTEM CALL NUMBER"
E04MSG STR "BAD SYSTEM CALL PARAMETER COUNT"
E25MSG STR "INTERRUPT TABLE FULL"
E27MSG STR "I/O ERROR"
E28MSG STR "NO DEVICE CONNECTED"
E2BMSG STR "DISK WRITE PROTECTED"
E2EMSG STR "DISK SWITCHED"
E40MSG STR "INVALID PATHNAME"
E42MSG STR "MAXIMUM NUMBER OF FILES OPEN"
E43MSG STR "INVALID REFERENCE NUMBER"
E44MSG STR "DIRECTORY NOT FOUND"
E45MSG STR "VOLUME NOT FOUND"
E46MSG STR "FILE NOT FOUND"
E47MSG STR "DUPLICATE FILENAME"
E48MSG STR "VOLUME FULL"
E49MSG STR "VOLUME DIRECTORY FULL"
E4AMSG STR "INCOMPATIBLE FILE FORMAT OR PRODOS DIRECTORY"
E4BMSG STR "UNSUPPORTED STORAGE TYPE"
E4CMSG STR "END OF FILE ENCOUNTERED"
E4DMSG STR "POSITION OUT OF RANGE"
E4EMSG STR "FILE ACCESS ERROR OR FILE LOCKED"
E50MSG STR "FILE IS OPEN"
E51MSG STR "DIRECTORY STRUCTURE DAMAGED"
E52MSG STR "NOT A PRODOS VOLUME"
E53MSG STR "INVALID SYSTEM CALL PARAMETER"
E55MSG STR "VOLUME CONTROL BLOCK TABLE FULL"
E56MSG STR "BAD BUFFER ADDRESS"
E57MSG STR "DUPLICATE VOLUME"
E5AMSG STR "FILE STRUCTURE DAMAGED"
E_UNK_MSG STR "UNKNOWN ERROR CODE"
ENVIEW STR 'ENTERING VIEWFILE'
EXVIEW STR 'EXITING VIEWFILE'
EXWRITEBUF STR 'EXITING WRITEBUF'
ENSTATB STR 'ENTERING STATUSBAR'
EXSTATB STR 'EXITING STATUSBAR'
ENERASEB STR 'ENTERING ERASEBAR'