| |
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? |
|
| |
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... |
| |
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! |
| |
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? ;-) |
| |
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. |
| |
Mace
Registered: May 2002 Posts: 1799 |
Thanks, will try that (too). |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
http://cadaver.homeftp.net/rants/irqload.htm |
| |
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
|
| |
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). |
| |
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. |
| |
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^^ |