]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fast mode chipset drawing updates
authorToni Wilen <twilen@winuae.net>
Tue, 25 Feb 2025 17:04:05 +0000 (19:04 +0200)
committerToni Wilen <twilen@winuae.net>
Tue, 25 Feb 2025 17:04:05 +0000 (19:04 +0200)
custom.cpp
drawing.cpp
genlinetoscr.cpp
include/drawing.h
linetoscr_aga_fast.cpp [new file with mode: 0644]
linetoscr_ecs_fast.cpp [new file with mode: 0644]

index 143f923dae866d1bea4345cbd9eb0aaea5c1fc3b..1b480be7aa9f3c8a2dfa56dd2996aec54acdcc49 100644 (file)
@@ -3523,8 +3523,8 @@ static void BPLCON0(uae_u16 v)
                return;
        }
 
-       // HAM, DPF, UHRES, BYPASS
-       if (va & (0x0800 | 0x0400 | 0x0080 | 0x0020)) {
+       // UHRES, BYPASS
+       if (va & (0x0080 | 0x0020)) {
                not_safe_mode |= 1;
        } else {
                not_safe_mode &= ~1;
@@ -10281,6 +10281,7 @@ static int getlinetype(void)
 static int getcolorcount(int planes)
 {
        bool ham = (bplcon0 & 0x800) != 0;
+       bool dpf = (bplcon0 & 0x400) != 0;
        if (aga_mode) {
                if (ham) {
                        if (planes < 8) {
@@ -10288,11 +10289,21 @@ static int getcolorcount(int planes)
                        }
                        return 64;
                }
+               if (dpf) {
+                       int pf2of2 = (bplcon3 >> 10) & 7;
+                       if (!pf2of2) {
+                               return 16;
+                       }
+                       return (1 << pf2of2) + 16;
+               }
                return 1 << planes;
        }
        if (ham) {
                return 16;
        }
+       if (dpf) {
+               return 16;
+       }
        if (planes > 5) {
                planes = 5;
        }
@@ -10373,24 +10384,29 @@ static int checkprevfieldlinestateequalbpl(struct linestate *l)
        return 0;
 }
 
-static void storelinestate(void);
-// draw line quickly (no copper, no sprites, no weird things, normal mode)
+// draw border line quickly (no copper, no sprites, no weird things, normal mode)
+static bool draw_border_fast(struct linestate *l)
+{
+       if (l->hbstrt_offset < 0 || l->hbstop_offset < 0) {
+               return false;
+       }
+       l->color0 = aga_mode ? agnus_colors.color_regs_aga[0] : agnus_colors.color_regs_ecs[0];
+       int dvp = calculate_linetype(linear_display_vpos + 1);
+       return draw_denise_border_line_fast(dvp, nextline_how, l);
+}
+// draw bitplane line quickly (no copper, no sprites, no weird things, normal mode)
 static int draw_line_fast(struct linestate *l)
 {
        if (l->bpl1dat_trigger_offset < 0) {
                return 0;
        }
-       // no HAM or DPF supported yet
-       if (bplcon0 & (0x800 | 0x400)) {
+       // no HAM+DPF
+       if ((bplcon0 & (0x800 | 0x400)) == (0x800 | 0x400)) {
                return 0;
        }
        int planes = GET_PLANES(bplcon0);
-       // no EHB
-       if (planes == 6 && (!(bplcon0 & 1) || !(bplcon2 & 0x200))) {
-               return 0;
-       }
-       // no odd/even scroll
-       if ((bplcon1 & 0x0f0f) != ((bplcon1 >> 4) & 0x0f0f)) {
+       // no odd/even scroll if not DPF
+       if (!(bplcon0 & 0x400) && (bplcon1 & 0x0f0f) != ((bplcon1 >> 4) & 0x0f0f)) {
                return 0;
        }
 
@@ -10412,7 +10428,7 @@ static int draw_line_fast(struct linestate *l)
        l->linecolorstate = dpt;
        // draw quickly, store new state
        int dvp = calculate_linetype(linear_display_vpos + 1);
-       if (draw_denise_line_fast(dvp, nextline_how, l)) {
+       if (draw_denise_bitplane_line_fast(dvp, nextline_how, l)) {
                // advance bpl pointers
                int len = l->bpllen;
                for (int i = 0; i < planes; i++) {
@@ -10443,6 +10459,8 @@ static bool checkprevfieldlinestateequal(void)
                                uae_u32 c = aga_mode ? agnus_colors.color_regs_aga[0] : agnus_colors.color_regs_ecs[0];
                                if (c == l->color0) {
                                        ret = true;
+                               } else {
+                                       ret = draw_border_fast(l);
                                }
                        }
                } else if (type == LINETYPE_BPL) {
@@ -10466,7 +10484,7 @@ static void resetlinestate(void)
        }
        struct linestate *l = &lines[linear_vpos][lof_display];
        l->type = 0;
-
+       l->cnt = displayresetcnt - 1;
 }
 
 #define MAX_STORED_BPL_DATA 204
@@ -10494,6 +10512,7 @@ static void storelinestate(void)
        l->bplcon4 = bplcon4;
        l->diwhigh = diwhigh;
        l->fmode = fmode;
+       l->ltsidx = -1;
 
        if (l->type == LINETYPE_BPL) {
                if (!l->linedatastate) {
@@ -10739,7 +10758,7 @@ static void quick_denise_rga(void)
                }
        }
        uae_u16 strobe = get_strobe_reg(0);
-       denise_handle_quick_strobe(strobe, display_hstart_fastmode);
+       //denise_handle_quick_strobe(strobe, display_hstart_fastmode);
 }
 
 static void do_draw_line(void)
@@ -10875,7 +10894,7 @@ static int can_fast_custom(void)
                        return 0;
                }
                int type = getlinetype();
-               if (type == LINETYPE_BPL || (type == LINETYPE_BORDER && (bplcon0 & 1) && (bplcon3 & 0x02) && !(bplcon3 & 0x20))) {
+               if (type != LINETYPE_BLANK) {
                        for (int i = 0; i < MAX_SPRITES; i++) {
                                struct sprite *s = &spr[i];
                                if (s->vstart == vpos || s->vstop == vpos) {
@@ -12104,17 +12123,6 @@ static void sync_fast_evhandler(void)
 }
 #endif
 
-static void fast_strobe(void)
-{
-       uae_u16 str = get_strobe_reg(0);
-       write_drga(str, NULL, 0);
-       if (prev_strobe == 0x3c && str != 0x3c) {
-               INTREQ_INT(5, 0);
-       }
-       denise_handle_quick_strobe(str, display_hstart_fastmode);
-       prev_strobe = str;
-}
-
 // horizontal sync callback when line not changed + fast cpu
 static void sync_equalline_handler(void)
 {
@@ -12129,7 +12137,13 @@ static void sync_equalline_handler(void)
 
        rga_denise_cycle += rdc_offset;
        rga_denise_cycle &= DENISE_RGA_SLOT_MASK;
-       fast_strobe();
+
+       uae_u16 str = get_strobe_reg(0);
+       write_drga(str, NULL, 0);
+       if (prev_strobe == 0x3c && str != 0x3c) {
+               INTREQ_INT(5, 0);
+       }
+       prev_strobe = str;
 
        int diff = display_hstart_fastmode - hpos_delta;
        linear_hpos += diff;
@@ -12143,6 +12157,7 @@ static void sync_equalline_handler(void)
                do_draw_line();
                rga_denise_cycle = rdc;
        } else {
+               denise_handle_quick_strobe(str, display_hstart_fastmode);
                next_denise_rga();
                decide_line_end();
        }
index f8cc174292b020edd6f2bc4859a765d9a178d9b6..844cf9c29f2cc3a19ea313d8f8b68fd4be3e6bf0 100644 (file)
@@ -205,6 +205,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*);
 
 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];
@@ -251,7 +252,7 @@ static int denise_planes, denise_max_planes;
 static bool denise_odd_even, denise_max_odd_even;
 static int pix_prev;
 static int last_bpl_pix;
-static int previous_strobe, previous_strobe_flag;
+static int previous_strobe;
 static bool denise_strlong, agnus_lol, extblank;
 static int lol;
 static int denise_lol_shift_prev, denise_lol_shifted_prev;
@@ -315,7 +316,7 @@ static uae_u8 pixx0, pixx1, pixx2, pixx3;
 static uae_u32 debug_buf[256 * 2 * 4], debug_bufx[256 * 2 * 4];
 static int hbstrt_offset, hbstop_offset;
 static int hstrt_offset, hstop_offset;
-static int bpl1dat_trigger_offset, bpl1dat_hcounter;
+static int bpl1dat_trigger_offset;
 static int internal_pixel_cnt, internal_pixel_start_cnt;
 static bool no_denise_lol;
 
@@ -2443,7 +2444,7 @@ static void setbplmode(void)
 {
        bplham = (bplcon0_denise & 0x800) != 0;
        bpldualpf = (bplcon0_denise & 0x400) == 0x400;
-       bplehb = denise_planes == 6 && !bplham && !bpldualpf && (!ecs_denise || !(bplcon2_denise & 0x200));
+       bplehb = denise_planes == 6 && !bplham && !bpldualpf && (!ecs_denise || !(bplcon2_denise & 0x200 || !(bplcon0_denise & 1)));
 
        // BYPASS: HAM and EHB select bits are ignored
        bpland = 0xff;
@@ -2800,7 +2801,7 @@ static void expand_bplcon2(uae_u16 v)
                // Check for KillEHB bit in ECS/AGA
                bplehb_eke = (bplcon2_denise & 0x0200) != 0;
        }
-       bplehb_mask = denisea1000_noehb ? 0x1f : 0xff;
+       bplehb_mask = denisea1000_noehb ? 0x1f : 0x3f;
        if (bplehb_eke_o != bplehb_eke) {
                setbplmode();
        }
@@ -3302,7 +3303,6 @@ static void bpldat_docopy(void)
 
        if (bpl1dat_trigger_offset < 0) {
                bpl1dat_trigger_offset = internal_pixel_cnt;
-               bpl1dat_hcounter = denise_hcounter;
        }
 
        if (debug_bpl_mask != 0xff) {
@@ -3463,7 +3463,6 @@ static void handle_strobes(struct denise_rga *rd)
                denise_visible_lines++;
        }
        previous_strobe = rd->rga;
-       previous_strobe_flag = rd->flags;
        reset_strlong();
        spr_nearest();
 }
@@ -3622,6 +3621,47 @@ void denise_update_reg(uae_u16 reg, uae_u16 v)
        check_lts_request();
 }
 
+// AGA HAM
+static uae_u32 decode_ham_pixel_aga_fast(uint8_t pw, int planes, uae_u8 bxor, uae_u32 *colors_aga)
+{
+       if (planes >= 7) { /* AGA mode HAM8 */
+               int pv = pw ^ bxor;
+               int pc = pv >> 2;
+               switch (pv & 0x3)
+               {
+                       case 0x0: ham_lastcolor = colors_aga[pc]; break;
+                       case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pw & 0xFC); break;
+                       case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pw & 0xFC) << 16; break;
+                       case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pw & 0xFC) << 8; break;
+               }
+       } else { /* AGA mode HAM6 */
+               int pv = pw ^ bxor;
+               uae_u32 pc = ((pw & 0xf) << 0) | ((pw & 0xf) << 4);
+               switch (pv & 0x30)
+               {
+                       case 0x00: ham_lastcolor = colors_aga[pv & 0x0f]; break;
+                       case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= pc << 0; break;
+                       case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= pc << 16; break;
+                       case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= pc << 8; break;
+               }
+       }
+       return CONVERT_RGB(ham_lastcolor);
+}
+
+// OCS/ECS HAM
+static uae_u32 decode_ham_pixel_fast(uint8_t pv, uae_u16 *colors_ocs)
+{
+       /* OCS/ECS mode HAM6 */
+       switch (pv & 0x30)
+       {
+               case 0x00: ham_lastcolor = colors_ocs[pv]; break;
+               case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
+               case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
+               case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
+       }
+       return xcolors[ham_lastcolor];
+}
+
 // AGA HAM
 static uae_u32 decode_ham_pixel_aga(uint8_t pw)
 {
@@ -4225,10 +4265,15 @@ void denise_handle_quick_strobe(uae_u16 strobe, int offset)
 {
        struct denise_rga rd = { 0 };
        rd.rga = strobe;
-       handle_strobes(&rd);
-       // 3 = refresh offset, 2 = pipeline delay
-       denise_hcounter_new = (offset - 3 - 2) * 2 + 2;
+       denise_hcounter_new += maxhpos * 2;
+       denise_hcounter_new &= 511;
        denise_hcounter = denise_hcounter_new;
+       handle_strobes(&rd);
+       if (denise_hcounter_new == 1 * 2) {
+               // 3 = refresh offset, 2 = pipeline delay
+               denise_hcounter_new = (offset - 3 - 2) * 2 + 2;
+               denise_hcounter = denise_hcounter_new;
+       }
 }
 void denise_handle_quick_disable_hblank(void)
 {
@@ -4954,7 +4999,6 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
        hstrt_offset = -1;
        hstop_offset = -1;
        bpl1dat_trigger_offset = -1;
-       bpl1dat_hcounter = -1;
        internal_pixel_cnt = 0;
        internal_pixel_start_cnt = 0;
 
@@ -5027,7 +5071,8 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
                        ls->hbstrt_offset = hbstrt_offset;
                        ls->hbstop_offset = hbstop_offset;
                        ls->bpl1dat_trigger_offset = bpl1dat_trigger_offset;
-                       ls->bpl1dat_hcounter = bpl1dat_hcounter;
+                       ls->internal_pixel_cnt = internal_pixel_cnt;
+                       ls->internal_pixel_start_cnt = internal_pixel_start_cnt;
                }
 #if 0
                static int testtoggle[1000];
@@ -5141,6 +5186,8 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start
 #include "linetoscr_aga_fm1_genlock.cpp"
 #include "linetoscr_aga_fm2_genlock.cpp"
 #include "linetoscr_ecs_shres.cpp"
+#include "linetoscr_ecs_fast.cpp"
+#include "linetoscr_aga_fast.cpp"
 
 // select linetoscr routine
 static void select_lts(void)
@@ -5736,7 +5783,7 @@ Don't touch this if you don't know what you are doing.  */
 
 #define DOLINE_SWAP 0
 
-#define GETLONG32(P) (*(uae_u32*)P)
+#define GETLONG32(P) (do_get_mem_long((uae_u32*)P))
 #define GETLONG64(P) (*(uae_u64*)P)
 
 STATIC_INLINE void pfield_doline32_1(uae_u32 *pixels, int wordcount, int planes, uae_u8 *real_bplpt[8])
@@ -5827,8 +5874,16 @@ static void NOINLINE pfield_doline32_n7(uae_u32 *data, int count, uae_u8 *real_b
 static void NOINLINE pfield_doline32_n8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_1(data, count, 8, real_bplpt); }
 #endif
 
-static void pfield_doline(int planecnt, int wordcount, uae_u8 *real_bplpt[8], uae_u32 *data)
+static void pfield_doline(int planecnt, int wordcount, uae_u8 *datap, struct linestate *ls)
 {
+       uae_u8 **real_bplpt = ls->bplpt;
+       uae_u32 *data = (uae_u32*)datap;
+       uae_u8 *dpt = ls->linedatastate;
+       int len = ls->bpllen;
+       for (int i = 0; i < planecnt; i++) {
+               memcpy(dpt, ls->bplpt[i], len);
+               dpt += len;
+       }
        switch (planecnt) {
                default: break;
                case 0: memset(data, 0, wordcount * 32); break;
@@ -5845,6 +5900,7 @@ static void pfield_doline(int planecnt, int wordcount, uae_u8 *real_bplpt[8], ua
        }
 }
 
+#if 0
 static void pfield_doline_not_fast_enough_yet(int planecnt, int wordcount, uae_u8 *data, struct linestate *ls)
 {
        wordcount *= 4;
@@ -5868,10 +5924,12 @@ static void pfield_doline_not_fast_enough_yet(int planecnt, int wordcount, uae_u
                                }
                                v[j] <<= 1;
                        }
+                       out &= debug_bpl_mask;
                        *data++ = out;
                }
        }
 }
+#endif
 
 static int r_shift(int v, int shift)
 {
@@ -5890,23 +5948,101 @@ static int l_shift(int v, int shift)
        }
 }
 
+bool draw_denise_border_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
+{
+       get_line(gfx_ypos, how);
+
+       if (!buf1) {
+               return false;
+       }
+
+       uae_u32 *buf1p = buf1;
+       uae_u32 *buf2p = buf2 != buf1 ? buf2 : buf1;
+
+       int rshift = RES_MAX - hresolution;
+
+       bool ecsena = ecs_denise && (ls->bplcon0 & 1) != 0;
+       bool brdblank = (ls->bplcon3 & 0x20) && ecsena;
+
+       uae_u32 bgcol;
+       if (aga_mode) {
+               bgcol = brdblank ? 0x000000 : ls->color0;
+       } else {
+               bgcol = brdblank ? 0x000000 : xcolors[ls->color0];
+       }
+
+       int hbstrt_offset = ls->hbstrt_offset >> rshift;
+       int hbstop_offset = ls->hbstop_offset >> rshift;
+       int draw_start = 0;
+       int draw_end = ls->internal_pixel_cnt >> rshift;
+       int draw_startoffset = ls->internal_pixel_start_cnt >> rshift;
+
+       buf1 = buf1p;
+       buf2 = buf2p;
+
+       for (int cnt = draw_start; cnt < hbstrt_offset; cnt++) {
+               if (cnt >= draw_end) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt >= hbstop_offset) {
+                               *buf1++ = bgcol;
+                               *buf2++ = bgcol;
+                       } else {
+                               buf1++;
+                               buf2++;
+                       }
+               }
+       }
+
+       return true;
+}
+
 extern int blop;
-static uae_u32 chunky_out[4096];
-bool draw_denise_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
+static uae_u32 chunky_out[4096], dpf_chunky_out[4096];
+bool draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
 {
        get_line(gfx_ypos, how);
 
        if (!buf1) {
                return false;
        }
+
        uae_u32 *buf1p = buf1;
        uae_u32 *buf2p = buf2 != buf1 ? buf2 : NULL;
        int planecnt = GET_PLANES(ls->bplcon0);
        int res = GET_RES_DENISE(ls->bplcon0);
+       bool dpf = (ls->bplcon0 & 0x400) != 0;
+       bool ham = (ls->bplcon0 & 0x800) != 0;
+
+       if (ls->ltsidx < 0) {
+               bool ehb = planecnt == 6 && !bplham && !dpf && (!ecs_denise || !(ls->bplcon0 & 1) || !(ls->bplcon2 & 0x200));
+               int mode = CMODE_NORMAL;
+               if (ham) {
+                       mode = CMODE_HAM;
+                       ham_lastcolor = 0;
+               } else if (dpf) {
+                       mode = CMODE_DUALPF;
+               } else if (ehb) {
+                       mode = CMODE_EXTRAHB;
+               }
+               int idx = mode + 5 * res + 5 * 3 * hresolution;
+               if (buf2p) {
+                       idx += 5 * 3 * 3;
+               }
+               ls->ltsidx = idx;
+       }
+
+       LINETOSRC_FUNCF ltsf;
+       if (aga_mode) {
+               ltsf = linetoscr_aga_fast_funcs[ls->ltsidx];
+       } else {
+               ltsf = linetoscr_ecs_fast_funcs[ls->ltsidx];
+       }
 
        uae_u32 *cstart = chunky_out + 1024;
        int len = (ls->bpllen + 3) / 4;
-       pfield_doline_not_fast_enough_yet(planecnt, len, (uae_u8*)cstart, ls);
+       pfield_doline(planecnt, len, (uae_u8*)cstart, ls);
 
        bool ecsena = ecs_denise && (ls->bplcon0 & 1) != 0;
        bool brdblank = (ls->bplcon3 & 0x20) && ecsena;
@@ -5917,13 +6053,41 @@ bool draw_denise_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
        } else {
                bgcol = brdblank ? 0x000000 : xcolors[ls->color0];
        }
+       
        //bgcol = 0xff00;
 
-       uae_u8 *cp = (uae_u8 *)cstart;
+       uae_u8 *cp = (uae_u8*)cstart;
+       uae_u8 *cp2 = cp;
+
+       if (!aga_mode) {
+               // OCS/ECS PF2 >= 5 and bit in plane 5 set: other planes are ignored in color selection.
+               int plf1pri = (ls->bplcon2 >> 0) & 7;
+               int plf2pri = (ls->bplcon2 >> 3) & 7;
+               if (!ham && !dpf && planecnt >= 5 && plf2pri >= 5) {
+                       for (int i = 0; i < len * 4 * 8; i++) {
+                               if (cp[i] & 0x10) {
+                                       cp[i] = 0x10;
+                               }
+                       }
+               }
+               // OCS/ECS DPF feature: if matching plf2pri>=5: value is always 0
+               if (dpf && (plf1pri >= 5 || plf2pri >= 5)) {
+                       for (int i = 0; i < len * 4 * 8; i++) {
+                               uae_u8 pix = cp[i];
+                               uae_u8 mask1 = 0x01 | 0x04 | 0x10;
+                               uae_u8 mask2 = 0x02 | 0x08 | 0x20;
+                               if (plf1pri >= 5 && (pix & mask1)) {
+                                       pix |= 0x40;
+                               }
+                               if (plf2pri >= 5 && (pix & mask2)) {
+                                       pix |= 0x80;
+                               }
+                               cp[i] = pix;
+                       }
+               }
+       }
 
        int doubling = hresolution - res;
-       int shift = hresolution;
-       int shift2 = shift + 1;
        int rshift = RES_MAX - hresolution;
 
        int delay1 = (ls->bplcon1 & 0x0f) | ((ls->bplcon1 & 0x0c00) >> 6);
@@ -5935,15 +6099,34 @@ bool draw_denise_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
        delay1 <<= 2;
        int s = r_shift(delay1, RES_MAX - res);
        cp -= s;
+       if (dpf) {
+               int delay2 = ((ls->bplcon1 & 0xf0) >> 4) | ((ls->bplcon1 & 0xc000) >> 10);
+               delay2 += delayoffset;
+               delay2 &= delaymask;
+               delay2 <<= 2;
+               s = r_shift(delay2, RES_MAX - res);
+               cp2 -= s;
+               // different bitplane delay in DPF? Merge them.
+               if (cp != cp2) {
+                       uae_u8 *dpout = (uae_u8*)(dpf_chunky_out + 1024);
+                       for (int i = 0; i < len * 8; i++) {
+                               uae_u32 pix0 = ((uae_u32*)cp)[i];
+                               uae_u32 pix1 = ((uae_u32*)cp2)[i];
+                               uae_u32 c = (pix0 & 0x55555555) | (pix1 & 0xaaaaaaaa);
+                               ((uae_u32*)dpout)[i] = c;
+                       }
+                       cp = dpout;
+               }
+       }
 
        int hbstrt_offset = ls->hbstrt_offset >> rshift;
        int hbstop_offset = ls->hbstop_offset >> rshift;
-       int hstrt_offset = ls->hstrt_offset < 0 ? hbstop_offset : ls->hstrt_offset >> rshift;
+       int hstrt_offset = ls->hstrt_offset < 0 || ls->hstrt_offset >= ls->hbstrt_offset ? hbstop_offset : ls->hstrt_offset >> rshift;
        int hstop_offset = ls->hstop_offset < 0 ? hbstrt_offset : ls->hstop_offset >> rshift;
        int bpl1dat_trigger_offset = (ls->bpl1dat_trigger_offset + (1 << RES_MAX)) >> rshift;
-       int start = 0;
-       int end = internal_pixel_cnt >> rshift;
-       int startoffset = internal_pixel_start_cnt >> rshift;
+       int draw_start = 0;
+       int draw_end = ls->internal_pixel_cnt >> rshift;
+       int draw_startoffset = ls->internal_pixel_start_cnt >> rshift;
        
        //write_log("%03d %03d %03d %03d %03d %03d %03d\n", vpos, hbstop_offset, hbstrt_offset, hstrt_offset, hstop_offset, bpl1dat_trigger_offset, delayoffset);
 
@@ -5976,542 +6159,11 @@ bool draw_denise_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls)
                }
        }
 
-       // TODO: code generator
-       int cnt = start;
-       while (cnt < end) {
-               bool bpl = false;
-               if (cnt >= hbstrt_offset) {
-                       break;
-               }
-               if (cnt >= startoffset) {
-                       if (cnt < hbstop_offset) {
-                               buf1 += bufadd;
-                               if (buf2) {
-                                       buf2 += bufadd;
-                               }
-                       } else if (cnt < hstrt_offset || cnt >= hstop_offset) {
-                               *buf1++ = bgcol;
-                               if (buf2) {
-                                       *buf2++ = bgcol;
-                               }
-                               if (doubling > 0) {
-                                       *buf1++ = bgcol;
-                                       if (buf2) {
-                                               *buf2++ = bgcol;
-                                       }
-                                       if (doubling > 1) {
-                                               *buf1++ = bgcol;
-                                               *buf1++ = bgcol;
-                                               if (buf2) {
-                                                       *buf2++ = bgcol;
-                                                       *buf2++ = bgcol;
-                                               }
-                                       }
-                               }
-                       }
-                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
-                               bpl = true;
-                               uae_u8 c;
-                               uae_u32 col;
-                               if (aga_mode) {
-                                       c = *cp;
-                                       cp += cpadds[0];
-                                       c ^= bxor;
-                                       col = colors_aga[c];
-                                       *buf1++ = col;
-                                       if (buf2) {
-                                               *buf2++ = col;
-                                       }
-                                       if (doubling > 0) {
-                                               c = *cp;
-                                               cp += cpadds[1];
-                                               c ^= bxor;
-                                               col = colors_aga[c];
-                                               *buf1++ = col;
-                                               if (buf2) {
-                                                       *buf2++ = col;
-                                               }
-                                               if (doubling > 1) {
-                                                       c = *cp;
-                                                       cp += cpadds[2];
-                                                       c ^= bxor;
-                                                       col = colors_aga[c];
-                                                       *buf1++ = col;
-                                                       if (buf2) {
-                                                               *buf2++ = col;
-                                                       }
-                                                       c = *cp;
-                                                       cp += cpadds[3];
-                                                       c ^= bxor;
-                                                       col = colors_aga[c];
-                                                       *buf1++ = col;
-                                                       if (buf2) {
-                                                               *buf2++ = col;
-                                                       }
-                                               }
-                                       }
-                               } else {
-                                       c = *cp;
-                                       cp += cpadds[0];
-                                       col = xcolors[colors_ocs[c]];
-                                       *buf1++ = col;
-                                       if (buf2) {
-                                               *buf2++ = col;
-                                       }
-                                       if (doubling > 0) {
-                                               c = *cp;
-                                               cp += cpadds[1];
-                                               col = xcolors[colors_ocs[c]];
-                                               *buf1++ = col;
-                                               if (buf2) {
-                                                       *buf2++ = col;
-                                               }
-                                               if (doubling > 1) {
-                                                       c = *cp;
-                                                       cp += cpadds[2];
-                                                       col = xcolors[colors_ocs[c]];
-                                                       *buf1++ = col;
-                                                       if (buf2) {
-                                                               *buf2++ = col;
-                                                       }
-                                                       c = *cp;
-                                                       cp += cpadds[3];
-                                                       col = xcolors[colors_ocs[c]];
-                                                       *buf1++ = col;
-                                                       if (buf2) {
-                                                               *buf2++ = col;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-               if (cnt >= bpl1dat_trigger_offset && !bpl) {
-                       cp += cpadd;
-               }
-               cnt += bufadd;
-       }
-
-       return true;
-}
-
-#if 0
-
-       int fmode = 16 << (((ls->fmode & 3) == 3 ? 2 : (ls->fmode & 3)));
-       int delaymask = (fmode >> res) - 1;
-       int delay1 = (ls->bplcon1 & 0x0f) | ((ls->bplcon1 & 0x0c00) >> 6);
-       int     delayoffset = ls->fetchmode_size - (((ls->ddfstrt - 0x18) & ls->fetchstart_mask) << 1);
-       delay1 += delayoffset;
-       delay1 &= delaymask;
-       delay1 <<= 2;
-       //delay1 <<= res;
-       //delay1 |= (ls->bplcon1 & 0x0300) >> 8;
-
-       if (vpos == 120)
-               write_log("%03d %03d %03d %03d %03d %03d\n", ls->hbstrt_offset, ls->hbstop_offset, ls->hstrt_offset, ls->hstop_offset, ls->bpl1dat_trigger_offset, delay1);
-
-       int doubling = hresolution - res;
-       int shift = hresolution;
-       int shift2 = shift + 1;
-       int rshift = RES_MAX - hresolution;
-
-       int hbstrt_offset = ls->hbstrt_offset >> shift;
-       int hbstop_offset = ls->hbstop_offset >> shift;
-       int hstrt_offset = ls->hstrt_offset < 0 ? hbstop_offset : ls->hstrt_offset >> shift;
-       int hstop_offset = ls->hstop_offset < 0 ? hbstrt_offset : ls->hstop_offset >> shift;
-       int bpl1dat_trigger_offset = ls->bpl1dat_trigger_offset >> shift;
-#if 0
-       if (exthblankon_ecs || exthblankon_aga) {
-               hbstrt_offset += 1 << shift;
-               hbstop_offset += 1 << shift;
-       }
-#endif
-       uae_u8 *cp = (uae_u8*)cstart;
-       uae_u32 bgcol;
-       uae_u32 *hstrt = buf1p + hstrt_offset + ((denise_hstrt & 3) >> rshift) + (1 << shift);
-       uae_u32 *hstop = buf1p + hstop_offset + ((denise_hstop & 3) >> rshift) + (1 << shift);
-       uae_u32 *hbstrt = buf1p + hbstrt_offset;
-
-       //bgcol = 0xff00;
-
-#if 1
-       int bpldiff = delay1 >> res;
-       if (doubling >= 0) {
-               bpldiff >>= doubling;
-       } else if (doubling < 0) {
-               bpldiff <<= (-doubling);
-       }
-#endif
-#if 0
-       if (hresolution > res) {
-               bpldiff >>= 1;
-       } else if (hresolution < res) {
-               bpldiff <<= 1;
-       }
-       int off = bpl1dat_trigger_offset;
-       if (doubling >= 0) {
-               off += 6 >> doubling;
-       } else if (doubling < 0) {
-               off += 6 << (-doubling);
-       }
-       off += bpldiff;
-#endif
-
-       buf1 = buf1p + hbstop_offset;
-       if (buf2p) {
-               buf2 = buf2p + hbstop_offset;
-       }
-
-       // left border
-       next = hstrt;
-       if (next > hbstrt) {
-               next = hbstrt;
-       }
-       if (buf2) {
-               while (buf1 < next) {
-                       *buf1++ = bgcol;
-                       *buf2++ = bgcol;
-               }
-       } else {
-               while (buf1 < next) {
-                       *buf1++ = bgcol;
-               }
-       }
-
-       // between DIWHSTRT - DDFSTRT
-       uae_u32 *p = buf1p + bpl1dat_trigger_offset;
-       if (buf2) {
-               while (buf1 < p) {
-                       *buf1++ = bgcol;
-                       *buf2++ = bgcol;
-               }
-       } else {
-               while (buf1 < p) {
-                       *buf1++ = bgcol;
-               }
-       }
-       int diff = buf1 - p;
-       if (doubling < 0) {
-               diff <<= (-doubling);
-       } else {
-               diff >>= doubling;
-       }
-       cp += diff;
-       next = hstop;
-       if (next > hbstrt) {
-               next = hbstrt;
-       }
-       if (aga_mode) {
-               uae_u8 bxor = ls->bplcon4 >> 8;
-               uae_u32 *colors = (uae_u32*)ls->linecolorstate;
-               if (doubling > 1) {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               c ^= bxor;
-                               uae_u32 col = colors[c];
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                               }
-                       }
-               } else if (doubling > 0) {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               c ^= bxor;
-                               uae_u32 col = colors[c];
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                               }
-                       }
-               } else if (doubling < 0) {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               c ^= bxor;
-                               uae_u32 col = colors[c];
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                               }
-                               if (doubling < -1) {
-                                       cp++;
-                               }
-                               cp++;
-                       }
-               } else {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               c ^= bxor;
-                               uae_u32 col = colors[c];
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                               }
-                       }
-               }
-       } else {
-               uae_u16 *colors = (uae_u16*)ls->linecolorstate;
-               if (doubling > 1) {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               uae_u32 col = xcolors[colors[c]];
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                               }
-                       }
-               } else if (doubling > 0) {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               uae_u32 col = xcolors[colors[c]];
-                               *buf1++ = col;
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                                       *buf2++ = col;
-                               }
-                       }
-               } else if (doubling < 0) {
-                       bool toggle = false;
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               uae_u32 col = xcolors[colors[c]];
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                               }
-                               if (doubling < -1) {
-                                       cp++;
-                               }
-                               cp++;
-                       }
-               } else {
-                       while (buf1 < next) {
-                               uae_u8 c = *cp++;
-                               uae_u32 col = xcolors[colors[c]];
-                               *buf1++ = col;
-                               if (buf2) {
-                                       *buf2++ = col;
-                               }
-                       }
-               }
-       }
-
-       // right border
-       if (buf2) {
-               while (buf1 < next) {
-                       *buf1++ = bgcol;
-                       *buf2++ = bgcol;
-               }
-       } else {
-               while (buf1 < next) {
-                       *buf1++ = bgcol;
-               }
-       }
+       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);
 
        return true;
 }
-#endif
-
-#if 0
-bool draw_denise_line_fast(uae_u8 *bplpt[8], int bplstart, int bpllen, int gfx_ypos, enum nln_how how, int total, int dstart, int dtotal, bool vblank, struct denise_fastsprite *dfs)
-{
-       int pos;
-       int pixtotal = dtotal * 4;
-       int end = dstart + pixtotal;
-       uae_u8 *c = (uae_u8*)chunky_out;
-
-       denise_hcounter_prev = -1;
-       denise_pixtotal = dtotal;
-       denise_total = total;
-       denise_cck = 0;
-
-       get_line(gfx_ypos, how);
-
-       if (!buf1) {
-               return true;
-       }
-
-       if (vblank) {
-               memset(buf1, 0, pixtotal * sizeof(uae_u32));
-               if (buf1 != buf2) {
-                       memset(buf2, 0, pixtotal * sizeof(uae_u32));
-               }
-               return true;
-       }
-
-       uae_u32 *buf1p = buf1;
-       uae_u32 *buf2p = buf2;
-       uae_u32* buf1e = buf1 + (end - dstart);
-
-       if (bpllen > 0) {
-               pfield_doline(denise_planes, bpllen, bplpt, chunky_out);
-       }
-
-       int hstrt = denise_hstrt >> 1;
-       int hstop = denise_hstop >> 1;
-       int hbstrt = denise_hbstrt_lores * 2;
-       int hbstop = denise_hbstop_lores * 2;
-       if (hbstrt < hbstop) {
-               hbstrt += maxhpos * 2 * 2;
-       }
-       bplstart *= 2;
-
-       // bitplanes
-       int bplstoppos = -1;
-       if (bpllen > 0) {
-               pos = bplstart;
-               buf1 = buf1p + (pos - dstart);
-               buf2 = buf2p + (pos - dstart);
-               int shift = bplcon1_shift[0];// << denise_res;
-               int delay = shift;
-               while (1 && delay > 0) {
-                       *buf1++ = bordercolor;
-                       *buf2++ = bordercolor;
-                       pos++;
-                       delay--;
-               }
-               while (pos < hstop && pos < end) {
-                       for (int i = 0; i < 4; i++) {
-                               for (int j = 0; j < 8; j++) {
-                                       uae_u8 pixc = c[(3 - i) * 8 + j];
-                                       uae_u32 pix = denise_colors.acolors[pixc];
-                                       *buf1++ = pix;
-                                       *buf2++ = pix;
-                                       pos++;
-                                       if (denise_res == 0) {
-                                               *buf1++ = pix;
-                                               *buf2++ = pix;
-                                               pos++;
-                                       }
-                               }
-                       }
-                       c += 32;
-               }
-               bplstoppos = pos;
-       }
-
-       // sprites
-       if (dfs && (bpllen > 0 || bordersprite)) {
-               for (int i = MAX_SPRITES - 1; i >= 0; i--) {
-                       struct denise_fastsprite *fs = &dfs[i];
-                       if (fs->active) {
-                               int sprxp = (fs->pos & 0xff) * 2 + (fs->ctl & 1);
-                               sprxp += 1;
-                               sprxp *= 2;
-                               buf1 = buf1p + (sprxp - dstart);
-                               buf2 = buf2p + (sprxp - dstart);
-                               if (denise_sprfmode < 2) {
-                                       int max = denise_sprfmode ? 32 : 16;
-                                       int shift = max - 1;
-                                       uae_u32 v0 = fs->data[0];
-                                       uae_u32 v1 = fs->data[1];
-                                       for (int p = 0; p < max && buf1 < buf1e; p++) {
-                                               int b1 = (v0 >> shift) & 1;
-                                               int b2 = (v1 >> shift) & 1;
-                                               v0 <<= 1;
-                                               v1 <<= 1;
-                                               int c = b2 * 2 + b1;
-                                               if (c) {
-                                                       uae_u32 pix = denise_colors.acolors[c + sbasecol[i & 1]];
-                                                       *buf1++ = pix;
-                                                       *buf2++ = pix;
-                                                       if (denise_sprres == 0) {
-                                                               *buf1++ = pix;
-                                                               *buf2++ = pix;
-                                                       }
-                                               } else {
-                                                       buf1++;
-                                                       buf2++;
-                                                       if (denise_sprres == 0) {
-                                                               buf1++;
-                                                               buf2++;
-                                                       }
-                                               }
-                                       }
-                               } else {
-                                       uae_u64 v0 = fs->data64[0];
-                                       uae_u64 v1 = fs->data64[1];
-                                       for (int p = 0; p < 64 && buf1 < buf1e; p++) {
-                                               int b1 = (v0 >> 63) & 1;
-                                               int b2 = (v1 >> 63) & 1;
-                                               v0 <<= 1;
-                                               v1 <<= 1;
-                                               int c = b2 * 2 + b1;
-                                               if (c) {
-                                                       uae_u32 pix = denise_colors.acolors[c + sbasecol[i & 1]];
-                                                       *buf1++ = pix;
-                                                       *buf2++ = pix;
-                                                       if (denise_sprres == 0) {
-                                                               *buf1++ = pix;
-                                                               *buf2++ = pix;
-                                                       }
-                                               } else {
-                                                       buf1++;
-                                                       buf2++;
-                                                       if (denise_sprres == 0) {
-                                                               buf1++;
-                                                               buf2++;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-       }
-
-       // borders and blanking
-       pos = dstart;
-       buf1 = buf1p;
-       buf2 = buf2p;
-       while (pos < hbstop && pos < end) {
-               *buf1++ = 0xff00ff;
-               *buf2++ = 0xff00ff;
-               pos++;
-       }
-       while (pos < hstrt && pos < end) {
-               *buf1++ = bordercolor;
-               *buf2++ = bordercolor;
-               pos++;
-       }
-       if (bplstoppos > 0) {
-               int opos = pos;
-               pos = bplstoppos;
-               if (pos > hstop) {
-                       pos = hstop;
-               }
-               buf1 += pos - opos;
-               buf2 += pos - opos;
-       }
-       while (pos < hbstrt && pos < end) {
-               *buf1++ = bordercolor;
-               *buf2++ = bordercolor;
-               pos++;
-       }
-       while (pos < end) {
-               *buf1++ = 0xff00ff;
-               *buf2++ = 0xff00ff;
-               pos++;
-       }
-
-       return true;
-}
-#endif
 
 #define RB restore_u8()
 #define SRB restore_s8()
index 98fc57067d71e7515f2da300fdba784070ed6b28..20dbd11ca7ca6b17d6ecce568d971640ca9f7dab 100644 (file)
@@ -16,6 +16,7 @@
 static FILE *outfile;
 static int outfile_indent = 0;
 static int aga, outres, res, planes, modes, bplfmode, sprres, oddeven, ecsshres, genlock, ntsc;
+static int isbuf2 = 0;
 static int maxplanes = 8;
 static char funcnames[500000];
 static char *funcnamep;
@@ -854,6 +855,158 @@ static bool gen_head(void)
        return true;
 }
 
+static bool gen_fasthead(void)
+{
+       char funcname[200];
+       sprintf(funcname, "lts_%s_%s_i%s_d%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");
+       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);
+       outf("{");
+       return true;
+}
+
+static void gen_fastdraw_mode(int off, int total)
+{
+       if (aga) {
+               outf("c = *cp;");
+               outf("cp += cpadds[%d];", off);
+               if (modes == CMODE_DUALPF) {
+                       outf("{");
+                       outf("uae_u8 dpval = dpf_lookup[c];");
+                       outf("if (dpf_lookup_no[c]) {");
+                       outf("  dpval += dblpfofs[bpldualpf2of];");
+                       outf("}");
+                       outf("dpval ^= bxor;");
+                       outf("col = colors_aga[dpval];");
+                       outf("}");
+               } else if (modes == CMODE_HAM) {
+                       outf("col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);");
+               } else if (modes == CMODE_EXTRAHB_ECS_KILLEHB) {
+                       outf("c ^= bxor;");
+                       outf("col = colors_aga[c & 31];");
+               } else if (modes == CMODE_EXTRAHB) {
+                       outf("c ^= bxor;");
+                       outf("if (c & 0x20) {");
+                       outf("  uae_u32 v = (colors_aga[c & 31] >> 1) & 0x7f7f7f;");
+                       outf("  col = CONVERT_RGB(v);");
+                       outf("} else {");
+                       outf("  col = colors_aga[c];");
+                       outf("}");
+               } else {
+                       outf("c ^= bxor;");
+                       outf("col = colors_aga[c];");
+               }
+       } else {
+               outf("c = *cp;");
+               if (off == total - 1) {
+                       outf("cp += cpadd;");
+               }
+               if (modes == CMODE_DUALPF) {
+                       outf("{");
+                       outf("uae_u8 dpval = dpf_lookup[c];");
+                       outf("col = xcolors[colors_ocs[dpval]];");
+                       outf("}");
+               } else if (modes == CMODE_HAM) {
+                       outf("col = decode_ham_pixel_fast(c, colors_ocs);");
+               } else if (modes == CMODE_EXTRAHB_ECS_KILLEHB) {
+                       outf("col = xcolors[colors_ocs[c & 31]];");
+               } else if (modes == CMODE_EXTRAHB) {
+                       outf("c &= bplehb_mask;");
+                       outf("if (c <= 31) {");
+                       outf("  col = xcolors[colors_ocs[c]];");
+                       outf("} else {");
+                       outf("  col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];");
+                       outf("}");
+               } else {
+                       outf("col = xcolors[colors_ocs[c]];");
+               }
+       }
+       outf("*buf1++ = col;");
+       if (isbuf2) {
+               outf("*buf2++ = col;");
+       }
+}
+
+static void gen_fastdraw(void)
+{
+       int doubling = outres - res;
+
+       if (aga) {
+               outf("uae_u32 *colors_aga = (uae_u32*)colors;");
+       } else {
+               outf("uae_u16 *colors_ocs = (uae_u16*)colors;");
+       }
+
+       outf("int cnt = draw_start;");
+       outf("while (cnt < draw_end) {");
+       outf("  bool bpl = false;");
+       outf("  if (cnt >= hbstrt_offset) {");
+       outf("          break;");
+       outf("  }");
+       outf("if (cnt >= draw_startoffset) {");
+       outf("  if (cnt < hbstop_offset) {");
+       outf("          buf1 += bufadd;");
+       if (isbuf2) {
+               outf("  buf2 += bufadd;");
+       }
+       outf("} else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {");
+       if (doubling <= 0) {
+               outf("*buf1++ = bgcolor;");
+               if (isbuf2) {
+                       outf("*buf2++ = bgcolor;");
+               }
+       } else if (doubling == 1) {
+               outf("*buf1++ = bgcolor;");
+               outf("*buf1++ = bgcolor;");
+               if (isbuf2) {
+                       outf("*buf2++ = bgcolor;");
+                       outf("*buf2++ = bgcolor;");
+               }
+       } else if (doubling == 2) {
+               outf("*buf1++ = bgcolor;");
+               outf("*buf1++ = bgcolor;");
+               outf("*buf1++ = bgcolor;");
+               outf("*buf1++ = bgcolor;");
+               if (isbuf2) {
+                       outf("*buf2++ = bgcolor;");
+                       outf("*buf2++ = bgcolor;");
+                       outf("*buf2++ = bgcolor;");
+                       outf("*buf2++ = bgcolor;");
+               }
+       }
+       outf("}");
+       outf("if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {");
+       outf("bpl = true;");
+       outf("uae_u8 c;");
+       outf("uae_u32 col;");
+       if (doubling <= 0) {
+               gen_fastdraw_mode(0, 1);
+       } else if (doubling == 1) {
+               gen_fastdraw_mode(0, 2);
+               gen_fastdraw_mode(1, 2);
+       } else if (doubling == 2) {
+               gen_fastdraw_mode(0, 4);
+               gen_fastdraw_mode(1, 4);
+               gen_fastdraw_mode(2, 4);
+               gen_fastdraw_mode(3, 4);
+       }
+       outf("}");
+       outf("}");
+       outf("if (cnt >= bpl1dat_trigger_offset && !bpl) {");
+       outf("  cp += cpadd;");
+       outf("}");
+       outf("cnt += bufadd;");
+       outf("}");
+}
+
 static void gen_null(void)
 {
        outf("lts_null();");
@@ -976,6 +1129,21 @@ static void write_funcs(const char *name)
        *funcnamep = 0;
 }
 
+static void write_funcs_fast(const char *name)
+{
+       outf("static LINETOSRC_FUNCF %s[] = {", name);
+       char *p = funcnames;
+       while (*p) {
+               outf("%s,", p);
+               p += strlen(p) + 1;
+       }
+       outf("NULL");
+       outf("};");
+
+       funcnamep = funcnames;
+       *funcnamep = 0;
+}
+
 int main (int argc, char *argv[])
 {
        set_outfile("../../linetoscr_common.cpp");
@@ -1282,6 +1450,46 @@ int main (int argc, char *argv[])
                write_funcs(genlock ? "linetoscr_ecs_shres_genlock_funcs" : "linetoscr_ecs_shres_funcs");
        }
 
+       // fast drawing
+       set_outfile("../../linetoscr_ecs_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_fast_funcs");
+
+       set_outfile("../../linetoscr_aga_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_fast_funcs");
+
+
        closefile();
 
        return 0;
index 5c65ac8f5f168656029f06cb83efbf57b778c492..bc5fad77b24c93de3d0f9cd0164f7cae7bd3734a 100644 (file)
@@ -186,13 +186,16 @@ struct linestate
        int hbstrt_offset, hbstop_offset;
        int hstrt_offset, hstop_offset;
        int bpl1dat_trigger_offset;
-       int bpl1dat_hcounter;
+       int internal_pixel_cnt;
+       int internal_pixel_start_cnt;
        int fetchmode_size, fetchstart_mask;
+       int ltsidx;
 };
 
 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_line_fast(int gfx_ypos, enum nln_how how, 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);
 bool start_draw_denise(void);
 void end_draw_denise(void);
 void denise_update_reg(uae_u16 reg, uae_u16 v);
diff --git a/linetoscr_aga_fast.cpp b/linetoscr_aga_fast.cpp
new file mode 100644 (file)
index 0000000..36e822e
--- /dev/null
@@ -0,0 +1,3744 @@
+/*
+* UAE - The portable Amiga emulator.
+*
+* 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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadds[1];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[2];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[3];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadds[1];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[2];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[3];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[2];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[3];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadds[1];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadds[1];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[2];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[3];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadds[1];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[2];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[3];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[2];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[3];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadds[1];
+                               col = decode_ham_pixel_aga_fast(c, planes, bxor, colors_aga);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadds[1];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u32 *colors_aga = (uae_u32*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadds[0];
+                               c ^= bxor;
+                               col = colors_aga[c & 31];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+static LINETOSRC_FUNCF linetoscr_aga_fast_funcs[] = {
+       lts_aga_n_ilores_dlores_b1,
+       lts_aga_dpf_ilores_dlores_b1,
+       lts_aga_ehb_ilores_dlores_b1,
+       lts_aga_ham_ilores_dlores_b1,
+       lts_aga_kehb_ilores_dlores_b1,
+       lts_aga_n_ihires_dlores_b1,
+       lts_aga_dpf_ihires_dlores_b1,
+       lts_aga_ehb_ihires_dlores_b1,
+       lts_aga_ham_ihires_dlores_b1,
+       lts_aga_kehb_ihires_dlores_b1,
+       lts_aga_n_ishres_dlores_b1,
+       lts_aga_dpf_ishres_dlores_b1,
+       lts_aga_ehb_ishres_dlores_b1,
+       lts_aga_ham_ishres_dlores_b1,
+       lts_aga_kehb_ishres_dlores_b1,
+       lts_aga_n_ilores_dhires_b1,
+       lts_aga_dpf_ilores_dhires_b1,
+       lts_aga_ehb_ilores_dhires_b1,
+       lts_aga_ham_ilores_dhires_b1,
+       lts_aga_kehb_ilores_dhires_b1,
+       lts_aga_n_ihires_dhires_b1,
+       lts_aga_dpf_ihires_dhires_b1,
+       lts_aga_ehb_ihires_dhires_b1,
+       lts_aga_ham_ihires_dhires_b1,
+       lts_aga_kehb_ihires_dhires_b1,
+       lts_aga_n_ishres_dhires_b1,
+       lts_aga_dpf_ishres_dhires_b1,
+       lts_aga_ehb_ishres_dhires_b1,
+       lts_aga_ham_ishres_dhires_b1,
+       lts_aga_kehb_ishres_dhires_b1,
+       lts_aga_n_ilores_dshres_b1,
+       lts_aga_dpf_ilores_dshres_b1,
+       lts_aga_ehb_ilores_dshres_b1,
+       lts_aga_ham_ilores_dshres_b1,
+       lts_aga_kehb_ilores_dshres_b1,
+       lts_aga_n_ihires_dshres_b1,
+       lts_aga_dpf_ihires_dshres_b1,
+       lts_aga_ehb_ihires_dshres_b1,
+       lts_aga_ham_ihires_dshres_b1,
+       lts_aga_kehb_ihires_dshres_b1,
+       lts_aga_n_ishres_dshres_b1,
+       lts_aga_dpf_ishres_dshres_b1,
+       lts_aga_ehb_ishres_dshres_b1,
+       lts_aga_ham_ishres_dshres_b1,
+       lts_aga_kehb_ishres_dshres_b1,
+       lts_aga_n_ilores_dlores_b2,
+       lts_aga_dpf_ilores_dlores_b2,
+       lts_aga_ehb_ilores_dlores_b2,
+       lts_aga_ham_ilores_dlores_b2,
+       lts_aga_kehb_ilores_dlores_b2,
+       lts_aga_n_ihires_dlores_b2,
+       lts_aga_dpf_ihires_dlores_b2,
+       lts_aga_ehb_ihires_dlores_b2,
+       lts_aga_ham_ihires_dlores_b2,
+       lts_aga_kehb_ihires_dlores_b2,
+       lts_aga_n_ishres_dlores_b2,
+       lts_aga_dpf_ishres_dlores_b2,
+       lts_aga_ehb_ishres_dlores_b2,
+       lts_aga_ham_ishres_dlores_b2,
+       lts_aga_kehb_ishres_dlores_b2,
+       lts_aga_n_ilores_dhires_b2,
+       lts_aga_dpf_ilores_dhires_b2,
+       lts_aga_ehb_ilores_dhires_b2,
+       lts_aga_ham_ilores_dhires_b2,
+       lts_aga_kehb_ilores_dhires_b2,
+       lts_aga_n_ihires_dhires_b2,
+       lts_aga_dpf_ihires_dhires_b2,
+       lts_aga_ehb_ihires_dhires_b2,
+       lts_aga_ham_ihires_dhires_b2,
+       lts_aga_kehb_ihires_dhires_b2,
+       lts_aga_n_ishres_dhires_b2,
+       lts_aga_dpf_ishres_dhires_b2,
+       lts_aga_ehb_ishres_dhires_b2,
+       lts_aga_ham_ishres_dhires_b2,
+       lts_aga_kehb_ishres_dhires_b2,
+       lts_aga_n_ilores_dshres_b2,
+       lts_aga_dpf_ilores_dshres_b2,
+       lts_aga_ehb_ilores_dshres_b2,
+       lts_aga_ham_ilores_dshres_b2,
+       lts_aga_kehb_ilores_dshres_b2,
+       lts_aga_n_ihires_dshres_b2,
+       lts_aga_dpf_ihires_dshres_b2,
+       lts_aga_ehb_ihires_dshres_b2,
+       lts_aga_ham_ihires_dshres_b2,
+       lts_aga_kehb_ihires_dshres_b2,
+       lts_aga_n_ishres_dshres_b2,
+       lts_aga_dpf_ishres_dshres_b2,
+       lts_aga_ehb_ishres_dshres_b2,
+       lts_aga_ham_ishres_dshres_b2,
+       lts_aga_kehb_ishres_dshres_b2,
+       NULL
+};
diff --git a/linetoscr_ecs_fast.cpp b/linetoscr_ecs_fast.cpp
new file mode 100644 (file)
index 0000000..444296c
--- /dev/null
@@ -0,0 +1,3498 @@
+/*
+* UAE - The portable Amiga emulator.
+*
+* 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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = 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;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               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;
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else 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;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               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;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               {
+                                       uae_u8 dpval = dpf_lookup[c];
+                                       col = xcolors[colors_ocs[dpval]];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               c &= bplehb_mask;
+                               if (c <= 31) {
+                                       col = xcolors[colors_ocs[c]];
+                               } else {
+                                       col = xcolors[(colors_ocs[c - 32] >> 1) & 0x777];
+                               }
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = decode_ham_pixel_fast(c, colors_ocs);
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+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)
+{
+       uae_u16 *colors_ocs = (uae_u16*)colors;
+       int cnt = draw_start;
+       while (cnt < draw_end) {
+               bool bpl = false;
+               if (cnt >= hbstrt_offset) {
+                       break;
+               }
+               if (cnt >= draw_startoffset) {
+                       if (cnt < hbstop_offset) {
+                               buf1 += bufadd;
+                               buf2 += bufadd;
+                       } else if (cnt < bpl1dat_trigger_offset || cnt < hstrt_offset || cnt >= hstop_offset) {
+                               *buf1++ = bgcolor;
+                               *buf2++ = bgcolor;
+                       }
+                       if (cnt >= bpl1dat_trigger_offset && cnt >= hstrt_offset && cnt < hstop_offset) {
+                               bpl = true;
+                               uae_u8 c;
+                               uae_u32 col;
+                               c = *cp;
+                               cp += cpadd;
+                               col = xcolors[colors_ocs[c & 31]];
+                               *buf1++ = col;
+                               *buf2++ = col;
+                       }
+               }
+               if (cnt >= bpl1dat_trigger_offset && !bpl) {
+                       cp += cpadd;
+               }
+               cnt += bufadd;
+       }
+}
+static LINETOSRC_FUNCF linetoscr_ecs_fast_funcs[] = {
+       lts_ecs_n_ilores_dlores_b1,
+       lts_ecs_dpf_ilores_dlores_b1,
+       lts_ecs_ehb_ilores_dlores_b1,
+       lts_ecs_ham_ilores_dlores_b1,
+       lts_ecs_kehb_ilores_dlores_b1,
+       lts_ecs_n_ihires_dlores_b1,
+       lts_ecs_dpf_ihires_dlores_b1,
+       lts_ecs_ehb_ihires_dlores_b1,
+       lts_ecs_ham_ihires_dlores_b1,
+       lts_ecs_kehb_ihires_dlores_b1,
+       lts_ecs_n_ishres_dlores_b1,
+       lts_ecs_dpf_ishres_dlores_b1,
+       lts_ecs_ehb_ishres_dlores_b1,
+       lts_ecs_ham_ishres_dlores_b1,
+       lts_ecs_kehb_ishres_dlores_b1,
+       lts_ecs_n_ilores_dhires_b1,
+       lts_ecs_dpf_ilores_dhires_b1,
+       lts_ecs_ehb_ilores_dhires_b1,
+       lts_ecs_ham_ilores_dhires_b1,
+       lts_ecs_kehb_ilores_dhires_b1,
+       lts_ecs_n_ihires_dhires_b1,
+       lts_ecs_dpf_ihires_dhires_b1,
+       lts_ecs_ehb_ihires_dhires_b1,
+       lts_ecs_ham_ihires_dhires_b1,
+       lts_ecs_kehb_ihires_dhires_b1,
+       lts_ecs_n_ishres_dhires_b1,
+       lts_ecs_dpf_ishres_dhires_b1,
+       lts_ecs_ehb_ishres_dhires_b1,
+       lts_ecs_ham_ishres_dhires_b1,
+       lts_ecs_kehb_ishres_dhires_b1,
+       lts_ecs_n_ilores_dshres_b1,
+       lts_ecs_dpf_ilores_dshres_b1,
+       lts_ecs_ehb_ilores_dshres_b1,
+       lts_ecs_ham_ilores_dshres_b1,
+       lts_ecs_kehb_ilores_dshres_b1,
+       lts_ecs_n_ihires_dshres_b1,
+       lts_ecs_dpf_ihires_dshres_b1,
+       lts_ecs_ehb_ihires_dshres_b1,
+       lts_ecs_ham_ihires_dshres_b1,
+       lts_ecs_kehb_ihires_dshres_b1,
+       lts_ecs_n_ishres_dshres_b1,
+       lts_ecs_dpf_ishres_dshres_b1,
+       lts_ecs_ehb_ishres_dshres_b1,
+       lts_ecs_ham_ishres_dshres_b1,
+       lts_ecs_kehb_ishres_dshres_b1,
+       lts_ecs_n_ilores_dlores_b2,
+       lts_ecs_dpf_ilores_dlores_b2,
+       lts_ecs_ehb_ilores_dlores_b2,
+       lts_ecs_ham_ilores_dlores_b2,
+       lts_ecs_kehb_ilores_dlores_b2,
+       lts_ecs_n_ihires_dlores_b2,
+       lts_ecs_dpf_ihires_dlores_b2,
+       lts_ecs_ehb_ihires_dlores_b2,
+       lts_ecs_ham_ihires_dlores_b2,
+       lts_ecs_kehb_ihires_dlores_b2,
+       lts_ecs_n_ishres_dlores_b2,
+       lts_ecs_dpf_ishres_dlores_b2,
+       lts_ecs_ehb_ishres_dlores_b2,
+       lts_ecs_ham_ishres_dlores_b2,
+       lts_ecs_kehb_ishres_dlores_b2,
+       lts_ecs_n_ilores_dhires_b2,
+       lts_ecs_dpf_ilores_dhires_b2,
+       lts_ecs_ehb_ilores_dhires_b2,
+       lts_ecs_ham_ilores_dhires_b2,
+       lts_ecs_kehb_ilores_dhires_b2,
+       lts_ecs_n_ihires_dhires_b2,
+       lts_ecs_dpf_ihires_dhires_b2,
+       lts_ecs_ehb_ihires_dhires_b2,
+       lts_ecs_ham_ihires_dhires_b2,
+       lts_ecs_kehb_ihires_dhires_b2,
+       lts_ecs_n_ishres_dhires_b2,
+       lts_ecs_dpf_ishres_dhires_b2,
+       lts_ecs_ehb_ishres_dhires_b2,
+       lts_ecs_ham_ishres_dhires_b2,
+       lts_ecs_kehb_ishres_dhires_b2,
+       lts_ecs_n_ilores_dshres_b2,
+       lts_ecs_dpf_ilores_dshres_b2,
+       lts_ecs_ehb_ilores_dshres_b2,
+       lts_ecs_ham_ilores_dshres_b2,
+       lts_ecs_kehb_ilores_dshres_b2,
+       lts_ecs_n_ihires_dshres_b2,
+       lts_ecs_dpf_ihires_dshres_b2,
+       lts_ecs_ehb_ihires_dshres_b2,
+       lts_ecs_ham_ihires_dshres_b2,
+       lts_ecs_kehb_ihires_dshres_b2,
+       lts_ecs_n_ishres_dshres_b2,
+       lts_ecs_dpf_ishres_dshres_b2,
+       lts_ecs_ehb_ishres_dshres_b2,
+       lts_ecs_ham_ishres_dshres_b2,
+       lts_ecs_kehb_ishres_dshres_b2,
+       NULL
+};