|
Post by stiggity on Oct 25, 2022 5:54:40 GMT
Hello, I'm back. im aware $90 (ST) is the zp location for the disk channels status. Well, no matter how I open an existing file, I get $90=0. Open a non existing file $90 reports 0. i cannot seem to retrieve sometime like "62"? or even a crude error #. Like, if 62 = some other value. I am opening program files, sequential files, still.. right now, im not sure how to monitor disk access report.
|
|
|
Post by stiggity on Oct 26, 2022 0:19:00 GMT
still hindering me.. i cannot get $90 to report nothing except "0" and posting the source probably wont help...
|
|
|
Post by stiggity on Oct 26, 2022 2:40:49 GMT
2Just a solution a colleague mentioned... must channel#15 be open in order for $90 to function? and if so, how on Gods Green Earth can i open 15,dv,15 in ASM.
|
|
|
Post by c128old on Oct 26, 2022 10:04:06 GMT
You would open 2 files. One does the I/O of bytes, the other is the command channel. This is exactly how you find commodore did this in their implementation, the routines to boot a disk in drive 8 use 2 open channels at the same time. I am not sure what would help you, so I'm including a bunch. Here is an except of the C1541-II manual (page 80)
Imagine we open a file, the MC equivalent of basic: open 3,8,0, "TEST" SETLF = $FFBA ; set logical chl, iec nr and 2nd adress SETNAM = $FFBD ; len and addr of fnam OPEN = $FFC0 ; open logical file CLOSE = $FFC3 ; close logical file CHKIN = $FFC6 ; channel to use for Input CHKOUT = $FFC9 ; channel to use for output CLRCHN = $FFCC ; back to normal channels CHRIN = $FFCF ; one byte from selected channel CHROUT = $FFD2 ; one byte to selected channel
START LDA #4 ; len of fnam LDX #<FNADR ; low bye of fnam LDY #>FNADR ; hi byte JSR SETNAM LDA #3 ; logical file number LDX #8 ; device number LDY #0 ; secondary address JSR SETLFS ; set A,X,Y JSR OPEN ; try to open file so open 3,8,0,"TEST" if this fails, then at this point you must check for carry set and inspect value for A LDX #3 JSR CHKIN ; select file 3 for input if this fails, then at this point you must check for carry set and inspect value for A NEXT JSR CHRIN ; get next byte from file BEQ END ; until finish (ie. A = 0 means end of file) JSR CHROUT ; output to screen JMP NEXT ; END LDA #3 JSR CLOSE JSR CLRCHN RTS
FNADR .BYT "TEST" ; file name --- From the above we see the official document Commodore suggested way to input a stream of bytes from disk. The KERNAL must know what logical file (this is just your favorite number) the file name on a device and 2nd address is you want to open The open command of the file may fail, of course. Note that the example in the C64 Reference manual (equal for c128) is for a 'load' on a file, here it is an 'open'. A 'load' gets the (whole) file to RAM while an 'open' means you end up looping to get the data yourself (until null) For the C128, the 'load' allows for an improved speed to get at data!
Also, for the c128 one should (at some point) indicate the BANK (like the basic BANK command) one wants to use. For instance: LDX #0 JSR SETBNK ; $FF68 This setting of the bank must be done before the IO calls. For instance your filename might be in a different banking (say, ram1) and the kernal will retrieve its info from there if you tell it to use that config.
Back to your question about the error handling. Assuming you use 'OPEN', this will attempt to send to the drive the information about the file you wish to work with. If you are successful in sending that info to the drive (because it is actually connected and on) then this will work fine. Of course, the drive will conclude things didn't work but unless you ask, you won't know (since it is its own computer). The communication to the drive may fail as well. Consider you set up the information for a file and at some point to tell the KERNAL to use the logical file (let's say you use logical file number 7, lucky seven), you have to connect "device 8" and "secondary channel 0" to that. Once you did that, you will find that an attempt to do a "CHKOUT" or "CHKIN" in that logical number may fail: LDX #7 ; a logical number you previously have set up with SETLFS (A=7, X=8, Y=0) JSR CHKOUT ; if your drive isn't on, this returns with Carry Set. If all is well, Carry will be Clear. BCS hdlerror ; Carry Set means error (A = error code) RTS
hdlerror: ; when CHKOUT failed (that is, CHKOUT returned with carry set) ; Fail means A = 0, 3, 5, 7 ; 0 = stop key pressed (user) ; 3 = file not open ; 5 = device not present ; 7 = file not input (CHKIN) or output (CHKOUT) CMP #5 ; device not present BEQ retnok CMP #3 ; file not open (no disk?) BNE tryinit retnok: SEC ; set carry to indicate error RTS ; return (A = 3 or 5, in any case you will need to read the error channel)
CMDSTR: .BYT "I"
tryinit: ; send an "I" command to the drive (clears errors and read BAM) LDA #23 JSR CLOSE ; close file first (just in case) LDA #0 JSR SETBNK ; kernal bank LDA #1 ; len of cmd to send LDX #<CMDSTR ; low bye of fnam LDY #>CMDSTR ; hi byte JSR SETNAM LDA #23 ; logical file for command channel (just some number, could be 15 too) ; using 15 is customary and saves because A == Y LDX #8 ; device 8 LDY #15 ; command channel as secondary JSR SETLFS ; set A,X,Y JSR OPEN ; try to open file so open 23,8,15,"I" BCS tstA ; drive responds. So now you CHKIN to file 23 and read out the string LDX #23 JSR CHKIN NEXTch15 JSR CHRIN ; get next byte from cmd-channel BEQ END ; until finish (ie. A = 0 means end of transmission) JSR CHROUT ; output to screen JMP NEXTch15 RTS
tstA: CMP #5 ; no drive BEQ print to tell user no drive RTS
|
|
|
Post by stiggity on Oct 26, 2022 22:35:56 GMT
i0 clears the error channel, and believe it or not, I'm already working with the 1581 users guide's example on how to open a file, and read until "0" I REALLY appreciate the time, and personal touch you put into that reply, but I still cannot read the error channel.. must I open #15 first and then this file#3, device #8??? I'm attempting to construct an all purpose routine that once jumped too, checks for any $90 <> 0, and reports back. Unfortunately, the perfect example you left, clears the value I'm interested in finding.. I see your example uses "i" ok? is "@" for read error channel? I've dissected the data retrieved during jsr $chrin, put it in a buffer, and then strung the buffer.. still all i need to know if the first 2 bytes read from the error channel is "00", anything else, i branch.... sorry to be such an idiot. and Thanks A lot!!! i appreciate your help...
|
|
|
Post by stiggity on Oct 26, 2022 22:39:01 GMT
does it matter which register gets loaded to setbank?? u show LDX, then later.. LDA, ldx#0 , jsr setbnk or lda#0, jsr setbnk?? i've dealt with the bank # in other areas , but im more than likrly not doing it right...
|
|
|
Post by stiggity on Oct 27, 2022 1:26:02 GMT
I dont know what doing this is called, but!! instead of opening the file, and checking for a 62, 0 etc.. i opened the directory and searched for the file.. grabbed filetype. If filetype = "p", or filetype = "s" file exists. if filetype = "" file doesn't exist, and branch accordingly.. jeez.. im trying not to use kernal calls, due to the whole thing banks off the irq, and other areas, but kernal calls need each call banked back in, called, and return.. sort of like a bunch of tabs.. welps, "c128old!!!!" thank you very very much!!! i couldnt figure out utilizing the error channel, so i worked around it... for now!!
|
|