From: Harry Potter on
As I have said before, I started creating a Sci-Fi text adventure
called Smir 3, 1 for the C64 under cc65 a long time ago, and ran into
a little problem. By the end of Chapter 1, the executable was just
under 20k long. I looked at a map of the program, and the major
problem was the words module, which cost about 10k. I reorgamized the
module so that a repeated string would only appear once, and
reorganized the code so that a function would only appear once. I am
also using the -O switch. Are there any other ways to optimize the
code without costing functionality? I could break apart the code into
smaller pieces and load the code for each word from disk every time
it's executed. Any other ideas? Thank you.
From: Richard James on
On Sun, 13 Apr 2008 12:43:30 -0700, Harry Potter wrote:

> As I have said before, I started creating a Sci-Fi text adventure called
> Smir 3, 1 for the C64 under cc65 a long time ago, and ran into a little
> problem. By the end of Chapter 1, the executable was just under 20k
> long. I looked at a map of the program, and the major problem was the
> words module, which cost about 10k. I reorgamized the module so that a
> repeated string would only appear once, and reorganized the code so that
> a function would only appear once. I am also using the -O switch. Are
> there any other ways to optimize the code without costing functionality?
> I could break apart the code into smaller pieces and load the code for
> each word from disk every time it's executed. Any other ideas? Thank
> you.

Without seeing the code this is very hard to say. Maybe you could put the
code on a website and post a link here so that people can look and see if
they can offer advice.

Richard James
--
sig fail on line -1
From: U. v. Bassewitz on
Harry Potter <maspethrose7(a)aol.com> wrote:
> Are there any other ways to optimize the code without costing
> functionality?

"How to generate the most effective code with cc65."

==> http://www.cc65.org/doc/coding.html

Regards


Uz


--
Ullrich von Bassewitz uz(a)spamtrap.musoftware.de
07:44:15 up 29 days, 17:35, 1 user, load average: 0.05, 0.09, 0.23
From: Marc 'BlackJack' Rintsch on
On Sun, 13 Apr 2008 12:43:30 -0700, Harry Potter wrote:

> As I have said before, I started creating a Sci-Fi text adventure
> called Smir 3, 1 for the C64 under cc65 a long time ago, and ran into
> a little problem. By the end of Chapter 1, the executable was just
> under 20k long. I looked at a map of the program, and the major
> problem was the words module, which cost about 10k. I reorgamized the
> module so that a repeated string would only appear once, and
> reorganized the code so that a function would only appear once. I am
> also using the -O switch. Are there any other ways to optimize the
> code without costing functionality? I could break apart the code into
> smaller pieces and load the code for each word from disk every time
> it's executed. Any other ideas? Thank you.

Factor out the data. The main program should be more of an interpreter
that loads the chapters or even smaller parts as data.

Ciao,
Marc 'BlackJack' Rintsch
From: Harry Potter on
On Apr 13, 6:15 pm, Richard James <rja...(a)invalid.com> wrote:
> Without seeing the code this is very hard to say. Maybe you could put the
> code on a website and post a link here so that people can look and see if
> they can offer advice.
>

I plan to make this project closed-source, but I will reveal the vLook
(verb look) and vGo (verb go) functions here:

void vLook (char Itm1)
{
unsigned char i;
if (Itm1!=-1) {
if (SearchInv (Player.Inv, Itm1)!=-1 ||
SearchInv (Player.RoomInv[Player.CurRoom], Itm1))
{
if (Itm1 < NumItems)
printf (Item[Itm1].Info);
//else
// ;
return;
}
else {
printf (Message[msgItemNotAvail]);
return;
}
}
printf (Room[Player.CurRoom].Desc);
(*Room[Player.CurRoom].RoomHandler) ();
putchar (13);

for (i=0; i<8 && Player.RoomInv[Player.CurRoom][i]!=-1;++i)
printf ("There is a %s here.\n",
Item[Player.RoomInv[Player.CurRoom][i]].Name);
if (i) /*{cputc (13); cputc (10);}*/
putchar (13);
}

void vGo (char Itm1)
{
char s=0; /* 1 if go successful */
char Dir=-1;
unsigned char i;
switch (Itm1)
{
case iNorth:
Dir = 0; s = 1; break;
case iSouth:
Dir = 1; s = 1; break;
case iEast:
Dir = 2; s = 1; break;
case iWest:
Dir = 3; s = 1; break;
case iTeleporter:
if (SearchInv(Player.RoomInv[Player.CurRoom],
iTeleporter) == 0) {
printf ("There's no teleporter here.\n");
return;
}
Player.ExitRoom = Player.CurRoom;
Player.CurRoom = rTeleporter;
s = 1; break;
}
if (s == 0) {
printf (Message[msgCantGoThere]); return;
}
if (Dir != -1) {
i= Room[Player.CurRoom].NextRoom[Dir];
if (i==-1) {
printf (Message[msgCantGoThere]); return;
}
Player.CurRoom = i; Player.ExitRoom = -1;
s = 1;
}
vLook(-1);
return;
};