| |
Majikeyric
Registered: Sep 2002 Posts: 83 |
Problem coding my own loading routine
Hi,
I'm not a loading routine programming guru, in fact in so many years that's the fist time I try myself to this...
I have read a lot of manuals and all say that if an error occurs when calling a kernal routine the carry flag is set but it doesn't seem to be really the case, here is my problem when in this little piece of code, there is an error when calling the OPEN routine, the carry is not set ?!! (e.g when opening a non existing file) and the CHKIN call just behind makes the machine crashes... :-(
How can I check if the file was successfully opened ???
lda FilenameLen
ldx #<Filename --> a non existing file
ldy #>Filename
jsr SETNAM
lda #8
ldx $ba
ldy #0
jsr SETLFS
jsr OPEN
bcs ERROR --> carry not set if an error occured ?!!
ldx #8
jsr CHKIN --> crash !!! :-(
I want my loading routine to run on all kind of drives (1541/CMD HD+FD/IDE64...).
Thank you very much !!! |
|
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
you have to read the error channel of the 1541 to retrieve information about disk drive errors. |
| |
Majikeyric
Registered: Sep 2002 Posts: 83 |
Thanks Graham I gonna do like you explain in the file not found error topic ;-) |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
in basic it's like this:
open15,8,15
input#15,nr,ft$,tr,sk
close15
but why would you want those open/close mania in assembler also? those routines only cause a lot of trouble and make everything complicated like hell. |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
some basics in communicating with the disk drive while avoiding all this basic shit:
sending data to the drive:
LDA $BA
JSR $FFB1 ; LISTEN
LDA #$6F ; secondary adress 15 (or $60 is a must!)
JSR $FF93 ; SECLSN
LDY #$00
l:
LDA mw,Y
JSR $FFA8 ; IECOUT
INY
CPY #...
BNE l
JSR $FFAE ; UNLSN
mw:
.text "m-w"
.word $0400
.byte $02
.byte .....
same for receiving data:
LDA $BA
JSR $FFB4 ; TALK
LDA #$6F
JSR $FF96 ; SECTLK
LDY #$00
STY $90 ; clear status
l:
JSR $FFA5 ; IECIN
BIT $90
BVS end ; drive has sent last byte
INY
BNE l
JSR $FFAB ; UNTLK
it's all pretty simple: for reading the error channel simply use the receive routine without sending any command to the drive on that channel before. ofcourse you can still use that open/close routines, but they cause a lot of trouble and crashes... |
| |
White Flame
Registered: Sep 2002 Posts: 136 |
Alternatively, you could avoid a lot of that crap and use the "B-E" drive command to have the drive load up a sector into a buffer and execute it to start your speeder, without having to transfer the data over to the C64 and back. |
| |
cadaver
Registered: Feb 2002 Posts: 1160 |
Hmm.. I guess this topic wasn't about speeders at all?
Anyway, TALK/LISTEN, IECIN/OUT + other direct serial bus access routines are a no-no for IDE64 compatibility. |
| |
Majikeyric
Registered: Sep 2002 Posts: 83 |
I didn't test all that yet but... hooo, doesn't work with IDE64 ?!! humm... What can I do then...
I'm currently working on a project that will require very big files, and the final product won't fit on a single 1541 side, I project to release it on different medias (1541s, FDs, big ZIP archive, maybe CD-ROM for IDE64 card...) and I want it fully compatible with all kind of drives then I won't use any fastloaders... In fact in my loading routine I simply want to test if the file I want to open is here, If not I will send a message like that :
insert disk
for 1541 : #4
for FD : #2
(for HD no problem!) |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
Quote: Hmm.. I guess this topic wasn't about speeders at all?
Anyway, TALK/LISTEN, IECIN/OUT + other direct serial bus access routines are a no-no for IDE64 compatibility.
talk + listen is the most basic stuff some iec hardware should be able to do, and if ide64 is not able to do it... then just throw it into your dustbin because it sucks. |
| |
Stryyker
Registered: Dec 2001 Posts: 468 |
How about resetting ST (lda #$00, sta $90) before you call OPEN. Then after you open, check $90. I can't remember if it is $60 or $40 for file not found. You may need to read a byte. |
| |
cadaver
Registered: Feb 2002 Posts: 1160 |
Well, IDE64 is not an IEC device..
Still, you get most of the same functionality with OPEN,CHKIN/OUT,CHRIN/OUT
This is how I do file open & read with Kernal
lda #filenamelength
ldx #<filename
ldy #>filename
jsr setnam
ldx $ba ;last used device
lda #2 ;file number
ldy #0 ;0 = open for read (1 = for write)
jsr setlfs
jsr open
ldx #2
jsr chkin
No error checking here yet :) as I don't think you'll get the error before trying to read the first byte of the file, so
jsr chrin ;returns file byte in A
ldx $90 ;check status for error/EOF, if zero then everything ok (refer to PRG for status codes)
If you're having crashes, you're doing something wrong :) |
... 12 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 - Next |