Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Disk routine problem (or not?)
2005-06-23 10:44
Majikeyric

Registered: Sep 2002
Posts: 83
Disk routine problem (or not?)

Hello everybody,

I have coded a routine using standard KERNAL IO calls : OPEN/CHKIN/CHRIN...etc.
to just load simple files into memory.

It works with Vice and my HD (IDE64+SCPU system) but when I test it on a floppy, it doesn't ?!!
I really wonder why ??? I gonna turn crazy...

Ok, here is the source (ACME):

; Etablissement d'un nom de fichier pour la routine OPEN

                                lda         #(sNomFichierFin-sNomFichier)
                                ldx         #<sNomFichier
                                ldy         #>sNomFichier
                                jsr         SETNAM

; Etablissement d'un fichier logique

                                lda         #1
                                ldx+1       $ba ; périphérique courant
                                ldy         #0  ; lecture
                                jsr         SETLFS

; Ouverture du fichier logique

                                jsr         OPEN

                                jsr         iLOADER_lireCanalErreur
                                ; ERROR code in A (error channel)

.si05                           bne         .sinon05
.alors05

; Association du fichier logique à un canal d'entrée

                                ldx         #1
                                jsr         CHKIN

                                lda         #<adresseChargement
                                sta+1       wAdresseDestination
                                lda         #>adresseChargement
                                sta+1       wAdresseDestination+1

                                ldy         #0

.tantQue05                      jsr         CHRIN
                                ldx+1       $90

                                sta+1       (wAdresseDestination),y

                                inc+1       wAdresseDestination
.si10                           bne         .finSi10
.alors10                        inc+1       wAdresseDestination+1
.finSi10
                                txa
                                and         #64
                                beq         .tantQue05
.finTantQue05
                                lda+1       wAdresseDestination
                                sta         wAdresseFinChargement
                                lda+1       wAdresseDestination+1
                                sta         wAdresseFinChargement+1

                                lda         #1
                                jsr         CLOSE

                                jmp         .finSi05
.sinon05
                                lda         #2         ; erreur
                                sta         $d021
.finSi05

; Fermeture des canaux d'entrée/sortie et restauration des canaux standards

                                jsr         CLRCHN

                                rts

sNomFichier                     !tx         "test"
sNomFichierFin
wAdresseFinChargement           !wo         0

;---------------------------------------------------------------------------
iLOADER_lireCanalErreur         !zn
; Lecture du canal d'erreur pour savoir si la dernière opération
; d'entrée/sortie s'est bien déroulée.
;
; Sortie :
; .s_bCodeErreur                :   code d'erreur,
;                                   0 si aucune erreur ne s'est produite
;---------------------------------------------------------------------------

; Variables locales

.s_bCodeErreur  = $02

                                ; Sauvegarde des @ de page 0
                                ; utilisées comme variables locales

                                lda+1       .s_bCodeErreur
                                pha

;---------------------------------------------------------------------------

; Ouverture du canal d'erreur

                                lda         #0
                                jsr         SETNAM

                                lda         #15
                                ldx+1       $ba  ; périphérique courant
                                tay              ; canal d'erreur
                                jsr         SETLFS

                                jsr         OPEN

                                ldx         #15
                                jsr         CHKIN

; Récupération du numéro d'erreur

                                jsr         CHRIN
                                asl
                                asl
                                asl
                                asl
                                sta+1       .s_bCodeErreur
                                jsr         CHRIN
                                and         #15
                                ora+1       .s_bCodeErreur
                                sta+1       .s_bCodeErreur

.repeter05                      jsr         CHRIN
.jusqua05                       cmp         #13
                                bne         .repeter05
.finRepeter05

; Fermeture du canal d'erreur

                                lda         #15
                                jsr         CLOSE

;---------------------------------------------------------------------------

                                lda+1       .s_bCodeErreur
                                sta         ._bResultat+1

                                ; Restauration des @ de page 0

                                pla
                                sta+1       .s_bCodeErreur

                                ; Transmission du résultat

._bResultat                     lda         #0
                                rts

;---------------------------------------------------------------------------

adresseChargement


Can you see why this doesn't work with floppy disc drives ???

PLEAAAAASE HELP !!!! ;-)
2005-06-23 10:58
Krill

Registered: Apr 2002
Posts: 2870
Rule 1: always comment your code in English and have English symbol names, especially when posting it in online forums
Rule 2: specify the error. "does not work" is usually not a good hint.

Okay.. so what does e.g. "ldx+1 $ba" mean in ACME? $ba contains the recently-used drive number. is that a sane value in your test environment?
2005-06-23 11:17
Majikeyric

Registered: Sep 2002
Posts: 83
Quote: Rule 1: always comment your code in English and have English symbol names, especially when posting it in online forums
Rule 2: specify the error. "does not work" is usually not a good hint.

Okay.. so what does e.g. "ldx+1 $ba" mean in ACME? $ba contains the recently-used drive number. is that a sane value in your test environment?


1: yes, sorry for that... but 6502 is worldwide ;-)
2: only one byte is loaded from the diskdrive and this one is wrong...

+1 in ACME forces specific addressing mode:

lda+1 $90 is translated into : lda $90
lda+2 $90 is translated into : lda $0090

(this is because I got a SCPU and this routine will be included in some 65816 code).

Yes, $ba is a sane value. And the right drive operates like asked... but wrongly... :-(
2005-06-23 12:56
Majikeyric

Registered: Sep 2002
Posts: 83
Hey! I had the answer from Soci/Singular posting my question directly to the IDE64 mailinglist !!!

-------------
When you close the error channel, it closes all open files on floppy drives. This is annoying, and was later fixed in C128's kernal. When you call CLOSE with the carry flag set there, it won't send "close" to the serial bus, if it was channel 15.


The workaround is to open the error channel at the beginning of your program, and close it after you closed the last open file. (move OPEN and CLOSE out of iLOADER_lireCanalErreur)
-------------

I Didn't know that !!!
Thank you very much Soci !!!
:-)
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Fred/Channel 4
Dr. Doom/RAD
stephan-a
Guests online: 84
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Aliens in Wonderland  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Birth of a Flower  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Offence  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Veto  (9.6)
3 Facet  (9.6)
4 The Sarge  (9.6)
5 Carrion  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.037 sec.