2 gbz80 backend overwrote still-needed value by using hl as address register for a global variable when the to-be-stored value was allocated to h or l.
8 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
14 #define to_x(x,y,z) ((x) + (y))
15 #define to_y(x,y,z) ((7u * 8u) + ((x) << 2u) - ((y) << 2u) - ((z) << 3u))
16 #define to_coords(x,y,z) (((x) << 8u) | ((8u - (y)) << 4u) | (z))
17 #define from_coords(coord, x, y, z) (x = ((coord) >> 8u), y = (8u - ((coord) >> 4u) & 0x0f), z = ((coord) & 0x0f))
19 typedef unsigned char UBYTE
;
20 typedef unsigned int UWORD
;
22 typedef unsigned char scene_t
[max_scene_x
][max_scene_z
][max_scene_y
];
24 typedef struct scene_item_t
{
27 struct scene_item_t
* next
;
30 scene_t collision_buf
;
32 void clear_map(void * data
) {
36 void scene_to_map(const scene_item_t
* sour
, scene_t
* dest
) {
37 static scene_item_t
* src
;
42 src
= (scene_item_t
*)sour
;
44 from_coords(src
->coords
, x
, y
, z
);
45 if ((x
< max_scene_x
) && (y
< max_scene_y
) && (z
< max_scene_z
)) {
46 (*dest
)[x
][z
][y
] = src
->id
+ 1;
51 const scene_item_t scene_items
[] = {
52 {.id
=1, .x
=to_x(0, 8, 0), .y
=to_y(0, 8, 0), .coords
=to_coords(0, 8, 0), .next
=&scene_items
[1]},
53 {.id
=1, .x
=to_x(0, 8, 1), .y
=to_y(0, 8, 1), .coords
=to_coords(0, 8, 1), .next
=0},
61 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
62 scene_to_map(scene_items
, &collision_buf
);
64 ASSERT(collision_buf
[0][0][max_scene_y
- 1] == 2);
65 ASSERT(collision_buf
[0][1][max_scene_y
- 1] == 2);