]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Chipset emulation updates, multithreaded Denise/Lisa emulation.
authorToni Wilen <twilen@winuae.net>
Fri, 7 Mar 2025 16:08:06 +0000 (18:08 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 7 Mar 2025 16:08:06 +0000 (18:08 +0200)
12 files changed:
custom.cpp
drawing.cpp
genlinetoscr.cpp
include/custom.h
include/drawing.h
include/xwin.h
linetoscr_aga_fast.cpp
linetoscr_aga_genlock_fast.cpp [new file with mode: 0644]
linetoscr_ecs_fast.cpp
linetoscr_ecs_genlock_fast.cpp [new file with mode: 0644]
od-win32/win32.cpp
specialmonitors.cpp

index 38059698b31494d5f902193470b6e7e67eb476ce..57a40dcee916c154699509dd017001b699518b44 100644 (file)
@@ -120,6 +120,7 @@ static uae_u32 custom_state_flags;
 static int not_safe_mode;
 static bool dmal_next;
 static int fast_lines_cnt;
+static bool lineoptimizations_allowed;
 
 static uae_u32 scandoubled_bpl_ptr[MAX_SCANDOUBLED_LINES][2][MAX_PLANES];
 static bool scandoubled_bpl_ena[MAX_SCANDOUBLED_LINES];
@@ -173,13 +174,18 @@ static void handle_pipelined_custom_write(bool now)
        }
 }
 
+#define CE_MODE_RGA_OPTIMIZATIONS 0
+
 static uae_u32 rga_slot_in_offset, rga_slot_first_offset, rga_slot_out_offset;
 static evt_t last_rga_cycle;
+
+#if CE_MODE_RGA_OPTIMIZATIONS
 static bool drga_written;
 static bool fast_mode_ce_not;
 static bool drga_bpl, drga_spr;
 static int fast_mode_strobe_cnt;
 static uae_u8 bpl_line_store[256 * 8];
+#endif
 
 static void write_drga_strobe(uae_u16 rga)
 {
@@ -187,6 +193,7 @@ static void write_drga_strobe(uae_u16 rga)
        r->rga = rga;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (rga == 0x38 || rga == 0x3a || rga == 0x3c) {
                if (agnus_hpos != 3 || fast_mode_strobe_cnt != 0) {
                        fast_mode_ce_not = true;
@@ -198,6 +205,7 @@ static void write_drga_strobe(uae_u16 rga)
                }
        }
        fast_mode_strobe_cnt++;
+#endif
 };
 static void write_drga(uae_u16 rga, uaecptr pt, uae_u32 v)
 {
@@ -207,7 +215,9 @@ static void write_drga(uae_u16 rga, uaecptr pt, uae_u32 v)
        r->pt = pt;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 };
 static void write_drga_dat_spr(uae_u16 rga, uaecptr pt, uae_u32 v)
 {
@@ -217,7 +227,9 @@ static void write_drga_dat_spr(uae_u16 rga, uaecptr pt, uae_u32 v)
        r->pt = pt;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        drga_spr = true;
+#endif
 };
 static void write_drga_dat_spr_wide(uae_u16 rga, uaecptr pt, uae_u64 v)
 {
@@ -227,12 +239,16 @@ static void write_drga_dat_spr_wide(uae_u16 rga, uaecptr pt, uae_u64 v)
        r->pt = pt;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        drga_spr = true;
+#endif
 };
 
+#if CE_MODE_RGA_OPTIMIZATIONS
 static uae_u16 *fast_plane_store16[MAX_PLANES];
 static uae_u32 *fast_plane_store32[MAX_PLANES];
 static uae_u64 *fast_plane_store64[MAX_PLANES];
+#endif
 
 static void write_drga_dat_bpl16(uae_u16 rga, uaecptr pt, uae_u16 v, int plane)
 {
@@ -242,11 +258,13 @@ static void write_drga_dat_bpl16(uae_u16 rga, uaecptr pt, uae_u16 v, int plane)
        r->pt = pt;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (currprefs.cpu_memory_cycle_exact) {
                *fast_plane_store16[plane] = v;
                fast_plane_store16[plane]++;
        }
        drga_bpl = true;
+#endif
 };
 static void write_drga_dat_bpl32(uae_u16 rga, uaecptr pt, uae_u32 v, int plane)
 {
@@ -256,11 +274,13 @@ static void write_drga_dat_bpl32(uae_u16 rga, uaecptr pt, uae_u32 v, int plane)
        r->pt = pt;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (currprefs.cpu_memory_cycle_exact) {
                *fast_plane_store32[plane] = v;
                fast_plane_store32[plane]++;
        }
        drga_bpl = true;
+#endif
 };
 static void write_drga_dat_bpl64(uae_u16 rga, uaecptr pt, uae_u64 v, int plane)
 {
@@ -270,11 +290,13 @@ static void write_drga_dat_bpl64(uae_u16 rga, uaecptr pt, uae_u64 v, int plane)
        r->pt = pt;
        r->flags = 0;
        r->line = rga_denise_cycle_line;
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (currprefs.cpu_memory_cycle_exact) {
                *fast_plane_store64[plane] = v;
                fast_plane_store64[plane]++;
        }
        drga_bpl = true;
+#endif
 };
 
 static void write_drga_flag(uae_u32 flags, uae_u32 mask)
@@ -689,7 +711,6 @@ int sprite_buffer_res;
 
 static uae_s16 bpl1mod, bpl2mod;
 static uaecptr bplpt[MAX_PLANES];
-static uaecptr bplptx[MAX_PLANES];
 
 
 uae_u16 bplcon0;
@@ -1237,6 +1258,8 @@ static void update_mirrors(void)
        if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
                hsyncdebug = currprefs.gfx_overscanmode - OVERSCANMODE_ULTRA + 1;
        }
+       struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
+       lineoptimizations_allowed = vidinfo->inbuffer == vidinfo->outbuffer && !lightpen_active;
 }
 
 void notice_new_xcolors(void)
@@ -1548,6 +1571,7 @@ static void resetfulllinestate(void)
 void compute_framesync(void)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
+       struct vidbuffer *vb = vidinfo->inbuffer;
        struct amigadisplay *ad = &adisplays[0];
        int islace = interlace_seen ? 1 : 0;
        int isntsc = (beamcon0 & BEAMCON0_PAL) ? 0 : 1;
@@ -1626,8 +1650,8 @@ void compute_framesync(void)
        }
        stored_chipset_refresh = cr;
        lof_changing = 0;
-       vidinfo->drawbuffer.inxoffset = -1;
-       vidinfo->drawbuffer.inyoffset = -1;
+       vb->inxoffset = -1;
+       vb->inyoffset = -1;
        updateextblk();
 
        hsync_end_left_border = display_hstart_cyclewait_end + display_hstart_cyclewait;
@@ -1661,57 +1685,57 @@ void compute_framesync(void)
        }
 
        if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) {
-               vidinfo->drawbuffer.inwidth = current_linear_hpos << (res2 + 1);
+               vb->inwidth = current_linear_hpos << (res2 + 1);
        } else {
-               vidinfo->drawbuffer.inwidth = (current_linear_hpos - (display_hstart_cyclewait_skip + display_hstart_cyclewait_skip2)) << (res2 + 1);
+               vb->inwidth = (current_linear_hpos - (display_hstart_cyclewait_skip + display_hstart_cyclewait_skip2)) << (res2 + 1);
        }
-       vidinfo->drawbuffer.inwidth2 = vidinfo->drawbuffer.inwidth;
-       vidinfo->drawbuffer.extrawidth = -2;
+       vb->inwidth2 = vb->inwidth;
+       vb->extrawidth = -2;
        if (currprefs.gfx_extrawidth > 0) {
-               vidinfo->drawbuffer.extrawidth = currprefs.gfx_extrawidth << res2;
+               vb->extrawidth = currprefs.gfx_extrawidth << res2;
        }
-       vidinfo->drawbuffer.extraheight = -2;
+       vb->extraheight = -2;
        if (currprefs.gfx_extraheight > 0) {
-               vidinfo->drawbuffer.extraheight = currprefs.gfx_extraheight << vres2;
+               vb->extraheight = currprefs.gfx_extraheight << vres2;
        }
-       if (vidinfo->drawbuffer.extrawidth == -2 && ((new_beamcon0 & (BEAMCON0_VARVBEN | bemcon0_vsync_mask)) || currprefs.gfx_overscanmode >= OVERSCANMODE_EXTREME)) {
-               vidinfo->drawbuffer.extrawidth = -1;
+       if (vb->extrawidth == -2 && ((new_beamcon0 & (BEAMCON0_VARVBEN | bemcon0_vsync_mask)) || currprefs.gfx_overscanmode >= OVERSCANMODE_EXTREME)) {
+               vb->extrawidth = -1;
        }
        int mfl = minfirstline + 1;
        int maxv = current_linear_vpos - (mfl > vsync_startline ? mfl - vsync_startline : 0);
-       vidinfo->drawbuffer.inheight = maxv << vres2;
-       vidinfo->drawbuffer.inheight2 = vidinfo->drawbuffer.inheight;
-       vidinfo->drawbuffer.inxoffset = 0;
+       vb->inheight = maxv << vres2;
+       vb->inheight2 = vb->inheight;
+       vb->inxoffset = 0;
 
-       //write_log(_T("Width %d Height %d\n"), vidinfo->drawbuffer.inwidth, vidinfo->drawbuffer.inheight);
+       //write_log(_T("Width %d Height %d\n"), vb->inwidth, vb->inheight);
 
-       if (vidinfo->drawbuffer.inwidth < 16)
-               vidinfo->drawbuffer.inwidth = 16;
-       if (vidinfo->drawbuffer.inwidth2 < 16)
-               vidinfo->drawbuffer.inwidth2 = 16;
-       if (vidinfo->drawbuffer.inheight < 1)
-               vidinfo->drawbuffer.inheight = 1;
-       if (vidinfo->drawbuffer.inheight2 < 1)
-               vidinfo->drawbuffer.inheight2 = 1;
+       if (vb->inwidth < 16)
+               vb->inwidth = 16;
+       if (vb->inwidth2 < 16)
+               vb->inwidth2 = 16;
+       if (vb->inheight < 1)
+               vb->inheight = 1;
+       if (vb->inheight2 < 1)
+               vb->inheight2 = 1;
 
-       if (vidinfo->drawbuffer.inwidth > vidinfo->drawbuffer.width_allocated)
-               vidinfo->drawbuffer.inwidth = vidinfo->drawbuffer.width_allocated;
-       if (vidinfo->drawbuffer.inwidth2 > vidinfo->drawbuffer.width_allocated)
-               vidinfo->drawbuffer.inwidth2 = vidinfo->drawbuffer.width_allocated;
+       if (vb->inwidth > vb->width_allocated)
+               vb->inwidth = vb->width_allocated;
+       if (vb->inwidth2 > vb->width_allocated)
+               vb->inwidth2 = vb->width_allocated;
 
-       if (vidinfo->drawbuffer.inheight > vidinfo->drawbuffer.height_allocated)
-               vidinfo->drawbuffer.inheight = vidinfo->drawbuffer.height_allocated;
-       if (vidinfo->drawbuffer.inheight2 > vidinfo->drawbuffer.height_allocated)
-               vidinfo->drawbuffer.inheight2 = vidinfo->drawbuffer.height_allocated;
+       if (vb->inheight > vb->height_allocated)
+               vb->inheight = vb->height_allocated;
+       if (vb->inheight2 > vb->height_allocated)
+               vb->inheight2 = vb->height_allocated;
 
-       vidinfo->drawbuffer.outwidth = vidinfo->drawbuffer.inwidth;
-       vidinfo->drawbuffer.outheight = vidinfo->drawbuffer.inheight;
+       vb->outwidth = vb->inwidth;
+       vb->outheight = vb->inheight;
 
-       if (vidinfo->drawbuffer.outwidth > vidinfo->drawbuffer.width_allocated)
-               vidinfo->drawbuffer.outwidth = vidinfo->drawbuffer.width_allocated;
+       if (vb->outwidth > vb->width_allocated)
+               vb->outwidth = vb->width_allocated;
 
-       if (vidinfo->drawbuffer.outheight > vidinfo->drawbuffer.height_allocated)
-               vidinfo->drawbuffer.outheight = vidinfo->drawbuffer.height_allocated;
+       if (vb->outheight > vb->height_allocated)
+               vb->outheight = vb->height_allocated;
 
        check_nocustom();
 
@@ -3172,9 +3196,11 @@ static void DMACON(int hpos, uae_u16 v)
        if (changed & (DMA_MASTER | DMA_AUD3 | DMA_AUD2 | DMA_AUD1 | DMA_AUD0)) {
                audio_state_machine();
        }
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (changed & (DMA_MASTER | DMA_BITPLANE | DMA_COPPER)) {
                fast_mode_ce_not = true;
        }
+#endif
 }
 
 static int irq_forced;
@@ -3553,12 +3579,16 @@ void set_picasso_hack_rate(int hz)
 static void BPLxPTH(uae_u16 v, int num)
 {
        bplpt[num] = (bplpt[num] & 0x0000ffff) | ((uae_u32)v << 16);
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 static void BPLxPTL(uae_u16 v, int num)
 {
        bplpt[num] = (bplpt[num] & 0xffff0000) | (v & 0x0000fffe);
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static uae_u16 BPLCON0_Agnus_mask(uae_u16 v)
@@ -3592,7 +3622,9 @@ static void BPLCON0_delayed(uae_u32 va)
        }
 
        checksyncstopped(va);
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static void BPLCON0(uae_u16 v)
@@ -3608,7 +3640,9 @@ static void BPLCON0(uae_u16 v)
                return;
        }
 
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 
        // UHRES, BYPASS
        if (va & (0x0080 | 0x0020)) {
@@ -3631,38 +3665,50 @@ static void BPLCON1(uae_u16 v)
 #endif
        bplcon1_saved = v;
        bplcon1 = v;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 static void BPLCON2(uae_u16 v)
 {
        bplcon2_saved = v;
        bplcon2 = v;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 static void BPLCON3(uae_u16 v)
 {
        bplcon3_saved = v;
        bplcon3 = v;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 static void BPLCON4(uae_u16 v)
 {
        bplcon4_saved = v;
        bplcon4 = v;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static void BPL1MOD(uae_u16 v)
 {
        v &= ~1;
        bpl1mod = v;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 static void BPL2MOD(uae_u16 v)
 {
        v &= ~1;
        bpl2mod = v;
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static void BPLxDAT(int num, uae_u16 data)
@@ -3730,7 +3776,9 @@ static void DDFSTRT(uae_u16 v)
        v &= ddf_mask;
        ddfstrt = 0xffff;
        push_pipeline(&ddfstrt, v);
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static void DDFSTOP(uae_u16 v)
@@ -3739,7 +3787,9 @@ static void DDFSTOP(uae_u16 v)
        ddfstop_saved = v;
        v &= ddf_mask;
        push_pipeline(&ddfstop, v);
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static void FMODE(uae_u16 v)
@@ -3759,7 +3809,9 @@ static void FMODE(uae_u16 v)
        }
        set_chipset_mode(false);
        setup_fmodes(bplcon0);
+#if CE_MODE_RGA_OPTIMIZATIONS
        fast_mode_ce_not = true;
+#endif
 }
 
 static void FNULL(uae_u16 v)
@@ -4146,6 +4198,7 @@ static void CLXCON2(uae_u16 v)
 
 static uae_u16 CLXDAT(void)
 {
+       draw_denise_line_queue_flush();
        uae_u16 v = clxdat | 0x8000;
        clxdat = 0;
        return v;
@@ -4348,10 +4401,6 @@ static void bprun_start(int hpos)
        }
 
        bpl_autoscale();
-
-       for (int i = 0; i < GET_PLANES(bplcon0); i++) {
-               bplptx[i] = bplpt[i];
-       }
 }
 
 /*
@@ -4777,14 +4826,25 @@ static bool framewait(void)
                                if (cpu_sleep_millis(1) < 0)
                                        break;
                        }
+
                        while (rpt_vsync(clockadjust) < 0) {
                                rtg_vsynccheck();
+#if 0
                                if (audio_is_pull_event()) {
                                        maybe_process_pull_audio();
                                        break;
                                }
+#endif
                        }
+
+#if 0
+                       static evt_t ttt;
+                       write_log("%lld\n", read_processor_time() - ttt);
+                       ttt = read_processor_time();
+#endif
                }
+
+
                evt_t tnow = read_processor_time();
                idletime += tnow - start;
                curr_time = tnow;
@@ -6310,10 +6370,10 @@ static void hsync_handler_post(bool onvsync)
                // the rest
                static int linecounter;
                static int nextwaitvpos;
-               int maxlc = 16;
+               int maxlc = 8, maxlcm = 4;
                linecounter++;
-               if (vpos == 0)
-                       nextwaitvpos = maxvpos_display * 1 / 4;
+               if (linear_vpos == 0)
+                       nextwaitvpos = maxlc * 4;
                if (audio_is_pull() > 0 && !currprefs.turbo_emulation && (linecounter & (maxlc - 1)) == 0) {
                        maybe_process_pull_audio();
                        frame_time_t rpt = read_processor_time();
@@ -6323,9 +6383,9 @@ static void hsync_handler_post(bool onvsync)
                                rpt = read_processor_time();
                        }
                }
-               if (linear_vpos + 1 < maxvpos + lof_store && linear_vpos >= nextwaitvpos && linear_vpos < maxvpos - (maxvpos / 3) && (audio_is_pull() <= 0 || (audio_is_pull() > 0 && audio_pull_buffer()))) {
-                       nextwaitvpos += maxvpos_display * 1 / 3;
-                       vsyncmintime += vsynctimeperline;
+               if (linear_vpos + maxlc * maxlcm < current_linear_vpos && linear_vpos >= nextwaitvpos && (audio_is_pull() <= 0 || (audio_is_pull() > 0 && audio_pull_buffer()))) {
+                       nextwaitvpos += maxlc * maxlcm;
+                       vsyncmintime += vsynctimeperline * maxlc * maxlcm;
                        if (vsync_isdone(NULL) <= 0 && !currprefs.turbo_emulation) {
                                frame_time_t rpt = read_processor_time();
                                // sleep if more than 2ms "free" time
@@ -6393,6 +6453,7 @@ static void hsync_handler(bool vs)
        }
        if (vpos == vsync_startline + 1 && !maxvpos_display_vsync_next) {
                inputdevice_read_msg(true);
+               draw_denise_line_queue_flush();
                vsync_display_render();
                vsync_display_rendered = false;
                if (currprefs.cs_hvcsync == 0) {
@@ -6501,11 +6562,13 @@ void custom_reset(bool hardreset, bool keyboardreset)
        rga_denise_cycle_start = 0;
        rga_denise_cycle_count = 0;
        rga_denise_cycle_line = 1;
+#if CE_MODE_RGA_OPTIMIZATIONS
        for (int i = 0; i < MAX_PLANES; i++) {
                fast_plane_store16[i] = (uae_u16*)bpl_line_store;
                fast_plane_store32[i] = (uae_u32*)bpl_line_store;
                fast_plane_store64[i] = (uae_u64*)bpl_line_store;
        }
+#endif
 
        vsync_startline = 3;
        copper_dma_change_cycle = 0;
@@ -10361,6 +10424,7 @@ static void next_denise_rga(void)
 {
        rga_denise_cycle_start = rga_denise_cycle;
        rga_denise_cycle_count = 0;
+#if 0
        for (int i = 0; i <= 5; i++) {
                struct denise_rga *rga = &rga_denise[(rga_denise_cycle - i) & DENISE_RGA_SLOT_MASK];
                if (rga->line == rga_denise_cycle_line && rga->rga != 0x1fe) {
@@ -10368,6 +10432,7 @@ static void next_denise_rga(void)
                }
                rga->line++;
        }
+#endif
        rga_denise_cycle_line++;
 }
 
@@ -10389,6 +10454,7 @@ static int getlinetype(void)
 {
        int type = 0;
        
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (currprefs.cpu_memory_cycle_exact) {
                if (get_strobe_reg(0) != 0x3c) {
                        type = LINETYPE_BLANK;
@@ -10401,17 +10467,21 @@ static int getlinetype(void)
                } else if (drga_bpl && ddfstop > ddfstrt && ddfstrt >= 0x14 && GET_RES_AGNUS(bplcon0) == GET_RES_DENISE(bplcon0) && dmaen(DMA_BITPLANE)) {
                        type = LINETYPE_BPL;
                }
-       } else {
+       } else 
+#endif
+       {
                if (get_strobe_reg(0) != 0x3c) {
                        type = LINETYPE_BLANK;
-               } else if (vdiwstate == diw_states::DIW_waiting_start || GET_PLANES(bplcon0) == 0 || !dmaen(DMA_BITPLANE)) {
-                       if ((bplcon0 & 1) && (bplcon3 & 0x20)) {
-                               type = LINETYPE_BLANK;
-                       } else {
-                               type = LINETYPE_BORDER;
+               } else if (lineoptimizations_allowed) {
+                       if (vdiwstate == diw_states::DIW_waiting_start || GET_PLANES(bplcon0) == 0 || !dmaen(DMA_BITPLANE)) {
+                               if ((bplcon0 & 1) && (bplcon3 & 0x20)) {
+                                       type = LINETYPE_BLANK;
+                               } else {
+                                       type = LINETYPE_BORDER;
+                               }
+                       } else if (ddfstop > ddfstrt && ddfstrt >= 0x14 && GET_RES_AGNUS(bplcon0) == GET_RES_DENISE(bplcon0) && dmaen(DMA_BITPLANE)) {
+                               type = LINETYPE_BPL;
                        }
-               } else if (ddfstop > ddfstrt && ddfstrt >= 0x14 && GET_RES_AGNUS(bplcon0) == GET_RES_DENISE(bplcon0) && dmaen(DMA_BITPLANE)) {
-                       type = LINETYPE_BPL;
                }
        }
        return type;
@@ -10487,7 +10557,7 @@ static int checkprevfieldlinestateequalbpl(struct linestate *l, bool dontaddbpl)
                int planes = GET_PLANES(bplcon0);
                int len = l->bpllen;
                for (int i = 0; i < planes; i++) {
-                       uaecptr apt = currprefs.cpu_memory_cycle_exact ? bplptx[i] : bplpt[i];
+                       uaecptr apt = bplpt[i];
 #if 0
                        if (custom_fastmode_bplextendmask & (1 << i)) {
                                int mod = getbplmod(i);
@@ -10514,7 +10584,7 @@ static int checkprevfieldlinestateequalbpl(struct linestate *l, bool dontaddbpl)
                                return -1;
                        }
                }
-               if (!dontaddbpl && !currprefs.cpu_memory_cycle_exact) {
+               if (!dontaddbpl) {
                        // advance bpl pointers
                        for (int i = 0; i < planes; i++) {
                                int mod = getbplmod(i);
@@ -10534,7 +10604,8 @@ static bool draw_border_fast(struct linestate *l, int ldv)
        }
        l->color0 = aga_mode ? agnus_colors.color_regs_aga[0] : agnus_colors.color_regs_ecs[0];
        int dvp = calculate_linetype(ldv);
-       return draw_denise_border_line_fast(dvp, nextline_how, l);
+       draw_denise_border_line_fast_queue(dvp, nextline_how, l);
+       return true;
 }
 
 // draw bitplane line quickly (no copper, no sprites, no weird things, normal mode)
@@ -10558,12 +10629,15 @@ static bool draw_line_fast(struct linestate *l, int ldv)
        }
        int colors = getcolorcount(planes);
        int len = l->bpllen;
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (currprefs.cpu_memory_cycle_exact) {
                for (int i = 0; i < planes; i++) {
                        uae_u8 *pt = bpl_line_store + i * 256;
                        l->bplpt[i] = pt;
                }
-       } else {
+       } else
+#endif
+       {
                for (int i = 0; i < planes; i++) {
                        uaecptr pt = bplpt[i];
                        l->bplpt[i] = get_real_address(pt);
@@ -10582,18 +10656,14 @@ static bool draw_line_fast(struct linestate *l, int ldv)
        l->fetchstart_mask = fetchstart_mask;
        // draw quickly, store new state
        int dvp = calculate_linetype(ldv);
-       if (draw_denise_bitplane_line_fast(dvp, nextline_how, l)) {
-               if (!currprefs.cpu_memory_cycle_exact) {
-                       // advance bpl pointers
-                       int len = l->bpllen;
-                       for (int i = 0; i < planes; i++) {
-                               int mod = getbplmod(i);
-                               bplpt[i] += mod + len;
-                       }
-               }
-               return true;
+       draw_denise_bitplane_line_fast_queue(dvp, nextline_how, l);
+       // advance bpl pointers
+       len = l->bpllen;
+       for (int i = 0; i < planes; i++) {
+               int mod = getbplmod(i);
+               bplpt[i] += mod + len;
        }
-       return false;
+       return true;
 }
 
 static bool draw_always(void)
@@ -10624,14 +10694,14 @@ static bool checkprevfieldlinestateequal(void)
                                uae_u32 c = aga_mode ? agnus_colors.color_regs_aga[0] : agnus_colors.color_regs_ecs[0];
                                if (!always && c == l->color0) {
                                        ret = true;
-                               } else if (always || currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL) {
+                               } else if (1 && (always || currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL)) {
                                        ret = draw_border_fast(l, linear_display_vpos + 1);
                                }
                        }
                } else if (type == LINETYPE_BPL && !l->vb) {
                        if (1) {
                                int r = checkprevfieldlinestateequalbpl(l, always);
-                               if (always || (r < 0 && currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL)) {
+                               if (1 && (always || (r < 0 && currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL))) {
                                        // no match but same parameters: do quick BPL emulation
                                        r = draw_line_fast(l, linear_display_vpos + 1);
                                }
@@ -10696,7 +10766,7 @@ static void storelinestate(void)
                        uae_u8 *dpt = l->linedatastate;
                        int planes = GET_PLANES(bplcon0);
                        for (int i = 0; i < planes; i++) {
-                               uaecptr apt = currprefs.cpu_memory_cycle_exact ? bplptx[i] : bplpt[i];
+                               uaecptr apt = bplpt[i];
 #if 0
                                if (custom_fastmode_bplextendmask & (1 << i)) {
                                        apt += fetchmode_bytes + getbplmod(i);
@@ -10722,6 +10792,7 @@ static void storelinestate(void)
        }
 }
 
+#if CE_MODE_RGA_OPTIMIZATIONS
 static bool draw_line_ce_fast(void)
 {
        if (linear_vpos >= MAX_SCANDOUBLED_LINES) {
@@ -10743,7 +10814,7 @@ static bool draw_line_ce_fast(void)
                                if (c == l->color0) {
                                        ret = true;
                                } else if (always|| currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL) {
-                                       ret = draw_border_fast(l, linear_display_vpos);
+                                       //ret = draw_border_fast(l, linear_display_vpos);
                                }
                        }
                } else if (type == LINETYPE_BPL && !l->vb) {
@@ -10757,10 +10828,7 @@ static bool draw_line_ce_fast(void)
                        }
                }
        }
-       if (ret) {
-               uae_u16 strobe = get_strobe_reg(0);
-               denise_handle_quick_strobe(strobe, agnus_hpos);
-       } else {
+       if (!ret) {
                l->type = 0;
        }
        return ret;
@@ -10774,13 +10842,14 @@ static void clear_fast_mode_ce(void)
        drga_bpl = false;
        drga_spr = false;
 }
+#endif
 
 static void draw_line(void)
 {
-       bool can_fast_ce = currprefs.cpu_memory_cycle_exact && currprefs.cs_optimizations < DISPLAY_OPTIMIZATIONS_NONE;
-
        int dvp = calculate_linetype(linear_display_vpos);
 
+#if CE_MODE_RGA_OPTIMIZATIONS
+       bool can_fast_ce = 0 && currprefs.cpu_memory_cycle_exact && currprefs.cs_optimizations < DISPLAY_OPTIMIZATIONS_NONE;
        if (can_fast_ce && !fast_mode_ce_not && !drga_spr) {
                if (draw_line_ce_fast()) {
                        clear_fast_mode_ce();
@@ -10788,6 +10857,7 @@ static void draw_line(void)
                        return;
                }
        }
+#endif
 
        int wclks = linear_hpos - (display_hstart_cyclewait_skip - display_hstart_cyclewait_skip2);
        if (wclks > linear_hpos) {
@@ -10803,6 +10873,7 @@ static void draw_line(void)
        struct linestate *l = NULL;
        if (linear_vpos < MAX_SCANDOUBLED_LINES) {
                l = &lines[linear_vpos][lof_display];
+#if CE_MODE_RGA_OPTIMIZATIONS
                if (can_fast_ce) {
                        if (!fast_mode_ce_not && !drga_spr) {
                                storelinestate();
@@ -10810,15 +10881,18 @@ static void draw_line(void)
                                resetlinestate();
                        }
                }
+#endif
        }
 
        int cs = 0;// (beamcon0 & BEAMCON0_VARHSYEN) ? agnus_phsync_end - agnus_phsync_start : agnus_hsync_end - agnus_hsync_start;
        int cslen = 10;
-       draw_denise_line(dvp, nextline_how, rga_denise_cycle_line, rga_denise_cycle_start, rga_denise_cycle_count,
+       draw_denise_line_queue(dvp, nextline_how, rga_denise_cycle_line, rga_denise_cycle_start, rga_denise_cycle, rga_denise_cycle_count,
                display_hstart_cyclewait_skip, display_hstart_cyclewait_skip2,
                wclks, cs, cslen, lol, l);
        
+#if CE_MODE_RGA_OPTIMIZATIONS
        clear_fast_mode_ce();
+#endif
 }
 
 static void dmal_fast(void)
@@ -10987,22 +11061,11 @@ static void draw_line_fast(void)
 }
 #endif
 
-static void quick_denise_rga(void)
-{
-       for (int i = 0; i < rga_denise_cycle_count; i++) {
-               int off = i + rga_denise_cycle_start;
-               struct denise_rga *rd = &rga_denise[off & DENISE_RGA_SLOT_MASK];
-               if (rd->line == rga_denise_cycle_line && rd->rga != 0x1fe && (rd->rga < 0x38 || rd->rga >= 0x40)) {
-                       denise_update_reg(rd->rga, rd->v);
-               }
-       }
-}
-
 static void do_draw_line(void)
 {
        if (custom_fastmode_exit) {
                custom_fastmode_exit = 0;
-               quick_denise_rga();
+               quick_denise_rga_queue(rga_denise_cycle_line, rga_denise_cycle_start, rga_denise_cycle);
                next_denise_rga();
                decide_line_end();
                goto end;
@@ -11010,8 +11073,10 @@ static void do_draw_line(void)
        if (!custom_disabled) {
                if (custom_fastmode >= 0) {
                        if (doflickerfix_active() && scandoubled_bpl_ena[linear_vpos]) {
+                               draw_denise_line_queue_flush();
                                denise_store_registers();
                                draw_line();
+                               draw_denise_line_queue_flush();
                                do_scandouble();
                                denise_restore_registers();
                                lof_display ^= 1;
@@ -11031,6 +11096,7 @@ static void do_draw_line(void)
        decide_line_end();
 
 end:;
+#if CE_MODE_RGA_OPTIMIZATIONS
        if (currprefs.cpu_memory_cycle_exact) {
                for (int i = 0; i < MAX_PLANES; i++) {
                        fast_plane_store16[i] = (uae_u16*)(bpl_line_store + i * 256);
@@ -11038,6 +11104,7 @@ end:;
                        fast_plane_store64[i] = (uae_u64*)(bpl_line_store + i * 256);
                }
        }
+#endif
 }
 
 static void decide_hsync(void)
@@ -11280,7 +11347,6 @@ static void custom_trigger_start(void)
                linear_vpos_prev[1] = linear_vpos_prev[0];
                linear_vpos_prev[0] = linear_vpos;
                linear_vpos = 0;
-               denise_mark_last_line();
 
                if (!custom_disabled) {
                        start_draw_denise();
@@ -12424,7 +12490,8 @@ static void sync_equalline_handler(void)
                do_draw_line();
                rga_denise_cycle = rdc;
        } else {
-               denise_handle_quick_strobe(str, display_hstart_fastmode);
+               denise_handle_quick_strobe_queue(str, display_hstart_fastmode, rga_denise_cycle);
+               //denise_handle_quick_strobe(str, display_hstart_fastmode);
                next_denise_rga();
                decide_line_end();
        }
index b50990b0be445480a778f2d787e03aa1206cca93..c215c92062f1926c2e8c9d659f01ef0604e39a53 100644 (file)
 #include "devices.h"
 #include "gfxboard.h"
 
+extern int multithread_enabled;
+#define MULTITHREADED_DENISE (multithread_enabled != 0)
+
 #define BLANK_COLOR 0x000000
 
 #define AUTOSCALE_SPRITES 1
 #define LOL_SHIFT_COLORS 0
 
+
+
+static uae_sem_t write_sem, read_sem;
+
+struct denise_rga_queue
+{
+       int type;
+       int vpos;
+       int gfx_ypos;
+       nln_how how;
+       uae_u32 linecnt;
+       int startpos, endpos;
+       int total;
+       int skip;
+       int skip2;
+       int dtotal;
+       int calib_start;
+       int calib_len;
+       bool lol;
+       uae_u16 strobe;
+       int strobe_pos;
+       struct linestate *ls;
+};
+
+static volatile uae_atomic rga_queue_read, rga_queue_write;
+static int denise_thread_state;
+static struct denise_rga_queue rga_queue[DENISE_RGA_SLOT_CHUNKS];
+
+static void quick_denise_rga(int linecnt, int startpos, int endpos)
+{
+       int pos = startpos;
+       while (pos != endpos) {
+               struct denise_rga *rd = &rga_denise[pos];
+               if (rd->line == linecnt && rd->rga != 0x1fe && (rd->rga < 0x38 || rd->rga >= 0x40)) {
+                       denise_update_reg(rd->rga, rd->v);
+               }
+               pos++;
+               pos &= DENISE_RGA_SLOT_MASK;
+       }
+}
+
+static void denise_handle_quick_strobe(uae_u16 strobe, int offset, int vpos);
+
+static void read_denise_line_queue(void)
+{
+       while (rga_queue_read == rga_queue_write) {
+               uae_sem_wait(&write_sem);
+       }
+
+       struct denise_rga_queue *q = &rga_queue[rga_queue_read & DENISE_RGA_SLOT_CHUNKS_MASK];
+       bool next = false;
+
+       //evt_t t1 = read_processor_time();
+
+       if (q->type == 0) {
+               draw_denise_line(q->gfx_ypos, q->how, q->linecnt, q->startpos, q->total, q->skip, q->skip2, q->dtotal, q->calib_start, q->calib_len, q->lol, q->ls);
+               next = true;
+       } else if (q->type == 1) {
+               draw_denise_bitplane_line_fast(q->gfx_ypos, q->how, q->ls);
+       } else if (q->type == 2) {
+               draw_denise_border_line_fast(q->gfx_ypos, q->how, q->ls);
+       } else if (q->type == 3) {
+               quick_denise_rga(q->linecnt, q->startpos, q->endpos);
+       } else if (q->type == 4) {
+               denise_handle_quick_strobe(q->strobe, q->strobe_pos, q->vpos);
+               next = true;
+       }
+
+       //evt_t t2 = read_processor_time();
+
+       //write_log("%lld ", (t2 - t1));
+
+       if (next) {
+               for (int i = 0; i <= 5; i++) {
+                       struct denise_rga *rga = &rga_denise[(q->endpos - i) & DENISE_RGA_SLOT_MASK];
+                       rga->line++;
+               }
+       }
+
+       atomic_inc(&rga_queue_read);
+
+       uae_sem_post(&read_sem);
+}
+
+static void denise_thread(void *v)
+{
+       denise_thread_state = 1;
+       while(denise_thread_state) {
+               read_denise_line_queue();
+       }
+       denise_thread_state = -1;
+}
+
+static bool denise_locked;
+
+static bool denise_lock(void)
+{
+       draw_denise_line_queue_flush();
+
+       if (denise_locked) {
+               return true;
+       }
+
+       int monid = 0;
+       struct amigadisplay *ad = &adisplays[monid];
+       struct vidbuf_description *vidinfo = &ad->gfxvidinfo;
+       struct vidbuffer *vb = &vidinfo->drawbuffer;
+       struct vidbuffer *vbin = &vidinfo->tempbuffer;
+
+       if (vb->inheight < vbin->inheight || vb->inwidth < vbin->inwidth) {
+               return false;
+       }
+
+       if (!lockscr(vb, false, display_reset > 0)) {
+               notice_screen_contents_lost(monid);
+               return false;
+       }
+       denise_locked = true;
+       return true;
+}
+
 int scandoubled_line;
 
 struct amigadisplay adisplays[MAX_AMIGADISPLAYS];
@@ -208,7 +332,7 @@ static struct denise_rga rga_denise_fast[DENISE_RGA_SLOT_FAST_TOTAL];
 typedef void (*LINETOSRC_FUNC)(void);
 static LINETOSRC_FUNC lts;
 static bool lts_changed, lts_request;
-typedef void (*LINETOSRC_FUNCF)(int,int,int,int,int,int,int,int,int,uae_u32,uae_u8*,uae_u8*,int,int*,int,uae_u8, void*);
+typedef void (*LINETOSRC_FUNCF)(int,int,int,int,int,int,int,int,int,uae_u32,uae_u8*,uae_u8*,int,int*,int,struct linestate*);
 
 static int denise_hcounter, denise_hcounter_next, denise_hcounter_new, denise_hcounter_prev;
 static uae_u32 bplxdat[MAX_PLANES], bplxdat2[MAX_PLANES], bplxdat3[MAX_PLANES];
@@ -256,9 +380,10 @@ static bool denise_odd_even, denise_max_odd_even;
 static int pix_prev;
 static int last_bpl_pix;
 static int previous_strobe;
-static bool denise_strlong, agnus_lol, extblank;
-static int lol;
-static int denise_lol_shift_prev, denise_lol_shifted_prev;
+static bool denise_strlong, denise_strlong_fast, agnus_lol, extblank;
+static int lol, lol_fast;
+static int denise_lol_shift_prev;
+static bool denise_lol_shift_enable;
 static int decode_specials, decode_specials_debug;
 static int *dpf_lookup, *dpf_lookup_no;
 static int denise_sprres, denise_spr_add, denise_spr_shiftsize;
@@ -321,7 +446,7 @@ static int hbstrt_offset, hbstop_offset;
 static int hstrt_offset, hstop_offset;
 static int bpl1dat_trigger_offset;
 static int internal_pixel_cnt, internal_pixel_start_cnt;
-static bool no_denise_lol;
+static bool no_denise_lol, denise_strlong_detected;
 
 void set_inhibit_frame(int monid, int bit)
 {
@@ -452,7 +577,7 @@ static void reset_custom_limits(void)
 int get_vertical_visible_height(bool useoldsize)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
-       int h = vidinfo->drawbuffer.inheight;
+       int h = vidinfo->inbuffer->inheight;
 
        if (programmedmode <= 1) {
                h = maxvsize_display;
@@ -614,8 +739,8 @@ int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh)
        }
 
        if (!isnativevidbuf(0)) {
-               *pw = vidinfo->outbuffer->outwidth;
-               *ph = vidinfo->outbuffer->outheight;
+               *pw = vidinfo->inbuffer->outwidth;
+               *ph = vidinfo->inbuffer->outheight;
                *pdx = 0;
                *pdy = 0;
                *prealh = -1;
@@ -753,9 +878,9 @@ int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh)
        if (w <= 0 || h <= 0 || dx < 0 || dy < 0)
                return ret;
        if (doublescan <= 0 && programmedmode != 1) {
-               if (dx > vidinfo->outbuffer->inwidth / 2)
+               if (dx > vidinfo->inbuffer->inwidth / 2)
                        return ret;
-               if (dy > vidinfo->outbuffer->inheight / 2)
+               if (dy > vidinfo->inbuffer->inheight / 2)
                        return ret;
        }
 
@@ -867,7 +992,17 @@ static bool get_genlock_very_rare_and_complex_case(uae_u8 v)
        return true;
 }
 // false = transparent
-STATIC_INLINE bool get_genlock_transparency(uae_u8 v)
+static bool get_genlock_transparency(uae_u8 v)
+{
+       if (!ecs_genlock_features_active) {
+               if (v == 0)
+                       return false;
+               return true;
+       } else {
+               return get_genlock_very_rare_and_complex_case(v);
+       }
+}
+static bool get_genlock_transparency_fast(uae_u8 v)
 {
        if (!ecs_genlock_features_active) {
                if (v == 0)
@@ -878,7 +1013,7 @@ STATIC_INLINE bool get_genlock_transparency(uae_u8 v)
        }
 }
 
-STATIC_INLINE bool get_genlock_transparency_border(void)
+static bool get_genlock_transparency_border(void)
 {
        if (!ecs_genlock_features_active) {
                return false;
@@ -890,6 +1025,19 @@ STATIC_INLINE bool get_genlock_transparency_border(void)
        }
 }
 
+static bool get_genlock_transparency_border_fast(uae_u16 bplcon3)
+{
+       if (!ecs_genlock_features_active) {
+               return false;
+       } else {
+               // border color with BRDNTRAN bit set = not transparent
+               if (bplcon3 & 0x0010)
+                       return true;
+               return get_genlock_very_rare_and_complex_case(0);
+       }
+}
+
+
 static void gen_pfield_tables(void)
 {
        for (int i = 0; i < 256; i++) {
@@ -921,62 +1069,10 @@ static void gen_pfield_tables(void)
        }
 }
 
-void init_row_map(void)
-{
-       struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
-       static uae_u8 *oldbufmem;
-       static int oldheight, oldpitch;
-       static bool oldgenlock, oldburst;
-       int i, j;
-
-       if (vidinfo->drawbuffer.height_allocated > max_uae_height) {
-               write_log (_T("Resolution too high, aborting\n"));
-               abort ();
-       }
-       if (!row_map) {
-               row_map = xmalloc(uae_u8*, max_uae_height + 1);
-               row_map_genlock = xmalloc(uae_u16*, max_uae_height + 1);
-       }
-
-       if (oldbufmem && oldbufmem == vidinfo->drawbuffer.bufmem &&
-               oldheight == vidinfo->drawbuffer.height_allocated &&
-               oldpitch == vidinfo->drawbuffer.rowbytes &&
-               oldgenlock == init_genlock_data &&
-               oldburst == (row_map_color_burst_buffer ? 1 : 0))
-               return;
-       xfree(row_map_genlock_buffer);
-       row_map_genlock_buffer = NULL;
-       if (init_genlock_data) {
-               row_map_genlock_buffer = xcalloc(uae_u16, vidinfo->drawbuffer.width_allocated * (vidinfo->drawbuffer.height_allocated + 2));
-       }
-       xfree(row_map_color_burst_buffer);
-       row_map_color_burst_buffer = NULL;
-       if (currprefs.cs_color_burst) {
-               row_map_color_burst_buffer = xcalloc(uae_u8, vidinfo->drawbuffer.height_allocated + 2);
-       }
-       j = oldheight == 0 ? max_uae_height : oldheight;
-       for (i = vidinfo->drawbuffer.height_allocated; i < max_uae_height + 1 && i < j + 1; i++) {
-               row_map[i] = row_tmp8;
-               row_map_genlock[i] = row_tmp16;
-       }
-       for (i = 0, j = 0; i < vidinfo->drawbuffer.height_allocated; i++, j += vidinfo->drawbuffer.rowbytes) {
-               row_map[i] = vidinfo->drawbuffer.bufmem + j;
-               if (init_genlock_data) {
-                       row_map_genlock[i] = row_map_genlock_buffer + vidinfo->drawbuffer.width_allocated * (i + 1);
-               } else {
-                       row_map_genlock[i] = NULL;
-               }
-       }
-       oldbufmem = vidinfo->drawbuffer.bufmem;
-       oldheight = vidinfo->drawbuffer.height_allocated;
-       oldpitch = vidinfo->drawbuffer.rowbytes;
-       oldgenlock = init_genlock_data;
-       oldburst = row_map_color_burst_buffer ? 1 : 0;
-}
-
 static void init_aspect_maps(void)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
+       struct vidbuffer *vb = vidinfo->inbuffer;
        int i, maxl, h;
 
        linedbld = linedbl = currprefs.gfx_vresolution;
@@ -996,7 +1092,7 @@ static void init_aspect_maps(void)
        visible_top_start = 0;
        visible_bottom_stop = MAX_STOP;
 
-       h = vidinfo->drawbuffer.height_allocated;
+       h = vb->height_allocated;
        if (h == 0)
                /* Do nothing if the gfx driver hasn't initialized the screen yet */
                return;
@@ -1034,6 +1130,66 @@ static void init_aspect_maps(void)
        }
 }
 
+void init_row_map(void)
+{
+       struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
+       struct vidbuffer *vb = vidinfo->inbuffer;
+       static uae_u8 *oldbufmem;
+       static int oldheight, oldpitch;
+       static bool oldgenlock, oldburst;
+       int i, j;
+
+       if (vb->height_allocated > max_uae_height) {
+               write_log(_T("Resolution too high, aborting\n"));
+               abort();
+       }
+       if (!row_map) {
+               row_map = xmalloc(uae_u8 *, max_uae_height + 1);
+               row_map_genlock = xmalloc(uae_u16 *, max_uae_height + 1);
+       }
+
+       if (oldbufmem && oldbufmem == vb->bufmem &&
+               oldheight == vb->height_allocated &&
+               oldpitch == vb->rowbytes &&
+               oldgenlock == init_genlock_data &&
+               oldburst == (row_map_color_burst_buffer ? 1 : 0))
+               return;
+       xfree(row_map_genlock_buffer);
+       row_map_genlock_buffer = NULL;
+       if (init_genlock_data) {
+               row_map_genlock_buffer = xcalloc(uae_u16, vb->width_allocated * (vb->height_allocated + 2));
+       }
+       xfree(row_map_color_burst_buffer);
+       row_map_color_burst_buffer = NULL;
+       if (currprefs.cs_color_burst) {
+               row_map_color_burst_buffer = xcalloc(uae_u8, vb->height_allocated + 2);
+       }
+       for (i = 0, j = 0; i < vb->height_allocated; i++, j += vb->rowbytes) {
+               if (i < vb->outheight) {
+                       row_map[i] = vb->bufmem + j;
+               } else {
+                       row_map[i] = row_tmp8;
+               }
+               if (init_genlock_data) {
+                       row_map_genlock[i] = row_map_genlock_buffer + vb->width_allocated * (i + 1);
+               } else {
+                       row_map_genlock[i] = NULL;
+               }
+       }
+       while (i < max_uae_height + 1) {
+               row_map[i] = row_tmp8;
+               row_map_genlock[i] = row_tmp16;
+               i++;
+       }
+       oldbufmem = vb->bufmem;
+       oldheight = vb->height_allocated;
+       oldpitch = vb->rowbytes;
+       oldgenlock = init_genlock_data;
+       oldburst = row_map_color_burst_buffer ? 1 : 0;
+
+       init_aspect_maps();
+}
+
 static void center_image (void)
 {
        struct amigadisplay *ad = &adisplays[0];
@@ -1042,8 +1198,12 @@ static void center_image (void)
        int prev_x_adjust = visible_left_border;
        int prev_y_adjust = thisframe_y_adjust;
 
-       int w = vidinfo->drawbuffer.inwidth;
-       int ew = vidinfo->drawbuffer.extrawidth;
+       if (!vidinfo->inbuffer) {
+               return;
+       }
+
+       int w = vidinfo->inbuffer->inwidth;
+       int ew = vidinfo->inbuffer->extrawidth;
        int maxdiw = denisehtotal;
 
        if (currprefs.gfx_overscanmode <= OVERSCANMODE_OVERSCAN && currprefs.gfx_xcenter && !fd->gfx_filter_autoscale && max_diwstop > 0) {
@@ -1077,10 +1237,10 @@ static void center_image (void)
                // normal
                visible_left_border = maxdiw - w;
        } else {
-               if (vidinfo->drawbuffer.inxoffset < 0) {
+               if (vidinfo->inbuffer->inxoffset < 0) {
                        visible_left_border = 0;
                } else {
-                       visible_left_border = vidinfo->drawbuffer.inxoffset << currprefs.gfx_resolution;
+                       visible_left_border = vidinfo->inbuffer->inxoffset << currprefs.gfx_resolution;
                }
        }
 
@@ -1090,18 +1250,18 @@ static void center_image (void)
                visible_left_border = 0;
        visible_left_border &= ~((xshift (1, lores_shift)) - 1);
 
-       //write_log (_T("%d %d %d %d %d\n"), max_diwlastword, vidinfo->drawbuffer.width, lores_shift, currprefs.gfx_resolution, visible_left_border);
+       //write_log (_T("%d %d %d %d %d\n"), max_diwlastword, vidinfo->inbuffer->width, lores_shift, currprefs.gfx_resolution, visible_left_border);
 
        linetoscr_x_adjust_pixels = visible_left_border;
-       linetoscr_x_adjust_pixbytes = linetoscr_x_adjust_pixels * vidinfo->drawbuffer.pixbytes;
+       linetoscr_x_adjust_pixbytes = linetoscr_x_adjust_pixels * vidinfo->inbuffer->pixbytes;
 
        visible_right_border = maxdiw + w + ((ew > 0 ? ew : 0) << currprefs.gfx_resolution);
        if (visible_right_border > maxdiw + ((ew > 0 ? ew : 0) << currprefs.gfx_resolution))
                visible_right_border = maxdiw + ((ew > 0 ? ew : 0) << currprefs.gfx_resolution);
 
        int max_drawn_amiga_line_tmp = max_drawn_amiga_line;
-       if (max_drawn_amiga_line_tmp > vidinfo->drawbuffer.inheight)
-               max_drawn_amiga_line_tmp = vidinfo->drawbuffer.inheight;
+       if (max_drawn_amiga_line_tmp > vidinfo->inbuffer->inheight)
+               max_drawn_amiga_line_tmp = vidinfo->inbuffer->inheight;
        max_drawn_amiga_line_tmp >>= linedbl;
        
        thisframe_y_adjust = minfirstline - 1;
@@ -1147,8 +1307,8 @@ static void center_image (void)
        max_diwstop = 0;
        min_diwstart = MAX_STOP;
 
-       vidinfo->drawbuffer.xoffset = visible_left_border << (RES_MAX - currprefs.gfx_resolution);
-       vidinfo->drawbuffer.yoffset = thisframe_y_adjust << VRES_MAX;
+       vidinfo->inbuffer->xoffset = visible_left_border << (RES_MAX - currprefs.gfx_resolution);
+       vidinfo->inbuffer->yoffset = thisframe_y_adjust << VRES_MAX;
 
        if (center_reset > 0) {
                center_reset--;
@@ -1373,8 +1533,8 @@ static uae_u8 *status_line_ptr(int monid, int line)
        struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo;
        int y;
 
-       y = line - (vidinfo->drawbuffer.outheight - TD_TOTAL_HEIGHT);
-       xlinebuffer = vidinfo->drawbuffer.linemem;
+       y = line - (vidinfo->inbuffer->outheight - TD_TOTAL_HEIGHT);
+       xlinebuffer = vidinfo->inbuffer->linemem;
        if (xlinebuffer == 0)
                xlinebuffer = row_map[line];
        xlinebuffer_genlock = row_map_genlock[line];
@@ -1388,19 +1548,19 @@ static void draw_status_line(int monid, int line, int statusy)
        if (!buf)
                return;
        if (statusy < 0)
-               statusline_render(monid, buf, vidinfo->drawbuffer.pixbytes, vidinfo->drawbuffer.rowbytes, vidinfo->drawbuffer.outwidth, TD_TOTAL_HEIGHT, xredcolors, xgreencolors, xbluecolors, NULL);
+               statusline_render(monid, buf, vidinfo->inbuffer->pixbytes, vidinfo->inbuffer->rowbytes, vidinfo->inbuffer->outwidth, TD_TOTAL_HEIGHT, xredcolors, xgreencolors, xbluecolors, NULL);
        else
-               draw_status_line_single(monid, buf, vidinfo->drawbuffer.pixbytes, statusy, vidinfo->drawbuffer.outwidth, xredcolors, xgreencolors, xbluecolors, NULL);
+               draw_status_line_single(monid, buf, vidinfo->inbuffer->pixbytes, statusy, vidinfo->inbuffer->outwidth, xredcolors, xgreencolors, xbluecolors, NULL);
 }
 
 static void draw_debug_status_line(int monid, int line)
 {
        struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo;
-       xlinebuffer = vidinfo->drawbuffer.linemem;
+       xlinebuffer = vidinfo->inbuffer->linemem;
        if (xlinebuffer == 0)
                xlinebuffer = row_map[line];
        xlinebuffer_genlock = row_map_genlock[line];
-       debug_draw(xlinebuffer, vidinfo->drawbuffer.pixbytes, line, vidinfo->drawbuffer.outwidth, vidinfo->drawbuffer.outheight, xredcolors, xgreencolors, xbluecolors);
+       debug_draw(xlinebuffer, vidinfo->inbuffer->pixbytes, line, vidinfo->inbuffer->outwidth, vidinfo->inbuffer->outheight, xredcolors, xgreencolors, xbluecolors);
 }
 
 #define LIGHTPEN_HEIGHT 12
@@ -1428,7 +1588,7 @@ static void draw_lightpen_cursor(int monid, int x, int y, int line, int onscreen
        int color1 = onscreen ? (lpnum ? 0x0ff : 0xff0) : (lpnum ? 0x0f0 : 0xf00);
        int color2 = (color1 & 0xeee) >> 1;
 
-       xlinebuffer = vidinfo->drawbuffer.linemem;
+       xlinebuffer = vidinfo->inbuffer->linemem;
        if (xlinebuffer == 0)
                xlinebuffer = row_map[line];
        xlinebuffer_genlock = row_map_genlock[line];
@@ -1436,8 +1596,8 @@ static void draw_lightpen_cursor(int monid, int x, int y, int line, int onscreen
        p = lightpen_cursor + y * LIGHTPEN_WIDTH;
        for (int i = 0; i < LIGHTPEN_WIDTH; i++) {
                int xx = x + i - LIGHTPEN_WIDTH / 2;
-               if (*p != '-' && xx >= 0 && xx < vidinfo->drawbuffer.outwidth) {
-                       putpixel(xlinebuffer, xlinebuffer_genlock, vidinfo->drawbuffer.pixbytes, xx, *p == 'x' ? xcolors[color1] : xcolors[color2]);
+               if (*p != '-' && xx >= 0 && xx < vidinfo->inbuffer->outwidth) {
+                       putpixel(xlinebuffer, xlinebuffer_genlock, vidinfo->inbuffer->pixbytes, xx, *p == 'x' ? xcolors[color1] : xcolors[color2]);
                }
                p++;
        }
@@ -1454,19 +1614,19 @@ static void lightpen_update(struct vidbuffer *vb, int lpnum)
 
        if (lightpen_x[lpnum] < -extra)
                lightpen_x[lpnum] = -extra;
-       if (lightpen_x[lpnum] >= vidinfo->drawbuffer.inwidth + extra)
-               lightpen_x[lpnum] = vidinfo->drawbuffer.inwidth + extra;
+       if (lightpen_x[lpnum] >= vidinfo->inbuffer->inwidth + extra)
+               lightpen_x[lpnum] = vidinfo->inbuffer->inwidth + extra;
        if (lightpen_y[lpnum] < -extra)
                lightpen_y[lpnum] = -extra;
-       if (lightpen_y[lpnum] >= vidinfo->drawbuffer.inheight + extra)
-               lightpen_y[lpnum] = vidinfo->drawbuffer.inheight + extra;
+       if (lightpen_y[lpnum] >= vidinfo->inbuffer->inheight + extra)
+               lightpen_y[lpnum] = vidinfo->inbuffer->inheight + extra;
        if (lightpen_y[lpnum] >= max_ypos_thisframe1)
                lightpen_y[lpnum] = max_ypos_thisframe1;
 
        if (lightpen_x[lpnum] < 0 || lightpen_y[lpnum] < 0) {
                out = true;
        }
-       if (lightpen_x[lpnum] >= vidinfo->drawbuffer.inwidth) {
+       if (lightpen_x[lpnum] >= vidinfo->inbuffer->inwidth) {
                out = true;
        }
        if (lightpen_y[lpnum] >= max_ypos_thisframe1) {
@@ -1500,7 +1660,9 @@ static void lightpen_update(struct vidbuffer *vb, int lpnum)
                        int line = lightpen_y[lpnum] + i - LIGHTPEN_HEIGHT / 2;
                        if (line >= 0 && line < max_ypos_thisframe1) {
                                if (lightpen_active & (1 << lpnum)) {
-                                       draw_lightpen_cursor(vb->monitor_id, lightpen_x[lpnum], i, line, cx > 0, lpnum);
+                                       if (denise_lock()) {
+                                               draw_lightpen_cursor(vb->monitor_id, lightpen_x[lpnum], i, line, cx > 0, lpnum);
+                                       }
                                }
                        }
                }
@@ -1563,10 +1725,10 @@ static void refresh_indicator_update(struct vidbuffer *vb)
                        color2 = refresh_indicator_colors[pixel - 5];
                }
                for (int x = 0; x < 8; x++) {
-                       putpixel(xlinebuffer, NULL, vidinfo->drawbuffer.pixbytes, x, xcolors[color1]);
+                       putpixel(xlinebuffer, NULL, vidinfo->inbuffer->pixbytes, x, xcolors[color1]);
                }
                for (int x = 8; x < 16; x++) {
-                       putpixel(xlinebuffer, NULL, vidinfo->drawbuffer.pixbytes, x, xcolors[color2]);
+                       putpixel(xlinebuffer, NULL, vidinfo->inbuffer->pixbytes, x, xcolors[color2]);
                }
        }
 }
@@ -1574,9 +1736,11 @@ static void refresh_indicator_update(struct vidbuffer *vb)
 static void draw_frame_extras(struct vidbuffer *vb, int y_start, int y_end)
 {
        if (debug_dma > 1 || debug_heatmap > 1) {
-               for (int i = 0; i < vb->outheight; i++) {
-                       int line = i;
-                       draw_debug_status_line(vb->monitor_id, line);
+               if (denise_lock()) {
+                       for (int i = 0; i < vb->outheight; i++) {
+                               int line = i;
+                               draw_debug_status_line(vb->monitor_id, line);
+                       }
                }
        }
 
@@ -1588,8 +1752,11 @@ static void draw_frame_extras(struct vidbuffer *vb, int y_start, int y_end)
                        lightpen_update(vb, 1);
                }
        }
-       if (refresh_indicator_buffer)
-               refresh_indicator_update(vb);
+       if (refresh_indicator_buffer) {
+               if (denise_lock()) {
+                       refresh_indicator_update(vb);
+               }
+       }
 }
 
 extern bool beamracer_debug;
@@ -1597,22 +1764,30 @@ extern bool beamracer_debug;
 static void setnativeposition(struct vidbuffer *vb)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
-       vb->inwidth = vidinfo->drawbuffer.inwidth;
-       vb->inheight = vidinfo->drawbuffer.inheight;
-       vb->inwidth2 = vidinfo->drawbuffer.inwidth2;
-       vb->inheight2 = vidinfo->drawbuffer.inheight2;
-       vb->outwidth = vidinfo->drawbuffer.outwidth;
-       vb->outheight = vidinfo->drawbuffer.outheight;
+       vb->inwidth = vidinfo->inbuffer->inwidth;
+       vb->inheight = vidinfo->inbuffer->inheight;
+       vb->inwidth2 = vidinfo->inbuffer->inwidth2;
+       vb->inheight2 = vidinfo->inbuffer->inheight2;
+       vb->outwidth = vidinfo->inbuffer->outwidth;
+       vb->outheight = vidinfo->inbuffer->outheight;
 }
 
 static void setspecialmonitorpos(struct vidbuffer *vb)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
-       vb->extrawidth = vidinfo->drawbuffer.extrawidth;
-       vb->xoffset = vidinfo->drawbuffer.xoffset;
-       vb->yoffset = vidinfo->drawbuffer.yoffset;
-       vb->inxoffset = vidinfo->drawbuffer.inxoffset;
-       vb->inyoffset = vidinfo->drawbuffer.inyoffset;
+       vb->extrawidth = vidinfo->inbuffer->extrawidth;
+       vb->xoffset = vidinfo->inbuffer->xoffset;
+       vb->yoffset = vidinfo->inbuffer->yoffset;
+       vb->inxoffset = vidinfo->inbuffer->inxoffset;
+       vb->inyoffset = vidinfo->inbuffer->inyoffset;
+}
+
+static void vbcopy(struct vidbuffer *vbout, struct vidbuffer *vbin)
+{
+
+       for (int h = 0; h < vbout->outheight; h++) {
+               memcpy(vbout->bufmem + h * vbout->rowbytes, vbin->bufmem + h * vbin->rowbytes, vbout->outwidth * vbout->pixbytes);
+       }
 }
 
 static void finish_drawing_frame(bool drawlines)
@@ -1620,26 +1795,24 @@ static void finish_drawing_frame(bool drawlines)
        int monid = 0;
        struct amigadisplay *ad = &adisplays[monid];
        struct vidbuf_description *vidinfo = &ad->gfxvidinfo;
-       struct vidbuffer *vb = &vidinfo->drawbuffer;
-
-       vidinfo->outbuffer = vb;
-       vb->last_drawn_line = 0;
+       struct vidbuffer *vbout = vidinfo->outbuffer;
+       struct vidbuffer *vbin = vidinfo->inbuffer;
 
-       if (!drawlines) {
+       if (!drawlines || !vbout || !vbin) {
                return;
        }
 
-       if (!lockscr(vb, false, true, display_reset > 0)) {
-               notice_screen_contents_lost(monid);
-               return;
-       }
-
-       draw_frame_extras(vb, -1, -1);
+       vbout->last_drawn_line = 0;
+       draw_frame_extras(vbin, -1, -1);
 
        // video port adapters
        if (currprefs.monitoremu) {
+               if (!denise_lock()) {
+                       return;
+               }
                struct vidbuf_description *outvi = &adisplays[currprefs.monitoremu_mon].gfxvidinfo;
-               struct vidbuffer *out = &outvi->drawbuffer;
+               struct vidbuffer *m_out = &outvi->drawbuffer;
+               struct vidbuffer *m_in = &outvi->tempbuffer;
                if (init_genlock_data != specialmonitor_need_genlock()) {
                        init_genlock_data = specialmonitor_need_genlock();
                        init_row_map();
@@ -1647,20 +1820,16 @@ static void finish_drawing_frame(bool drawlines)
                bool locked = true;
                bool multimon = currprefs.monitoremu_mon != 0;
                if (multimon) {
-                       locked = lockscr(out, false, true, display_reset > 0);
+                       locked = lockscr(m_out, false, display_reset > 0);
                        outvi->xchange = vidinfo->xchange;
                        outvi->ychange = vidinfo->ychange;
                } else {
-                       out = &vidinfo->tempbuffer;
+                       m_out = vbout;
                }
-               setspecialmonitorpos(out);
-               if (locked && emulate_specialmonitors(vb, out)) {
-                       if (!multimon) {
-                               vb->tempbufferinuse = true;
-                               vb = vidinfo->outbuffer = out;
-                       }
-                       if (out->nativepositioning) {
-                               setnativeposition(out);
+               setspecialmonitorpos(m_out);
+               if (locked && emulate_specialmonitors(m_in, m_out)) {
+                       if (m_out->nativepositioning) {
+                               setnativeposition(m_out);
                        }
                        if (!ad->specialmonitoron) {
                                need_genlock_data = specialmonitor_need_genlock();
@@ -1669,44 +1838,47 @@ static void finish_drawing_frame(bool drawlines)
                        }
                } else {
                        need_genlock_data = false;
-                       if (ad->specialmonitoron || out->tempbufferinuse) {
-                               out->tempbufferinuse = false;
+                       if (ad->specialmonitoron) {
                                ad->specialmonitoron = false;
                                compute_framesync();
                        }
+                       vbcopy(vbout, vbin);
                }
                if (multimon && locked) {
-                       unlockscr(out, -1, -1);
-                       render_screen(out->monitor_id, 1, true);
-                       show_screen(out->monitor_id, 0);
+                       unlockscr(m_out, -1, -1);
+                       render_screen(m_out->monitor_id, 1, true);
+                       show_screen(m_out->monitor_id, 0);
                }
        }
 
        // genlock
        if (currprefs.genlock_image && (currprefs.genlock || currprefs.genlock_effects) && !currprefs.monitoremu && vidinfo->tempbuffer.bufmem_allocated) {
-               setspecialmonitorpos(&vidinfo->tempbuffer);
+               if (!denise_lock()) {
+                       return;
+               }
+               setspecialmonitorpos(vbout);
                if (init_genlock_data != specialmonitor_need_genlock()) {
                        need_genlock_data = init_genlock_data = specialmonitor_need_genlock();
                        init_row_map();
                        lts_request = true;
                }
-               emulate_genlock(vb, &vidinfo->tempbuffer, aga_genlock_features_zdclken);
-               vb = vidinfo->outbuffer = &vidinfo->tempbuffer;
-               if (vb->nativepositioning)
-                       setnativeposition(vb);
-               vidinfo->drawbuffer.tempbufferinuse = true;
+               emulate_genlock(vbin, vbout, aga_genlock_features_zdclken);
+               if (vbout->nativepositioning) {
+                       setnativeposition(vbout);
+               }
        }
 
 #ifdef CD32
        // cd32 fmv
        if (!currprefs.monitoremu && vidinfo->tempbuffer.bufmem_allocated && currprefs.cs_cd32fmv) {
+               if (!denise_lock()) {
+                       return;
+               }
                if (cd32_fmv_active) {
-                       cd32_fmv_genlock(vb, &vidinfo->tempbuffer);
-                       vb = vidinfo->outbuffer = &vidinfo->tempbuffer;
-                       setnativeposition(vb);
-                       vidinfo->drawbuffer.tempbufferinuse = true;
+                       cd32_fmv_genlock(vbin, vbout);
+                       setnativeposition(vbout);
                } else {
-                       vidinfo->drawbuffer.tempbufferinuse = false;
+                       vbcopy(vbout, vbin);
                }
        }
 #endif
@@ -1714,15 +1886,19 @@ static void finish_drawing_frame(bool drawlines)
        // grayscale
        if (!currprefs.monitoremu && vidinfo->tempbuffer.bufmem_allocated &&
                ((!currprefs.genlock && (!bplcolorburst_field && currprefs.cs_color_burst)) || currprefs.gfx_grayscale)) {
-               setspecialmonitorpos(&vidinfo->tempbuffer);
-               emulate_grayscale(vb, &vidinfo->tempbuffer);
-               vb = vidinfo->outbuffer = &vidinfo->tempbuffer;
-               if (vb->nativepositioning)
-                       setnativeposition(vb);
-               vidinfo->drawbuffer.tempbufferinuse = true;
+               if (!denise_lock()) {
+                       return;
+               }
+               setspecialmonitorpos(vbout);
+               emulate_grayscale(vbin, vbout);
+               if (vbout->nativepositioning)
+                       setnativeposition(vbout);
        }
 
-       unlockscr(vb, display_reset ? -2 : -1, -1);
+       if (denise_locked) {
+               unlockscr(vbout, display_reset ? -2 : -1, -1);
+               denise_locked = false;
+       }
 }
 
 void check_prefs_picasso(void)
@@ -1794,7 +1970,7 @@ void full_redraw_all(void)
        bool redraw = false;
        struct amigadisplay *ad = &adisplays[monid];
        struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo;
-       if (vidinfo->drawbuffer.height_allocated && amiga2aspect_line_map) {
+       if (vidinfo->inbuffer && vidinfo->inbuffer->height_allocated && amiga2aspect_line_map) {
                notice_screen_contents_lost(monid);
                if (!ad->picasso_on) {
                        redraw_frame();
@@ -1818,14 +1994,10 @@ bool vsync_handle_check(void)
        int changed = check_prefs_changed_gfx();
        if (changed > 0) {
                reset_drawing();
-               init_row_map();
-               init_aspect_maps();
                notice_screen_contents_lost(monid);
                notice_new_xcolors();
        } else if (changed < 0) {
                reset_drawing();
-               init_row_map();
-               init_aspect_maps();
                notice_screen_contents_lost(monid);
                notice_new_xcolors();
        }
@@ -2007,10 +2179,6 @@ void reset_drawing(void)
        denise_sprite_blank_active = false;
        delayed_sprite_vblank_ecs = false;
 
-       init_aspect_maps ();
-
-       init_row_map ();
-
        last_redraw_point = 0;
 
        notice_screen_contents_lost(monid);
@@ -2041,7 +2209,7 @@ void reset_drawing(void)
        if (currprefs.gfx_overscanmode < OVERSCANMODE_OVERSCAN) {
                denise_vblank_extra = (OVERSCANMODE_OVERSCAN - currprefs.gfx_overscanmode) * 5;
        }
-       no_denise_lol = !currprefs.cpu_memory_cycle_exact && !currprefs.chipset_hr;
+       no_denise_lol = !currprefs.cpu_memory_cycle_exact; // && !currprefs.chipset_hr;
 }
 
 static void gen_direct_drawing_table(void)
@@ -2061,6 +2229,13 @@ void drawing_init (void)
        struct amigadisplay *ad = &adisplays[monid];
        struct vidbuf_description *vidinfo = &ad->gfxvidinfo;
 
+       if (!denise_thread_state) {
+               uae_sem_init(&read_sem, 0, 1);
+               uae_sem_init(&write_sem, 0, 1);
+               denise_thread_state = 1;
+               uae_start_thread(_T("denise"), denise_thread, NULL, NULL);
+       }
+
        refresh_indicator_init();
 
        gen_pfield_tables();
@@ -2076,7 +2251,8 @@ void drawing_init (void)
                gfx_set_picasso_state(0, 0);
        }
 #endif
-       xlinebuffer = vidinfo->drawbuffer.bufmem;
+       xlinebuffer = NULL;
+       xlinebuffer2 = NULL;
        xlinebuffer_genlock = NULL;
 
        ad->inhibit_frame = 0;
@@ -2996,8 +3172,12 @@ static void expand_clxcon2(uae_u16 v)
 
 static void set_strlong(void)
 {
+       denise_strlong_detected = true;
        if (no_denise_lol) {
                denise_strlong = false;
+               denise_strlong_fast = true;
+               denise_lol_shift_enable = false;
+               denise_lol_shift_prev = 0;
                return;
        }
        denise_strlong = true;
@@ -3010,6 +3190,7 @@ static void set_strlong(void)
 static void copy_strlong(void)
 {
        lol = denise_strlong ? 1 : 0;
+       lol_fast = denise_strlong_fast ? 1 : 0;
        if (denisea1000) {
                memset(dtbuf, 0, sizeof(dtbuf));
        }
@@ -3017,6 +3198,7 @@ static void copy_strlong(void)
 static void reset_strlong(void)
 {
        denise_strlong = false;
+       denise_strlong_fast = false;
 }
 
 void denise_reset(bool hard)
@@ -3024,6 +3206,7 @@ void denise_reset(bool hard)
        static int dummyint = 0;
        static struct dma_rec dummydrec = { 0 };
 
+       draw_denise_line_queue_flush();
        dummyint = 0;
        memset(&dummydrec, 0, sizeof(dummydrec));
        memset(chunky_out, 0, sizeof(chunky_out));
@@ -3032,7 +3215,11 @@ void denise_reset(bool hard)
        debug_dma_ptr = &dummydrec;
        denise_cycle_half = 0;
        denise_strlong = false;
+       denise_strlong_fast = false;
        rga_denise_fast_read = rga_denise_fast_write = 0;
+       rga_queue_write = rga_queue_read = 0;
+       denise_lol_shift_enable = false;
+       denise_lol_shift_prev = 0;
        if (hard) {
                strlong_emulation = false;
                denise_res = 0;
@@ -3494,8 +3681,11 @@ static void expand_drga(struct denise_rga *rd)
                        agnus_lol = (rd->flags & DENISE_RGA_FLAG_LOL_ON) != 0;
                        if (no_denise_lol) {
                                agnus_lol = false;
+                               denise_lol_shift_enable = false;
+                               denise_lol_shift_prev = 0;
+                               return;
                        }
-                       if (!agnus_lol && !denise_lol_shift_prev) {
+                       if (!agnus_lol && (!denise_lol_shift_prev || denise_lol_shift_enable)) {
                                int add = 1 << hresolution;
                                buf1 += add;
                                buf2 += add;
@@ -3504,7 +3694,8 @@ static void expand_drga(struct denise_rga *rd)
                                        gbuf += add;
                                }
                                denise_lol_shift_prev = add;
-                       } else if (agnus_lol && denise_lol_shift_prev) {
+                               denise_lol_shift_enable = true;
+                       } else if (agnus_lol && denise_lol_shift_prev > 0) {
                                buf1 -= denise_lol_shift_prev;
                                buf2 -= denise_lol_shift_prev;
                                buf_d -= denise_lol_shift_prev;
@@ -3512,6 +3703,7 @@ static void expand_drga(struct denise_rga *rd)
                                        gbuf -= denise_lol_shift_prev;
                                }
                                denise_lol_shift_prev = 0;
+                               denise_lol_shift_enable = true;
                        }
                }
        }
@@ -4312,15 +4504,17 @@ static void check_fast_hb(void)
        hstart_new();
 }
 
-
 // fix strobe position after fast mode
-void denise_handle_quick_strobe(uae_u16 strobe, int offset)
+static void denise_handle_quick_strobe(uae_u16 strobe, int offset, int vpos)
 {
        struct denise_rga rd = { 0 };
        rd.rga = strobe;
        denise_hcounter_new += maxhpos * 2;
        denise_hcounter_new &= 511;
        denise_hcounter = denise_hcounter_new;
+
+       //write_log("%d %04x %d %d\n", vpos, strobe, offset, denise_hcounter_new);
+
        handle_strobes(&rd);
        if (denise_hcounter_new == 1 * 2) {
                // 3 = refresh offset, 2 = pipeline delay
@@ -4710,10 +4904,23 @@ bool start_draw_denise(void)
        struct vidbuffer *vb = &vidinfo->drawbuffer;
 
        vidinfo->outbuffer = vb;
-       if (!lockscr(vb, false, false, display_reset > 0)) {
+
+       if (!lockscr(vb, false, display_reset > 0)) {
                return false;
        }
 
+       if (vidinfo->tempbuffer.bufmem) {
+               vidinfo->inbuffer = &vidinfo->tempbuffer;
+       } else {
+               vidinfo->inbuffer = &vidinfo->drawbuffer;
+       }
+
+       if (vidinfo->outbuffer != vidinfo->inbuffer) {
+               vidinfo->inbuffer->locked = vidinfo->outbuffer->locked;
+       }
+
+       init_row_map();
+
        denise_y_start = 0;
        denise_y_end = -1;
 
@@ -4725,7 +4932,14 @@ void end_draw_denise(void)
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
        struct vidbuffer *vb = &vidinfo->drawbuffer;
 
+       draw_denise_line_queue_flush();
+       denise_mark_last_line();
+
        unlockscr(vb, denise_y_start, denise_y_end);
+
+       if (vidinfo->outbuffer != vidinfo->inbuffer) {
+               vidinfo->inbuffer->locked = vidinfo->outbuffer->locked;
+       }
 }
 
 // emulate black level calibration (vb and hb)
@@ -4894,6 +5108,7 @@ static void lts_null(void)
 
 static int prevline;
 static int prev_last_line;
+static int highestline;
 static bool prev_last_line_req;
 
 void denise_mark_last_line(void)
@@ -4918,24 +5133,45 @@ void denise_set_line(int gfx_ypos)
 static void get_line(int gfx_ypos, enum nln_how how)
 {
        struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
-       struct vidbuffer *vb = &vidinfo->drawbuffer;
+       struct vidbuffer *vb = vidinfo->inbuffer;
 
-       // clear remaining lines if mode height is now smaller than previously
-       if (prev_last_line_req) {
-               struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
-               struct vidbuffer *vb = &vidinfo->drawbuffer;
-               int l = prev_last_line;
+       xlinebuffer = NULL;
+       xlinebuffer2 = NULL;
 
-               while (l < prevline && l < vb->inheight) {
-                       uae_u8 *b = row_map[l];
-                       memset(b, 0, vb->inwidth * vb->pixbytes);
-                       l++;
-               }
-               prev_last_line_req = false;
+       denise_pixtotal_max = denise_pixtotalv - denise_pixtotalskip2;
+       denise_pixtotal = -denise_pixtotalskip;
+
+       if (!vb->locked) {
+               denise_pixtotal_max = -0x7fffffff;
+               return;
        }
 
-       xlinebuffer = NULL;
-       xlinebuffer2 = NULL;
+       if (gfx_ypos < prevline - 1) {
+
+               if (!denise_strlong_detected && strlong_emulation) {
+                       strlong_emulation = false;
+                       write_log("STRLONG strobe emulation deactivated.\n");
+                       select_lts();
+                       denise_lol_shift_enable = false;
+                       denise_lol_shift_prev = 0;
+               }
+               denise_strlong_detected = false;
+
+               // clear remaining lines if mode height is now smaller than previously
+               struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo;
+               if (prevline != highestline) {
+                       int l = prevline;
+                       while (l < highestline && l < vb->inheight) {
+                               uae_u8 *b = row_map[l];
+                               memset(b, 0, vb->inwidth * vb->pixbytes);
+                               l++;
+                       }
+                       highestline = prevline;
+               }
+       }
+       if (gfx_ypos > prevline && gfx_ypos >= 0) {
+               prevline = gfx_ypos;
+       }
 
        if (currprefs.gfx_overscanmode < OVERSCANMODE_ULTRA) {
                gfx_ypos -= minfirstline_linear << currprefs.gfx_vresolution;
@@ -4993,9 +5229,6 @@ static void get_line(int gfx_ypos, enum nln_how how)
                }
        }
        
-       denise_pixtotal_max = denise_pixtotalv - denise_pixtotalskip2;
-       denise_pixtotal = -denise_pixtotalskip;
-
        if ((denise_pixtotal_max << (1 + hresolution)) > vb->inwidth) {
                denise_pixtotal_max = vb->inwidth >> (1 + hresolution);
        }
@@ -5041,6 +5274,10 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
                buf2 = debug_buf;
        }
 
+       if (!row_map) {
+               return;
+       }
+
        get_line(gfx_ypos, how);
 
        hbstrt_offset = -1;
@@ -5094,7 +5331,7 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
                }
 
                if (buf1 && gbuf && denise_pixtotal_max > 0) {
-                       memset(gbuf, 0xff, ((2 * denise_pixtotal_max) << hresolution) * sizeof(uae_u16));
+                       memset(gbuf, 0, ((2 * denise_pixtotal_max) << hresolution) * sizeof(uae_u16));
                }
 
        } else {
@@ -5130,26 +5367,30 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
                        }
                }
 #endif
-#if 0
-               uae_u32 *hbstrt_ptr2 = buf2 ? buf2t + (hbstrt_ptr1 - buf1t) : NULL;
-               uae_u32 *hbstop_ptr2 = buf2 ? buf2t + (hbstop_ptr1 - buf1t) : NULL;
+               int rshift = RES_MAX - hresolution;
+               int hbstrt_offset2 = (hbstrt_offset - internal_pixel_start_cnt) >> rshift;
+               int hbstop_offset2 = (hbstop_offset - internal_pixel_start_cnt) >> rshift;
+               uae_u32 *hbstrt_ptr1 = hbstrt_offset >= 0 ? buf1t + hbstrt_offset2 : NULL;
+               uae_u32 *hbstop_ptr1 = hbstop_offset >= 0 ? buf1t + hbstop_offset2 : NULL;
+               uae_u32 *hbstrt_ptr2 = buf2 && hbstrt_offset >= 0 ? buf2t + hbstrt_offset2 : NULL;
+               uae_u32 *hbstop_ptr2 = buf2 && hbstop_offset >= 0 ? buf2t + hbstop_offset2 : NULL;
                // blank last pixel row if normal overscan mode, it might have NTSC artifacts
                if (denise_pixtotal_max != -0x7fffffff && hbstrt_ptr1 && currprefs.gfx_overscanmode <= OVERSCANMODE_OVERSCAN && !ecs_denise) {
                        int add = 1 << hresolution;
                        uae_u32 *p1 = hbstrt_ptr1 - denise_lol_shift_prev;
                        uae_u32 *p2 = hbstrt_ptr2 - denise_lol_shift_prev;
                        for (int i = 0; i < add * 2; i++) {
-                               *p1++ = 0x000000;
-                               *p2++ = 0x000000;
+                               *p1++ = BLANK_COLOR;
+                               *p2++ = BLANK_COLOR;
                        }
                }
-               if (no_denise_lol && denise_pixtotal_max != -0x7fffffff && hbstrt_ptr1 && !lol) {
+               if (1 && no_denise_lol && denise_pixtotal_max != -0x7fffffff && hbstrt_ptr1 && !lol_fast && denise_strlong_detected) {
                        int add = 1 << hresolution;
-                       uae_u32 *p1 = hbstrt_ptr1 - denise_lol_shift_prev * 2;
-                       uae_u32 *p2 = hbstrt_ptr2 - denise_lol_shift_prev * 2;
+                       uae_u32 *p1 = hbstrt_ptr1 - 2 * add;
+                       uae_u32 *p2 = hbstrt_ptr2 - 2 * add;
                        for (int i = 0; i < add * 2; i++) {
-                               *p1++ = 0x000000;
-                               *p2++ = 0x000000;
+                               *p1++ = BLANK_COLOR;
+                               *p2++ = BLANK_COLOR;
                        }
                }
                if (currprefs.gfx_overscanmode < OVERSCANMODE_OVERSCAN) {
@@ -5195,15 +5436,14 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
                                        if (bufg) {
                                                uae_u16 *gp1 = (p1 - ptr2) + bufg;
                                                if (i >= 2) {
-                                                       memset(gp1, 0xff, w * sizeof(uae_u16));
+                                                       memset(gp1, 0, w * sizeof(uae_u16));
                                                } else {
-                                                       memset(gp1 - w, 0xff, w * sizeof(uae_u16));
+                                                       memset(gp1 - w, 0, w * sizeof(uae_u16));
                                                }
                                        }
                                }
                        }
                }
-#endif
 
                if (currprefs.display_calibration && xlinebuffer) {
                        emulate_black_level_calibration(buf1t, buf2t, bufdt, total, calib_start, calib_len);
@@ -5240,6 +5480,8 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
 #include "linetoscr_ecs_shres.cpp"
 #include "linetoscr_ecs_fast.cpp"
 #include "linetoscr_aga_fast.cpp"
+#include "linetoscr_ecs_genlock_fast.cpp"
+#include "linetoscr_aga_genlock_fast.cpp"
 
 // select linetoscr routine
 static void select_lts(void)
@@ -6340,12 +6582,12 @@ static int l_shift(int v, int shift)
 }
 
 // draw border from hb to hb
-bool draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
+void draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
 {
        get_line(gfx_ypos, how);
 
        if (!buf1) {
-               return false;
+               return;
        }
 
        uae_u32 *buf1p = buf1;
@@ -6428,17 +6670,14 @@ bool draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linesta
                }
        }
 
-       return true;
 }
 
-static int previous_c_len;
-
-bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
+void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
 {
        get_line(gfx_ypos, how);
 
        if (!buf1) {
-               return false;
+               return;
        }
 
        uae_u32 *buf1p = buf1;
@@ -6450,7 +6689,7 @@ bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines
        int fmode = 16 << (((ls->fmode & 3) == 3 ? 2 : (ls->fmode & 3)));
 
        if (ls->ltsidx < 0) {
-               bool ehb = planecnt == 6 && !bplham && !dpf && (!ecs_denise || !(ls->bplcon0 & 1) || !(ls->bplcon2 & 0x200));
+               bool ehb = planecnt == 6 && !ham && !dpf && (!ecs_denise || !(ls->bplcon0 & 1) || !(ls->bplcon2 & 0x200));
                int mode = CMODE_NORMAL;
                if (ham) {
                        mode = CMODE_HAM;
@@ -6469,14 +6708,22 @@ bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines
 
        LINETOSRC_FUNCF ltsf;
        if (aga_mode) {
-               ltsf = linetoscr_aga_fast_funcs[ls->ltsidx];
+               if (need_genlock_data) {
+                       ltsf = linetoscr_aga_genlock_fast_funcs[ls->ltsidx];
+               } else {
+                       ltsf = linetoscr_aga_fast_funcs[ls->ltsidx];
+               }
        } else {
-               ltsf = linetoscr_ecs_fast_funcs[ls->ltsidx];
+               if (need_genlock_data) {
+                       ltsf = linetoscr_ecs_genlock_fast_funcs[ls->ltsidx];
+               } else {
+                       ltsf = linetoscr_ecs_fast_funcs[ls->ltsidx];
+               }
        }
 
        uae_u32 *cstart = chunky_out + 1024;
        int len = (ls->bpllen + 3) / 4;
-       if (currprefs.cpu_memory_cycle_exact) {
+       if (0 && currprefs.cpu_memory_cycle_exact) {
                if (fmode == 16) {
                        pfield_doline_16(planecnt, len, (uae_u8*)cstart, ls);
                } else if (fmode == 32) {
@@ -6575,8 +6822,6 @@ bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines
        //write_log("%03d %03d %03d %03d %03d %03d %03d\n", vpos, hbstop_offset, hbstrt_offset, hstrt_offset, hstop_offset, bpl1dat_trigger_offset, delayoffset);
 
        uae_u8 bxor = ls->bplcon4 >> 8;
-       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
-       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
        buf1 = buf1p;
        buf2 = buf2p;
 //     int cpadd = doubling < 0 ? (doubling < -1 ? 4 : 2) : 1;
@@ -6610,7 +6855,7 @@ bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines
 #if 1
        
        ltsf(draw_start, draw_end, draw_startoffset, hbstrt_offset, hbstop_offset, hstrt_offset, hstop_offset, bpl1dat_trigger_offset,
-               planecnt, bgcol, cp, cp2, cpadd, cpadds, bufadd, bxor, ls->linecolorstate);
+               planecnt, bgcol, cp, cp2, cpadd, cpadds, bufadd, ls);
 
 #else
 
@@ -6649,7 +6894,7 @@ bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines
                cnt += bufadd;
        }
 #endif
-       return true;
+
 }
 
 #define RB restore_u8()
@@ -6774,3 +7019,160 @@ uae_u8 *restore_custom_sprite_denise(int num, uae_u8 *src, uae_u16 pos, uae_u16
 
        return src;
 }
+
+static bool waitqueue(void)
+{
+       while (((rga_queue_write + 1) & DENISE_RGA_SLOT_CHUNKS_MASK) == (rga_queue_read & DENISE_RGA_SLOT_CHUNKS_MASK)) {
+               uae_sem_trywait_delay(&read_sem, 500);
+       }
+       return true;
+}
+static void addtowritequeue(void)
+{
+       atomic_inc(&rga_queue_write);
+
+       uae_sem_post(&write_sem);
+}
+
+void draw_denise_border_line_fast_queue(int gfx_ypos, enum nln_how how, struct linestate *ls)
+{
+       if (MULTITHREADED_DENISE) {
+               
+               if (!waitqueue()) {
+                       return;
+               }
+
+               struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK];
+               q->gfx_ypos = gfx_ypos;
+               q->how = how;
+               q->ls = ls;
+               q->type = 2;
+               q->vpos = vpos;
+
+               addtowritequeue();
+
+       } else {
+       
+               draw_denise_border_line_fast(gfx_ypos, how, ls);
+       
+       }
+}
+
+void draw_denise_bitplane_line_fast_queue(int gfx_ypos, enum nln_how how, struct linestate *ls)
+{
+       if (MULTITHREADED_DENISE) {
+               
+               if (!waitqueue()) {
+                       return;
+               }
+
+               struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK];
+               q->gfx_ypos = gfx_ypos;
+               q->how = how;
+               q->ls = ls;
+               q->type = 1;
+               q->vpos = vpos;
+
+               addtowritequeue();
+
+       } else {
+       
+               draw_denise_bitplane_line_fast(gfx_ypos, how, ls);
+       
+       }
+}
+
+void quick_denise_rga_queue(int linecnt, int startpos, int endpos)
+{
+       if (MULTITHREADED_DENISE) {
+
+               if (!waitqueue()) {
+                       return;
+               }
+
+               struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK];
+               q->linecnt = linecnt;
+               q->startpos = startpos;
+               q->endpos = endpos;
+               q->type = 3;
+               q->vpos = vpos;
+
+               addtowritequeue();
+       
+       } else {
+
+               quick_denise_rga(linecnt, startpos, endpos);
+       
+       }
+}
+
+void denise_handle_quick_strobe_queue(uae_u16 strobe, int strobe_pos, int endpos)
+{
+       if (MULTITHREADED_DENISE) {
+
+               if (!waitqueue()) {
+                       return;
+               }
+
+               struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK];
+               q->strobe = strobe;
+               q->strobe_pos = strobe_pos;
+               q->endpos = endpos;
+               q->type = 4;
+               q->vpos = vpos;
+
+               addtowritequeue();
+
+       } else {
+
+               denise_handle_quick_strobe(strobe, strobe_pos, endpos);
+
+       }
+}
+
+
+void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int endpos, int total, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lol, struct linestate *ls)
+{
+       if (MULTITHREADED_DENISE) {
+
+               if (!waitqueue()) {
+                       return;
+               }
+
+               struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK];
+               q->type = 0;
+               q->gfx_ypos = gfx_ypos;
+               q->how = how;
+               q->linecnt = linecnt;
+               q->startpos = startpos;
+               q->endpos = endpos;
+               q->total = total;
+               q->skip = skip;
+               q->skip2 = skip2;
+               q->dtotal = dtotal;
+               q->calib_start = calib_start;
+               q->calib_len = calib_len;
+               q->lol = lol;
+               q->ls = ls;
+               q->vpos = vpos;
+
+               addtowritequeue();
+
+       } else {
+
+               draw_denise_line(gfx_ypos, how, linecnt, startpos, total, skip, skip2, dtotal, calib_start, calib_len, lol, ls);
+
+       }
+}
+
+void draw_denise_line_queue_flush(void)
+{
+       if (MULTITHREADED_DENISE) {
+               for (;;) {
+                       if (rga_queue_read == rga_queue_write) {
+                               return;
+                       }
+                       uae_sem_trywait_delay(&read_sem, 500);
+               }
+       }
+}
index dd7e7dba624dc50891316d0ed2e9f7b7ae68a546..af728d8e2683fb910c9f9a1709d6478af007fbee 100644 (file)
@@ -858,17 +858,18 @@ static bool gen_head(void)
 static bool gen_fasthead(void)
 {
        char funcname[200];
-       sprintf(funcname, "lts_%s_%s_i%s_d%s_%s",
+       sprintf(funcname, "lts_%s_%s_i%s_d%s_%s%s",
                aga ? "aga" : "ecs",
                modes == 0 ? "n" : (modes == 1 ? "dpf" : (modes == 2 ? "ehb" : (modes == 4 ? "kehb" : "ham"))),
                res == 0 ? "lores" : (res == 1 ? "hires" : "shres"),
                outres == 0 ? "lores" : (outres == 1 ? "hires" : "shres"),
-               isbuf2 ? "b2" : "b1");
+               isbuf2 ? "b2" : "b1",
+               genlock ? "_genlock" : "");
        strcpy(funcnamep, funcname);
        funcnamep += strlen(funcnamep) + 1;
        *funcnamep = 0;
        outf("static void %s(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,"
-               "int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)", funcname);
+               "int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)", funcname);
        outf("{");
        return true;
 }
@@ -907,7 +908,7 @@ static void gen_fastdraw_mode(int off, int total)
        } else {
                outf("c = *cp;");
                if (off == total - 1) {
-                       outf("cp += 1 << cpadd;");
+                       outf("cp += cpaddv;");
                }
                if (modes == CMODE_DUALPF) {
                        outf("{");
@@ -933,6 +934,10 @@ static void gen_fastdraw_mode(int off, int total)
        if (isbuf2) {
                outf("*buf2++ = col;");
        }
+       if (genlock) {
+               outf("gpix = get_genlock_transparency_fast(col);");
+               outf("*gbuf++ = gpix;");
+       }
 }
 
 static void gen_fastdraw(void)
@@ -940,9 +945,17 @@ static void gen_fastdraw(void)
        int doubling = outres - res;
 
        if (aga) {
-               outf("uae_u32 *colors_aga = (uae_u32*)colors;");
+               outf("uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;");
        } else {
-               outf("uae_u16 *colors_ocs = (uae_u16*)colors;");
+               outf("uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;");
+       }
+       if (aga) {
+               outf("uae_u8 bxor = ls->bplcon4 >> 8;");
+       }
+       outf("int bufaddv = 1 << bufadd;");
+       outf("int cpaddv = 1 << cpadd;");
+       if (genlock) {
+               outf("uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);");
        }
 
        outf("int cnt = draw_start;");
@@ -980,6 +993,9 @@ static void gen_fastdraw(void)
                if (isbuf2) {
                        outf("*buf2++ = bgcolor;");
                }
+               if (genlock) {
+                       outf("*gbuf++ = gpix;");
+               }
        } else if (doubling == 1) {
                outf("*buf1++ = bgcolor;");
                outf("*buf1++ = bgcolor;");
@@ -987,6 +1003,10 @@ static void gen_fastdraw(void)
                        outf("*buf2++ = bgcolor;");
                        outf("*buf2++ = bgcolor;");
                }
+               if (genlock) {
+                       outf("*gbuf++ = gpix;");
+                       outf("*gbuf++ = gpix;");
+               }
        } else if (doubling == 2) {
                outf("*buf1++ = bgcolor;");
                outf("*buf1++ = bgcolor;");
@@ -998,6 +1018,12 @@ static void gen_fastdraw(void)
                        outf("*buf2++ = bgcolor;");
                        outf("*buf2++ = bgcolor;");
                }
+               if (genlock) {
+                       outf("*gbuf++ = gpix;");
+                       outf("*gbuf++ = gpix;");
+                       outf("*gbuf++ = gpix;");
+                       outf("*gbuf++ = gpix;");
+               }
        }
        outf("} else {");
        outf("bpl = true;");
@@ -1016,9 +1042,9 @@ static void gen_fastdraw(void)
        }
        outf("}");
        outf("if (cnt >= bpl1dat_trigger_offset && !bpl) {");
-       outf("  cp += 1 << cpadd;");
+       outf("  cp += cpaddv;");
        outf("}");
-       outf("cnt += 1 << bufadd;");
+       outf("cnt += bufaddv;");
        outf("}");
 }
 
@@ -1466,6 +1492,8 @@ int main (int argc, char *argv[])
        }
 
        // fast drawing
+       genlock = 0;
+
        set_outfile("../../linetoscr_ecs_fast.cpp");
        aga = 0;
        bplfmode = 3;
@@ -1504,6 +1532,46 @@ int main (int argc, char *argv[])
        }
        write_funcs_fast("linetoscr_aga_fast_funcs");
 
+       genlock = 1;
+
+       set_outfile("../../linetoscr_ecs_genlock_fast.cpp");
+       aga = 0;
+       bplfmode = 3;
+       planes = 1;
+       for (isbuf2 = 0; isbuf2 < 2; isbuf2++) {
+               for (outres = 0; outres < 3; outres++) {
+                       for (res = 0; res < 3; res++) {
+                               for (modes = 0; modes < 5; modes++) {
+                                       if (gen_fasthead()) {
+                                               gen_fastdraw();
+                                       } else {
+                                               gen_null();
+                                       }
+                                       gen_tail();
+                               }
+                       }
+               }
+       }
+       write_funcs_fast("linetoscr_ecs_genlock_fast_funcs");
+
+       set_outfile("../../linetoscr_aga_genlock_fast.cpp");
+       aga = 1;
+       for (isbuf2 = 0; isbuf2 < 2; isbuf2++) {
+               for (outres = 0; outres < 3; outres++) {
+                       for (res = 0; res < 3; res++) {
+                               for (modes = 0; modes < 5; modes++) {
+                                       if (gen_fasthead()) {
+                                               gen_fastdraw();
+                                       } else {
+                                               gen_null();
+                                       }
+                                       gen_tail();
+                               }
+                       }
+               }
+       }
+       write_funcs_fast("linetoscr_aga_genlock_fast_funcs");
+
 
        closefile();
 
index 0995872dee044850209cfbae956f34a2d584db6c..f585db2ac3ebfa0246775f8c9b2734189d17a528 100644 (file)
@@ -172,14 +172,7 @@ extern evt_t frametime;
 extern uae_u16 htotal, vtotal, beamcon0, new_beamcon0;
 extern uae_u16 bemcon0_hsync_mask, bemcon0_vsync_mask;
 
-// 100 words give you 1600 horizontal pixels. Should be more than enough for superhires. 
-// Extreme overscan superhires needs more.
-// must be divisible by 8
-#ifdef CUSTOM_SIMPLE
-#define MAX_WORDS_PER_LINE 56
-#else
 #define MAX_WORDS_PER_LINE 112
-#endif
 
 #ifdef AGA
 /* AGA mode color lookup tables */
@@ -276,8 +269,10 @@ extern struct custom_store custom_storage[256];
 
 struct denise_rga
 {
-       uae_u64 v64;
-       uae_u32 v;
+       union {
+               uae_u64 v64;
+               uae_u32 v;
+       };
        uae_u16 rga;
        uae_u32 line;
        uae_u32 flags;
@@ -287,14 +282,18 @@ struct denise_rga
 #endif
 };
 
-#define DENISE_RGA_SLOT_TOTAL 512
+#define DENISE_RGA_SLOT_CHUNKS 8
+#define DENISE_RGA_SLOT_CHUNKS_MASK (DENISE_RGA_SLOT_CHUNKS - 1)
+#define DENISE_RGA_SLOT_TOTAL (512 * DENISE_RGA_SLOT_CHUNKS)
 #define DENISE_RGA_SLOT_MASK (DENISE_RGA_SLOT_TOTAL - 1)
 extern struct denise_rga rga_denise[DENISE_RGA_SLOT_TOTAL];
 
 struct denise_fastsprite
 {
-       uae_u64 data64[2];
-       uae_u32 data[2];
+       union {
+               uae_u64 data64[2];
+               uae_u32 data[2];
+       };
        uae_u16 pos, ctl;
        bool active;
 };
index c12169cc706c63775fd944e369b6fecd10d5379d..5355a1ececbac5541c117e61bec2ce3403f93cf7 100644 (file)
 
 #include "uae/types.h"
 
-#define SMART_UPDATE 1
-
-#ifdef SUPPORT_PENGUINS
-#undef SMART_UPDATE
-#define SMART_UPDATE 1
-#endif
-
 #ifdef AGA
 #define MAX_PLANES 8
 #else
@@ -95,22 +88,8 @@ STATIC_INLINE int color_reg_get (struct color_entry *ce, int c)
 #endif
                return ce->color_regs_ecs[c];
 }
-STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v)
-{
-#ifdef AGA
-       if (aga_mode)
-               ce->color_regs_aga[c] = v;
-       else
-#endif
-               ce->color_regs_ecs[c] = v;
-}
 
-/* 440 rather than 880, since sprites are always lores.  */
-#ifdef UAE_MINI
-#define MAX_PIXELS_PER_LINE 880
-#else
 #define MAX_PIXELS_PER_LINE 2304
-#endif
 
 /* Functions in drawing.c.  */
 extern int coord_native_to_amiga_y (int);
@@ -194,12 +173,17 @@ struct linestate
        int fetchmode_size, fetchstart_mask;
        int ltsidx;
        bool vb;
+       uae_u16 strobe;
+       int strobe_pos;
 };
 
 extern struct color_entry denise_colors;
 void draw_denise_line(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int total, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lol, struct linestate *ls);
-bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls);
-bool draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls);
+void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int endpos, int total, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lol, struct linestate *ls);
+void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls);
+void draw_denise_bitplane_line_fast_queue(int gfx_ypos, enum nln_how how, struct linestate *ls);
+void draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls);
+void draw_denise_border_line_fast_queue(int gfx_ypos, enum nln_how how, struct linestate *ls);
 bool start_draw_denise(void);
 void end_draw_denise(void);
 void denise_update_reg(uae_u16 reg, uae_u16 v);
@@ -209,7 +193,9 @@ void denise_store_registers(void);
 void denise_restore_registers(void);
 void denise_set_line(int gfx_ypos);
 void denise_mark_last_line(void);
-void denise_handle_quick_strobe(uae_u16 strobe, int offset);
 bool denise_is_vb(void);
+void draw_denise_line_queue_flush(void);
+void quick_denise_rga_queue(int linecnt, int startpos, int endpos);
+void denise_handle_quick_strobe_queue(uae_u16 strobe, int strobe_pos, int endpos);
 
 #endif /* UAE_DRAWING_H */
index 84d0b9a52393d3214fbb52b49dfe099643d6ce7c..0668e5ac4a24761cc53bf669e480fa1adf9742a4 100644 (file)
@@ -54,7 +54,7 @@ extern bool render_screen(int monid, int, bool);
 extern void show_screen(int monid, int mode);
 extern bool show_screen_maybe(int monid, bool);
 
-extern int lockscr(struct vidbuffer*, bool, bool, bool);
+extern int lockscr(struct vidbuffer*, bool, bool);
 extern void unlockscr(struct vidbuffer*, int, int);
 extern bool target_graphics_buffer_update(int monid, bool force);
 extern float target_adjust_vblank_hz(int monid, float);
@@ -105,6 +105,8 @@ struct vidbuffer
     uae_u8 *realbufmem;
        uae_u8 *bufmem_allocated;
        bool bufmem_lockable;
+       bool locked;
+       bool vram_buffer;
     int rowbytes; /* Bytes per row in the memory pointed at by bufmem. */
     int pixbytes; /* Bytes per pixel. */
        /* size of this buffer */
@@ -121,8 +123,6 @@ struct vidbuffer
        int inheight2;
        /* use drawbuffer instead */
        bool nativepositioning;
-       /* tempbuffer in use */
-       bool tempbufferinuse;
        /* extra width, chipset hpos extra in right border */
        int extrawidth, extraheight;
 
index a6a2f04384c82ef69bb8bd0e45bf87a22fac5cfa..4d4d8f760bc2ca94c14762c3477819d89f8181a4 100644 (file)
@@ -4,9 +4,12 @@
 * This file was generated by genlinetoscr. Don't edit.
 */
 
-static void lts_aga_n_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -43,14 +46,17 @@ static void lts_aga_n_ilores_dlores_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -93,14 +99,17 @@ static void lts_aga_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -142,14 +151,17 @@ static void lts_aga_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -185,14 +197,17 @@ static void lts_aga_ham_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -229,14 +244,17 @@ static void lts_aga_kehb_ilores_dlores_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -273,14 +291,17 @@ static void lts_aga_n_ihires_dlores_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -323,14 +344,17 @@ static void lts_aga_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -372,14 +396,17 @@ static void lts_aga_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -415,14 +442,17 @@ static void lts_aga_ham_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -459,14 +489,17 @@ static void lts_aga_kehb_ihires_dlores_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -503,14 +536,17 @@ static void lts_aga_n_ishres_dlores_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -553,14 +589,17 @@ static void lts_aga_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -602,14 +641,17 @@ static void lts_aga_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -645,14 +687,17 @@ static void lts_aga_ham_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -689,14 +734,17 @@ static void lts_aga_kehb_ishres_dlores_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -739,14 +787,17 @@ static void lts_aga_n_ilores_dhires_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -801,14 +852,17 @@ static void lts_aga_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -861,14 +915,17 @@ static void lts_aga_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -909,14 +966,17 @@ static void lts_aga_ham_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -959,14 +1019,17 @@ static void lts_aga_kehb_ilores_dhires_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1003,14 +1066,17 @@ static void lts_aga_n_ihires_dhires_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1053,14 +1119,17 @@ static void lts_aga_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1102,14 +1171,17 @@ static void lts_aga_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1145,14 +1217,17 @@ static void lts_aga_ham_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1189,14 +1264,17 @@ static void lts_aga_kehb_ihires_dhires_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1233,14 +1311,17 @@ static void lts_aga_n_ishres_dhires_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1283,14 +1364,17 @@ static void lts_aga_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1332,14 +1416,17 @@ static void lts_aga_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1375,14 +1462,17 @@ static void lts_aga_ham_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1419,14 +1509,17 @@ static void lts_aga_kehb_ishres_dhires_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1481,14 +1574,17 @@ static void lts_aga_n_ilores_dshres_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1567,14 +1663,17 @@ static void lts_aga_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1649,14 +1748,17 @@ static void lts_aga_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1707,14 +1809,17 @@ static void lts_aga_ham_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1769,14 +1874,17 @@ static void lts_aga_kehb_ilores_dshres_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1819,14 +1927,17 @@ static void lts_aga_n_ihires_dshres_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1881,14 +1992,17 @@ static void lts_aga_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1941,14 +2055,17 @@ static void lts_aga_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1989,14 +2106,17 @@ static void lts_aga_ham_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2039,14 +2159,17 @@ static void lts_aga_kehb_ihires_dshres_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2083,14 +2206,17 @@ static void lts_aga_n_ishres_dshres_b1(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2133,14 +2259,17 @@ static void lts_aga_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2182,14 +2311,17 @@ static void lts_aga_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2225,14 +2357,17 @@ static void lts_aga_ham_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2269,14 +2404,17 @@ static void lts_aga_kehb_ishres_dshres_b1(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2316,14 +2454,17 @@ static void lts_aga_n_ilores_dlores_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2369,14 +2510,17 @@ static void lts_aga_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2421,14 +2565,17 @@ static void lts_aga_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2467,14 +2614,17 @@ static void lts_aga_ham_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2514,14 +2664,17 @@ static void lts_aga_kehb_ilores_dlores_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2561,14 +2714,17 @@ static void lts_aga_n_ihires_dlores_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2614,14 +2770,17 @@ static void lts_aga_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2666,14 +2825,17 @@ static void lts_aga_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2712,14 +2874,17 @@ static void lts_aga_ham_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2759,14 +2924,17 @@ static void lts_aga_kehb_ihires_dlores_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2806,14 +2974,17 @@ static void lts_aga_n_ishres_dlores_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2859,14 +3030,17 @@ static void lts_aga_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2911,14 +3085,17 @@ static void lts_aga_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2957,14 +3134,17 @@ static void lts_aga_ham_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3004,14 +3184,17 @@ static void lts_aga_kehb_ishres_dlores_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3059,14 +3242,17 @@ static void lts_aga_n_ilores_dhires_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3126,14 +3312,17 @@ static void lts_aga_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3191,14 +3380,17 @@ static void lts_aga_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3244,14 +3436,17 @@ static void lts_aga_ham_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3299,14 +3494,17 @@ static void lts_aga_kehb_ilores_dhires_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3346,14 +3544,17 @@ static void lts_aga_n_ihires_dhires_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3399,14 +3600,17 @@ static void lts_aga_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3451,14 +3655,17 @@ static void lts_aga_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3497,14 +3704,17 @@ static void lts_aga_ham_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3544,14 +3754,17 @@ static void lts_aga_kehb_ihires_dhires_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3591,14 +3804,17 @@ static void lts_aga_n_ishres_dhires_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3644,14 +3860,17 @@ static void lts_aga_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3696,14 +3915,17 @@ static void lts_aga_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3742,14 +3964,17 @@ static void lts_aga_ham_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3789,14 +4014,17 @@ static void lts_aga_kehb_ishres_dhires_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3860,14 +4088,17 @@ static void lts_aga_n_ilores_dshres_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3955,14 +4186,17 @@ static void lts_aga_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4046,14 +4280,17 @@ static void lts_aga_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4113,14 +4350,17 @@ static void lts_aga_ham_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4184,14 +4424,17 @@ static void lts_aga_kehb_ilores_dshres_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4239,14 +4482,17 @@ static void lts_aga_n_ihires_dshres_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4306,14 +4552,17 @@ static void lts_aga_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4371,14 +4620,17 @@ static void lts_aga_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4424,14 +4676,17 @@ static void lts_aga_ham_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4479,14 +4734,17 @@ static void lts_aga_kehb_ihires_dshres_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_n_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_n_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4526,14 +4784,17 @@ static void lts_aga_n_ishres_dshres_b2(int draw_start, int draw_end, int draw_st
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4579,14 +4840,17 @@ static void lts_aga_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4631,14 +4895,17 @@ static void lts_aga_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_ham_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_ham_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4677,14 +4944,17 @@ static void lts_aga_ham_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_aga_kehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_aga_kehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u32 *colors_aga = (uae_u32*)colors;
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4724,9 +4994,9 @@ static void lts_aga_kehb_ishres_dshres_b2(int draw_start, int draw_end, int draw
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
 static LINETOSRC_FUNCF linetoscr_aga_fast_funcs[] = {
diff --git a/linetoscr_aga_genlock_fast.cpp b/linetoscr_aga_genlock_fast.cpp
new file mode 100644 (file)
index 0000000..562ce33
--- /dev/null
@@ -0,0 +1,5604 @@
+/*
+* UAE - The portable Amiga emulator.
+*
+* This file was generated by genlinetoscr. Don't edit.
+*/
+
+static void lts_aga_n_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[2];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[3];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpadds[1];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_n_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_dpf_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               if (dpf_lookup_no[c]) {
+                                       dpval += dblpfofs[bpldualpf2of];
+                               }
+                               dpval ^= bxor;
+                               col = colors_aga[dpval];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ehb_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       if (c & 0x20) {
+                               uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;
+                               col = CONVERT_RGB(v);
+                       } else {
+                               col = colors_aga[c];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_ham_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_aga_kehb_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u32 *colors_aga = (uae_u32*)ls->linecolorstate;
+       uae_u8 bxor = ls->bplcon4 >> 8;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpadds[0];
+                       c ^= bxor;
+                       col = colors_aga[c & 31];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static LINETOSRC_FUNCF linetoscr_aga_genlock_fast_funcs[] = {
+       lts_aga_n_ilores_dlores_b1_genlock,
+       lts_aga_dpf_ilores_dlores_b1_genlock,
+       lts_aga_ehb_ilores_dlores_b1_genlock,
+       lts_aga_ham_ilores_dlores_b1_genlock,
+       lts_aga_kehb_ilores_dlores_b1_genlock,
+       lts_aga_n_ihires_dlores_b1_genlock,
+       lts_aga_dpf_ihires_dlores_b1_genlock,
+       lts_aga_ehb_ihires_dlores_b1_genlock,
+       lts_aga_ham_ihires_dlores_b1_genlock,
+       lts_aga_kehb_ihires_dlores_b1_genlock,
+       lts_aga_n_ishres_dlores_b1_genlock,
+       lts_aga_dpf_ishres_dlores_b1_genlock,
+       lts_aga_ehb_ishres_dlores_b1_genlock,
+       lts_aga_ham_ishres_dlores_b1_genlock,
+       lts_aga_kehb_ishres_dlores_b1_genlock,
+       lts_aga_n_ilores_dhires_b1_genlock,
+       lts_aga_dpf_ilores_dhires_b1_genlock,
+       lts_aga_ehb_ilores_dhires_b1_genlock,
+       lts_aga_ham_ilores_dhires_b1_genlock,
+       lts_aga_kehb_ilores_dhires_b1_genlock,
+       lts_aga_n_ihires_dhires_b1_genlock,
+       lts_aga_dpf_ihires_dhires_b1_genlock,
+       lts_aga_ehb_ihires_dhires_b1_genlock,
+       lts_aga_ham_ihires_dhires_b1_genlock,
+       lts_aga_kehb_ihires_dhires_b1_genlock,
+       lts_aga_n_ishres_dhires_b1_genlock,
+       lts_aga_dpf_ishres_dhires_b1_genlock,
+       lts_aga_ehb_ishres_dhires_b1_genlock,
+       lts_aga_ham_ishres_dhires_b1_genlock,
+       lts_aga_kehb_ishres_dhires_b1_genlock,
+       lts_aga_n_ilores_dshres_b1_genlock,
+       lts_aga_dpf_ilores_dshres_b1_genlock,
+       lts_aga_ehb_ilores_dshres_b1_genlock,
+       lts_aga_ham_ilores_dshres_b1_genlock,
+       lts_aga_kehb_ilores_dshres_b1_genlock,
+       lts_aga_n_ihires_dshres_b1_genlock,
+       lts_aga_dpf_ihires_dshres_b1_genlock,
+       lts_aga_ehb_ihires_dshres_b1_genlock,
+       lts_aga_ham_ihires_dshres_b1_genlock,
+       lts_aga_kehb_ihires_dshres_b1_genlock,
+       lts_aga_n_ishres_dshres_b1_genlock,
+       lts_aga_dpf_ishres_dshres_b1_genlock,
+       lts_aga_ehb_ishres_dshres_b1_genlock,
+       lts_aga_ham_ishres_dshres_b1_genlock,
+       lts_aga_kehb_ishres_dshres_b1_genlock,
+       lts_aga_n_ilores_dlores_b2_genlock,
+       lts_aga_dpf_ilores_dlores_b2_genlock,
+       lts_aga_ehb_ilores_dlores_b2_genlock,
+       lts_aga_ham_ilores_dlores_b2_genlock,
+       lts_aga_kehb_ilores_dlores_b2_genlock,
+       lts_aga_n_ihires_dlores_b2_genlock,
+       lts_aga_dpf_ihires_dlores_b2_genlock,
+       lts_aga_ehb_ihires_dlores_b2_genlock,
+       lts_aga_ham_ihires_dlores_b2_genlock,
+       lts_aga_kehb_ihires_dlores_b2_genlock,
+       lts_aga_n_ishres_dlores_b2_genlock,
+       lts_aga_dpf_ishres_dlores_b2_genlock,
+       lts_aga_ehb_ishres_dlores_b2_genlock,
+       lts_aga_ham_ishres_dlores_b2_genlock,
+       lts_aga_kehb_ishres_dlores_b2_genlock,
+       lts_aga_n_ilores_dhires_b2_genlock,
+       lts_aga_dpf_ilores_dhires_b2_genlock,
+       lts_aga_ehb_ilores_dhires_b2_genlock,
+       lts_aga_ham_ilores_dhires_b2_genlock,
+       lts_aga_kehb_ilores_dhires_b2_genlock,
+       lts_aga_n_ihires_dhires_b2_genlock,
+       lts_aga_dpf_ihires_dhires_b2_genlock,
+       lts_aga_ehb_ihires_dhires_b2_genlock,
+       lts_aga_ham_ihires_dhires_b2_genlock,
+       lts_aga_kehb_ihires_dhires_b2_genlock,
+       lts_aga_n_ishres_dhires_b2_genlock,
+       lts_aga_dpf_ishres_dhires_b2_genlock,
+       lts_aga_ehb_ishres_dhires_b2_genlock,
+       lts_aga_ham_ishres_dhires_b2_genlock,
+       lts_aga_kehb_ishres_dhires_b2_genlock,
+       lts_aga_n_ilores_dshres_b2_genlock,
+       lts_aga_dpf_ilores_dshres_b2_genlock,
+       lts_aga_ehb_ilores_dshres_b2_genlock,
+       lts_aga_ham_ilores_dshres_b2_genlock,
+       lts_aga_kehb_ilores_dshres_b2_genlock,
+       lts_aga_n_ihires_dshres_b2_genlock,
+       lts_aga_dpf_ihires_dshres_b2_genlock,
+       lts_aga_ehb_ihires_dshres_b2_genlock,
+       lts_aga_ham_ihires_dshres_b2_genlock,
+       lts_aga_kehb_ihires_dshres_b2_genlock,
+       lts_aga_n_ishres_dshres_b2_genlock,
+       lts_aga_dpf_ishres_dshres_b2_genlock,
+       lts_aga_ehb_ishres_dshres_b2_genlock,
+       lts_aga_ham_ishres_dshres_b2_genlock,
+       lts_aga_kehb_ishres_dshres_b2_genlock,
+       NULL
+};
index a15b32090a5658c29f6d0c1331f28f3ed0ee7674..98f8773425b6248a0c227396e9740b8be2a17b06 100644 (file)
@@ -4,9 +4,11 @@
 * This file was generated by genlinetoscr. Don't edit.
 */
 
-static void lts_ecs_n_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -37,19 +39,21 @@ static void lts_ecs_n_ilores_dlores_b1(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -80,7 +84,7 @@ static void lts_ecs_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -88,14 +92,16 @@ static void lts_ecs_dpf_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -126,7 +132,7 @@ static void lts_ecs_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -136,14 +142,16 @@ static void lts_ecs_ehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -174,19 +182,21 @@ static void lts_ecs_ham_ilores_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ilores_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -217,19 +227,21 @@ static void lts_ecs_kehb_ilores_dlores_b1(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -260,19 +272,21 @@ static void lts_ecs_n_ihires_dlores_b1(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -303,7 +317,7 @@ static void lts_ecs_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -311,14 +325,16 @@ static void lts_ecs_dpf_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -349,7 +365,7 @@ static void lts_ecs_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -359,14 +375,16 @@ static void lts_ecs_ehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -397,19 +415,21 @@ static void lts_ecs_ham_ihires_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ihires_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -440,19 +460,21 @@ static void lts_ecs_kehb_ihires_dlores_b1(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -483,19 +505,21 @@ static void lts_ecs_n_ishres_dlores_b1(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -526,7 +550,7 @@ static void lts_ecs_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -534,14 +558,16 @@ static void lts_ecs_dpf_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -572,7 +598,7 @@ static void lts_ecs_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -582,14 +608,16 @@ static void lts_ecs_ehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -620,19 +648,21 @@ static void lts_ecs_ham_ishres_dlores_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ishres_dlores_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -663,19 +693,21 @@ static void lts_ecs_kehb_ishres_dlores_b1(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -710,19 +742,21 @@ static void lts_ecs_n_ilores_dhires_b1(int draw_start, int draw_end, int draw_st
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -760,7 +794,7 @@ static void lts_ecs_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        }
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -768,14 +802,16 @@ static void lts_ecs_dpf_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -815,7 +851,7 @@ static void lts_ecs_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        }
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -825,14 +861,16 @@ static void lts_ecs_ehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -867,19 +905,21 @@ static void lts_ecs_ham_ilores_dhires_b1(int draw_start, int draw_end, int draw_
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ilores_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -914,19 +954,21 @@ static void lts_ecs_kehb_ilores_dhires_b1(int draw_start, int draw_end, int draw
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -957,19 +999,21 @@ static void lts_ecs_n_ihires_dhires_b1(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1000,7 +1044,7 @@ static void lts_ecs_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -1008,14 +1052,16 @@ static void lts_ecs_dpf_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1046,7 +1092,7 @@ static void lts_ecs_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -1056,14 +1102,16 @@ static void lts_ecs_ehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1094,19 +1142,21 @@ static void lts_ecs_ham_ihires_dhires_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ihires_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1137,19 +1187,21 @@ static void lts_ecs_kehb_ihires_dhires_b1(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1180,19 +1232,21 @@ static void lts_ecs_n_ishres_dhires_b1(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1223,7 +1277,7 @@ static void lts_ecs_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -1231,14 +1285,16 @@ static void lts_ecs_dpf_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1269,7 +1325,7 @@ static void lts_ecs_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -1279,14 +1335,16 @@ static void lts_ecs_ehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1317,19 +1375,21 @@ static void lts_ecs_ham_ishres_dhires_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ishres_dhires_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1360,19 +1420,21 @@ static void lts_ecs_kehb_ishres_dhires_b1(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1415,19 +1477,21 @@ static void lts_ecs_n_ilores_dshres_b1(int draw_start, int draw_end, int draw_st
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1479,7 +1543,7 @@ static void lts_ecs_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        }
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -1487,14 +1551,16 @@ static void lts_ecs_dpf_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1552,7 +1618,7 @@ static void lts_ecs_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        }
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -1562,14 +1628,16 @@ static void lts_ecs_ehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1612,19 +1680,21 @@ static void lts_ecs_ham_ilores_dshres_b1(int draw_start, int draw_end, int draw_
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ilores_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1667,19 +1737,21 @@ static void lts_ecs_kehb_ilores_dshres_b1(int draw_start, int draw_end, int draw
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1714,19 +1786,21 @@ static void lts_ecs_n_ihires_dshres_b1(int draw_start, int draw_end, int draw_st
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1764,7 +1838,7 @@ static void lts_ecs_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        }
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -1772,14 +1846,16 @@ static void lts_ecs_dpf_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1819,7 +1895,7 @@ static void lts_ecs_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        }
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -1829,14 +1905,16 @@ static void lts_ecs_ehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1871,19 +1949,21 @@ static void lts_ecs_ham_ihires_dshres_b1(int draw_start, int draw_end, int draw_
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ihires_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1918,19 +1998,21 @@ static void lts_ecs_kehb_ihires_dshres_b1(int draw_start, int draw_end, int draw
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -1961,19 +2043,21 @@ static void lts_ecs_n_ishres_dshres_b1(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2004,7 +2088,7 @@ static void lts_ecs_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -2012,14 +2096,16 @@ static void lts_ecs_dpf_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2050,7 +2136,7 @@ static void lts_ecs_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -2060,14 +2146,16 @@ static void lts_ecs_ehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2098,19 +2186,21 @@ static void lts_ecs_ham_ishres_dshres_b1(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ishres_dshres_b1(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2141,19 +2231,21 @@ static void lts_ecs_kehb_ishres_dshres_b1(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2186,20 +2278,22 @@ static void lts_ecs_n_ilores_dlores_b2(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2232,7 +2326,7 @@ static void lts_ecs_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -2241,14 +2335,16 @@ static void lts_ecs_dpf_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2281,7 +2377,7 @@ static void lts_ecs_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -2292,14 +2388,16 @@ static void lts_ecs_ehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2332,20 +2430,22 @@ static void lts_ecs_ham_ilores_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ilores_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2378,20 +2478,22 @@ static void lts_ecs_kehb_ilores_dlores_b2(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2424,20 +2526,22 @@ static void lts_ecs_n_ihires_dlores_b2(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2470,7 +2574,7 @@ static void lts_ecs_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -2479,14 +2583,16 @@ static void lts_ecs_dpf_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2519,7 +2625,7 @@ static void lts_ecs_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -2530,14 +2636,16 @@ static void lts_ecs_ehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2570,20 +2678,22 @@ static void lts_ecs_ham_ihires_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ihires_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2616,20 +2726,22 @@ static void lts_ecs_kehb_ihires_dlores_b2(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2662,20 +2774,22 @@ static void lts_ecs_n_ishres_dlores_b2(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2708,7 +2822,7 @@ static void lts_ecs_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -2717,14 +2831,16 @@ static void lts_ecs_dpf_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2757,7 +2873,7 @@ static void lts_ecs_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -2768,14 +2884,16 @@ static void lts_ecs_ehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2808,20 +2926,22 @@ static void lts_ecs_ham_ishres_dlores_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ishres_dlores_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2854,20 +2974,22 @@ static void lts_ecs_kehb_ishres_dlores_b2(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2906,20 +3028,22 @@ static void lts_ecs_n_ilores_dhires_b2(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -2961,7 +3085,7 @@ static void lts_ecs_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -2970,14 +3094,16 @@ static void lts_ecs_dpf_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3021,7 +3147,7 @@ static void lts_ecs_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -3032,14 +3158,16 @@ static void lts_ecs_ehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3078,20 +3206,22 @@ static void lts_ecs_ham_ilores_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ilores_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3130,20 +3260,22 @@ static void lts_ecs_kehb_ilores_dhires_b2(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3176,20 +3308,22 @@ static void lts_ecs_n_ihires_dhires_b2(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3222,7 +3356,7 @@ static void lts_ecs_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -3231,14 +3365,16 @@ static void lts_ecs_dpf_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3271,7 +3407,7 @@ static void lts_ecs_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -3282,14 +3418,16 @@ static void lts_ecs_ehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3322,20 +3460,22 @@ static void lts_ecs_ham_ihires_dhires_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ihires_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3368,20 +3508,22 @@ static void lts_ecs_kehb_ihires_dhires_b2(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3414,20 +3556,22 @@ static void lts_ecs_n_ishres_dhires_b2(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3460,7 +3604,7 @@ static void lts_ecs_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -3469,14 +3613,16 @@ static void lts_ecs_dpf_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3509,7 +3655,7 @@ static void lts_ecs_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -3520,14 +3666,16 @@ static void lts_ecs_ehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3560,20 +3708,22 @@ static void lts_ecs_ham_ishres_dhires_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ishres_dhires_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3606,20 +3756,22 @@ static void lts_ecs_kehb_ishres_dhires_b2(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3670,20 +3822,22 @@ static void lts_ecs_n_ilores_dshres_b2(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3743,7 +3897,7 @@ static void lts_ecs_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -3752,14 +3906,16 @@ static void lts_ecs_dpf_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3825,7 +3981,7 @@ static void lts_ecs_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -3836,14 +3992,16 @@ static void lts_ecs_ehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3894,20 +4052,22 @@ static void lts_ecs_ham_ilores_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ilores_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -3958,20 +4118,22 @@ static void lts_ecs_kehb_ilores_dshres_b2(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4010,20 +4172,22 @@ static void lts_ecs_n_ihires_dshres_b2(int draw_start, int draw_end, int draw_st
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4065,7 +4229,7 @@ static void lts_ecs_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -4074,14 +4238,16 @@ static void lts_ecs_dpf_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4125,7 +4291,7 @@ static void lts_ecs_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -4136,14 +4302,16 @@ static void lts_ecs_ehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4182,20 +4350,22 @@ static void lts_ecs_ham_ihires_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ihires_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4234,20 +4404,22 @@ static void lts_ecs_kehb_ihires_dshres_b2(int draw_start, int draw_end, int draw
                        *buf1++ = col;
                        *buf2++ = col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_n_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_n_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4280,20 +4452,22 @@ static void lts_ecs_n_ishres_dshres_b2(int draw_start, int draw_end, int draw_st
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4326,7 +4500,7 @@ static void lts_ecs_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        {
                                uae_u8 dpval = dpf_lookup[c];
                                col = xcolors[colors_ocs[dpval]];
@@ -4335,14 +4509,16 @@ static void lts_ecs_dpf_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4375,7 +4551,7 @@ static void lts_ecs_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        c &= bplehb_mask;
                        if (c <= 31) {
                                col = xcolors[colors_ocs[c]];
@@ -4386,14 +4562,16 @@ static void lts_ecs_ehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_ham_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_ham_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4426,20 +4604,22 @@ static void lts_ecs_ham_ishres_dshres_b2(int draw_start, int draw_end, int draw_
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = decode_ham_pixel_fast(c, colors_ocs);
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
-static void lts_ecs_kehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, uae_u8 bxor, void *colors)
+static void lts_ecs_kehb_ishres_dshres_b2(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
 {
-       uae_u16 *colors_ocs = (uae_u16*)colors;
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
        int cnt = draw_start;
        if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
                cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
@@ -4472,15 +4652,15 @@ static void lts_ecs_kehb_ishres_dshres_b2(int draw_start, int draw_end, int draw
                        uae_u8 c;
                        uae_u32 col;
                        c = *cp;
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                        col = xcolors[colors_ocs[c & 31]];
                        *buf1++ = col;
                        *buf2++ = col;
                }
                if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += 1 << cpadd;
+                       cp += cpaddv;
                }
-               cnt += 1 << bufadd;
+               cnt += bufaddv;
        }
 }
 static LINETOSRC_FUNCF linetoscr_ecs_fast_funcs[] = {
diff --git a/linetoscr_ecs_genlock_fast.cpp b/linetoscr_ecs_genlock_fast.cpp
new file mode 100644 (file)
index 0000000..2c388c6
--- /dev/null
@@ -0,0 +1,5268 @@
+/*
+* UAE - The portable Amiga emulator.
+*
+* This file was generated by genlinetoscr. Don't edit.
+*/
+
+static void lts_ecs_n_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ilores_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ihires_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ishres_dlores_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ilores_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ihires_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ishres_dhires_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ilores_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ihires_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ishres_dshres_b1_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ilores_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ihires_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ishres_dlores_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ilores_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ihires_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ishres_dhires_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ilores_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ihires_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_n_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_dpf_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       {
+                               uae_u8 dpval = dpf_lookup[c];
+                               col = xcolors[colors_ocs[dpval]];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ehb_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       c &= bplehb_mask;
+                       if (c <= 31) {
+                               col = xcolors[colors_ocs[c]];
+                       } else {
+                               col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                       }
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_ham_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = decode_ham_pixel_fast(c, colors_ocs);
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static void lts_ecs_kehb_ishres_dshres_b2_genlock(int draw_start, int draw_end, int draw_startoffset, int hbstrt_offset, int hbstop_offset, int hstrt_offset, int hstop_offset,int bpl1dat_trigger_offset, int planes, uae_u32 bgcolor, uae_u8 *cp, uae_u8 *cp2, int cpadd, int *cpadds, int bufadd, struct linestate *ls)
+{
+       uae_u16 *colors_ocs = (uae_u16*)ls->linecolorstate;
+       int bufaddv = 1 << bufadd;
+       int cpaddv = 1 << cpadd;
+       uae_u16 gpix = get_genlock_transparency_border_fast(ls->bplcon3);
+       int cnt = draw_start;
+       if (draw_startoffset > cnt && bpl1dat_trigger_offset > cnt) {
+               cnt = draw_startoffset > bpl1dat_trigger_offset ? bpl1dat_trigger_offset : draw_startoffset;
+               if (cnt > hbstop_offset) {
+                       cnt = hbstop_offset;
+               }
+       }
+       int end = draw_end;
+       if (end > hbstrt_offset) {
+               end = hbstrt_offset;
+       }
+       if (cnt < draw_startoffset) {
+               int d = (draw_startoffset - cnt) >> bufadd;
+               cp += d << cpadd;
+               cnt = draw_startoffset;
+       }
+       if (cnt < hbstop_offset) {
+               int d = (hbstop_offset - cnt) >> bufadd;
+               buf1 += d << bufadd;
+               buf2 += d << bufadd;
+               cnt = hbstop_offset;
+       }
+       while (cnt < end) {
+               bool bpl = false;
+               if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                       *buf1++ = bgcolor;
+                       *buf2++ = bgcolor;
+                       *gbuf++ = gpix;
+               } else {
+                       bpl = true;
+                       uae_u8 c;
+                       uae_u32 col;
+                       c = *cp;
+                       cp += cpaddv;
+                       col = xcolors[colors_ocs[c & 31]];
+                       *buf1++ = col;
+                       *buf2++ = col;
+                       gpix = get_genlock_transparency_fast(col);
+                       *gbuf++ = gpix;
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpaddv;
+               }
+               cnt += bufaddv;
+       }
+}
+static LINETOSRC_FUNCF linetoscr_ecs_genlock_fast_funcs[] = {
+       lts_ecs_n_ilores_dlores_b1_genlock,
+       lts_ecs_dpf_ilores_dlores_b1_genlock,
+       lts_ecs_ehb_ilores_dlores_b1_genlock,
+       lts_ecs_ham_ilores_dlores_b1_genlock,
+       lts_ecs_kehb_ilores_dlores_b1_genlock,
+       lts_ecs_n_ihires_dlores_b1_genlock,
+       lts_ecs_dpf_ihires_dlores_b1_genlock,
+       lts_ecs_ehb_ihires_dlores_b1_genlock,
+       lts_ecs_ham_ihires_dlores_b1_genlock,
+       lts_ecs_kehb_ihires_dlores_b1_genlock,
+       lts_ecs_n_ishres_dlores_b1_genlock,
+       lts_ecs_dpf_ishres_dlores_b1_genlock,
+       lts_ecs_ehb_ishres_dlores_b1_genlock,
+       lts_ecs_ham_ishres_dlores_b1_genlock,
+       lts_ecs_kehb_ishres_dlores_b1_genlock,
+       lts_ecs_n_ilores_dhires_b1_genlock,
+       lts_ecs_dpf_ilores_dhires_b1_genlock,
+       lts_ecs_ehb_ilores_dhires_b1_genlock,
+       lts_ecs_ham_ilores_dhires_b1_genlock,
+       lts_ecs_kehb_ilores_dhires_b1_genlock,
+       lts_ecs_n_ihires_dhires_b1_genlock,
+       lts_ecs_dpf_ihires_dhires_b1_genlock,
+       lts_ecs_ehb_ihires_dhires_b1_genlock,
+       lts_ecs_ham_ihires_dhires_b1_genlock,
+       lts_ecs_kehb_ihires_dhires_b1_genlock,
+       lts_ecs_n_ishres_dhires_b1_genlock,
+       lts_ecs_dpf_ishres_dhires_b1_genlock,
+       lts_ecs_ehb_ishres_dhires_b1_genlock,
+       lts_ecs_ham_ishres_dhires_b1_genlock,
+       lts_ecs_kehb_ishres_dhires_b1_genlock,
+       lts_ecs_n_ilores_dshres_b1_genlock,
+       lts_ecs_dpf_ilores_dshres_b1_genlock,
+       lts_ecs_ehb_ilores_dshres_b1_genlock,
+       lts_ecs_ham_ilores_dshres_b1_genlock,
+       lts_ecs_kehb_ilores_dshres_b1_genlock,
+       lts_ecs_n_ihires_dshres_b1_genlock,
+       lts_ecs_dpf_ihires_dshres_b1_genlock,
+       lts_ecs_ehb_ihires_dshres_b1_genlock,
+       lts_ecs_ham_ihires_dshres_b1_genlock,
+       lts_ecs_kehb_ihires_dshres_b1_genlock,
+       lts_ecs_n_ishres_dshres_b1_genlock,
+       lts_ecs_dpf_ishres_dshres_b1_genlock,
+       lts_ecs_ehb_ishres_dshres_b1_genlock,
+       lts_ecs_ham_ishres_dshres_b1_genlock,
+       lts_ecs_kehb_ishres_dshres_b1_genlock,
+       lts_ecs_n_ilores_dlores_b2_genlock,
+       lts_ecs_dpf_ilores_dlores_b2_genlock,
+       lts_ecs_ehb_ilores_dlores_b2_genlock,
+       lts_ecs_ham_ilores_dlores_b2_genlock,
+       lts_ecs_kehb_ilores_dlores_b2_genlock,
+       lts_ecs_n_ihires_dlores_b2_genlock,
+       lts_ecs_dpf_ihires_dlores_b2_genlock,
+       lts_ecs_ehb_ihires_dlores_b2_genlock,
+       lts_ecs_ham_ihires_dlores_b2_genlock,
+       lts_ecs_kehb_ihires_dlores_b2_genlock,
+       lts_ecs_n_ishres_dlores_b2_genlock,
+       lts_ecs_dpf_ishres_dlores_b2_genlock,
+       lts_ecs_ehb_ishres_dlores_b2_genlock,
+       lts_ecs_ham_ishres_dlores_b2_genlock,
+       lts_ecs_kehb_ishres_dlores_b2_genlock,
+       lts_ecs_n_ilores_dhires_b2_genlock,
+       lts_ecs_dpf_ilores_dhires_b2_genlock,
+       lts_ecs_ehb_ilores_dhires_b2_genlock,
+       lts_ecs_ham_ilores_dhires_b2_genlock,
+       lts_ecs_kehb_ilores_dhires_b2_genlock,
+       lts_ecs_n_ihires_dhires_b2_genlock,
+       lts_ecs_dpf_ihires_dhires_b2_genlock,
+       lts_ecs_ehb_ihires_dhires_b2_genlock,
+       lts_ecs_ham_ihires_dhires_b2_genlock,
+       lts_ecs_kehb_ihires_dhires_b2_genlock,
+       lts_ecs_n_ishres_dhires_b2_genlock,
+       lts_ecs_dpf_ishres_dhires_b2_genlock,
+       lts_ecs_ehb_ishres_dhires_b2_genlock,
+       lts_ecs_ham_ishres_dhires_b2_genlock,
+       lts_ecs_kehb_ishres_dhires_b2_genlock,
+       lts_ecs_n_ilores_dshres_b2_genlock,
+       lts_ecs_dpf_ilores_dshres_b2_genlock,
+       lts_ecs_ehb_ilores_dshres_b2_genlock,
+       lts_ecs_ham_ilores_dshres_b2_genlock,
+       lts_ecs_kehb_ilores_dshres_b2_genlock,
+       lts_ecs_n_ihires_dshres_b2_genlock,
+       lts_ecs_dpf_ihires_dshres_b2_genlock,
+       lts_ecs_ehb_ihires_dshres_b2_genlock,
+       lts_ecs_ham_ihires_dshres_b2_genlock,
+       lts_ecs_kehb_ihires_dshres_b2_genlock,
+       lts_ecs_n_ishres_dshres_b2_genlock,
+       lts_ecs_dpf_ishres_dshres_b2_genlock,
+       lts_ecs_ehb_ishres_dshres_b2_genlock,
+       lts_ecs_ham_ishres_dshres_b2_genlock,
+       lts_ecs_kehb_ishres_dshres_b2_genlock,
+       NULL
+};
index b423d8ea7b5c7e2810c581aa8ce5391710208a51..a38695b294b06dfcef55497fe380ad55f34408f4 100644 (file)
@@ -135,6 +135,7 @@ int pissoff_value = 15000 * CYCLE_UNIT;
 unsigned int fpucontrol;
 int extraframewait, extraframewait2;
 int busywait;
+int multithread_enabled = 1;
 static int noNtDelayExecution;
 
 extern FILE *debugfile;
@@ -7032,6 +7033,10 @@ static int parseargs(const TCHAR *argx, const TCHAR *np, const TCHAR *np2)
                on_screen_keyboard = 1;
                return 1;
        }
+       if (!_tcscmp(arg, _T("nomt"))) {
+               multithread_enabled = 0;
+               return 1;
+       }
 
        if (!np)
                return 0;
index cadbc4f6d72c7b16c0585054a596c27dd303e21e..e05f417be52c6751d7c6d7082b59508224a8b431 100755 (executable)
@@ -2697,16 +2697,17 @@ static bool do_grayscale(struct vidbuffer *src, struct vidbuffer *dst, bool doub
        uae_u8 r = 0, g = 0, b = 0;
        for (y = ystart; y < yend; y++) {
                int yoff = (((y * 2 + oddlines) - src->yoffset) >> vdbl);
-               if (yoff < 0)
+               int dyoff = (((y * 2 + oddlines) - dst->yoffset) >> vdbl);
+               if (yoff < 0 || dyoff < 0)
                        continue;
-               if (yoff >= src->inheight)
+               if (yoff >= src->inheight || dyoff >= dst->inheight)
                        continue;
 
                uae_u8 *line = src->bufmem + yoff * src->rowbytes;
-               uae_u8 *dstline = dst->bufmem + (((y * 2 + oddlines) - dst->yoffset) >> vdbl) * dst->rowbytes;
+               uae_u8 *dstline = dst->bufmem + dyoff * dst->rowbytes;
                uae_u8 line_colorburst = currprefs.gfx_grayscale ? 0 : row_map_color_burst_buffer[yoff];
 
-               for (x = 0; x < src->inwidth; x++) {
+               for (x = 0; x < src->inwidth && x < dst->inwidth; x++) {
                        uae_u8 *s = line + x * src->pixbytes;
                        uae_u8 *d = dstline + x * dst->pixbytes;
                        uae_u8 *s2 = s + src->rowbytes;