Index: loader.c
===================================================================
--- loader.c	(revision 3)
+++ loader.c	(revision 4)
@@ -95,6 +95,18 @@
 	ret=go_trk255(); 
 	border(1);
-/*	dump16b(1,16,ret); */
 	border(2);
+
+	ret=string(0,0,"Checking Host mode...",21);
+	ret=rd_sec(0); 
+	ret=dump16b(22,0,ret); 
+	
+	if (buf[0]!='H') {
+		string(0,2,"Fatal cannot setup Host mode...",31);
+		while (1==1) ;
+	}
+
+	string(0,1,buf,8);
+	string(8,1,buf+8,12);
+
 	ret=rd_lba(0,0);
 	lbaBeg_l=mk_16(buf[446+9],buf[446+8]); 
@@ -245,5 +257,4 @@
 	hi_line(select+4,0xC7);
 
-	irq();
 	while (1) {
 		i=getc();
@@ -296,5 +307,5 @@
 			if (cfgnum==-1) {
 				cls();
-				string(0,2,"Sorry, no HXCSDFE.CFG found. read only..",40);
+				string(0,2,"fatal missing CFG",17);
 				k=getc();
 				cls();
@@ -306,5 +317,5 @@
 			if (f_clusz<2) {
 				cls();
-				string(0,2,"Sorry, cluster size 1 is unsupported..",38);
+				string(0,2,"cluster size 1 is unsupported..",33);
 				k=getc();
 				cls();
@@ -413,15 +424,16 @@
 				dump16b(0,24,ret);
 
-				string(0,13,"Press a key...",14);
+/*				string(0,13,"Press a key...",14);
 
 				k=getc();
-
+*/
+				string(0,14,"Leaving host...",15);
 				
-				/* leave LBA (need 3 times) */
+				leave_lba();
+				/* also seek just in case... () */
 				go_track(0);
-				go_track(0);
-				go_track(0);
-
-				string(0,14,"... REBOOT ...",10);
+
+
+				string(0,15,"... REBOOT ...",10);
 				/* and reset */
 				{
@@ -456,5 +468,5 @@
 banner()
 {
-	string(0,0,"HxC TO8 File selector by VitalMotion",38);
+	string(0,0,"HxC TO File selector by VitalMotion",37);
 	string(0,2,"Select your File:\0",17);
 	return 0;
@@ -641,4 +653,17 @@
 {
 #asm
+		LDA	$E000
+		CMPA	#$44 		| for WD floppy (ie TO9)
+		BNE	go_norm
+
+		LDA	#$FF
+		STA	$6051
+		LDA    #127      | try to go -128 tracks...
+		STA    _DKVAL
+		CLR    _DKTRK
+		LDA    #$40
+		JSR    $E004
+		
+go_norm
 		LDA    #$20     | rech piste 0
 		STA    _DKOPC
@@ -684,4 +709,34 @@
 	p[13]=0xA5;
 	p[14]=0x08;
+
+	/* init fields with a read */
+	wt_sec(0);
+	i=rd_sec(1);
+	return i;
+}
+
+leave_lba(v)
+int v;
+{
+	int i;
+	char *p;
+
+	for (i=0x6300;i<0x6500;i++) {
+		p=i;
+		*p=0x00;
+	}
+	i=0x6300;p=i;
+	p[0]='H';
+	p[1]='x';
+	p[2]='C';
+	p[3]='F';
+	p[4]='E';
+	p[5]='D';
+	p[6]='A';
+	p[7]=0;
+
+	p[8]=0x02;
+	p[9]=0x00;
+	p[10]=0x00;
 
 	/* init fields with a read */
@@ -833,4 +888,8 @@
 }
 
+/*
+ * Physical read/write in 9sect/512byte
+ */
+
 rd_sec(sect) 
 char sect;
@@ -844,5 +903,19 @@
 		PSHS   U,DP
 		LDX    #$6300
-		STX    $604F           | sector buffer	
+		STX    $604F           | sector buffer
+
+		LDA	$E000
+		CMPA	#$44		| for WD floppy (ie TO9)
+		BNE	rd_TO8
+		CLR	$6051
+		LDA    #$FF
+		STA    $E7D1
+		LDA    #$02
+		STA    _DKOPC
+		JSR    $E004
+		BRA    rd_sect_end
+
+rd_TO8
+		LDA    #$02            | read sector (monitor)
 		JSR    $789D
 		JSR    $78A7
@@ -856,7 +929,9 @@
 		PULS   A               | E0EE
 		JSR    $78B9           | motor off
+rd_sect_end
 		PULS   DP,U		
 		LDA    #$00
 		LDB    _DKERR
+
 		TFR    D,X             | return in X		
 #endasm
@@ -876,4 +951,19 @@
 		LDX    #$6300
 		STX    $604F           | sector buffer	
+
+		LDA	$E000
+		CMPA	#$44 		| for WD floppy (ie TO9)
+		BNE	wt_TO8
+		CLR	$6051
+		LDA    #$FF
+		STA    $E7D1
+		LDA    #$08
+		STA    _DKOPC
+		JSR    $E004
+		BRA    wt_sect_end
+
+wt_TO8
+
+		LDA    #$08            | read sector (monitor)
 		JSR    $789D
 		JSR    $78A7
@@ -887,4 +977,5 @@
 		PULS   A               | E0EE
 		JSR    $78B9           | motor off
+wt_sect_end
 		PULS   DP,U		
 		LDA    #$00
@@ -895,21 +986,4 @@
 }
 
-irq()
-{
-{
-#asm
-
-#endasm
-}
-}
-
-noirq()
-{
-{
-#asm
-
-#endasm
-}
-}
 
 getc() 
@@ -1085,4 +1159,74 @@
     PULS U,PC	; retour de fonction compatible mini C                
 
+* MC09 internal functions/lib
+	
+_00001	PSHS	D,X,Y		multiply
+	
+	LDA	,S
+	LDB	3,S
+	MUL
+	STB	4,S
+	
+	LDD	1,S
+	MUL
+	STB	5,S
+	
+	LDA	1,S
+	LDB	3,S
+	MUL
+	ADDA	4,S
+	ADDA	5,S
+	
+	LEAS	6,S
+	RTS
+	
+_00006	CMPX	#0		signed left shift
+	BMI	_06001
+ 
+_06000	BEQ	_06009
+	LSLB
+	ROLA
+	LEAX	-1,X
+	BRA	_06000
+	
+_06001	BEQ	_06009
+	ASRA
+	RORB
+	LEAX	1,X
+	BRA	_06001
+	
+_06009	RTS
+_00008	CMPX	#0		sined right shift
+	BMI	_08001
+	
+_08000	BEQ	_08009
+	ASRA
+	RORB
+	LEAX	-1,X
+	BRA	_08000
+	
+_08001	BEQ	_08009
+	LSLB
+	ROLA
+	LEAX	1,X
+	BRA	_08001
+	
+_08009	RTS	
+_00009	CMPX	#0		unsined right shift
+	BMI	_09001
+	
+_09000	BEQ	_09009
+	LSRA
+	RORB
+	LEAX	-1,X
+	BRA	_09000
+	
+_09001	BEQ	_09009
+	LSLB
+	ROLA
+	LEAX	1,X
+	BRA	_09001
+	
+_09009	RTS	
 	
 BASE_TXT_ADR
@@ -1243,74 +1387,5 @@
 	FCB	$0,$8,$14,$22,$41,$41,$7F,$0
 
-* MC09 internal functions/lib
-	
-_00001	PSHS	D,X,Y		multiply
-	
-	LDA	,S
-	LDB	3,S
-	MUL
-	STB	4,S
-	
-	LDD	1,S
-	MUL
-	STB	5,S
-	
-	LDA	1,S
-	LDB	3,S
-	MUL
-	ADDA	4,S
-	ADDA	5,S
-	
-	LEAS	6,S
-	RTS
-	
-_00006	CMPX	#0		signed left shift
-	BMI	_06001
- 
-_06000	BEQ	_06009
-	LSLB
-	ROLA
-	LEAX	-1,X
-	BRA	_06000
-	
-_06001	BEQ	_06009
-	ASRA
-	RORB
-	LEAX	1,X
-	BRA	_06001
-	
-_06009	RTS
-_00008	CMPX	#0		sined right shift
-	BMI	_08001
-	
-_08000	BEQ	_08009
-	ASRA
-	RORB
-	LEAX	-1,X
-	BRA	_08000
-	
-_08001	BEQ	_08009
-	LSLB
-	ROLA
-	LEAX	1,X
-	BRA	_08001
-	
-_08009	RTS	
-_00009	CMPX	#0		unsined right shift
-	BMI	_09001
-	
-_09000	BEQ	_09009
-	LSRA
-	RORB
-	LEAX	-1,X
-	BRA	_09000
-	
-_09001	BEQ	_09009
-	LSLB
-	ROLA
-	LEAX	1,X
-	BRA	_09001
-	
-_09009	RTS	
+
 #endasm	
 }
