iMPdos Public Edition v1.17 - AsT/iMPact 2016-2018
------------

What's iMPdos ? iMPdos is a new rom which allows you to use your xMass Card.
Maximum size is original xMass size, 128 Mb.

1. How & where to install it ?
iMPdos must be installed between rom 1 and 6. (Before Rom 7, in fact!)

When rom is installed, iMPdos will format your x-Mass to detect it properly.
After done, if all is ok, your xMass is detected and rom is actived. 
If not, xMass will not be detected and rom will have to be invisible.

2. How to use iMPdos ?
For the first time, i suggest you to use the |hlp command to display all possibilities.

3. Let's see all the commands.
xMass is located as drive X, so you can use |x command to access xMass drive.

|a : select drive a
|b : select drive b
|x : select x-Mass drive

a. Root & directories


cat or |cat to display directory.

|cd,"/ to go back to root
|cd,".. for previous directory
|cd,"cmp" to go to "cmp" directory

About Root and directories.
Root has a maximum of 512 files, no more.
Each direcotries can accepted up to 62 files max.
You can't do more.

b. Load, run & save files.

|l,"filename" command will load bin/bas files without any memory basic command in first adr saved.
|l,"filename",&4000 will load bin/bas files at #4000.
|r,"file" command will load and run any bin/bas files.

basic command are also compatibles, so you can use load" save" & run" too.

if |x:run"filename run filename from drive a or b instead of xMass, 
just use : 

|x:|r,"filename

c. Erase files or directories.

|del,"filename" will erase this file in your xMass.
|rd,"filename" will erase the directory name.
You will have to give a confirmation if some files are presents on the directory before erase it.

------ |era are only used for drive a & b -----

d. Create directories.

|md,"filename" will create a new directory.

e. Formatting your xMass.

|format,1 : Fast format as written in the |hlp.
in fact, this command format your x-mass up to the last files written.
|format,2 : Full format. Format all tracks on your xMass.

f. Filenames header.

|head,"filename" will display important informations as :
 -filename type : 00-01 : basic / basic protected
                02    : binary
                #16   : ascii
 -StartAdr : Start Adress
 -Lenght : Lenght of the file
 -Exec   : Execution Adress
 -NbSect : how many sectors compose this file
 -StSect : first file sector
 
g. Extended dos commands

You could access extended dos commands which allow you to have 366k free in drive B.
This command was developped for Gotek users. Before using this command, you'll have 
to create a 366k dsk file by formatting it with 80 tracks. 
And then :

|dos : install drive b 366 driver
|dosoff : drive b back to normal configuration 

In iMPdos boot, you are in normal config (|dosoff)

h. Copying file into xMass and more.

Some commands were done to make fast file copies between drive & xMass.

|cpax,"filename" copies filename from drive a to xMass
|cpbx,"filename" copies filename from drive b to xMass
|cpax,"* copies all files from drive a to xMass
|cpbx,"* copies all files from drive b to xMass
---
|cpxa,"filename" copies filename from xMass to drive a
|cpxb,"filename" copies filename from xMass to drive b

----- wildcard will not work in this way.
----- Ascii files can't be copied using this commands

i. Connect roms.

|connect : connect roms 16 up to 31.

j. Hexa Sector Editor. 

As i love discology's hexa sector editor, i coded one for iMPdos.

|ed,&221,0 : edit 000221 sector.
When you are in editor mode : 

----Up/Down/Left/right 
----Return    : Change byte
----P         : Previous Sector
----N         : Next Sector
----Ctrl+Up   : Page 0/1 - #0000-#00ff
----Crtc+Down : Page 2/1 - #0100-#01ff
----Esc       : Quit Hexa Editor
----Ctrl+R    : Read current sector
----Crtl+S    : Save current sector

k. Some information to use/detect iMPdos properly in your next production.

You could find all informations in AmstradPlus forum : http://amstradplus.forumforever.com/t381-Loader-universel.htm

---- Load :
;
; Loader Universel v2 compatible iMPdos - AsT/iMPact 29/03/2018
; #b8fa-fb-fc : Secteur répertoire courant
; #b8fd : numéro de drive (0=A | 1=B | 3=X-Mass)
;
         org #a000
;
         ld hl,#b8fa ; sauve la config
         ld de,config ; drive+repertoire
         ld bc,4
         ldir
;
         LD   HL,(&BE7D) ; Début de l'Amsdos
         LD   A,(HL) ; récupère numéro du lecteur
         push af ; sauve lecteur
         ld (#b8fd),a
         DI
         LD   BC,&7F88+2 ; mode 2 - Lower Rom On | Upper Rom Off
         OUT  (C),C
         EXX
         CALL &44     ; réinit la zone 0-#3f
         CALL &08BD   ; réinit les vecteurs systèmes (vecteur pour 6128 et 6128 plus)
         CALL &BB00   ; init le Key Manager
         LD   A,&C9    ; disable char pour eviter les messages des roms                                              
         LD   (&BB5A),A  ; c'est un peu brut mais ça fonctionne !
         LD   DE,&40    ; init All ROMs
         LD   HL,&ABFF
         CALL &BCCB
         LD   A,&CF    ; enable char 
         LD   (&BB5A),A
;
          ld hl,config ; restitue la config
          ld de,#b8fa ; repertoire+numéro de drive
          ld bc,4
          ldir
          ld hl,#b8fa ; copie adresse secteur repertoire
          ld de,#b34A ; dans adresse impdos
                      ; Sector Low
          ldi:ldi
          ld a,(hl)   ; Sector High
          ld (#b349),a 
          inc hl      ; Drive
;         
          ld a,(hl)
          CP   3
          CALL Z,foundrsx    ; si lecteur =3 recherche et execute Rsx (ùX)   
;
          pop af ; recupère numéro du lecteur
          LD   HL,(&BE7D) ; Quoiqu'il en soit on poke le bon lecteur
          LD   (HL),A
;
; Load a file
;
loading   LD   DE,&C000     ; buffer
          LD   HL,file      ; nom a charger
          LD   B,endfile-file ; 
          CALL &BC77        ; charge le Header
           
          LD   HL,&c000      ; adresse de début du fichier
          CALL &BC83
          CALL &BC7A
          JP   &bb18    ; Attente d'une touche
 
;
; Cherche iMPdos ?          
;
foundrsx
          LD   HL,rsxX
          CALL &BCD4
          JR   NC,bip
          jp #1b
;
config byte 0,0,0,0 ; sauvegarde du répertoire+du numéro de drive                  
;
; Rsx Not found -> Bip
; Bip si iMPdos n'est pas trouvé.
;
bip       LD   A,7      ; biiiip
           JP   &BB5A
;
rsxX   BYTE "X"+&80
file  BYTE "ast.scr"
endfile

----- Save :

;
; Sauvegarde Xmass Universel - Drive A/B/xMass iMPdos  
; by AsT/iMPact 
;
  org #a000
        LD   HL,(&BE7D) ; Debut de l'Amsdos
        LD   A,(HL) ; recupere numero du lecteur
        push af ; sauve lecteur
        ld (#b8fd),a
;
  ld hl,#b349 ; sauve les datas du secteurs
  ld de,config
  ld bc,3
  ldir
;
  ld hl,#B300 ; sauve parametre dir
  ld de,param
  ld bc,#60
  ldir
;
  ld hl,#b8fa ; sauve adresse sect repertoire
  ld de,config2
  ld bc,3
  ldir
;
        DI
        LD   BC,&7F88+2 ; mode 2 - Lower Rom On | Upper Rom Off
        OUT  (C),C
        EXX
        CALL &44     ; reinit la zone 0-#3f
        CALL &08BD   ; reinit les vecteurs systemes (vecteur pour 6128 et 6128 plus)
        CALL &BB00   ; init le Key Manager
        LD   A,&C9    ; disable char pour eviter les messages des roms                                              
        LD   (&BB5A),A  ; c'est un peu brut mais ca fonctionne !
        LD   DE,&40    ; init All ROMs
        LD   HL,&ABFF
        CALL &BCCB
        LD   A,&CF    ; enable char 
        LD   (&BB5A),A
;
  ld bc,#7f8c+2
  out (c),c
;
  ld hl,config ; recupere secteur ou ecrire le
  ld de,#b349 ; nom du fichier dans directory
  ld bc,3
  ldir
 
  ld hl,(#be7d)
  pop af
  ld (hl),a
  ld (#b8fd),a
;
        ld a,(hl)
        CP   3
        CALL Z,foundrsx    ; si lecteur =3 recherche et execute Rsx (ùX)    
;
   ld b,finnom-nom ; longueur du nom à sauvegarder
  ld hl,nom ; adresse du nom du fichier 
  ld de,#c000 ; buffer
  call #bc8c ; ouverture du fichier en sortie
  jr nc,bip  ; si erreur -> bip
  ld hl,#c000 ; adresse de départ
  ld de,#3FFF ; Longueur du fichier à sauver
  ld bc,#caca ; Adresse d'execution
  ld a,2      ; type de fichier (0 : bas | 1 : Basic Protégé | 2 : Binaire | #16 : Ascii)
  call #bc98  ; On sauvegarde
  jr nc,bip   ; si erreur -> Bip
  call #bc8f  ; Fermeture du fichier en sortie
;
lastconfig
;
  ld hl,config2 ; recupere secteur position directory
  ld de,#B34A
  ld bc,2
  ldir
  ld a,(hl)
  ld (#b349),a
;
   ld hl,param ; restitut parametre dir
  ld de,#b300
  ld bc,#60
  ldir
  ret
;
; Cherche iMPdos ?          
;
foundrsx
LD   HL,rsxX
        CALL &BCD4
        JR   NC,bip
        jp #1b
;
; Rsx Not found -> Bip
; Bip si iMPdos n'est pas trouve.
;
bip   LD   A,7      ; biiiip
        call   &BB5A
  jr lastconfig
;
rsxX  BYTE "X"+&80
;
nom  byte "chany.ch1"
finnom
;
config  byte 0,0,0,0 ;                  
config2 byte 0,0,0 ; retour repertoire
param  ds #60,0
;

L. Thanks & Bugs reports

Thanks to all my beta-testers : Kris, Cmp, Chany, Dirtybb, Madram, Power, ArnoldEmu, Audronic & Subaru.
Other people ask me to be beta-tester but never send me feedback. so...

For bugs reports : 

http://amstradplus.forumforever.com/t293-iMPdos.htm