Subj : Re: Looking moremore optimizations!
To   : [email protected]
From : Herr Doktor
Date : Thu Nov 08 2018 01:04 pm

I realize I'm jumping into the middle of a conversation and it isn't
my intention to derail it.  What jumps out at me from your code is the
lack of comments.  It's been years since I did any programming but
when I did I always commented extensively.  I also use many small
modules rather than one huge source file.  Then the main program
becomes just the flow of logic and decision with calls to the
appropriate modules as required.

I find that writing in this way makes things much easier all the way
around, all aspects.

You say your program is going to be a big one.  They can become
unwieldy pretty fast when good organizing techniques are not used.
On Sat, 27 Oct 2018 05:21:07 -0700 (PDT), Harry Potter
<[email protected]> wrote:

>Let me try again:
>-------------------------
>void vLook (void)//char Itm1)
>{
>   static void (*func)();
>   if (Itm1!=0xFF) {
>      if (SearchInvPlayer () || SearchInvRoom ())
>      {
>            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*)&CRm->Desc));
>   func=hidereadw((void*)&CRm->RoomHandler);
>   (*func) ();
>   printcr();
>
>   for (i=0; i<8 && (c=CurRoomInv[i])!=0xFF;++i) {
>      prints ("There is a ");
>      printh (hidereadw((void*)&Item[/*CurRoomInv[i]*/c].Name));
>      printscr (" here.");
>   }
>   if (i)
>      printcr();
>}
>
>void vLook2 (void)
>{
>   Itm1=-1;
>   vLook ();
>
>}
>
>void vGo ()//char Itm1)
>{
>   if (Itm1>=160 && Itm1<164) {
>      j = Itm1&0x0F; //goto godir;
>      if ((i=CRm->NextRoom[j])==0xFF) {
>         printmsg(msgCantGoThere); return;
>      }
>      CRoom = i; goto exitgood;
>   }
>   switch (Itm1)
>   {
>   case iTeleporter:
>      if (!SearchInvRoom()) {
>         printscr ("There's no teleporter here.");
>         return;
>      }
>      Player.ExitRoom = CRoom;
>      CRoom = rTeleporter;
>      goto exitgood;
>   }
>   printmsg(msgCantGoThere); return;
>godir:
>exitgood:
>   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?");
>      switch (getkey ())
>      {
>      case 'd': ++c;
>      case 'y': ++c;
>      }
>   InitPlayer ();
>   if (c==2) {
>      printscr ("Debug mode: Enter room #"); GetInput (Input, 4);
>      for (CurPos=0;Input[CurPos]; ++CurPos)
>      {
>         CRoom=(((CRoom<<2)+CRoom)<<1)+(Input[CurPos]&0xF);
>      }
>   }
>   vLook2 ();
>   while (1)
>   {
>      DispScoreBoard();
>      if (!GetInput (Input,38)) continue;
>      Vrb = FindVerb (/*Input*/);
>      if (Vrb == 0xFF) {
>         prints ("I don't know how to ");
>         prints (Input);
>         printperiod ();
>         continue;
>      }
>      while (Input[CurPos]==32) ++CurPos;
>      if (Input[CurPos]) //Itm1=-1; goto runverb;}
>      {
>         if ((Itm1 = FindItem (&Input[CurPos]))==0xFF ) {
>            prints ("I don't know what a ");
>            prints (&Input[CurPos]);
>            printscr (" is.");
>            continue;
>         }
>      } else Itm1=0xFF;
>      vfunc=hidereadw((void*)&Verb[Vrb].vdo);
>      (*vfunc) ();
>   }
>}
>-----------------------
>Does this help?  :)
>
>BTW, if necesssary, I can supply some of the variables' purposes.

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