
typedef unsigned char U8;
typedef unsigned char S8;
typedef unsigned int U16;

#define NUMBER_OF_GROUPS 9
#define UNITS_PER_GROUP  8

unsigned char code ID_TBL[NUMBER_OF_GROUPS * UNITS_PER_GROUP] = {
    0x01, 0x02, 0x03, 0x04, 0x65, 0x66, 0x67, 0x68, /* Group 01 */
    0x05, 0x06, 0x07, 0x08, 0x69, 0x70, 0x71, 0x72, /* Group 02 */
    0x09, 0x10, 0x11, 0x12, 0x73, 0x74, 0x75, 0x76, /* Group 03	*/
    0x13, 0x14, 0x15, 0x16, 0x77, 0x78, 0x79, 0x80, /* Group 04	*/
    0x17, 0x18, 0x19, 0x20, 0x81, 0x82, 0x83, 0x84, /* Group 05 */
    0x21, 0x22, 0x23, 0x24, 0x85, 0x86, 0x87, 0x88, /* Group 06 */
    0x25, 0x26, 0x27, 0x28, 0x89, 0x90, 0x91, 0x92, /* Group 07 */
    0x29, 0x30, 0x31, 0x32, 0x93, 0x94, 0x95, 0x96, /* Group 08 */
    0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40	/* Group 09 */
};

typedef struct {
    U8 num;
    U16 price;
    U8 num_units;
    U8 unit_status;
    /* char code *name; */
} group_t;


/* code size = 19 bytes */
U8 get_unit_id1(group_t xdata *pgr, U8 unit_indx)
{
    U8 idata x;

    x = (pgr->num - 1) * UNITS_PER_GROUP;
    return ID_TBL[x + unit_indx];
}

/* code size = 20 bytes */
U8 get_unit_id2(group_t xdata *pgr, U8 unit_indx)
{
    U8 idata x;

    x = ((pgr->num - 1) * UNITS_PER_GROUP) + unit_indx;
    return ID_TBL[x];
}

/* code size = 25 bytes */
U8 get_unit_id3(group_t xdata *pgr, U8 unit_indx)
{
    U8 idata x;

    x = pgr->num - 1;
    x *= UNITS_PER_GROUP;
    x += unit_indx;
    x = ID_TBL[x];
    return x;
}

/* code size = 33 bytes */
U8 get_unit_id4(group_t xdata *pgr, U8 unit_indx)
{
    return ID_TBL[((pgr->num - 1) * UNITS_PER_GROUP) + unit_indx];
}
