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 > Coding for the floppy drive (Flexloader)
2012-11-10 21:47
Mace

Registered: May 2002
Posts: 1799
Coding for the floppy drive (Flexloader)

On Codebase64, there's the Flexloader, from Jayce/Focus.
It's a short IRQ/fastloader that I'm investigating to get some knowledge of coding for the floppy drive.

There's a part where this happens:
         .
         .
         .
fopen1   lda fstt,y
         jsr $ffa8
         iny
         cpy #$20                  ; why 32 bytes?!
         bne fopen1
         .
         .
         .
fstt     .byte $4d,$2d,$45,$05,$02 ; M-E $0205
         cli
         lda $f9
         asl a
         tax
         lda $06,x
         sta $08
         lda $07,x
         sta $09
         lda #$80
         sta $01
         jmp $030d


I understand that the bytes are sent to the drive's command string buffer @ $0200 and so $0205 is de CLI in that piece of code.
The sequence is 25 bytes long, however. So why are 32 bytes being sent?
Or is that just a glitch in the code?
2012-11-11 01:35
Mr Wegi
Account closed

Registered: Jul 2009
Posts: 25
32 bytes - it's maybe a habbit or for possiblity extend this code till max 32 bytes - this is not a glitch for me, maybe a bit unprecision...
2012-11-11 03:06
Burglar

Registered: Dec 2004
Posts: 1101
why 32 bytes? when you send data to the drive, there's a limit of how many bytes you can send in one go. its probably 32 bytes, or a bit more (dunno), before you have to sync again.

and its not Jayce's loader, he just copied stuff (I guess from GI Joe loader). still, gi joe loader was the basis of all irq loaders, so its a good place to start.

its hella slow though!
2012-11-11 08:21
Mace

Registered: May 2002
Posts: 1799
Thanks.
Speed is not the goal, it's just to learn how stuff works.

I have Krill's loader right here, but it's just TOO MUCH code to analyse :-)

BTW, can someone put a speedsaver on Codebase64, please? ;-)
2012-11-11 08:56
Urban Space Cowboy

Registered: Nov 2004
Posts: 45
If you'll settle for code here on CSDB instead (haha) then try Explorer/Agony's saver from Remake.
2012-11-11 09:02
Mace

Registered: May 2002
Posts: 1799
Thanks, will try that (too).
2012-11-11 17:15
MagerValp

Registered: Dec 2001
Posts: 1078
http://cadaver.homeftp.net/rants/irqload.htm
2012-11-11 17:42
sailor

Registered: Jan 2002
Posts: 90
...you can send max 32 bytes at a time, call it a bug or a feature :)

if your driveside code is bigger, you need to make a loop and increase pointers

Regards
Jani
2012-11-11 19:09
Frantic

Registered: Mar 2003
Posts: 1648
....or use Krill's fixup irqsaver from 2000 or so. Search for fixup here on csdb. Krill's saver uses the drive kernal to allocate new blocks and update the dir when adding a new file to the directory.

Magervalp's ULoad3 also includes file save functionality, but that one is only able to overwrite existing files with new data (for saving config files, savegame-files, and stuff like that, with constant size).
2012-11-11 19:30
Mace

Registered: May 2002
Posts: 1799
Choice enough, I reckon :-)

I'm dusting of my coding skill (again), so let me first fumble with Flexloader a bit (a bit, 1 bit... hahaha, uh, oh... sorry, accidental pun ;-) ).
After that I'd say Cadaver's rants are a good read.

In the end we always have Krill's loader, of course ;-)

Thanks again, for the ideas.
2012-11-11 20:16
TWW

Registered: Jul 2009
Posts: 545
The 32 byte limit is due to the size of the receive buffer on the 1541 (As I understand it). It's 40 bytes total but 6 bytes is used for the command (M-W+mem+#bytes) so you can in fact send 34 bytes. However 32 is one of the magic numbers so I guess that's why.

Alternatively, you can use a more direct way to upload to the drive:



    .var DriveCommandMWE  = List().add("M-E", DriveRAM1+[DriveCode1-DriveCmdMWE])  // Memory Write&Execute command

IRQLoaderInit:

    // Configure SETLFS (File and secondary adress number = 15 & Device number = 8)
    lda #15
    sta $b9                            // Channel Number (15 is used for sending commands to the drive).
    sta $b8                            // File Number (15 set as logical file number (numbers between 1 and 127 are valid)).
    lda #8
    sta $ba                            // Device Number (8 is the default).

    // Configure SETNAM (Send M-WE command to the Diskdrive)
    lda #DriveCode1_End - DriveCmdMWE  // Size of Command + Code
    sta $b7                            // ZP: Length of the Drive Command String / Filename
    lda #<DriveCmdMWE
    sta $bb                            // ZP: Drive Command String / Filename Lo-Pointer
    lda #>DriveCmdMWE
    sta $bc                            // ZP: Drive Command String / Filename Hi-Pointer

    // opens the file and executes the code
    jsr $f34a                          // KERNAL: open


DriveCmdMWE:
    .text DriveCommandMWE.get(0) .word DriveCommandMWE.get(1) .byte DriveCode1_End - DriveCode1

DriveCode1:

XXXX Code or data you wish to upload goes here.

DriveCode1_End:




All smacked in via KickAssembler ofcourse :-) You'll need to define the DriveRAM1 var to where you want it sent.

PS. Still in Beta phase so don't blame me^^
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
Guests online: 95
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

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