static void toaplan2_scroll_reg_data_w(int offset, int data, int controller) {
        /**
         * *********************************************************************
         */
        /**
         * *** X and Y layer flips can be set independantly, so emulate it *****
         */
        /**
         * *********************************************************************
         */

        //	int vid_controllers = 1;
        switch (toaplan2_scroll_reg[controller]) {
            case 0x00:
                bg_scrollx[controller] = data - 0x1d6;
                /* 1D6h */
                bg_flip[controller] &= (~TILEMAP_FLIPX);
                tilemap_set_flip(bg_tilemap[controller], bg_flip[controller]);
                tilemap_set_scrollx(bg_tilemap[controller], 0, bg_scrollx[controller]);
                break;
            case 0x01:
                bg_scrolly[controller] = data - 0x1ef;
                /* 1EFh */
                bg_flip[controller] &= (~TILEMAP_FLIPY);
                tilemap_set_flip(bg_tilemap[controller], bg_flip[controller]);
                tilemap_set_scrolly(bg_tilemap[controller], 0, bg_scrolly[controller]);
                break;
            case 0x02:
                fg_scrollx[controller] = data - 0x1d8;
                /* 1D0h */
                fg_flip[controller] &= (~TILEMAP_FLIPX);
                tilemap_set_flip(fg_tilemap[controller], fg_flip[controller]);
                tilemap_set_scrollx(fg_tilemap[controller], 0, fg_scrollx[controller]);
                break;
            case 0x03:
                fg_scrolly[controller] = data - 0x1ef;
                /* 1EFh */
                fg_flip[controller] &= (~TILEMAP_FLIPY);
                tilemap_set_flip(fg_tilemap[controller], fg_flip[controller]);
                tilemap_set_scrolly(fg_tilemap[controller], 0, fg_scrolly[controller]);
                break;
            case 0x04:
                top_scrollx[controller] = data - 0x1da;
                /* 1DAh */
                top_flip[controller] &= (~TILEMAP_FLIPX);
                tilemap_set_flip(top_tilemap[controller], top_flip[controller]);
                tilemap_set_scrollx(top_tilemap[controller], 0, top_scrollx[controller]);
                break;
            case 0x05:
                top_scrolly[controller] = data - 0x1ef;
                /* 1EFh */
                top_flip[controller] &= (~TILEMAP_FLIPY);
                tilemap_set_flip(top_tilemap[controller], top_flip[controller]);
                tilemap_set_scrolly(top_tilemap[controller], 0, top_scrolly[controller]);
                break;
            case 0x06:
                sprite_scrollx[controller] = data - 0x1cc;
                /* 1D4h */
                if ((sprite_scrollx[controller] & 0x80000000) != 0) {
                    sprite_scrollx[controller] |= 0xfffffe00;
                } else {
                    sprite_scrollx[controller] &= 0x1ff;
                }
                sprite_flip[controller] &= (~TOAPLAN2_SPRITE_FLIPX);
                break;
            case 0x07:
                sprite_scrolly[controller] = data - 0x1ef;
                /* 1F7h */
                if ((sprite_scrolly[controller] & 0x80000000) != 0) {
                    sprite_scrolly[controller] |= 0xfffffe00;
                } else {
                    sprite_scrolly[controller] &= 0x1ff;
                }
                sprite_flip[controller] &= (~TOAPLAN2_SPRITE_FLIPY);
                break;
            case 0x0f:
                break;
            case 0x80:
                bg_scrollx[controller] = data - 0x229;
                /* 169h */
                bg_flip[controller] |= TILEMAP_FLIPX;
                tilemap_set_flip(bg_tilemap[controller], bg_flip[controller]);
                tilemap_set_scrollx(bg_tilemap[controller], 0, bg_scrollx[controller]);
                break;
            case 0x81:
                bg_scrolly[controller] = data - 0x210;
                /* 100h */
                bg_flip[controller] |= TILEMAP_FLIPY;
                tilemap_set_flip(bg_tilemap[controller], bg_flip[controller]);
                tilemap_set_scrolly(bg_tilemap[controller], 0, bg_scrolly[controller]);
                break;
            case 0x82:
                fg_scrollx[controller] = data - 0x227;
                /* 15Fh */
                fg_flip[controller] |= TILEMAP_FLIPX;
                tilemap_set_flip(fg_tilemap[controller], fg_flip[controller]);
                tilemap_set_scrollx(fg_tilemap[controller], 0, fg_scrollx[controller]);
                break;
            case 0x83:
                fg_scrolly[controller] = data - 0x210;
                /* 100h */
                fg_flip[controller] |= TILEMAP_FLIPY;
                tilemap_set_flip(fg_tilemap[controller], fg_flip[controller]);
                tilemap_set_scrolly(fg_tilemap[controller], 0, fg_scrolly[controller]);
                break;
            case 0x84:
                top_scrollx[controller] = data - 0x225;
                /* 165h */
                top_flip[controller] |= TILEMAP_FLIPX;
                tilemap_set_flip(top_tilemap[controller], top_flip[controller]);
                tilemap_set_scrollx(top_tilemap[controller], 0, top_scrollx[controller]);
                break;
            case 0x85:
                top_scrolly[controller] = data - 0x210;
                /* 100h */
                top_flip[controller] |= TILEMAP_FLIPY;
                tilemap_set_flip(top_tilemap[controller], top_flip[controller]);
                tilemap_set_scrolly(top_tilemap[controller], 0, top_scrolly[controller]);
                break;
            case 0x86:
                sprite_scrollx[controller] = data - 0x17b;
                /* 17Bh */
                if ((sprite_scrollx[controller] & 0x80000000) != 0) {
                    sprite_scrollx[controller] |= 0xfffffe00;
                } else {
                    sprite_scrollx[controller] &= 0x1ff;
                }
                sprite_flip[controller] |= TOAPLAN2_SPRITE_FLIPX;
                break;
            case 0x87:
                sprite_scrolly[controller] = data - 0x108;
                /* 108h */
                if ((sprite_scrolly[controller] & 0x80000000) != 0) {
                    sprite_scrolly[controller] |= 0xfffffe00;
                } else {
                    sprite_scrolly[controller] &= 0x1ff;
                }
                sprite_flip[controller] |= TOAPLAN2_SPRITE_FLIPY;
                break;
            case 0x8f:
                break;

            case 0x0e:
                /**
                 * ***** Initialise video controller register ? ******
                 */
                if ((toaplan2_sub_cpu == CPU_2_Z80) && (data == 3)) {
                    /* HACK! When tilted, sound CPU needs to be reset. */
                    cpu_set_reset_line(1, PULSE_LINE);
                    YM3812_sh_reset();
                }
            default:
                if (errorlog != null) {
                    fprintf(errorlog, "Hmmm, writing %08x to unknown video control register (%08x)  Video controller %01x  !!!\n", data, toaplan2_scroll_reg[controller], controller);
                }
                break;
        }

    }