static void musicpal_lcd_write(void *opaque, target_phys_addr_t offset,

                               uint64_t value, unsigned size)

{

    musicpal_lcd_state *s = opaque;



    switch (offset) {

    case MP_LCD_IRQCTRL:

        s->irqctrl = value;

        break;



    case MP_LCD_SPICTRL:

        if (value == MP_LCD_SPI_DATA || value == MP_LCD_SPI_CMD) {

            s->mode = value;

        } else {

            s->mode = MP_LCD_SPI_INVALID;

        }

        break;



    case MP_LCD_INST:

        if (value >= MP_LCD_INST_SETPAGE0 && value <= MP_LCD_INST_SETPAGE7) {

            s->page = value - MP_LCD_INST_SETPAGE0;

            s->page_off = 0;

        }

        break;



    case MP_LCD_DATA:

        if (s->mode == MP_LCD_SPI_CMD) {

            if (value >= MP_LCD_INST_SETPAGE0 &&

                value <= MP_LCD_INST_SETPAGE7) {

                s->page = value - MP_LCD_INST_SETPAGE0;

                s->page_off = 0;

            }

        } else if (s->mode == MP_LCD_SPI_DATA) {

            s->video_ram[s->page*128 + s->page_off] = value;

            s->page_off = (s->page_off + 1) & 127;

        }

        break;

    }

}

static void musicpal_lcd_write(void *opaque, target_phys_addr_t offset,

                               uint64_t value, unsigned size)

{

    musicpal_lcd_state *s = opaque;



    switch (offset) {

    case MP_LCD_IRQCTRL:

        s->irqctrl = value;

        break;



    case MP_LCD_SPICTRL:

        if (value == MP_LCD_SPI_DATA || value == MP_LCD_SPI_CMD) {

            s->mode = value;

        } else {

            s->mode = MP_LCD_SPI_INVALID;

        }

        break;



    case MP_LCD_INST:

        if (value >= MP_LCD_INST_SETPAGE0 && value <= MP_LCD_INST_SETPAGE7) {

            s->page = value - MP_LCD_INST_SETPAGE0;

            s->page_off = 0;

        }

        break;



    case MP_LCD_DATA:

        if (s->mode == MP_LCD_SPI_CMD) {

            if (value >= MP_LCD_INST_SETPAGE0 &&

                value <= MP_LCD_INST_SETPAGE7) {

                s->page = value - MP_LCD_INST_SETPAGE0;

                s->page_off = 0;

            }

        } else if (s->mode == MP_LCD_SPI_DATA) {

            s->video_ram[s->page*128 + s->page_off] = value;

            s->page_off = (s->page_off + 1) & 127;

        }

        break;

    }

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,

                               uint64_t VAR_2, unsigned VAR_3)

{

    musicpal_lcd_state *s = VAR_0;



    switch (VAR_1) {

    case MP_LCD_IRQCTRL:

        s->irqctrl = VAR_2;

        break;



    case MP_LCD_SPICTRL:

        if (VAR_2 == MP_LCD_SPI_DATA || VAR_2 == MP_LCD_SPI_CMD) {

            s->mode = VAR_2;

        } else {

            s->mode = MP_LCD_SPI_INVALID;

        }

        break;



    case MP_LCD_INST:

        if (VAR_2 >= MP_LCD_INST_SETPAGE0 && VAR_2 <= MP_LCD_INST_SETPAGE7) {

            s->page = VAR_2 - MP_LCD_INST_SETPAGE0;

            s->page_off = 0;

        }

        break;



    case MP_LCD_DATA:

        if (s->mode == MP_LCD_SPI_CMD) {

            if (VAR_2 >= MP_LCD_INST_SETPAGE0 &&

                VAR_2 <= MP_LCD_INST_SETPAGE7) {

                s->page = VAR_2 - MP_LCD_INST_SETPAGE0;

                s->page_off = 0;

            }

        } else if (s->mode == MP_LCD_SPI_DATA) {

            s->video_ram[s->page*128 + s->page_off] = VAR_2;

            s->page_off = (s->page_off + 1) & 127;

        }

        break;

    }

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{ musicpal_lcd_state *s = VAR_0; switch (VAR_1) { case MP_LCD_IRQCTRL:
s->irqctrl = VAR_2; break; case MP_LCD_SPICTRL:
if (VAR_2 == MP_LCD_SPI_DATA || VAR_2 == MP_LCD_SPI_CMD) { s->mode = VAR_2; } else { s->mode = MP_LCD_SPI_INVALID; } break; case MP_LCD_INST:
if (VAR_2 >= MP_LCD_INST_SETPAGE0 && VAR_2 <= MP_LCD_INST_SETPAGE7) { s->page = VAR_2 - MP_LCD_INST_SETPAGE0; s->page_off = 0; } break; case MP_LCD_DATA:
if (s->mode == MP_LCD_SPI_CMD) { if (VAR_2 >= MP_LCD_INST_SETPAGE0 &&
VAR_2 <= MP_LCD_INST_SETPAGE7) { s->page = VAR_2 - MP_LCD_INST_SETPAGE0; s->page_off = 0; } } else if (s->mode == MP_LCD_SPI_DATA) { s->video_ram[s->page*128 + s->page_off] = VAR_2; s->page_off = (s->page_off + 1) & 127; } break; } }