--- snes9x-1.51-src-orig/debug.cpp	2012-01-31 01:24:14 +0900
+++ snes9x-1.51-src/debug.cpp	2012-01-31 01:35:57 +0900
@@ -344,7 +344,7 @@
     {
     case 0:
 	//Implied
-	    sprintf (Line, "%s         %s", Line, S9xMnemonics[S9xOpcode]);
+	    sprintf (Line+strlen(Line), "         %s", S9xMnemonics[S9xOpcode]);
 	Size = 1;
 	break;
     case 1:
@@ -352,8 +352,7 @@
 	    if (!CheckFlag (MemoryFlag))
 	{
 	    //Accumulator 16 - Bit
-		sprintf (Line, "%s%02X %02X    %s #$%02X%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X %02X    %s #$%02X%02X",
 			 Operant[0],
 			 Operant[1],
 			 S9xMnemonics[S9xOpcode],
@@ -364,8 +363,7 @@
 	else
 	{
 	    //Accumulator 8 - Bit
-		sprintf (Line, "%s%02X       %s #$%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X       %s #$%02X",
 			 Operant[0],
 			 S9xMnemonics[S9xOpcode],
 			 Operant[0]);
@@ -377,8 +375,7 @@
 	    if (!CheckFlag (IndexFlag))
 	{
 	    //X / Y 16 - Bit
-		sprintf (Line, "%s%02X %02X    %s #$%02X%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X %02X    %s #$%02X%02X",
 			 Operant[0],
 			 Operant[1],
 			 S9xMnemonics[S9xOpcode],
@@ -389,8 +386,7 @@
 	else
 	{
 	    //X / Y 8 - Bit
-		sprintf (Line, "%s%02X       %s #$%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X       %s #$%02X",
 			 Operant[0],
 			 S9xMnemonics[S9xOpcode],
 			 Operant[0]);
@@ -402,8 +398,7 @@
 	    if (1)
 	{
 	    //Always 8 - Bit
-		sprintf (Line, "%s%02X       %s #$%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X       %s #$%02X",
 			 Operant[0],
 			 S9xMnemonics[S9xOpcode],
 			 Operant[0]);
@@ -412,8 +407,7 @@
 	break;
     case 4:
 	//Relative
-	    sprintf (Line, "%s%02X       %s $%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -421,13 +415,12 @@
 	Word = Address;
 	Word += SByte;
 	Word += 2;
-	sprintf (Line, "%-32s[$%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 5:
 	//Relative Long
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -437,64 +430,59 @@
 	Word = Address;
 	Word += SWord;
 	Word += 3;
-	sprintf (Line, "%-32s[$%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 3;
 	break;
     case 6:
 	//Direct
-	    sprintf (Line, "%s%02X       %s $%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += Registers.D.W;
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 7:
 	//Direct indexed (with x)
-	    sprintf (Line, "%s%02X       %s $%02X,x",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X,x",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += Registers.D.W;
 	Word += Registers.X.W;
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 8:
 	//Direct indexed (with y)
-	    sprintf (Line, "%s%02X       %s $%02X,y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X,y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += Registers.D.W;
 	Word += Registers.Y.W;
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 9:
 	//Direct Indirect
-	    sprintf (Line, "%s%02X       %s ($%02X)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X)",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += Registers.D.W;
 	Word = S9xGetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 2;
 	break;
     case 10:
 	//Direct Indexed Indirect
-	    sprintf (Line, "%s%02X       %s ($%02X,x)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X,x)",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -502,13 +490,12 @@
 	Word += Registers.D.W;
 	Word += Registers.X.W;
 	Word = S9xGetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 2;
 	break;
     case 11:
 	//Direct Indirect Indexed
-	    sprintf (Line, "%s%02X       %s ($%02X),y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X),y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -516,13 +503,12 @@
 	Word += Registers.D.W;
 	Word = S9xGetWord (Word);
 	Word += Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 2;
 	break;
     case 12:
 	//Direct Indirect Long
-	    sprintf (Line, "%s%02X       %s [$%02X]",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s [$%02X]",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -530,13 +516,12 @@
 	Word += Registers.D.W;
 	Byte = S9xGetByte (Word + 2);
 	Word = S9xGetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Byte, Word);
 	Size = 2;
 	break;
     case 13:
 	//Direct Indirect Indexed Long
-	    sprintf (Line, "%s%02X       %s [$%02X],y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s [$%02X],y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -545,26 +530,24 @@
 	Byte = S9xGetByte (Word + 2);
 	Word = S9xGetWord (Word);
 	Word += Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Byte, Word);
 	Size = 2;
 	break;
     case 14:
 	//Absolute
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[1],
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 3;
 	break;
     case 15:
 	//Absolute Indexed (With X)
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X,x",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X,x",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -572,13 +555,12 @@
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += Registers.X.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 3;
 	break;
     case 16:
 	//Absolute Indexed (With Y)
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X,y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X,y",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -586,13 +568,12 @@
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 3;
 	break;
     case 17:
 	//Absolute long
-	 sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X",
-		   Line,
+	 sprintf (Line+strlen(Line), "%02X %02X %02X %s $%02X%02X%02X",
 		   Operant[0],
 		   Operant[1],
 		   Operant[2],
@@ -601,13 +582,12 @@
 		   Operant[1],
 		   Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Operant[2], Word);
 	Size = 4;
 	break;
     case 18:
 	//Absolute Indexed long
-	 sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X,x",
-		   Line,
+	 sprintf (Line+strlen(Line), "%02X %02X %02X %s $%02X%02X%02X,x",
 		   Operant[0],
 		   Operant[1],
 		   Operant[2],
@@ -617,25 +597,23 @@
 		   Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += Registers.X.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Operant[2], Word);
 	Size = 4;
 	break;
     case 19:
 	//StackRelative
-	    sprintf (Line, "%s%02X       %s $%02X,s",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X,s",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Registers.S.W;
 	Word += Operant[0];
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 20:
 	//Stack Relative Indirect Indexed
-	    sprintf (Line, "%s%02X       %s ($%02X,s),y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X,s),y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -643,13 +621,12 @@
 	Word += Operant[0];
 	Word = S9xGetWord (Word);
 	Word += Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.DB, Word);
 	Size = 2;
 	break;
     case 21:
 	//Absolute Indirect
-	    sprintf (Line, "%s%02X %02X    %s ($%02X%02X)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s ($%02X%02X)",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -657,13 +634,12 @@
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word = S9xGetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.PB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.PB, Word);
 	Size = 3;
 	break;
     case 22:
 	//Absolute Indirect Long
-	    sprintf (Line, "%s%02X %02X    %s [$%02X%02X]",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s [$%02X%02X]",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -672,13 +648,12 @@
 	Word = (Operant[1] << 8) | Operant[0];
 	Byte = S9xGetByte (Word + 2);
 	Word = S9xGetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Byte, Word);
 	Size = 3;
 	break;
     case 23:
 	//Absolute Indexed Indirect
-	    sprintf (Line, "%s%02X %02X    %s ($%02X%02X,x)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s ($%02X%02X,x)",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -687,24 +662,23 @@
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += Registers.X.W;
 	Word = S9xGetWord (ICPU.ShiftedPB + Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.PB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Registers.PB, Word);
 	Size = 3;
 	break;
     case 24:
 	//Implied accumulator
-	    sprintf (Line, "%s         %s A", Line, S9xMnemonics[S9xOpcode]);
+	    sprintf (Line+strlen(Line), "         %s A", S9xMnemonics[S9xOpcode]);
 	Size = 1;
 	break;
     case 25:
 	// MVN/MVP SRC DST
-	    sprintf (Line, "%s%02X %02X    %s %02X %02X", Line, Operant[0], Operant[1], S9xMnemonics[S9xOpcode],
+	    sprintf (Line+strlen(Line), "%02X %02X    %s %02X %02X", Operant[0], Operant[1], S9xMnemonics[S9xOpcode],
 		     Operant[1], Operant[0]);
 	Size = 3;
 	break;
     case 26:
 	// PEA
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -714,21 +688,20 @@
 	break;
     case 27:
 	// PEI Direct Indirect
-	    sprintf (Line, "%s%02X       %s ($%02X)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X)",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += Registers.D.W;
 	Word = S9xGetWord (Word);
-	sprintf (Line, "%-32s[$%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     }
 // XXX:
-    sprintf (Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04d VC:%03d FC:%02d %02x",
-	     Line, Registers.A.W, Registers.X.W, Registers.Y.W,
+    sprintf (Line+strlen(Line), "%*s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04d VC:%03d FC:%02d %02x",
+	     -(44-(int)strlen(Line)), "", Registers.A.W, Registers.X.W, Registers.Y.W,
 	     Registers.D.W, Registers.DB, Registers.S.W,
 	     CheckEmulation () ? 'E' : 'e',
 	     CheckNegative () ? 'N' : 'n',
@@ -788,7 +761,7 @@
     {
     case 0:
 	//Implied
-	    sprintf (Line, "%s         %s", Line, S9xMnemonics[S9xOpcode]);
+	    sprintf (Line+strlen(Line), "         %s", S9xMnemonics[S9xOpcode]);
 	Size = 1;
 	break;
     case 1:
@@ -796,8 +769,7 @@
 	    if (!SA1CheckFlag (MemoryFlag))
 	{
 	    //Accumulator 16 - Bit
-		sprintf (Line, "%s%02X %02X    %s #$%02X%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X %02X    %s #$%02X%02X",
 			 Operant[0],
 			 Operant[1],
 			 S9xMnemonics[S9xOpcode],
@@ -808,8 +780,7 @@
 	else
 	{
 	    //Accumulator 8 - Bit
-		sprintf (Line, "%s%02X       %s #$%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X       %s #$%02X",
 			 Operant[0],
 			 S9xMnemonics[S9xOpcode],
 			 Operant[0]);
@@ -821,8 +792,7 @@
 	    if (!SA1CheckFlag (IndexFlag))
 	{
 	    //X / Y 16 - Bit
-		sprintf (Line, "%s%02X %02X    %s #$%02X%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X %02X    %s #$%02X%02X",
 			 Operant[0],
 			 Operant[1],
 			 S9xMnemonics[S9xOpcode],
@@ -833,8 +803,7 @@
 	else
 	{
 	    //X / Y 8 - Bit
-		sprintf (Line, "%s%02X       %s #$%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X       %s #$%02X",
 			 Operant[0],
 			 S9xMnemonics[S9xOpcode],
 			 Operant[0]);
@@ -846,8 +815,7 @@
 	    if (1)
 	{
 	    //Always 8 - Bit
-		sprintf (Line, "%s%02X       %s #$%02X",
-			 Line,
+		sprintf (Line+strlen(Line), "%02X       %s #$%02X",
 			 Operant[0],
 			 S9xMnemonics[S9xOpcode],
 			 Operant[0]);
@@ -856,8 +824,7 @@
 	break;
     case 4:
 	//Relative
-	    sprintf (Line, "%s%02X       %s $%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -865,13 +832,12 @@
 	Word = Address;
 	Word += SByte;
 	Word += 2;
-	sprintf (Line, "%-32s[$%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 5:
 	//Relative Long
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -881,64 +847,59 @@
 	Word = Address;
 	Word += SWord;
 	Word += 3;
-	sprintf (Line, "%-32s[$%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 3;
 	break;
     case 6:
 	//Direct
-	    sprintf (Line, "%s%02X       %s $%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += SA1Registers.D.W;
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 7:
 	//Direct indexed (with x)
-	    sprintf (Line, "%s%02X       %s $%02X,x",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X,x",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += SA1Registers.D.W;
 	Word += SA1Registers.X.W;
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 8:
 	//Direct indexed (with y)
-	    sprintf (Line, "%s%02X       %s $%02X,y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X,y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += SA1Registers.D.W;
 	Word += SA1Registers.Y.W;
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 9:
 	//Direct Indirect
-	    sprintf (Line, "%s%02X       %s ($%02X)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X)",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = Operant[0];
 	Word += SA1Registers.D.W;
 	Word = S9xSA1GetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 2;
 	break;
     case 10:
 	//Direct Indexed Indirect
-	    sprintf (Line, "%s%02X       %s ($%02X,x)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X,x)",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -946,13 +907,12 @@
 	Word += SA1Registers.D.W;
 	Word += SA1Registers.X.W;
 	Word = S9xSA1GetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 2;
 	break;
     case 11:
 	//Direct Indirect Indexed
-	    sprintf (Line, "%s%02X       %s ($%02X),y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X),y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -960,13 +920,12 @@
 	Word += SA1Registers.D.W;
 	Word = S9xSA1GetWord (Word);
 	Word += SA1Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 2;
 	break;
     case 12:
 	//Direct Indirect Long
-	    sprintf (Line, "%s%02X       %s [$%02X]",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s [$%02X]",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -974,13 +933,12 @@
 	Word += SA1Registers.D.W;
 	Byte = S9xSA1GetByte (Word + 2);
 	Word = S9xSA1GetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Byte, Word);
 	Size = 2;
 	break;
     case 13:
 	//Direct Indirect Indexed Long
-	    sprintf (Line, "%s%02X       %s [$%02X],y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s [$%02X],y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -989,26 +947,24 @@
 	Byte = S9xSA1GetByte (Word + 2);
 	Word = S9xSA1GetWord (Word);
 	Word += SA1Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Byte, Word);
 	Size = 2;
 	break;
     case 14:
 	//Absolute
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[1],
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 3;
 	break;
     case 15:
 	//Absolute Indexed (With X)
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X,x",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X,x",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -1016,13 +972,12 @@
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += SA1Registers.X.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 3;
 	break;
     case 16:
 	//Absolute Indexed (With Y)
-	    sprintf (Line, "%s%02X %02X    %s $%02X%02X,y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s $%02X%02X,y",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -1030,13 +985,12 @@
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += SA1Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 3;
 	break;
     case 17:
 	//Absolute long
-	 sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X",
-		   Line,
+	 sprintf (Line+strlen(Line), "%02X %02X %02X %s $%02X%02X%02X",
 		   Operant[0],
 		   Operant[1],
 		   Operant[2],
@@ -1045,13 +999,12 @@
 		   Operant[1],
 		   Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Operant[2], Word);
 	Size = 4;
 	break;
     case 18:
 	//Absolute Indexed long
-	 sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X,x",
-		   Line,
+	 sprintf (Line+strlen(Line), "%02X %02X %02X %s $%02X%02X%02X,x",
 		   Operant[0],
 		   Operant[1],
 		   Operant[2],
@@ -1061,25 +1014,23 @@
 		   Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += SA1Registers.X.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Operant[2], Word);
 	Size = 4;
 	break;
     case 19:
 	//StackRelative
-	    sprintf (Line, "%s%02X       %s $%02X,s",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s $%02X,s",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
 	Word = SA1Registers.S.W;
 	Word += Operant[0];
-	sprintf (Line, "%-32s[$00:%04X]", Line, Word);
+	sprintf (Line+strlen(Line), "%*s[$00:%04X]", -(32-(int)strlen(Line)), "", Word);
 	Size = 2;
 	break;
     case 20:
 	//Stack Relative Indirect Indexed
-	    sprintf (Line, "%s%02X       %s ($%02X,s),y",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X       %s ($%02X,s),y",
 		     Operant[0],
 		     S9xMnemonics[S9xOpcode],
 		     Operant[0]);
@@ -1087,13 +1038,12 @@
 	Word += Operant[0];
 	Word = S9xSA1GetWord (Word);
 	Word += SA1Registers.Y.W;
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.DB, Word);
 	Size = 2;
 	break;
     case 21:
 	//Absolute Indirect
-	    sprintf (Line, "%s%02X %02X    %s ($%02X%02X)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s ($%02X%02X)",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -1101,13 +1051,12 @@
 		     Operant[0]);
 	Word = (Operant[1] << 8) | Operant[0];
 	Word = S9xSA1GetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.PB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.PB, Word);
 	Size = 3;
 	break;
     case 22:
 	//Absolute Indirect Long
-	    sprintf (Line, "%s%02X %02X    %s [$%02X%02X]",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s [$%02X%02X]",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -1116,13 +1065,12 @@
 	Word = (Operant[1] << 8) | Operant[0];
 	Byte = S9xSA1GetByte (Word + 2);
 	Word = S9xSA1GetWord (Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", Byte, Word);
 	Size = 3;
 	break;
     case 23:
 	//Absolute Indexed Indirect
-	    sprintf (Line, "%s%02X %02X    %s ($%02X%02X,x)",
-		     Line,
+	    sprintf (Line+strlen(Line), "%02X %02X    %s ($%02X%02X,x)",
 		     Operant[0],
 		     Operant[1],
 		     S9xMnemonics[S9xOpcode],
@@ -1131,23 +1079,23 @@
 	Word = (Operant[1] << 8) | Operant[0];
 	Word += SA1Registers.X.W;
 	Word = S9xSA1GetWord (SA1.ShiftedPB + Word);
-	sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.PB, Word);
+	sprintf (Line+strlen(Line), "%*s[$%02X:%04X]", -(32-(int)strlen(Line)), "", SA1Registers.PB, Word);
 	Size = 3;
 	break;
     case 24:
 	//Implied accumulator
-	    sprintf (Line, "%s         %s A", Line, S9xMnemonics[S9xOpcode]);
+	    sprintf (Line+strlen(Line), "         %s A", S9xMnemonics[S9xOpcode]);
 	Size = 1;
 	break;
     case 25:
 	// MVN/MVP SRC DST
-	    sprintf (Line, "%s         %s %02X %02X", Line, S9xMnemonics[S9xOpcode],
+	    sprintf (Line+strlen(Line), "         %s %02X %02X", S9xMnemonics[S9xOpcode],
 		     Operant[0], Operant[1]);
 	Size = 3;
 	break;
     }
-    sprintf (Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%03ld VC:%03ld",
-	     Line, SA1Registers.A.W, SA1Registers.X.W, SA1Registers.Y.W,
+    sprintf (Line+strlen(Line), "%*s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%03ld VC:%03ld",
+	     -(44-(int)strlen(Line)), "", SA1Registers.A.W, SA1Registers.X.W, SA1Registers.Y.W,
 	     SA1Registers.D.W, SA1Registers.DB, SA1Registers.S.W,
 	     SA1CheckEmulation () ? 'E' : 'e',
 	     SA1CheckNegative () ? 'N' : 'n',
@@ -1688,9 +1636,9 @@
 		{
 		    MemoryByte = S9xGetByte ((Bank << 16) + Address + CByte);
 		}
-		sprintf (String, "%s %02X", String, MemoryByte);
+		sprintf (String+strlen(String), " %02X", MemoryByte);
 	    }
-	    sprintf (String, "%s-", String);
+	    sprintf (String+strlen(String), "-");
 	    for (CByte = 0; CByte != 16; CByte++)
 	    {
 		if (Address + CByte == 0x2140 ||
@@ -1707,7 +1655,7 @@
 		}
 		if (MemoryByte < 32 || MemoryByte >= 127)
 		    MemoryByte = '?';
-		sprintf (String, "%s%c", String, MemoryByte);
+		sprintf (String+strlen(String), "%c", MemoryByte);
 	    }
 	    Address += 16;
 	    DPrint (String);
