Re: [cc65] ASM to C help a n00b

From: S M <san.mes1gmail.com>
Date: 2010-05-27 14:32:19
Hello

I tried your code and I got the same error on the line uint8_t
*tile_buffers[] = {tile_buffer01, tile_buffer02, tile_buffer03,
   tile_buffer04, tile_buffer05, tile_buffer06, tile_buffer07,
   tile_buffer08, tile_buffer09, tile_buffer10, tile_buffer11,
   tile_buffer12};

as I was getting on line 29 previously with

unsigned char *tile_buffer [] =  {tile_buffer01, tile_buffer02,
tile_buffer03, tile_buffer04, tile_buffer05, tile_buffer06,
tile_buffer07, tile_buffer08, tile_buffer09, tile_buffer10,
tile_buffer11, tile_buffer12};

The code(arrays char tile_buffer) I posted in my first email was taken from
a working z88dk c file , I am porting that game to the c64. I might change
it later on to optimize for example create just an array of size 96 instead
of the 12 arrays.

Thank you




2010/5/27 Marc 'BlackJack Rintsch <marc@rintsch.de>

> On Thursday 27 May 2010, S M wrote:
> > How can I have the following but in C?:
>
> What exactly of this do you need in C?  I mean do you really need two
> names for the low and high part of the pointer to the `char0` for
> example?  Or is that just more convenient in ASM.
>
> > I tried for example:
> >
> > unsigned char tile_buffer01 [8];
> > unsigned char tile_buffer02 [8];
> > unsigned char tile_buffer03 [8];
> > unsigned char tile_buffer04 [8];
> > unsigned char tile_buffer05 [8];
> > unsigned char tile_buffer06 [8];
> > unsigned char tile_buffer07 [8];
> > unsigned char tile_buffer08 [8];
> > unsigned char tile_buffer09 [8];
> > unsigned char tile_buffer10 [8];
> > unsigned char tile_buffer11 [8];
> > unsigned char tile_buffer12 [8];
> > unsigned char *tile_buffer [] =  {tile_buffer01, tile_buffer02,
> > tile_buffer03, tile_buffer04, tile_buffer05, tile_buffer06,
> > tile_buffer07, tile_buffer08, tile_buffer09, tile_buffer10,
> > tile_buffer11, tile_buffer12};
> >
> > but it didn't work I get teste.c(29) Error: Constant expression
> > expected teste.c(29): Warning: Converting integer to pointer without
> > a cast .
>
> That's not 29 lines so you don't get that error for just the shown
> source.  Just that compiles fine for me.  Here's what I used:
>
> ----
>
> #include <stdint.h>
>
> uint8_t tile_buffer01[8];
> uint8_t tile_buffer02[8];
> uint8_t tile_buffer03[8];
> uint8_t tile_buffer04[8];
> uint8_t tile_buffer05[8];
> uint8_t tile_buffer06[8];
> uint8_t tile_buffer07[8];
> uint8_t tile_buffer08[8];
> uint8_t tile_buffer09[8];
> uint8_t tile_buffer10[8];
> uint8_t tile_buffer11[8];
> uint8_t tile_buffer12[8];
>
> uint8_t *tile_buffers[] = {tile_buffer01, tile_buffer02, tile_buffer03,
>     tile_buffer04, tile_buffer05, tile_buffer06, tile_buffer07,
>    tile_buffer08, tile_buffer09, tile_buffer10, tile_buffer11,
>    tile_buffer12};
>
> int main(void)
> {
>    return 0;
> }
>
> ----
>
> Again the question: Is that really what you need in C?  Do you change
> the content of the pointer array within the program?  If not then::
>
>  uint8_t tile_buffers[12][8];
>
> would be much shorter.  Even if the pointer table to the individual
> buffers is needed at runtime I would write it that way because
> enumerating variable names is a "code smell" indicating that you really
> wanted an array in the first place.
>
> Ciao,
>        Marc 'BlackJack' Rintsch
> --
> “Think of it!  With VLSI we can pack 100 ENIACS in 1 cm².”
>                                         -- Alan J. Perlis
>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu May 27 14:32:25 2010

This archive was generated by hypermail 2.1.8 : 2010-05-27 14:32:28 CEST