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


Forums > C64 Coding > Kernal save (again)
2018-10-08 13:00
JackAsser

Registered: Jun 2002
Posts: 1472
Kernal save (again)

After calling JSR $FFD8 to save a file the motor keeps spinning and the file isn't really "finalised". Works fine with Jiffy DOS, but not using the regular Kernal.

When SAVE returns I immediately throw out the kernal again and take over the system. Is there a call I need to make to "shut it down" properly or wait for it to complete the operation? Feels like some kind of race condition to me..
 
... 8 posts hidden. Click here to view all posts....
 
2018-10-08 14:50
JackAsser

Registered: Jun 2002
Posts: 1472
Narrowing down. :) Totally reproducible from basic.

10 REM STUPID DRIVE

SAVE "TEST",8:POKE 56576,63

This will keep the drive motor on indefinitely.
2018-10-08 14:51
JackAsser

Registered: Jun 2002
Posts: 1472
So, follow up question. When is it safe to touch $dd00?!
2018-10-08 14:55
JackAsser

Registered: Jun 2002
Posts: 1472
Oh well, I didn't need to touch $dd00 after the SAVE anyway so I removed it and now it works. But still... weird. A good polling solution would be much appreciated.
2018-10-08 16:43
TWW

Registered: Jul 2009
Posts: 444
Hello

This from a piece of code from somewhere which might be of help:

Init:
    // ========================
    // Serial Bus Clock Pulse Output

    lda $dd00
    ora #$13
    sta $dd00

InitializeDrive:
        ldx #6
    !:  lda SetParameters,x
        sta $b7,x            // Set SETLFS & SETNAM
        dex
        bpl !-
        jsr $ffc0
        lda #$0f
        jsr $ffc3
        rts

    SetParameters:
        .byte $01            // Length of Filename
        .byte $0f            // Logical File Number
        .byte $6f            // Channel
        .byte $08            // Device
        .word FormatName
    FormatName:
        .text "I"


        //---------------------------------------------------------------------
        // Save memory to a file
        //
        // A = File Number/Pointer

    SaveFile:
        asl                            // A = File Pointer x 2
        tax                            // X = File Pointer x 2
        lda $01
        pha                            // Preserve Memory Configuration
        lda #$36
        sta $01                        // BANK KERNAL+IO+RAM
        lda $d015
        pha
        lda #$00
        sta $d015
        lda FileLocationRAM_End,x
        sta !SMC1++1                   // File Save Memory Stop LoByte
        lda FileLocationRAM_End+1,x
        sta !SMC2++1                   // File Save Memory Stop HiByte
        lda FileLocationRAM_Start,x
        sta ZP_Vector1Lo               // File Save Memory Start LoByte
        lda FileLocationRAM_Start+1,x
        sta ZP_Vector1Hi               // File Save Memory Start HiByte
        ldy FileNameList+1,x           // Pointer to Filename LoByte
        lda FileNameList,x             // Pointer to Filename HiByte
        tax
        lda #$03                       // All filenames are 3 characters long
        jsr $ffbd                      // SETNAM
        lda #$00
        tay
        ldx #$08                       // Device Number
        jsr $ffba                      // SETLFS
    !SMC1:
        ldx #$00
    !SMC2:
        ldy #$00
        lda #ZP_Vector1                // Start Address (ZP_Vector1)
        jsr $ffd8                      // SAVE
        pla
        sta $d015
        pla
        sta $01
        rts

FileLocationRAM_Start:
        .word $c000, $c000, $c000, $c000, $c000, $c000, $c000, $c000
        .word $c000, $c000, $c000, $c000, $c000, $c000, $c000, $c000
        .word $c000, $c000, $c000, $c000, $c000, $c000, $c000, $c000
        .word $c000, $c000, $c000, $c000, $c000, $c000, $c000, $c000
        .word $c000, $c000, $c000, $c000, $c000, $c000, $c000
FileLocationRAM_End:
        .word $c080, $c080, $c080, $c080, $c080, $c080, $c080, $c080
        .word $c080, $c080, $c080, $c080, $c080, $c080, $c080, $c080
        .word $c080, $c080, $c080, $c080, $c080, $c080, $c080, $c080
        .word $c080, $c080, $c080, $c080, $c080, $c080, $c080, $c080
        .word $c080, $d000, $c7b0, $c7b0, $c7b0, $c7b0, $c7b0
FileNameList:
        .word FileName00, FileName01, FileName02, FileName03, FileName04, FileName05, FileName06, FileName07
        .word FileName08, FileName09, FileName0a, FileName0b, FileName0c, FileName0d, FileName0e, FileName0f
        .word FileName10, FileName11, FileName12, FileName13, FileName14, FileName15, FileName16, FileName17
        .word FileName18, FileName19, FileName1a, FileName1b, FileName1c, FileName1d, FileName1e, FileName1f
        .word FileName20, FileName21, FileName22, FileName23, FileName24, FileName25, FileName26
FileName00:  .text "T00"
FileName01:  .text "W00"
FileName02:  .text "W01"
FileName03:  .text "W02"
FileName04:  .text "W03"
FileName05:  .text "W04"
FileName06:  .text "W05"
FileName07:  .text "W06"
FileName08:  .text "W07"
FileName09:  .text "W08"
FileName0a:  .text "W09"
FileName0b:  .text "W0A"
FileName0c:  .text "W0B"
FileName0d:  .text "W0C"
FileName0e:  .text "W0D"
FileName0f:  .text "W0E"
FileName10:  .text "W0F"
FileName11:  .text "W80"
FileName12:  .text "W81"
FileName13:  .text "W82"
FileName14:  .text "W83"
FileName15:  .text "W84"
FileName16:  .text "W85"
FileName17:  .text "W86"
FileName18:  .text "W87"
FileName19:  .text "W88"
FileName1a:  .text "W89"
FileName1b:  .text "W8A"
FileName1c:  .text "W8B"
FileName1d:  .text "W8C"
FileName1e:  .text "W8D"
FileName1f:  .text "W8E"
FileName20:  .text "W8F"
FileName21:  .text "WFF"
FileName22:  .text "R00"
FileName23:  .text "R01"
FileName24:  .text "R02"
FileName25:  .text "R03"
FileName26:  .text "R04"


Then again maybee not...
2018-10-08 17:11
JackAsser

Registered: Jun 2002
Posts: 1472
TWW: try set dd00 after the jsr to save. No, this is not helpful at all. ;) saving per se is not the problem.

The ”problem” is touching dd00 immediatly after save is not safe and imho a Kernal bug
2018-10-08 17:29
tlr

Registered: Sep 2003
Posts: 1198
Quote: TWW: try set dd00 after the jsr to save. No, this is not helpful at all. ;) saving per se is not the problem.

The ”problem” is touching dd00 immediatly after save is not safe and imho a Kernal bug


Don't expect an official patch anytime soon... ;)
2018-10-08 17:29
JackAsser

Registered: Jun 2002
Posts: 1472
Quote: Don't expect an official patch anytime soon... ;)

Hehe no. I just avoid it.
2018-10-08 17:30
cadaver

Registered: Feb 2002
Posts: 1072
Can you modify just the videobank bits, which should be safe? (ie. lda, and/or, sta). That way the ATN line is left alone, and the drive can't interpret the change as a new incoming command.
2018-10-08 17:39
JackAsser

Registered: Jun 2002
Posts: 1472
Quote: Can you modify just the videobank bits, which should be safe? (ie. lda, and/or, sta). That way the ATN line is left alone, and the drive can't interpret the change as a new incoming command.

Yes. Lda, and, ora, sta seems fine.
2018-10-08 18:15
JackAsser

Registered: Jun 2002
Posts: 1472
Quote: Yes. Lda, and, ora, sta seems fine.

Which makes it my bug.. :)
Previous - 1 | 2 - Next
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
AuMTRoN
Mr Ammo/SCS*TRC
Kickback/G★P/Venom
sailor/Triad
XmikeX
Guests online: 21
Top Demos
1 Uncensored  (9.7)
2 Comaland 100%  (9.7)
3 Unboxed  (9.7)
4 Edge of Disgrace  (9.7)
5 Coma Light 13  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.6)
8 Wonderland XII  (9.6)
9 X Marks the Spot  (9.6)
10 C=Bit 18  (9.6)
Top onefile Demos
1 Arok 20 Invitation  (9.6)
2 FMX Music Demo  (9.6)
3 Daah, Those Acid Pil..  (9.6)
4 Pandemoniac Part 2 o..  (9.5)
5 Rewind  (9.5)
6 Party Horse  (9.4)
7 Dawnfall V1.1  (9.4)
8 Crystal Gazer  (9.4)
9 Merry Xmas 2017  (9.4)
10 Dawnfall  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.3)
5 The Transfer Team  (9.3)
Top Coders
1 Axis  (9.8)
2 CRT  (9.8)
3 Graham  (9.8)
4 Trap  (9.8)
5 Crossbow  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.071 sec.