$NetBSD: patch-ad,v 1.3 2001/06/03 17:34:58 kei Exp $

--- MSX.c.orig	Mon May 14 07:35:08 2001
+++ MSX.c	Sun Jun  3 04:36:49 2001
@@ -287,6 +287,7 @@
   byte *P;
   word A;
   FILE *F;
+  char string[FILENAME_MAX];
 
   /*** STARTUP CODE starts here: ***/
 
@@ -380,7 +381,7 @@
 
   /* Save current directory and cd to wherever system ROMs are */
   if(ProgDir)
-    if(WorkDir=getcwd(NULL,0))
+    if((WorkDir=getcwd(NULL,0)))
     {
       Chunks[CCount++]=WorkDir;
       chdir(ProgDir);
@@ -391,7 +392,10 @@
   {
     case 0:
       if(Verbose) printf("  Opening MSX.ROM...");
-      P=LoadROM("MSX.ROM",0x8000,0);
+      bzero(string, sizeof(string));
+      strcpy(string, RomDir);
+      strcat(string, "MSX.ROM");
+      P=LoadROM(string,0x8000,0);
       PRINTRESULT(P);
       if(!P) return(0);
       MemMap[0][0][0]=P;
@@ -402,7 +406,10 @@
 
     case 1:
       if(Verbose) printf("  Opening MSX2.ROM...");
-      P=LoadROM("MSX2.ROM",0x8000,0);
+      bzero(string, sizeof(string));
+      strcpy(string, RomDir);
+      strcat(string, "MSX2.ROM");
+      P=LoadROM(string,0x8000,0);
       PRINTRESULT(P);
       if(!P) return(0);
       MemMap[0][0][0]=P;
@@ -410,7 +417,10 @@
       MemMap[0][0][2]=P+0x4000;
       MemMap[0][0][3]=P+0x6000;
       if(Verbose) printf("  Opening MSX2EXT.ROM...");
-      P=LoadROM("MSX2EXT.ROM",0x4000,0);
+      bzero(string, sizeof(string));
+      strcpy(string, RomDir);
+      strcat(string, "MSX2EXT.ROM");
+      P=LoadROM(string,0x4000,0);
       PRINTRESULT(P);
       if(!P) return(0);
       MemMap[3][1][0]=P;
@@ -419,7 +429,10 @@
 
     case 2:
       if(Verbose) printf("  Opening MSX2P.ROM...");
-      P=LoadROM("MSX2P.ROM",0x8000,0);
+      bzero(string, sizeof(string));
+      strcpy(string, RomDir);
+      strcat(string, "MSX2P.ROM");
+      P=LoadROM(string,0x8000,0);
       PRINTRESULT(P);
       if(!P) return(0);
       MemMap[0][0][0]=P;
@@ -427,7 +440,10 @@
       MemMap[0][0][2]=P+0x4000;
       MemMap[0][0][3]=P+0x6000;
       if(Verbose) printf("  Opening MSX2PEXT.ROM...");
-      P=LoadROM("MSX2PEXT.ROM",0x4000,0);
+      bzero(string, sizeof(string));
+      strcpy(string, RomDir);
+      strcat(string, "MSX2PEXT.ROM");
+      P=LoadROM(string,0x4000,0);
       PRINTRESULT(P);
       if(!P) return(0);
       MemMap[3][1][0]=P;
@@ -436,7 +452,10 @@
   }
 
   /* Try loading DiskROM */
-  if(P=LoadROM("DISK.ROM",0x4000,0))
+  bzero(string, sizeof(string));
+  strcpy(string, RomDir);
+  strcat(string, "DISK.ROM");
+  if((P=LoadROM(string,0x4000,0)))
   {
     if(Verbose) puts("  Opening DISK.ROM...OK");
     MemMap[3][1][2]=P;
@@ -469,16 +488,25 @@
   if(Verbose) printf("Loading other ROMs: ");
 
   /* Try loading CMOS memory contents */
-  if(LoadROM("CMOS.ROM",sizeof(RTC),(byte *)RTC))
+  bzero(string, sizeof(string));
+  strcpy(string, RomDir);
+  strcat(string, "CMOS.ROM");
+  if(LoadROM(string,sizeof(RTC),(byte *)RTC))
   { if(Verbose) printf("CMOS.ROM.."); }
   else memcpy(RTC,RTCInit,sizeof(RTC));
 
   /* Try loading Kanji alphabet ROM */
-  if(Kanji=LoadROM("KANJI.ROM",0x20000,0))
+  bzero(string, sizeof(string));
+  strcpy(string, RomDir);
+  strcat(string, "KANJI.ROM");
+  if((Kanji=LoadROM(string,0x20000,0)))
   { if(Verbose) printf("KANJI.ROM.."); }
 
   /* Try loading RS232 support ROM */
-  if(P=LoadROM("RS232.ROM..",0x4000,0))
+  bzero(string, sizeof(string));
+  strcpy(string, RomDir);
+  strcat(string, "RS232.ROM");
+  if((P=LoadROM(string,0x4000,0)))
   {
     if(Verbose) printf("RS232.ROM..");
     MemMap[3][0][2]=P;
@@ -486,7 +514,10 @@
   }
 
   /* Try loading FM-PAC support ROM */
-  if(P=LoadROM("FMPAC.ROM",0x4000,0))
+  bzero(string, sizeof(string));
+  strcpy(string, RomDir);
+  strcat(string, "FMPAC.ROM");
+  if((P=LoadROM(string,0x4000,0)))
   {
     if(Verbose) printf("FMPAC.ROM..");
     MemMap[3][3][2]=P;
@@ -574,7 +605,10 @@
     if(J&&(MemMap[3][1][2]!=EmptyRAM))
     {
       if(J==2) ROMTypeB=1; else ROMTypeA=1;
-      if(LoadCart("MSXDOS2.ROM",J-1))
+      bzero(string, sizeof(string));
+      strcpy(string, RomDir);
+      strcat(string, "MSXDOS2.ROM");
+      if(LoadCart(string,J-1))
         SetMegaROM(J-1,0,1,ROMMask[J-1]-1,ROMMask[J-1]);
     }
 
@@ -584,15 +618,21 @@
          else J=0;
 
     /* Try loading PAINTER ROM if slot found */
-    if(J) LoadCart("PAINTER.ROM",J-1);
+    bzero(string, sizeof(string));
+    strcpy(string, RomDir);
+    strcat(string, "PAINTER.ROM");
+    if(J) LoadCart(string,J-1);
   }
 
   /* We are now back to working directory */
   if(WorkDir) chdir(WorkDir);
 
   /* Try loading font */
-  if(Verbose) printf("Loading %s font...",FontName);
-  FontBuf=LoadROM(FontName,0x800,0);
+  bzero(string, sizeof(string));
+  strcpy(string, RomDir);
+  strcat(string, FontName);
+  if(Verbose) printf("Loading %s font...",string);
+  FontBuf=LoadROM(string,0x800,0);
   PRINTRESULT(FontBuf);
 
   /* Open stream for a printer */
@@ -624,7 +664,7 @@
 
   /* Open casette image */
   if(CasName)
-    if(CasStream=fopen(CasName,"r+b"))
+    if((CasStream=fopen(CasName,"r+b")))
       if(Verbose) printf("Using %s as a tape\n",CasName);
 
   if(Verbose)
