Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Can't compile latest WIP 2005-06-24

Reply to topic
Author Message
  • Joined: 27 Apr 2005
  • Posts: 50
  • Location: Poland
Reply with quote
Can't compile latest WIP 2005-06-24
Post Posted: Fri Jun 24, 2005 10:47 am
Quote
cc -I. -I./tools -I./sound -Ilibs -I/home/jsikorski/downloads/seal-1.07/include -I../include -DUNIX -DX86_ASM -DMEKA_SOUND -DMEKA_ZIP -DMEKA_PNG -DMEKA_JOY -DMEKA_Z80_DEBUGGER -Wall -march=prescott -O3 -ffast-math -fno-strength-reduce -funroll-all-loops -DMARAT_Z80 -c blit.c -oobj/blit.o
blit.c: In function ‘Blit_Fullscreen_TV_Mode’:
blit.c:273: error: invalid lvalue in increment
blit.c:286: error: invalid lvalue in increment
blit.c: In function ‘Blit_Fullscreen_TV_Mode_Double’:
blit.c:316: error: invalid lvalue in increment
blit.c:320: error: invalid lvalue in increment
make: *** [obj/blit.o] Error 1
[jsikorski@DOMOWY srcs]$

I am using Fedora Core 4. What can be wrong? Greets.
  View user's profile Send private message
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8653
  • Location: Paris, France
Reply with quote
Post Posted: Fri Jun 24, 2005 10:49 am
Please quote the corresponding code.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14749
  • Location: London
Reply with quote
Post Posted: Fri Jun 24, 2005 11:03 am
  byte *psrc;
...
         int color = *((int *)psrc)++;

It's complaining about incrementing cast pointers for each line mentioned. An extra pair of brackets to make
         int color = *(((int *)psrc)++);

is needed because ++ and *(dereference) are equal priority so it is ambiguous otherwise.
  View user's profile Send private message Visit poster's website
  • Joined: 27 Apr 2005
  • Posts: 50
  • Location: Poland
Reply with quote
Post Posted: Fri Jun 24, 2005 12:37 pm
I have changed the code but unfortunately the error is still the same.
void    Blit_Fullscreen_TV_Mode (void)
{
  byte  b;
  int   i, j;
  byte *psrc;
  byte *pdst;

  Blit_Fullscreen_Misc ();
  for (i = 0; i < cur_drv->y_res; i ++)
      {
      blit (screenbuffer, fs_out,
         blit_cfg.src_sx, blit_cfg.src_sy + i,
         blit_cfg.dst_sx, blit_cfg.dst_sy + (i * 2),
         cur_drv->x_res, 1);
      j = cur_drv->x_res;
      psrc = &screenbuffer->line[blit_cfg.src_sy + i][blit_cfg.src_sx];
      pdst = &Work_Line->line[0][0];
      while (j > 4)
         {
         int color = *(((int *)psrc)++);
         // FIXME: the test is due to black & white colors
         // If we can have them set in the upper color area, then
         // the test could be safely removed
         // Note: & 0xC0 is to only increase game colors (0-63)
         if (!(color & 0x000000C0))
            color += GUI_COL_AVAIL_START;
         if (!(color & 0x0000C000))
            color += GUI_COL_AVAIL_START << 8;
         if (!(color & 0x00C00000))
            color += GUI_COL_AVAIL_START << 16;
         if (!(color & 0xC0000000))
            color += GUI_COL_AVAIL_START << 24;
         *(((int *)pdst)++) = color;
         j -= 4;
         }
      while (j--)
         {
         b = *psrc++;
         if (!(b & 0xC0))
            b += GUI_COL_AVAIL_START;
         *pdst++ = b;
         }
      blit (Work_Line, fs_out,
          0, 0,
          blit_cfg.dst_sx, blit_cfg.dst_sy + (i * 2) + 1,
          cur_drv->x_res, 1);
      }
}

void    Blit_Fullscreen_TV_Mode_Double (void)
{
  int   i;
  for (i = 0; i < cur_drv->y_res; i ++)
      {
      byte *psrc  = &screenbuffer->line[blit_cfg.src_sy + i][blit_cfg.src_sx];
      byte *pdst1 = double_buffer->line[(i * 2)];
      byte *pdst2 = double_buffer->line[(i * 2) + 1];
      int j = cur_drv->x_res;
      while (j--)
         {
         byte b = *psrc++;
         word color = b | (b << 8);
         *(((word *)pdst1)++) = color;
         // Note: & 0xC0 is to only increase game colors (0-63)
         if (!(color & 0xC0C0))
            color += GUI_COL_AVAIL_START | (GUI_COL_AVAIL_START << 8);
         *(((word *)pdst2)++) = color;
         }
      }
  Blit_Fullscreen_Misc ();
  blit (double_buffer, fs_out,
         0, 0,
         blit_cfg.dst_sx, blit_cfg.dst_sy,
         cur_drv->x_res * 2, cur_drv->y_res * 2);
}

Fedora Core 4 is bundled with gcc 4.0.0, maybe this is causing a problem.
  View user's profile Send private message
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8653
  • Location: Paris, France
Reply with quote
Post Posted: Fri Jun 24, 2005 1:46 pm
Apparently the C language doesn't allow casting a lvalue pointers for the purpose of incrementing it. I've been using this feature since forever to ease the increment of pointers based on a given type.

Apparently (again), GCC 4.0 for some reason broke this to enforce good coding practice, or possibly for another reason. They might have left a compiler switch to enable compatibility.

A fix could be:

Change:
*((int *)psrc)++

To:
*(int *)(psrc)
 Then psrc += 4; on the next line

Untested. Various possible alternatives
  View user's profile Send private message Visit poster's website
  • Joined: 27 Apr 2005
  • Posts: 50
  • Location: Poland
Reply with quote
Post Posted: Sat Jun 25, 2005 7:38 am
I did so for all 4 errors, which allowed me to compile everything. Now what I get at the linking stage:
Quote
obj/blit.o(.text+0xe06): In function `Blit_Fullscreen_HQ2X':
blit.c: undefined reference to `hq2x_16'
obj/blit.o(.text+0x2b): In function `Blit_Init':
blit.c: undefined reference to `HQ2X_Init'
collect2: ld returned 1 exit status
make: *** [../meka.exe] Error 1
[jsikorski@DOMOWY srcs]$

I've edited both hq2x16.asm and hq2x32.asm according to 'unix underscore' pattern.

[edit]
I've managed to get a bit further by adding hq2x.o and hq2x16.o to the makefile. You also need to add there -O1 option for assembling hq2x files. Also adding hq2x32.o gives the following error:
Quote
obj/hq2x32.o(.text+0x0): In function `hq2x_16':
hq2x16.asm: multiple definition of `hq2x_16'
obj/hq2x16.o(.text+0x0):hq2x16.asm: first defined here
collect2: ld returned 1 exit status
make: *** [../meka.exe] Error 1
[jsikorski@DOMOWY srcs]$
  View user's profile Send private message
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8653
  • Location: Paris, France
Reply with quote
Post Posted: Sat Jun 25, 2005 11:44 am
Maybe you have pasted symbolsfrom hq2x16 into hq2x32?
Anyway hq2x32 is not used as of yet.

I always forget to update the Makefile. I should get myself a Linux installation somewhere to be able to test those.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!