1 /** bug-3741.c: A segfault at compile time that only happens on some systems?
6 #define PRN_TILE_WIDTH 20
8 #if defined(__SDCC_z80) || defined(SDCC_sm83)
9 #define PR __preserves_regs(b, c, h, l)
15 void mymemset(void *s
, unsigned char c
, unsigned int n
);
16 unsigned char * get_xy(unsigned char x
, unsigned char y
);
17 unsigned char get_byte(unsigned char * addr
) PR
;
18 void vmemcpy(unsigned char *dest
, unsigned char *sour
, unsigned int len
);
20 unsigned char * _VRAM8000
= (__xdata
unsigned char *)0x8000;
21 unsigned char * _VRAM9000
= (__xdata
unsigned char *)0x9000;
23 unsigned char some_func(unsigned char sx
, unsigned char sy
, unsigned char sw
, unsigned char sh
, unsigned char centered
) __banked
{
25 unsigned char tile_data
[16], rows
= ((sh
& 0x01) ? (sh
+ 1) : sh
), x_ofs
= (centered
) ? ((PRN_TILE_WIDTH
- sw
) >> 1) : 0;
27 for (unsigned char y
= 0; y
!= rows
; y
++) {
28 unsigned char * map_addr
= get_xy(sx
, y
+ sy
);
29 for (unsigned char x
= 0; x
!= PRN_TILE_WIDTH
; x
++) {
30 if ((x
>= x_ofs
) && (x
< (x_ofs
+ sw
)) && (y
< sh
)) {
31 unsigned char tile
= get_byte(map_addr
++);
32 unsigned char * source
= (((y
+ sy
) > 11) || (tile
> 127)) ? _VRAM8000
: _VRAM9000
;
33 vmemcpy(tile_data
, source
+ ((unsigned int)tile
<< 4), sizeof(tile_data
));
35 else mymemset(tile_data
, 0x00, sizeof(tile_data
));
46 void mymemset(void *s
, unsigned char c
, unsigned int n
)
53 unsigned char * get_xy(unsigned char x
, unsigned char y
)
60 unsigned char get_byte(unsigned char * addr
) PR
66 void vmemcpy(unsigned char *dest
, unsigned char *sour
, unsigned int len
)