Subj : Re: Looking for more optimizations!
To : All
From : Harry Potter
Date : Thu Oct 25 2018 07:24 am
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;