static int toaplan2_videoram_r(int offset, int controller) {

        int videoram_offset;

        switch (toaplan2_voffs[controller] & 0xfc00) {
            case 0x0400:
            case 0x0000:
                videoram_offset = bg_offs[controller] & (TOAPLAN2_BG_VRAM_SIZE - 1);
                video_data = bgvideoram[controller].READ_WORD(videoram_offset);
                bg_offs[controller] += 2;
                if (bg_offs[controller] > TOAPLAN2_BG_VRAM_SIZE) {
                    if (errorlog != null) {
                        fprintf(errorlog, "Reading %04x from out of range BG Layer address (%08x)  Video controller %01x  !!!\n", video_data, bg_offs[controller], controller);
                    }
                }
                break;
            case 0x0c00:
            case 0x0800:
                videoram_offset = fg_offs[controller] & (TOAPLAN2_FG_VRAM_SIZE - 1);
                video_data = fgvideoram[controller].READ_WORD(videoram_offset);
                fg_offs[controller] += 2;
                if (fg_offs[controller] > TOAPLAN2_FG_VRAM_SIZE) {
                    if (errorlog != null) {
                        fprintf(errorlog, "Reading %04x from out of range FG Layer address (%08x)  Video controller %01x  !!!\n", video_data, fg_offs[controller], controller);
                    }
                }
                break;
            case 0x1400:
            case 0x1000:
                videoram_offset = top_offs[controller] & (TOAPLAN2_TOP_VRAM_SIZE - 1);
                video_data = topvideoram[controller].READ_WORD(videoram_offset);
                top_offs[controller] += 2;
                if (top_offs[controller] > TOAPLAN2_TOP_VRAM_SIZE) {
                    if (errorlog != null) {
                        fprintf(errorlog, "Reading %04x from out of range TOP Layer address (%08x)  Video controller %01x  !!!\n", video_data, top_offs[controller], controller);
                    }
                }
                break;
            case 0x1800:
                videoram_offset = sprite_offs[controller] & (TOAPLAN2_SPRITERAM_SIZE - 1);
                video_data = spriteram_new[controller].READ_WORD(videoram_offset);
                sprite_offs[controller] += 2;
                if (sprite_offs[controller] > TOAPLAN2_SPRITERAM_SIZE) {
                    if (errorlog != null) {
                        fprintf(errorlog, "Reading %04x from out of range Sprite address (%08x)  Video controller %01x  !!!\n", video_data, sprite_offs[controller], controller);
                    }
                }
                break;
            default:
                video_data = toaplan2_unk_vram;
                if (errorlog != null) {
                    fprintf(errorlog, "Hmmm, reading %04x from unknown video layer (%08x)  Video controller %01x  !!!\n", video_data, toaplan2_voffs[controller], controller);
                }
                break;
        }
        return video_data;
    }