TIP: Click on subject to list as thread! ANSI
echo: cbm
to: All
from: Harry Potter
date: 2018-10-25 07:24:00
subject: Re: Looking for more opti

Following are snippets of the code I'm optimizing:
--------------------------
void vLook (void)//char Itm1)
{
   //static unsigned char i;
   //static char* s;
   static void (*func)();
   //if (Itm1!=-1) {
   if (Itm1!=0xFF) {
      //if (Itm1>=128 && Itm1<160){
      if ((signed char)Itm1<160) {
         //i=
      }
      //if (SearchInv (Player.Inv, Itm1) ||
      //   SearchInv (Player.RoomInv[CRoom], Itm1))
      //if (SearchInv2 (Player.Inv) || SearchInv2 (Player.RoomInv[CRoom]))
      if (SearchInvPlayer () || SearchInvRoom ())
      {
         //if (Itm1 < NumItems) {
         //if ((signed char)Itm1>=0) {
            if ((s=hidereadw((void*)&Item[Itm1].Info))==0) {
               printscr ("No help available for that item.");
               return;
            }
            printh (s);
            //printh ((void*)&Item[Itm1].Info);
         //else
         //   ;
         //return;
         //}
      }
      else {
         //puts (Message[msgItemNotAvail]);
         printmsg(msgItemNotAvail);
      }
      return;
   }
   CurRoomInv=Player.RoomInv[CRoom];
   CRm=(void*)&Room[CRoom];
   //printh ((char*)hidereadw((void*)&Room[CRoom].Desc));
   printh ((char*)hidereadw((void*)&CRm->Desc));
   //printh (hidereadw(hidereadw((void*)&Room[CRoom].Desc)));
   //puts (Room[CRoom].Desc);
   //printh (&Room[CRoom].Desc);
   //printh (Room[CRoom].RoomHandler);
   func=hidereadw((void*)&CRm->RoomHandler);
   (*func) ();
   printcr();//putchar (13);

   for (i=0; i<8 && (c=CurRoomInv[i])!=0xFF;++i) {
      //printf ("There is a %s here.\n",
      prints ("There is a ");
      printh (hidereadw((void*)&Item[/*CurRoomInv[i]*/c].Name));
      printscr (" here.");
      //printf ("There is a %Hs here.\n",
      //   hidereadw((void*)&Item[Player.RoomInv[CRoom][i]].Name));
   }
   if (i) /*{cputc (13); cputc (10);}*/
      printcr();//putchar (13);
}

void vLook2 (void)
{
   Itm1=-1;
   vLook ();

}

void vGo ()//char Itm1)
{
   //static unsigned char s; /* 1 if go successful */
   //static unsigned char Dir;
   //static unsigned char i;
   //s=0;Dir=-1;
   if (Itm1>=160 && Itm1<164) {
   //if ((Itm1&~3)==160) {
      //j = Itm1-iNorth; goto godir;
      j = Itm1&0x0F; //goto godir;
      //if ((i= Room[CRoom].NextRoom[j])==0xFF) {
      if ((i=CRm->NextRoom[j])==0xFF) {
         printmsg(msgCantGoThere); return;
      }
      CRoom = i; goto exitgood;
   }
   switch (Itm1)
   {
   /*case iNorth:
   case iSouth:
   case iEast:
   case iWest:
      j = Itm1-iNorth; goto godir;*/
   case iTeleporter:
      if (!SearchInvRoom(/*,
         iTeleporter*/)) {
         printscr ("There's no teleporter here.");
         return;
      }
      Player.ExitRoom = CRoom;
      CRoom = rTeleporter;
      goto exitgood;
   //default:
//err:
      //printmsg(msgCantGoThere); return;
   }
   printmsg(msgCantGoThere); return;
godir:
/*   if ((i= Room[CRoom].NextRoom[j])==0xFF) {
      printmsg(msgCantGoThere); return;
   }
   CRoom = i; //Player.ExitRoom = -1;*/
exitgood:
   //Player.ExitRoom =Itm1=-1; vLook();
   Player.ExitRoom =-1; vLook2();
}
------------------------------------
void main (void)
{
   //static unsigned char c;
   //static char Input [38];
   //static unsigned char Vrb;//, Itm, ItmNum, CurPos;
   //static unsigned char CurPos;//IncPos;
   //static unsigned char i;
   static void (* vfunc) ();
        //printf ("%X\n", &Item[0].Name);
        //cgetc();
   //bordercolor(8); bgcolor (1);
   //textcolor (4);
   brdrcol=8;
   backcol=1;
   //textcol=4;
      /*123456789012345678901234567890123456789*/
   //clrscr ();
   printscr("\f\n\x9cWelcome to \"Adventures on Planet Smir\n"
       "III, Episode 1, v .10\" for the Commo-\n"
       "dore 64 and emulators, created with cc65"
       "by Joseph Rose.\n\n"

       "Type INTRO during the game for\n"
       "instructions.\n\n"
       "Do you want to load a saved game?");
   //do//while(1)
   //{
      //c=tolower(cgetc ());
      //if ((c=tolower(getkey ()))=='y'/* || c=='Y'*/) { /* If user pressed "Y" 
*/
      //if ((c=(getkey ()&0x7F))=='y'/* || c=='Y'*/) { /* If user pressed "Y" 
*/
      //   c=1; break;
      //} if (c=='n' /*|| c=='N'*/) { /* If user pressed "N" */
      //   c=2; break;
      //} if (c=='d' /*|| c=='D'*/) { /* Debug mode */
      //   c=3; break;
      //}
      //switch (c) {
      //case 'y': c=1; break;
      //case 'n': c=2; break;
      //case 'd': c=3; break;
      //default:  c=0;
      //}
      switch (getkey ())
      {
      case 'd': ++c;
      case 'y': ++c;
      //default:  ++c;
      //case 'y': ++c; //break;
      //default: continue;
      }
   //} while (!c);
   InitPlayer ();
   if (c==2) {
      printscr ("Debug mode: Enter room #"); GetInput (Input, 4);
      //CRoom=0;
      for (CurPos=0;Input[CurPos]; ++CurPos)
      {
         //CRoom=CRoom*10+(Input[CurPos]-'0');
         //CRoom=CRoom*10+(Input[CurPos]&0xF);
         CRoom=(((CRoom<<2)+CRoom)<<1)+(Input[CurPos]&0xF);
      }
      //CRoom=atoi(Input);
   }
   //Itm1=-1;
   vLook2 ();
   while (1)
   {
//bordercolor(0);
      /*Itm1=Vrb=Itm = -1;
      ItmNum =
         CurPos =
         IncPos = 0;*/
      //Itm1=Vrb= -1;
      //CurPos = 0;

      DispScoreBoard();
      if (!GetInput (Input,38)) continue;
//puts (Input);
      //if (Input[0] == 0) continue;
      //CvtLowerCase (Input);
      //for (; Input[CurPos] == 32; CurPos++);
      //while (Input[CurPos] == 32) ++CurPos;
      //if (Input[0] == 0) continue;
//bordercolor(1);
      Vrb = FindVerb (/*Input*/);
//bordercolor(2); cgetc();
      if (Vrb == 0xFF) {
         //Input [CurPos]=0;
         //printf("I don't know how to %s.\n",
         //   &Input [CurPos]);
         prints ("I don't know how to ");
         prints (Input);
         printperiod ();
         continue;
      }
      //CurPos = IncPos;
//bordercolor(3);cgetc();
      //while (Input [CurPos] != 0 && !ItmNum)
      //{
         /*for (; ispunct(Input [CurPos]); CurPos++);*/
         //if ((isspace (Input [CurPos]) /*||
         //   ispunct (Input [CurPos])*/) &&
         //   Input [CurPos] != '$')
         //{
         //   ++CurPos; continue;
         //}

         //do {
         //   if (Input[CurPos]==32) {++CurPos; continue;}
         //   //c = isNullWord(&Input[CurPos]);
         //   //CurPos+=c;
         //} while (c!=0);
         while (Input[CurPos]==32) ++CurPos;
         if (Input[CurPos]) //Itm1=-1; goto runverb;}
//puts (&Input[CurPos]); cgetc();
         //Itm1 = FindItem (&Input[CurPos]);
         {
//bordercolor(4);cgetc();
            if ((Itm1 = FindItem (&Input[CurPos]))==0xFF ) {
               //Input [CurPos+IncPos]=0;
               //printf ("I don't know what a %s is.\n",
               //   &Input[CurPos]);
               prints ("I don't know what a ");
               prints (&Input[CurPos]);
               //prints (Input+CurPos);
               printscr (" is.");
               //Vrb = -1;
               //goto runverb;
               continue;
            }
         } else Itm1=0xFF;
         //CurPos+=IncPos;
         //Itm1 = c; //ItmNum=1;
//printc ('");
      //}
runverb:
      //if (Vrb != 0xFF) {
         //(*(void*)hidereadw(Verb[Vrb].vdo)) ();
         vfunc=hidereadw((void*)&Verb[Vrb].vdo);
//printf ("%04.4X %d\n", vfunc, (unsigned) Vrb);
//bordercolor(5);cgetc();
         (*vfunc) ();
      //}
   }
}
-----------------------
Does anybody have any optimizations I can use?  :)

--- SoupGate-Win32 v1.05
                                                                                                                      
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@dmine.net

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.