Fileloader v2.1 ( 21.01.2013 22:46 )
---------------------------------------------------------------

About this loader:
---------------------------------------------------------------
It's a small fast loader system that works on PAL & NTSC computers 
and it supports most drives & devices.
It's not a irq loader that you want to use in a demo.

How it works:
---------------------------------------------------------------
Loads exomizer crunched files by filename.
Filename input is done by setting $ffbd, and then calling loader.
Loader is installed in the drive each time you try to load a file,
when loading is finished the drive returns to idle mode. This way
you will also have access to the kernal routines to open/close/load/save files using
standard kernal routines.
 
Details:
---------------------------------------------------------------
* It's 2bit loader with a 256 bytes load buffer to gain speed.
* It works on PAL & NTSC computers.
* It works with any device number #6-30
* Autodetects and works with most of the known disk drives 
  and devices for the c64 and c128:
  1541, 1541-II and clones (Oceanic, Ecelerator etc.)
  1570, 1571 (uses 2mhz native mode if possible)
  1581, CMD FD, CMD HD
  IDE64, Ramlink/Ramdrive, sd2iec, uiec and other iec drives (uses kernal loader if enabled)
  Unknown devices will fall back to be using a kernal loader if enabled.
* It loads by filenames.
* You can link several files into one for faster loading.
* It has error checking to allow for multiple disks.
* Files must be crunched with Exomizer 1.1.5 or Exomizer 2.
* Loads to whole RAM area (0000-FFFF).
* Loader code must stay in the area 0000-D000 when loading.

Compiling details:
---------------------------------------------------------------
Source code is compiled with the latest version of 64tass v1.46
Example: 64tass.exe -a boot.tas -o boot.o64

If you get "blah blah not identifed error" then make sure the installer is
compiled first in the source. Or you will have to move fload.cfg
out of installer and place at top of your boot.tas file.

Loader details:
---------------------------------------------------------------
There are 3 loader types available:
1) fload_sloader.tas
   This one can have the screen on to display a text screen or a picture.
   It also needs SEI to be set at all times during the load process.
   Sprites must be off. NMI must be off.
   
2) fload_loader.tas
   This one loads with SEI set and the screen turned off.
   All IRQ's and NMI muset be off.
   Sprites must be off.

3) fload_iloader.tas
   This is the irq loader version. 
   It needs a running $fffe/$ffff irq that can push and pull $01. 
   You should perhaps also setup the $0314/$0315 irq for this.
   It's not a perfect irq loader, because you need to modify the
   source code a little to get it working without stops during the
   drive installation part.
   NMI must be off.
   Sprites must be off.


All loaders are initialized by first setting $ffbd to point to the filename
and then call the loader (with the Y register set if you use numfiles).

Installer details:
---------------------------------------------------------------
fload_installer.tas - drive detection and installer.
fload.cfg           - configuration file to setup installer & loader.

Modify fload.cfg to your needs.

The installer and the loader must be compiled together.
The reason for this is that the installer moves drive code to the loader part.

When you call the installer the screen will go black and be cleared and a 
"fload" message will show at the top.
A successful install will display the drive dos message followed by 00,00.
Any errors will also be displayed.
(You might have to insert the correct disk side and press space to retry?)


Example usage:
---------------------------------------------------------------

                * = $1000
;only call installer once
                jsr fload_install       ;Identify device/drive AND MOVES loader/drive code up in C64 memory.
                sta a                   ;returns axy for custom user treatment
                stx x
                sty y

                lda #$04
                ldx #<filename
                ldy #>filename
                jsr $ffbd
                ldy #2                  ;file contains 2 linked subfile (def_numfiles = 1)
                jsr fload               ;This calls loader directly-
                                        ;NOTE: you may also change $0330/0331 vectors to point to fload
                                        ;.. and then you can call loader with jsr $ffd5
                jmp startgame

filename        .text "boot"

                * = $2000
                .include fload_installer.tas    ;(fload_install)
                
                * = $c800
                .include fload_sloader.tas      ;(fload)


Even more details:
---------------------------------------------------------------
The installer returns the following values after
a successful install:

RETURNS A = 0           ;serial driver
        A = $64         ;kernal driver
RETURNS X = 1-11 or $64 ;actual drivetype in X
RETURNS Y = 0/1         ;if SCPU was detected (only if def_scpu is enabled)

Drivetype Table (X register):

ID_1541         = 1
ID_1570         = 2
ID_1571         = 3
ID_1581         = 4
ID_CMDHD        = 5
ID_CMDFD        = 6
ID_IDE64        = 7
ID_RamLink      = 8
ID_RamDrive     = 9
ID_XIEC         = 10            ;For all IEC devices
ID_KERNAL       = $64           ;For all unknown devices


If the disk drive fails to be detected ( power is off ) you will get a error message.
If the file to be checked is not present on the disk you will get a file not found error. (see fload.cfg)

IDE64 details:
---------------------------------------------------------------
If you want compatability with IDE64 then please note that it will choke on using serial kernal calls(ffa5,ffae etc).
Don't mess up the IO vectors at 031a-0332 for ML games. (some jsr at $ff81,$ff8a might do that)
Don't mess up the basic/IO vectors at 0300-0332 for Basic games.
IDE64 may change and update a few zeropages between $90-$c3.


Copyright and terms of use:
---------------------------------------------------------------
This source code is copyright (c) 2013 6R6/Nostalgia/Shape.
You may use it for free in your own productions as long 
as you don't charge money for it.