]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc2020b2.zip
authorToni Wilen <twilen@winuae.net>
Sat, 9 Jan 2010 09:38:57 +0000 (11:38 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:50:27 +0000 (21:50 +0200)
17 files changed:
blitter.c
custom.c
debug.c
disk.c
drawing.c
gencpu.c
genlinetoscr.c
include/debug.h
inputdevice.c
newcpu.c
od-win32/blkdev_win32_ioctl.c
od-win32/unicode.c
od-win32/win32.c
od-win32/win32.h
od-win32/win32gui.c
od-win32/winuaechangelog.txt
prowizard/rippers/Promizer18a.c

index 7ca9c576cda406979ff3a6684fad2d913df60bef..6749e338707c6544fa0283cbbcc3ca88d9723fca 100644 (file)
--- a/blitter.c
+++ b/blitter.c
@@ -75,7 +75,7 @@ static int blit_linecycles, blit_extracycles, blit_nod;
 static const int *blit_diag;
 static int blit_frozen, blit_faulty;
 static int blit_final;
-
+static int blt_delayed_irq;
 static uae_u16 ddat1, ddat2;
 static int ddat1use, ddat2use;
 
@@ -164,7 +164,7 @@ using normal BLTDDAT)
 - C-channel disabled: nothing is written
 
 There is one tricky situation, writing to DFF058 just before
-last D write cycle (which is normally free) does not distrupt
+last D write cycle (which is normally free) does not disturb
 blitter operation, final D is still written correctly before
 blitter starts normally (after 2 idle cycles)
 
@@ -968,6 +968,12 @@ void decide_blitter (int hpos)
        if (blit_startcycles > 0)
                do_startcycles (hpos);
 
+       if (blt_delayed_irq > 0 && hsync) {
+               blt_delayed_irq--;
+               if (!blt_delayed_irq)
+                       INTREQ (0x8040);
+       }
+
        if (bltstate == BLT_done)
                return;
 #ifdef BLITTER_DEBUG
@@ -1090,11 +1096,12 @@ static void blitter_force_finish (void)
                        int rounds = 10000;
                        while (bltstate != BLT_done && rounds > 0) {
                                memset (cycle_line, 0, sizeof cycle_line);
-                               decide_blitter (maxhpos);
+                               decide_blitter (-1);
                                rounds--;
                        }
                        if (rounds == 0)
                                write_log (L"blitter froze!?\n");
+                       blit_startcycles = 0;
                } else {
                        actually_do_blit ();
                }
@@ -1463,13 +1470,18 @@ uae_u8 *restore_blitter (uae_u8 *src)
 {
        uae_u32 flags = restore_u32();
 
+       blt_delayed_irq = 0;
        bltstate = BLT_done;
-       if (bltstate & 4) {
+       if (flags & 4) {
                bltstate = (flags & 1) ? BLT_done : BLT_init;
        }
        if (flags & 2) {
                write_log (L"blitter was force-finished when this statefile was saved\n");
                write_log (L"contact the author if restored program freezes\n");
+               // there is a problem. if system ks vblank is active, we must not activate
+               // "old" blit's intreq until vblank is handled or ks 1.x thinks it was blitter
+               // interrupt..
+               blt_delayed_irq = -1;
        }
        return src;
 }
@@ -1483,6 +1495,11 @@ void restore_blitter_finish (void)
                write_log (L"blitter was started but DMA was inactive during save\n");
                //do_blitter (0);
        }
+       if (blt_delayed_irq < 0) {
+               if (intreq & 0x0040)
+                       blt_delayed_irq = 3;
+               intreq &= 0x0040;
+       }
 }
 
 uae_u8 *save_blitter (int *len, uae_u8 *dstptr)
index 3c1f3b8302611137f33642df8a330ad5e1d98bbb..251ba6e995f12f9d0e8e1254a8e48058951e1d20 100644 (file)
--- a/custom.c
+++ b/custom.c
@@ -249,7 +249,7 @@ static int bplcon1_hpos;
 
 enum diw_states
 {
-       DIW_waiting_start, DIW_waiting_stop, DIW_waiting_frozen
+       DIW_waiting_start, DIW_waiting_stop
 };
 
 static int plffirstline, plflastline;
@@ -584,11 +584,8 @@ static void decide_diw (int hpos)
           ECS Denise and AGA: no above "features"
        */
 
-       int hdiw = hpos == maxhpos ? hpos * 2 + 1 : hpos * 2 + 2;
-
+       int hdiw = hpos >= maxhpos ? maxhpos * 2 + 1 : hpos * 2 + 2;
        if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE) && vpos <= equ_vblank_endline) {
-               if (vpos == equ_vblank_endline)
-                       diw_hcounter++;
                hdiw = diw_hcounter;
                hdiw &= 511;
        }
@@ -1880,10 +1877,7 @@ STATIC_INLINE void decide_line (int hpos)
 {
        /* Take care of the vertical DIW.  */
        if (vpos == plffirstline) {
-               if (diwstate == DIW_waiting_stop && last_decide_line_hpos < 2 && hpos > last_decide_line_hpos && diw_hstrt <= 2 && !(currprefs.chipset_mask & CSMASK_ECS_DENISE))
-                       diwstate = DIW_waiting_frozen; // OCS Denise bug
-               else if (hpos >= 2 && diwstate != DIW_waiting_frozen)
-                       diwstate = DIW_waiting_stop;
+               diwstate = DIW_waiting_stop;
                ddf_change = vpos;
        }
        if (vpos == plflastline) {
@@ -2531,8 +2525,11 @@ static void finish_decisions (void)
        /* Large DIWSTOP values can cause the stop position never to be
        * reached, so the state machine always stays in the same state and
        * there's a more-or-less full-screen DIW. */
-       if (hdiwstate == DIW_waiting_stop /* || thisline_decision.diwlastword > max_diwlastword */)
+       if (hdiwstate == DIW_waiting_stop) {
                thisline_decision.diwlastword = max_diwlastword;
+               if (thisline_decision.diwfirstword == -1)
+                       thisline_decision.diwfirstword = 0;
+       }
 
        if (thisline_decision.diwfirstword != line_decisions[next_lineno].diwfirstword)
                MARK_LINE_CHANGED;
@@ -2579,6 +2576,8 @@ static void finish_decisions (void)
        next_color_change += (HBLANK_OFFSET + 1) / 2;
 
        diw_hcounter += maxhpos * 2;
+       if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE) && vpos == equ_vblank_endline - 1)
+               diw_hcounter++;
        if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) || vpos > equ_vblank_endline) {
                diw_hcounter = maxhpos * 2;
                last_hdiw = 2 - 1;
@@ -2956,7 +2955,7 @@ STATIC_INLINE uae_u16 DMACONR (int hpos)
        decide_fetch (hpos);
        decide_blitter (hpos);
        dmacon &= ~(0x4000 | 0x2000);
-       dmacon |= (blit_interrupt || (!blit_interrupt && currprefs.cs_agnusbltbusybug && !blt_info.got_cycle) ? 0 : 0x4000)
+       dmacon |= ((blit_interrupt || (!blit_interrupt && currprefs.cs_agnusbltbusybug && !blt_info.got_cycle)) ? 0 : 0x4000)
                | (blt_info.blitzero ? 0x2000 : 0);
        return dmacon;
 }
@@ -3318,15 +3317,23 @@ STATIC_INLINE void INTENA (uae_u16 v)
 
 void INTREQ_0 (uae_u16 v)
 {
+       uae_u16 tmp = intreq;
        intreqr = intreq;
        /* data in intreq is immediately available (vsync only currently because there is something unknown..) */
        setclr (&intreqr, v & (0x8000 | 0x20));
+       setclr (&tmp, v);
 
-       if (use_eventmode ())
-               prepare_interrupt ();
+       if (use_eventmode ()) {
+               if (tmp != intreq)
+                       prepare_interrupt ();
+               if (tmp > intreq) {
+                       if (debug_dma)
+                               record_dma_event (DMA_EVENT_INTREQ, current_hpos (), vpos);
+               }
+       }
        if (v & (0x80 | 0x100 | 0x200 | 0x400))
                audio_update_irq (v);
-       setclr (&intreq, v);
+       intreq = tmp;
        intreqr = intreq;
        doint ();
 }
@@ -3584,7 +3591,7 @@ static void BPL2MOD (int hpos, uae_u16 v)
 }
 
 /* needed in special OCS/ECS "7-plane" mode. */
-/* (in reality only BPL5DAT and BPL6DAT needed) */
+/* (in reality only BPL0DAT, BPL5DAT and BPL6DAT needed) */
 static void BPLxDAT (int hpos, int num, uae_u16 v)
 {
        decide_line (hpos);
@@ -4272,6 +4279,9 @@ static void update_copper (int until_hpos)
                                        record_dma (0x8c, cop_state.i2, cop_state.ip - 2, old_hpos, vpos, DMARECORD_COPPER);
 #endif
                        } else { // MOVE
+#ifdef DEBUGGER
+                               uaecptr debugip = cop_state.ip;
+#endif
                                unsigned int reg = cop_state.i1 & 0x1FE;
                                uae_u16 data = cop_state.i2;
                                cop_state.state = COP_read1;
@@ -4312,7 +4322,7 @@ static void update_copper (int until_hpos)
                                }
 #ifdef DEBUGGER
                                if (debug_copper)
-                                       record_copper (cop_state.ip - 4, old_hpos, vpos);
+                                       record_copper (debugip - 4, old_hpos, vpos);
 #endif
                        }
                        break;
@@ -5231,9 +5241,9 @@ static void hsync_handler (void)
 #ifdef CDTV
        CDTV_hsync_handler ();
 #endif
+       decide_blitter (-1);
 #ifdef CPUEMU_12
        if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) {
-               decide_blitter (-1);
                memset (cycle_line, 0, sizeof cycle_line);
        }
 #endif
@@ -5526,17 +5536,11 @@ static void MISC_handler (void)
        recursive--;
 }
 
-STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
+STATIC_INLINE void event2_newevent_xx (int no, evt t, uae_u32 data, evfunc2 func)
 {
        evt et;
 
-       if (((int)t) <= 0) {
-               func (data);
-               return;
-       }
-
-       et = t * CYCLE_UNIT + get_cycles ();
-
+       et = t + get_cycles ();
        if (no < 0) {
                for (no = ev2_misc; no < ev2_max; no++) {
                        if (!eventtab2[no].active)
@@ -5557,6 +5561,17 @@ STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
        eventtab2[no].data = data;
        MISC_handler ();
 }
+
+STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
+{
+       if (((int)t) <= 0) {
+               func (data);
+               return;
+       }
+
+       event2_newevent_xx (no, t * CYCLE_UNIT, data, func);
+}
+
 void event2_newevent (int no, evt t)
 {
        event2_newevent_x (no, t, 0, eventtab2[no].handler);
@@ -6818,11 +6833,12 @@ STATIC_INLINE void decide_fetch_ce (int hpos)
 // at least 4 cycles (all DMA cycles count, not just blitter cycles, even
 // blitter idle cycles do count!)
 
-STATIC_INLINE int dma_cycle (void)
+STATIC_INLINE int dma_cycle (int *waited)
 {
        int hpos, hpos_old;
 
        blitter_nasty = 1;
+       *waited = 0;
        for (;;) {
                int bpldma;
                int blitpri = dmacon & DMA_BLITPRI;
@@ -6845,6 +6861,7 @@ STATIC_INLINE int dma_cycle (void)
                        alloc_cycle (hpos_old, CYCLE_CPU);
                        break;
                }
+               *waited = 1;
                regs.ce020memcycles -= CYCLE_UNIT;
                do_cycles (1 * CYCLE_UNIT);
                /* bus was allocated to dma channel, wait for next cycle.. */
@@ -6861,10 +6878,13 @@ STATIC_INLINE void checknasty (int hpos, int vpos)
 uae_u32 wait_cpu_cycle_read (uaecptr addr, int mode)
 {
        uae_u32 v = 0;
-       int hpos;
+       int hpos, waited;
        struct dma_rec *dr;
 
-       hpos = dma_cycle ();
+       hpos = dma_cycle (&waited);
+       if (waited)
+               do_cycles_ce (CYCLE_UNIT);
+
 #ifdef DEBUGGER
        if (debug_dma) {
                dr = record_dma (0x1000, v, addr, hpos, vpos, DMARECORD_CPU);
@@ -6877,11 +6897,16 @@ uae_u32 wait_cpu_cycle_read (uaecptr addr, int mode)
                v = get_word (addr);
        else if (mode == 0)
                v = get_byte (addr);
+
 #ifdef DEBUGGER
        if (debug_dma)
                dr->dat = v;
 #endif
-       do_cycles_ce (2 * CYCLE_UNIT);
+
+       if (!waited)
+               do_cycles_ce (2 * CYCLE_UNIT);
+       else
+               do_cycles_ce (CYCLE_UNIT);
        regs.ce020memcycles -= 2 * CYCLE_UNIT;
        return v;
 }
@@ -6894,21 +6919,29 @@ uae_u32 wait_cpu_cycle_read_ce020 (uaecptr addr, int mode)
 void wait_cpu_cycle_write (uaecptr addr, int mode, uae_u32 v)
 {
        int hpos;
+       int waited;
+
+       hpos = dma_cycle (&waited);
+       if (waited)
+               do_cycles_ce (CYCLE_UNIT);
 
-       hpos = dma_cycle ();
 #ifdef DEBUGGER
        if (debug_dma) {
                record_dma (0x1001, v, addr, hpos, vpos, DMARECORD_CPU);
                checknasty (hpos, vpos);
        }
 #endif
+
        if (mode < 0)
                put_long (addr, v);
        else if (mode > 0)
                put_word (addr, v);
        else if (mode == 0)
                put_byte (addr, v);
-       do_cycles_ce (2 * CYCLE_UNIT);
+       if (!waited)
+               do_cycles_ce (2 * CYCLE_UNIT);
+       else
+               do_cycles_ce (CYCLE_UNIT);
        regs.ce020memcycles -= 2 * CYCLE_UNIT;
 }
 
@@ -6919,9 +6952,9 @@ void wait_cpu_cycle_write_ce020 (uaecptr addr, int mode, uae_u32 v)
 
 void do_cycles_ce (long cycles)
 {
-       static int extra;
+       static int extra_cycle;
 
-       cycles += extra;
+       cycles += extra_cycle;
        while (cycles >= CYCLE_UNIT) {
                int hpos = current_hpos () + 1;
                sync_copper (hpos);
@@ -6932,7 +6965,7 @@ void do_cycles_ce (long cycles)
                do_cycles (1 * CYCLE_UNIT);
                cycles -= CYCLE_UNIT;
        }
-       extra = cycles;
+       extra_cycle = cycles;
 }
 
 int is_cycle_ce (void)
diff --git a/debug.c b/debug.c
index 5e9f537c81920bcd000eabecc1740b08060b3adc..58a0766a7549a023e6449bfa90d801ea8db5eb1a 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -908,6 +908,10 @@ static void decode_dma_record (int hpos, int vpos, int toggle)
                                l2[cl2++] = 'p';
                        if (dr->evt & DMA_EVENT_COPPERWAKE)
                                l2[cl2++] = 'W';
+                       if (dr->evt & DMA_EVENT_CPUIRQ)
+                               l2[cl2++] = 'I';
+                       if (dr->evt & DMA_EVENT_INTREQ)
+                               l2[cl2++] = 'i';
                        if (i < cols - 1 && h < maxh - 1) {
                                l1[cl + col - 1] = 32;
                                l2[cl + col - 1] = 32;
diff --git a/disk.c b/disk.c
index e4ccb3c2c542e7632e2fc2e799db3f6deeb12610..8728930a3b05dc9f627aaa4b3ea1485b2837ac74 100644 (file)
--- a/disk.c
+++ b/disk.c
@@ -2116,7 +2116,7 @@ void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk
        xfree (chunk);
        zfile_fclose (f);
        if (f)
-               DISK_history_add (name, -1, 0);
+               DISK_history_add (name, -1, TRUE);
 
 }
 
index 6969c5de42523d33db97253160e73791d85e0873..1f3592877ad822073516fbf935a71f04dc9d50a6 100644 (file)
--- a/drawing.c
+++ b/drawing.c
@@ -622,8 +622,13 @@ static void pfield_init_linetoscr (void)
        }
 #endif
 
-       if (sprite_first_x < sprite_last_x)
+       if (sprite_first_x < sprite_last_x) {
+               if (sprite_first_x < 0)
+                       sprite_first_x = 0;
+               if (sprite_last_x >= MAX_PIXELS_PER_LINE)
+                       sprite_last_x = MAX_PIXELS_PER_LINE - 1;
                memset (spritepixels + sprite_first_x, 0, sizeof (struct spritepixelsbuf) * (sprite_last_x - sprite_first_x + 1));
+       }
        sprite_last_x = 0;
        sprite_first_x = MAX_PIXELS_PER_LINE - 1;
 
@@ -1434,17 +1439,12 @@ static void gen_pfield_tables (void)
 {
        int i;
 
-       /* For now, the AGA stuff is broken in the dual playfield case. We encode
-       * sprites in dpf mode by ORing the pixel value with 0x80. To make dual
-       * playfield rendering easy, the lookup tables contain are made linear for
-       * values >= 128. That only works for OCS/ECS, though. */
-
        for (i = 0; i < 256; i++) {
-               int plane1 = (i & 1) | ((i >> 1) & 2) | ((i >> 2) & 4) | ((i >> 3) & 8);
+               int plane1 = ((i >> 0) & 1) | ((i >> 1) & 2) | ((i >> 2) & 4) | ((i >> 3) & 8);
                int plane2 = ((i >> 1) & 1) | ((i >> 2) & 2) | ((i >> 3) & 4) | ((i >> 4) & 8);
 
-               dblpf_2nd1[i] = plane1 == 0 ? (plane2 == 0 ? 0 : 2) : 1;
-               dblpf_2nd2[i] = plane2 == 0 ? (plane1 == 0 ? 0 : 1) : 2;
+               dblpf_2nd1[i] = plane1 == 0 && plane2 != 0;
+               dblpf_2nd2[i] = plane2 != 0;
 
 #ifdef AGA
                dblpf_ind1_aga[i] = plane1 == 0 ? plane2 : plane1;
@@ -1454,6 +1454,7 @@ static void gen_pfield_tables (void)
                dblpf_ms1[i] = plane1 == 0 ? (plane2 == 0 ? 16 : 8) : 0;
                dblpf_ms2[i] = plane2 == 0 ? (plane1 == 0 ? 16 : 0) : 8;
                dblpf_ms[i] = i == 0 ? 16 : 8;
+
                if (plane2 > 0)
                        plane2 += 8;
                dblpf_ind1[i] = i >= 128 ? i & 0x7F : (plane1 == 0 ? plane2 : plane1);
index 880a9b8b6e231f40d3213ca92bced1b5d72f2dd2..16a9366d1116f9b701dfe7d341bfbaeb8d499005 100644 (file)
--- a/gencpu.c
+++ b/gencpu.c
@@ -1889,12 +1889,15 @@ static void gen_opcode (unsigned long int opcode)
                        * - MOVE <ea>,-(An) = prefetch is before writes (Apdi)
                        * - MOVE memory,(xxx).L, the most stupid ever. 2 prefetches after write
                        * - all others = prefetch is done after writes
+                       *
+                       * - move.x xxx,[at least 1 extension word here] = fetch 1 extension word before (xxx)
                        */
-                       int prefetch_done = 0;
+                       int prefetch_done = 0, flags;
                        int dualprefetch = curi->dmode == absl && (curi->smode != Dreg && curi->smode != Areg && curi->smode != imm);
                        genamode_pre (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
+                       flags = 1 | (dualprefetch ? GF_NOREFILL : 0);
                        /* MOVE.L dx,(ax) exception3 PC points to next instruction. hackhackhack */
-                       genamode_e3 (curi->dmode, "dstreg", curi->size, "dst", 2, 0, 1 | (dualprefetch ? GF_NOREFILL : 0), curi->smode == Dreg && curi->dmode == Aind ? 2 : 0);
+                       genamode_e3 (curi->dmode, "dstreg", curi->size, "dst", 2, 0, flags, curi->smode == Dreg && curi->dmode == Aind ? 2 : 0);
                        genamode_post (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
                        if (curi->mnemo == i_MOVEA && curi->size == sz_word)
                                printf ("\tsrc = (uae_s32)(uae_s16)src;\n");
@@ -3750,3 +3753,7 @@ int main (int argc, char **argv)
        free (table68k);
        return 0;
 }
+
+void write_log (const TCHAR *format,...)
+{
+}
index af8bb052f0be88ae36744ffe284e38fb830a9236..a12ccfdda0328754159e4dd5e68d5ea42a7dea89 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * E-UAE - The portable Amiga Emulator
- *
- * Generate pixel output code.
- *
- * (c) 2006 Richard Drummond
- */
+* E-UAE - The portable Amiga Emulator
+*
+* Generate pixel output code.
+*
+* (c) 2006 Richard Drummond
+*/
 
 #include <stdlib.h>
 #include <stdarg.h>
@@ -15,70 +15,70 @@ int do_bigendian;
 
 typedef enum
 {
-    DEPTH_8BPP,
-    DEPTH_16BPP,
-    DEPTH_32BPP,
+       DEPTH_8BPP,
+       DEPTH_16BPP,
+       DEPTH_32BPP,
 } DEPTH_T;
 #define DEPTH_MAX DEPTH_32BPP
 
 static const char *get_depth_str (DEPTH_T bpp)
 {
-   if (bpp == DEPTH_8BPP)
-       return "8";
-   else if (bpp == DEPTH_16BPP)
-       return "16";
-   else
-       return "32";
+       if (bpp == DEPTH_8BPP)
+               return "8";
+       else if (bpp == DEPTH_16BPP)
+               return "16";
+       else
+               return "32";
 }
 
 static const char *get_depth_type_str (DEPTH_T bpp)
 {
-    if (bpp == DEPTH_8BPP)
-       return "uae_u8";
-    else if (bpp == DEPTH_16BPP)
-       return "uae_u16";
-    else
-       return "uae_u32";
+       if (bpp == DEPTH_8BPP)
+               return "uae_u8";
+       else if (bpp == DEPTH_16BPP)
+               return "uae_u16";
+       else
+               return "uae_u32";
 }
 
 
 typedef enum
 {
-    HMODE_NORMAL,
-    HMODE_DOUBLE,
-    HMODE_DOUBLE2X,
-    HMODE_HALVE1,
-    HMODE_HALVE1F,
-    HMODE_HALVE2,
-    HMODE_HALVE2F
+       HMODE_NORMAL,
+       HMODE_DOUBLE,
+       HMODE_DOUBLE2X,
+       HMODE_HALVE1,
+       HMODE_HALVE1F,
+       HMODE_HALVE2,
+       HMODE_HALVE2F
 } HMODE_T;
 #define HMODE_MAX HMODE_HALVE2F
 
 static const char *get_hmode_str (HMODE_T hmode)
 {
-    if (hmode == HMODE_DOUBLE)
-       return "_stretch1";
-   else if (hmode == HMODE_DOUBLE2X)
-       return "_stretch2";
-   else if (hmode == HMODE_HALVE1)
-       return "_shrink1";
-   else if (hmode == HMODE_HALVE1F)
-       return "_shrink1f";
-   else if (hmode == HMODE_HALVE2)
-       return "_shrink2";
-   else if (hmode == HMODE_HALVE2F)
-       return "_shrink2f";
-   else
-       return "";
+       if (hmode == HMODE_DOUBLE)
+               return "_stretch1";
+       else if (hmode == HMODE_DOUBLE2X)
+               return "_stretch2";
+       else if (hmode == HMODE_HALVE1)
+               return "_shrink1";
+       else if (hmode == HMODE_HALVE1F)
+               return "_shrink1f";
+       else if (hmode == HMODE_HALVE2)
+               return "_shrink2";
+       else if (hmode == HMODE_HALVE2F)
+               return "_shrink2f";
+       else
+               return "";
 }
 
 
 typedef enum
 {
-    CMODE_NORMAL,
-    CMODE_DUALPF,
-    CMODE_EXTRAHB,
-    CMODE_HAM
+       CMODE_NORMAL,
+       CMODE_DUALPF,
+       CMODE_EXTRAHB,
+       CMODE_HAM
 } CMODE_T;
 #define CMODE_MAX CMODE_HAM
 
@@ -88,415 +88,408 @@ static unsigned int outfile_indent = 0;
 
 void set_outfile (FILE *f)
 {
-    outfile = f;
+       outfile = f;
 }
 
 int set_indent (int indent)
 {
-    int old_indent = outfile_indent;
-    outfile_indent = indent;
-    return old_indent;
+       int old_indent = outfile_indent;
+       outfile_indent = indent;
+       return old_indent;
 }
 
 void outln (const char *s)
 {
-    unsigned int i;
-    for (i = 0; i < outfile_indent; i++)
-       fputc (' ', outfile);
-    fprintf (outfile, "%s\n", s);
+       unsigned int i;
+       for (i = 0; i < outfile_indent; i++)
+               fputc (' ', outfile);
+       fprintf (outfile, "%s\n", s);
 }
 
 void outlnf (const char *s, ...)
 {
-    va_list ap;
-    unsigned int i;
-    for (i = 0; i < outfile_indent; i++)
-       fputc (' ', outfile);
-    va_start (ap, s);
-    vfprintf (outfile, s, ap);
-    fputc ('\n', outfile);
+       va_list ap;
+       unsigned int i;
+       for (i = 0; i < outfile_indent; i++)
+               fputc (' ', outfile);
+       va_start (ap, s);
+       vfprintf (outfile, s, ap);
+       fputc ('\n', outfile);
 }
 
 static void out_linetoscr_decl (DEPTH_T bpp, HMODE_T hmode, int aga, int spr)
 {
-    outlnf ("static int NOINLINE linetoscr_%s%s%s%s (int spix, int dpix, int stoppos)",
-           get_depth_str (bpp),
-           get_hmode_str (hmode), aga ? "_aga" : "", spr ? "_spr" : "");
+       outlnf ("static int NOINLINE linetoscr_%s%s%s%s (int spix, int dpix, int stoppos)",
+               get_depth_str (bpp),
+               get_hmode_str (hmode), aga ? "_aga" : "", spr ? "_spr" : "");
 }
 
 static void out_linetoscr_do_srcpix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode, int spr)
 {
-    if (aga && cmode != CMODE_DUALPF) {
-       if (spr)
-           outln (     "    sprpix_val = pixdata.apixels[spix];");
-       outln (         "    spix_val = pixdata.apixels[spix] ^ xor_val;");
-    } else if (cmode != CMODE_HAM) {
-       outln (         "    spix_val = pixdata.apixels[spix];");
-       if (spr)
-           outln (     "    sprpix_val = spix_val;");
-    }
+       if (aga && cmode != CMODE_DUALPF) {
+               if (spr)
+                       outln (     "    sprpix_val = pixdata.apixels[spix];");
+               outln (         "    spix_val = pixdata.apixels[spix] ^ xor_val;");
+       } else if (cmode != CMODE_HAM) {
+               outln (         "    spix_val = pixdata.apixels[spix];");
+               if (spr)
+                       outln (     "    sprpix_val = spix_val;");
+       }
 }
 
 static void out_linetoscr_do_dstpix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode, int spr)
 {
-    if (aga && cmode == CMODE_HAM) {
-       outln (         "    dpix_val = CONVERT_RGB (ham_linebuf[spix]);");
-       if (spr)
-           outln (     "    sprpix_val = dpix_val;");
-    } else if (cmode == CMODE_HAM) {
-       outln (         "    dpix_val = xcolors[ham_linebuf[spix]];");
-       if (spr)
-           outln (     "    sprpix_val = dpix_val;");
-    } else if (aga && cmode == CMODE_DUALPF) {
-       if (spr) {
-           outlnf (    "    sprcol = render_sprites (dpix, 1, sprpix_val, %d);", aga);
-           outln (     "    if (sprcol) {");
-           outln (     "        dpix_val = colors_for_drawing.acolors[sprcol];");
-           outln (     "    } else {");
-       } else {
-           outln (     "        if (1) {");
-       }
-       outln (         "        unsigned int val = lookup[spix_val];");
-       outln (         "        if (lookup_no[spix_val] == 2)");
-       outln (         "            val += dblpfofs[bpldualpf2of];");
-       outln (         "        val ^= xor_val;");
-       outln (         "        dpix_val = colors_for_drawing.acolors[val];");
-       outln (         "    }");
-    } else if (cmode == CMODE_DUALPF) {
-       outln (         "    dpix_val = colors_for_drawing.acolors[lookup[spix_val]];");
-    } else if (aga && cmode == CMODE_EXTRAHB) {
-       outln (         "    if (spix_val >= 32 && spix_val < 64) {");
-       outln (         "        unsigned int c = (colors_for_drawing.color_regs_aga[spix_val - 32] >> 1) & 0x7F7F7F;");
-       outln (         "        dpix_val = CONVERT_RGB (c);");
-       outln (         "    } else");
-       outln (         "        dpix_val = colors_for_drawing.acolors[spix_val];");
-    } else if (cmode == CMODE_EXTRAHB) {
-       outln (         "    if (spix_val <= 31)");
-       outln (         "        dpix_val = colors_for_drawing.acolors[spix_val];");
-       outln (         "    else");
-       outln (         "        dpix_val = xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];");
-    } else
-       outln (         "    dpix_val = colors_for_drawing.acolors[spix_val];");
+       if (aga && cmode == CMODE_HAM) {
+               outln (     "    dpix_val = CONVERT_RGB (ham_linebuf[spix]);");
+               if (spr)
+                       outln ( "    sprpix_val = dpix_val;");
+       } else if (cmode == CMODE_HAM) {
+               outln (         "    dpix_val = xcolors[ham_linebuf[spix]];");
+               if (spr)
+                       outln ( "    sprpix_val = dpix_val;");
+       } else if (aga && cmode == CMODE_DUALPF) {
+               outln (     "    {");
+               outln (         "        uae_u8 val = lookup[spix_val];");
+               outln (         "        if (lookup_no[spix_val])");
+               outln (         "            val += dblpfofs[bpldualpf2of];");
+               outln (         "        val ^= xor_val;");
+               outln (         "        dpix_val = colors_for_drawing.acolors[val];");
+               outln (         "    }");
+       } else if (cmode == CMODE_DUALPF) {
+               outln (         "    dpix_val = colors_for_drawing.acolors[lookup[spix_val]];");
+       } else if (aga && cmode == CMODE_EXTRAHB) {
+               outln (         "    if (spix_val >= 32 && spix_val < 64) {");
+               outln (         "        unsigned int c = (colors_for_drawing.color_regs_aga[spix_val - 32] >> 1) & 0x7F7F7F;");
+               outln (         "        dpix_val = CONVERT_RGB (c);");
+               outln (         "    } else");
+               outln (         "        dpix_val = colors_for_drawing.acolors[spix_val];");
+       } else if (cmode == CMODE_EXTRAHB) {
+               outln (         "    if (spix_val <= 31)");
+               outln (         "        dpix_val = colors_for_drawing.acolors[spix_val];");
+               outln (         "    else");
+               outln (         "        dpix_val = xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];");
+       } else
+               outln (         "    dpix_val = colors_for_drawing.acolors[spix_val];");
 }
 
 static void out_linetoscr_do_incspix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode, int spr)
 {
-    if (hmode == HMODE_HALVE1F) {
-       outln (         "    {");
-       outln (         "    uae_u32 tmp_val;");
-       outln (         "    spix++;");
-       outln (         "    tmp_val = dpix_val;");
-       out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-       outlnf (        "    dpix_val = merge_2pixel%d (dpix_val, tmp_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
-       outln (         "    spix++;");
-       outln (         "    }");
-    } else if (hmode == HMODE_HALVE2F) {
-       outln (         "    {");
-       outln (         "    uae_u32 tmp_val, tmp_val2, tmp_val3;");
-       outln (         "    spix++;");
-       outln (         "    tmp_val = dpix_val;");
-       out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-       outln (         "    spix++;");
-       outln (         "    tmp_val2 = dpix_val;");
-       out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-       outln (         "    spix++;");
-       outln (         "    tmp_val3 = dpix_val;");
-       out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-       outlnf (        "    tmp_val = merge_2pixel%d (tmp_val, tmp_val2);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
-       outlnf (        "    tmp_val2 = merge_2pixel%d (tmp_val3, dpix_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
-       outlnf (        "    dpix_val = merge_2pixel%d (tmp_val, tmp_val2);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
-       outln (         "    spix++;");
-       outln (         "    }");
-    } else if (hmode == HMODE_HALVE1) {
-       outln (         "    spix += 2;");
-    } else if (hmode == HMODE_HALVE2) {
-       outln (         "    spix += 4;");
-    } else {
-       outln (         "    spix++;");
-    }
+       if (hmode == HMODE_HALVE1F) {
+               outln (         "    {");
+               outln (         "    uae_u32 tmp_val;");
+               outln (         "    spix++;");
+               outln (         "    tmp_val = dpix_val;");
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               outlnf (        "    dpix_val = merge_2pixel%d (dpix_val, tmp_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
+               outln (         "    spix++;");
+               outln (         "    }");
+       } else if (hmode == HMODE_HALVE2F) {
+               outln (         "    {");
+               outln (         "    uae_u32 tmp_val, tmp_val2, tmp_val3;");
+               outln (         "    spix++;");
+               outln (         "    tmp_val = dpix_val;");
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               outln (         "    spix++;");
+               outln (         "    tmp_val2 = dpix_val;");
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               outln (         "    spix++;");
+               outln (         "    tmp_val3 = dpix_val;");
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               outlnf (        "    tmp_val = merge_2pixel%d (tmp_val, tmp_val2);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
+               outlnf (        "    tmp_val2 = merge_2pixel%d (tmp_val3, dpix_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
+               outlnf (        "    dpix_val = merge_2pixel%d (tmp_val, tmp_val2);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
+               outln (         "    spix++;");
+               outln (         "    }");
+       } else if (hmode == HMODE_HALVE1) {
+               outln (         "    spix += 2;");
+       } else if (hmode == HMODE_HALVE2) {
+               outln (         "    spix += 4;");
+       } else {
+               outln (         "    spix++;");
+       }
 }
 
 static void out_sprite (DEPTH_T bpp, HMODE_T hmode, CMODE_T cmode, int aga, int cnt)
 {
-    if (aga) {
-       if (cnt == 1) {
-           outlnf ( "    if (spritepixels[dpix].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    buf[dpix++] = out_val;");
-       } else if (cnt == 2) {
-           outlnf ( "    {");
-           outlnf ( "    uae_u32 out_val1 = out_val;");
-           outlnf ( "    uae_u32 out_val2 = out_val;");
-           outlnf ( "    if (spritepixels[dpix + 0].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val1 = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    if (spritepixels[dpix + 1].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 1, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val2 = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    buf[dpix++] = out_val1;");
-           outlnf ( "    buf[dpix++] = out_val2;");
-           outlnf ( "    }");
-       } else if (cnt == 4) {
-           outlnf ( "    {");
-           outlnf ( "    uae_u32 out_val1 = out_val;");
-           outlnf ( "    uae_u32 out_val2 = out_val;");
-           outlnf ( "    uae_u32 out_val3 = out_val;");
-           outlnf ( "    uae_u32 out_val4 = out_val;");
-           outlnf ( "    if (spritepixels[dpix + 0].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val1 = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    if (spritepixels[dpix + 1].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 1, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val2 = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    if (spritepixels[dpix + 2].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 2, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val3 = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    if (spritepixels[dpix + 3].data) {");
-           outlnf ( "        sprcol = render_sprites (dpix + 3, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-           outlnf ( "        if (sprcol)");
-           outlnf ( "            out_val4 = colors_for_drawing.acolors[sprcol];");
-           outlnf ( "    }");
-           outlnf ( "    buf[dpix++] = out_val1;");
-           outlnf ( "    buf[dpix++] = out_val2;");
-           outlnf ( "    buf[dpix++] = out_val3;");
-           outlnf ( "    buf[dpix++] = out_val4;");
-           outlnf ( "    }");
+       if (aga) {
+               if (cnt == 1) {
+                       outlnf ( "    if (spritepixels[dpix].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    buf[dpix++] = out_val;");
+               } else if (cnt == 2) {
+                       outlnf ( "    {");
+                       outlnf ( "    uae_u32 out_val1 = out_val;");
+                       outlnf ( "    uae_u32 out_val2 = out_val;");
+                       outlnf ( "    if (spritepixels[dpix + 0].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val1 = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    if (spritepixels[dpix + 1].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 1, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val2 = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    buf[dpix++] = out_val1;");
+                       outlnf ( "    buf[dpix++] = out_val2;");
+                       outlnf ( "    }");
+               } else if (cnt == 4) {
+                       outlnf ( "    {");
+                       outlnf ( "    uae_u32 out_val1 = out_val;");
+                       outlnf ( "    uae_u32 out_val2 = out_val;");
+                       outlnf ( "    uae_u32 out_val3 = out_val;");
+                       outlnf ( "    uae_u32 out_val4 = out_val;");
+                       outlnf ( "    if (spritepixels[dpix + 0].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 0, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val1 = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    if (spritepixels[dpix + 1].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 1, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val2 = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    if (spritepixels[dpix + 2].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 2, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val3 = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    if (spritepixels[dpix + 3].data) {");
+                       outlnf ( "        sprcol = render_sprites (dpix + 3, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+                       outlnf ( "        if (sprcol)");
+                       outlnf ( "            out_val4 = colors_for_drawing.acolors[sprcol];");
+                       outlnf ( "    }");
+                       outlnf ( "    buf[dpix++] = out_val1;");
+                       outlnf ( "    buf[dpix++] = out_val2;");
+                       outlnf ( "    buf[dpix++] = out_val3;");
+                       outlnf ( "    buf[dpix++] = out_val4;");
+                       outlnf ( "    }");
+               }
+       } else {
+               outlnf ( "    if (spritepixels[dpix].data) {");
+               outlnf ( "        sprcol = render_sprites (dpix, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
+               outlnf ( "        if (sprcol) {");
+               outlnf ( "            uae_u32 spcol = colors_for_drawing.acolors[sprcol];");
+               outlnf ( "            out_val = spcol;");
+               outlnf ( "        }");
+               outlnf ( "    }");
+               while (cnt-- > 0)
+                       outlnf ( "    buf[dpix++] = out_val;");
        }
-    } else {
-       outlnf ( "    if (spritepixels[dpix].data) {");
-       outlnf ( "        sprcol = render_sprites (dpix, %d, sprpix_val, %d);", cmode == CMODE_DUALPF ? 1 : 0, aga);
-       outlnf ( "        if (sprcol) {");
-       outlnf ( "            uae_u32 spcol = colors_for_drawing.acolors[sprcol];");
-        outlnf ( "            out_val = spcol;");
-       outlnf ( "        }");
-       outlnf ( "    }");
-       while (cnt-- > 0)
-           outlnf ( "    buf[dpix++] = out_val;");
-    }
 }
 
 static void out_linetoscr_mode (DEPTH_T bpp, HMODE_T hmode, int aga, int spr, CMODE_T cmode)
 {
-    int old_indent = set_indent (8);
-
-    if (aga && cmode == CMODE_DUALPF) {
-       outln (        "int *lookup    = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;");
-       outln (        "int *lookup_no = bpldualpfpri ? dblpf_2nd2     : dblpf_2nd1;");
-    } else if (cmode == CMODE_DUALPF)
-       outln (        "int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;");
-
+       int old_indent = set_indent (8);
+
+       if (aga && cmode == CMODE_DUALPF) {
+               outln (        "int *lookup    = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;");
+               outln (        "int *lookup_no = bpldualpfpri ? dblpf_2nd2     : dblpf_2nd1;");
+       } else if (cmode == CMODE_DUALPF)
+               outln (        "int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;");
+
+
+       /* TODO: add support for combining pixel writes in 8-bpp modes. */
+
+       if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && spr == 0) {
+               outln (         "int rem;");
+               outln (         "if (((long)&buf[dpix]) & 2) {");
+               outln (         "    uae_u32 spix_val;");
+               outln (         "    uae_u32 dpix_val;");
+
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
+
+               outln (         "    buf[dpix++] = dpix_val;");
+               outln (         "}");
+               outln (         "if (dpix >= stoppos)");
+               outln (         "    return spix;");
+               outln (         "rem = (((long)&buf[stoppos]) & 2);");
+               outln (         "if (rem)");
+               outln (         "    stoppos--;");
+       }
 
-    /* TODO: add support for combining pixel writes in 8-bpp modes. */
 
-    if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && spr == 0) {
-       outln (         "int rem;");
-       outln (         "if (((long)&buf[dpix]) & 2) {");
+       outln (         "while (dpix < stoppos) {");
+       if (spr)
+               outln (         "    uae_u32 sprpix_val;");
        outln (         "    uae_u32 spix_val;");
        outln (         "    uae_u32 dpix_val;");
+       outln (         "    uae_u32 out_val;");
+       outln (         "");
 
        out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
        out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
        out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
 
-       outln (         "    buf[dpix++] = dpix_val;");
-       outln (         "}");
-       outln (         "if (dpix >= stoppos)");
-       outln (         "    return spix;");
-       outln (         "rem = (((long)&buf[stoppos]) & 2);");
-       outln (         "if (rem)");
-       outln (         "    stoppos--;");
-    }
+       outln (         "    out_val = dpix_val;");
 
+       if (hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && bpp == DEPTH_16BPP && spr == 0) {
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
 
-    outln (            "while (dpix < stoppos) {");
-    if (spr)
-       outln (         "    uae_u32 sprpix_val;");
-    outln (            "    uae_u32 spix_val;");
-    outln (            "    uae_u32 dpix_val;");
-    outln (            "    uae_u32 out_val;");
-    outln (            "");
-
-    out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-    out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-    out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
-
-    outln (            "    out_val = dpix_val;");
-
-    if (hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && bpp == DEPTH_16BPP && spr == 0) {
-       out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
-
-       if (do_bigendian)
-           outln (     "    out_val = (out_val << 16) | (dpix_val & 0xFFFF);");
-       else
-           outln (     "    out_val = (out_val & 0xFFFF) | (dpix_val << 16);");
-    }
-
-    if (hmode == HMODE_DOUBLE) {
-       if (bpp == DEPTH_8BPP) {
-           outln (     "    *((uae_u16 *)&buf[dpix]) = (uae_u16) out_val;");
-           outln (     "    dpix += 2;");
-       } else if (bpp == DEPTH_16BPP) {
-           if (spr) {
-               out_sprite (bpp, hmode, cmode, aga, 2);
-           } else {
-               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
-               outln ( "    dpix += 2;");
-           }
-       } else {
-           if (spr) {
-               out_sprite (bpp, hmode, cmode, aga, 2);
-           } else {
-               outln ( "    buf[dpix++] = out_val;");
-               outln ( "    buf[dpix++] = out_val;");
-           }
-       }
-    } else if (hmode == HMODE_DOUBLE2X) {
-       if (bpp == DEPTH_8BPP) {
-           outln (     "    *((uae_u32 *)&buf[dpix]) = (uae_u32) out_val;");
-           outln (     "    dpix += 4;");
-       } else if (bpp == DEPTH_16BPP) {
-           if (spr) {
-               out_sprite (bpp, hmode, cmode, aga, 4);
-           } else {
-               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
-               outln ( "    dpix += 2;");
-               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
-               outln ( "    dpix += 2;");
-           }
-       } else {
-           if (spr) {
-               out_sprite (bpp, hmode, cmode, aga, 4);
-           } else {
-               outln ( "    buf[dpix++] = out_val;");
-               outln ( "    buf[dpix++] = out_val;");
-               outln ( "    buf[dpix++] = out_val;");
-               outln ( "    buf[dpix++] = out_val;");
-           }
+               if (do_bigendian)
+                       outln ( "    out_val = (out_val << 16) | (dpix_val & 0xFFFF);");
+               else
+                       outln ( "    out_val = (out_val & 0xFFFF) | (dpix_val << 16);");
        }
-    } else {
-       if (bpp == DEPTH_16BPP) {
-           if (spr) {
-               out_sprite (bpp, hmode, cmode, aga, 1);
-           } else {
-               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
-               outln ( "    dpix += 2;");
-           }
+
+       if (hmode == HMODE_DOUBLE) {
+               if (bpp == DEPTH_8BPP) {
+                       outln ( "    *((uae_u16 *)&buf[dpix]) = (uae_u16) out_val;");
+                       outln ( "    dpix += 2;");
+               } else if (bpp == DEPTH_16BPP) {
+                       if (spr) {
+                               out_sprite (bpp, hmode, cmode, aga, 2);
+                       } else {
+                               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
+                               outln ( "    dpix += 2;");
+                       }
+               } else {
+                       if (spr) {
+                               out_sprite (bpp, hmode, cmode, aga, 2);
+                       } else {
+                               outln ( "    buf[dpix++] = out_val;");
+                               outln ( "    buf[dpix++] = out_val;");
+                       }
+               }
+       } else if (hmode == HMODE_DOUBLE2X) {
+               if (bpp == DEPTH_8BPP) {
+                       outln ( "    *((uae_u32 *)&buf[dpix]) = (uae_u32) out_val;");
+                       outln ( "    dpix += 4;");
+               } else if (bpp == DEPTH_16BPP) {
+                       if (spr) {
+                               out_sprite (bpp, hmode, cmode, aga, 4);
+                       } else {
+                               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
+                               outln ( "    dpix += 2;");
+                               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
+                               outln ( "    dpix += 2;");
+                       }
+               } else {
+                       if (spr) {
+                               out_sprite (bpp, hmode, cmode, aga, 4);
+                       } else {
+                               outln ( "    buf[dpix++] = out_val;");
+                               outln ( "    buf[dpix++] = out_val;");
+                               outln ( "    buf[dpix++] = out_val;");
+                               outln ( "    buf[dpix++] = out_val;");
+                       }
+               }
        } else {
-           if (spr) {
-               out_sprite (bpp, hmode, cmode, aga, 1);
-           } else {
-               outln ( "    buf[dpix++] = out_val;");
-           }
+               if (bpp == DEPTH_16BPP) {
+                       if (spr) {
+                               out_sprite (bpp, hmode, cmode, aga, 1);
+                       } else {
+                               outln ( "    *((uae_u32 *)&buf[dpix]) = out_val;");
+                               outln ( "    dpix += 2;");
+                       }
+               } else {
+                       if (spr) {
+                               out_sprite (bpp, hmode, cmode, aga, 1);
+                       } else {
+                               outln ( "    buf[dpix++] = out_val;");
+                       }
+               }
        }
-    }
 
-    outln (            "}");
+       outln (         "}");
 
 
-    if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && spr == 0) {
-       outln (         "if (rem) {");
-       outln (         "    uae_u32 spix_val;");
-       outln (         "    uae_u32 dpix_val;");
+       if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE && hmode != HMODE_DOUBLE2X && spr == 0) {
+               outln (         "if (rem) {");
+               outln (         "    uae_u32 spix_val;");
+               outln (         "    uae_u32 dpix_val;");
 
-       out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
-       out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_srcpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_dstpix (bpp, hmode, aga, cmode, spr);
+               out_linetoscr_do_incspix (bpp, hmode, aga, cmode, spr);
 
-       outln (         "    buf[dpix++] = dpix_val;");
-       outln (         "}");
-    }
+               outln (         "    buf[dpix++] = dpix_val;");
+               outln (         "}");
+       }
 
-    set_indent (old_indent);
+       set_indent (old_indent);
 
-    return;
+       return;
 }
 
 static void out_linetoscr (DEPTH_T bpp, HMODE_T hmode, int aga, int spr)
 {
-    if (aga)
-       outln  ("#ifdef AGA");
-
-    out_linetoscr_decl (bpp, hmode, aga, spr);
-    outln  (   "{");
-
-    outlnf (   "    %s *buf = (%s *) xlinebuffer;", get_depth_type_str (bpp), get_depth_type_str (bpp));
-    if (spr)
-       outln ( "    uae_u8 sprcol;");
-    if (aga)
-       outln ( "    uae_u8 xor_val = bplxor;");
-    outln  (   "");
-
-    outln  (   "    if (dp_for_drawing->ham_seen) {");
-    out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_HAM);
-    outln  (   "    } else if (bpldualpf) {");
-    out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_DUALPF);
-    outln  (   "    } else if (bplehb) {");
-    out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_EXTRAHB);
-    outln  (   "    } else {");
-    out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_NORMAL);
-
-    outln  (   "    }\n");
-    outln  (   "    return spix;");
-    outln  (   "}");
-
-    if (aga)
-       outln ( "#endif");
-    outln  (   "");
+       if (aga)
+               outln  ("#ifdef AGA");
+
+       out_linetoscr_decl (bpp, hmode, aga, spr);
+       outln  (        "{");
+
+       outlnf (        "    %s *buf = (%s *) xlinebuffer;", get_depth_type_str (bpp), get_depth_type_str (bpp));
+       if (spr)
+               outln ( "    uae_u8 sprcol;");
+       if (aga)
+               outln ( "    uae_u8 xor_val = bplxor;");
+       outln  (        "");
+
+       outln  (        "    if (dp_for_drawing->ham_seen) {");
+       out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_HAM);
+       outln  (        "    } else if (bpldualpf) {");
+       out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_DUALPF);
+       outln  (        "    } else if (bplehb) {");
+       out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_EXTRAHB);
+       outln  (        "    } else {");
+       out_linetoscr_mode (bpp, hmode, aga, spr, CMODE_NORMAL);
+
+       outln  (        "    }\n");
+       outln  (        "    return spix;");
+       outln  (        "}");
+
+       if (aga)
+               outln ( "#endif");
+       outln  (        "");
 }
 
 int main (int argc, char *argv[])
 {
-   DEPTH_T bpp;
-   int aga, spr;
-   HMODE_T hmode;
-   unsigned int i;
-
-    do_bigendian = 0;
-
-    for (i = 1; i < argc; i++) {
-       if (argv[i][0] != '-')
-           continue;
-       if (argv[i][1] == 'b' && argv[i][2] == '\0')
-           do_bigendian = 1;
-    }
-
-   set_outfile (stdout);
-
-   outln ("/*");
-   outln (" * E-UAE - The portable Amiga emulator.");
-   outln (" *");
-   outln (" * This file was generated by genlinetoscr. Don't edit.");
-   outln (" */");
-   outln ("");
-
-   for (bpp = DEPTH_8BPP; bpp <= DEPTH_MAX; bpp++) {
-       for (aga = 0; aga <= 1 ; aga++) {
-           if (aga && bpp == DEPTH_8BPP)
-               continue;
-           for (spr = 0; spr <= 1; spr++) {
-               for (hmode = HMODE_NORMAL; hmode <= HMODE_MAX; hmode++)
-                   out_linetoscr (bpp, hmode, aga, spr);
-           }
+       DEPTH_T bpp;
+       int aga, spr;
+       HMODE_T hmode;
+       unsigned int i;
+
+       do_bigendian = 0;
+
+       for (i = 1; i < argc; i++) {
+               if (argv[i][0] != '-')
+                       continue;
+               if (argv[i][1] == 'b' && argv[i][2] == '\0')
+                       do_bigendian = 1;
+       }
+
+       set_outfile (stdout);
+
+       outln ("/*");
+       outln (" * E-UAE - The portable Amiga emulator.");
+       outln (" *");
+       outln (" * This file was generated by genlinetoscr. Don't edit.");
+       outln (" */");
+       outln ("");
+
+       for (bpp = DEPTH_8BPP; bpp <= DEPTH_MAX; bpp++) {
+               for (aga = 0; aga <= 1 ; aga++) {
+                       if (aga && bpp == DEPTH_8BPP)
+                               continue;
+                       for (spr = 0; spr <= 1; spr++) {
+                               for (hmode = HMODE_NORMAL; hmode <= HMODE_MAX; hmode++)
+                                       out_linetoscr (bpp, hmode, aga, spr);
+                       }
+               }
        }
-    }
-    return 0;
+       return 0;
 }
index 9ca6a1de2ac1b19dbdf537caef99ca925ed9cf3f..d4f7fdde986bd67e34f5b30db1ab84cda64e4e36 100644 (file)
@@ -88,6 +88,8 @@ struct dma_rec
 #define DMA_EVENT_BLITFINISHED 4
 #define DMA_EVENT_BPLFETCHUPDATE 8
 #define DMA_EVENT_COPPERWAKE 16
+#define DMA_EVENT_CPUIRQ 32
+#define DMA_EVENT_INTREQ 64
 
 #define DMARECORD_REFRESH 1
 #define DMARECORD_CPU 2
index 367b2b3f14da9a45a36eceea21c045f9a9e64895..9a2e188a753f0819684d5070409260c4e1cd0044 100644 (file)
@@ -1221,7 +1221,7 @@ static void inputdevice_mh_abs (int x, int y)
        off = getmhoffset ();
        p = rtarea + off;
 
-       memcpy (tmp, p + MH_ABSX, 4);
+       memcpy (tmp, p + MH_ABSX, sizeof tmp);
 
        x -= mouseoffset_x + 1;
        y -= mouseoffset_y + 2;
@@ -1231,7 +1231,7 @@ static void inputdevice_mh_abs (int x, int y)
        p[MH_ABSY] = y >> 8;
        p[MH_ABSY + 1] = y;
 
-       if (!memcmp (tmp, p + MH_ABSX, 4))
+       if (!memcmp (tmp, p + MH_ABSX, sizeof tmp))
                return;
        rtarea[off + MH_E] = 0xc0 | 1;
        p[MH_CNT]++;
@@ -1936,8 +1936,8 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor)
                        potgor |= potgo_value & p5dat;
                        if (!(potgo_value & p9dir))
                                potgor |= p9dat;
-                       /* P5 output and 1 -> shift register is kept reset (Blue button) */
-                       if ((potgo_value & p5dir) && (potgo_value & p5dat))
+                       /* (P5 output and 1) or floating -> shift register is kept reset (Blue button) */
+                       if (!(potgo_value & p5dir) || ((potgo_value & p5dat) && (potgo_value & p5dir)))
                                cd32_shifter[i] = 8;
                        /* shift at 1 == return one, >1 = return button states */
                        if (cd32_shifter[i] == 0)
@@ -2034,7 +2034,7 @@ void POTGO (uae_u16 v)
                if (cd32_pad_enabled[i]) {
                        uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
                        uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
-                       if ((potgo_value & p5dir) && (potgo_value & p5dat))
+                       if (!(potgo_value & p5dir) || ((potgo_value & p5dat) && (potgo_value & p5dir)))
                                cd32_shifter[i] = 8;
                }
        }
@@ -4233,6 +4233,9 @@ void setmousestate (int mouse, int axis, int data, int isabs)
        mouse_p = &mouse_axis[mouse][axis];
        oldm_p = &oldm_axis[mouse][axis];
        if (!isabs) {
+               // eat relative movements while in mousehack mode
+               if (currprefs.input_tablet == TABLET_MOUSEHACK && mousehack_alive ())
+                       return;
                *oldm_p = *mouse_p;
                *mouse_p += data;
                d = (*mouse_p - *oldm_p) * currprefs.input_mouse_speed / 100.0;
index a09dfc2739281a9bdd55b8eb98f6a58cb9ae559b..6c6047347fc8f9f1d1cdfdc1c922010973bea16e 100644 (file)
--- a/newcpu.c
+++ b/newcpu.c
@@ -1353,10 +1353,10 @@ Illegal Instruction:
 Interrupt cycle diagram:
 
 - 6 idle cycles
-- read exception number byte from (0xfffff1 | (interrupt number << 1))
 - write PC low word
-- write SR
+- read exception number byte from (0xfffff1 | (interrupt number << 1))
 - 4 idle cycles
+- write SR
 - write PC high word
 - read exception address high word
 - read exception address low word
@@ -1384,10 +1384,6 @@ static void Exception_ce000 (int nr, uaecptr oldpc)
        if (start)
                do_cycles_ce000 (start);
 
-       if (interrupt) { // fetch interrupt vector number
-               nr = get_byte_ce (0x00fffff1 | ((nr - 24) << 1));
-       }
-
        exception_debug (nr);
        MakeSR ();
 
@@ -1414,9 +1410,12 @@ static void Exception_ce000 (int nr, uaecptr oldpc)
        }
        m68k_areg (regs, 7) -= 6;
        put_word_ce (m68k_areg (regs, 7) + 4, currpc); // write low address
-       put_word_ce (m68k_areg (regs, 7) + 0, regs.sr); // write SR
-       if (interrupt)
+       if (interrupt) {
+               // fetch interrupt vector number
+               nr = get_byte_ce (0x00fffff1 | ((nr - 24) << 1));
                do_cycles_ce000 (4);
+       }
+       put_word_ce (m68k_areg (regs, 7) + 0, regs.sr); // write SR
        put_word_ce (m68k_areg (regs, 7) + 2, currpc >> 16); // write high address
 kludge_me_do:
        newpc = get_word_ce (4 * nr) << 16; // read high address
@@ -1762,6 +1761,9 @@ void REGPARAM2 Exception (int nr, uaecptr oldpc)
 
 STATIC_INLINE void do_interrupt (int nr)
 {
+       if (debug_dma)
+               record_dma_event (DMA_EVENT_CPUIRQ, current_hpos (), vpos);
+
        regs.stopped = 0;
        unset_special (SPCFLAG_STOP);
        assert (nr < 8 && nr >= 0);
index 6cb3d85e03f13c15fa919ee6f848508941921751..ec69e798af4181cb39a68a61ebd2fbdb4602bb82 100644 (file)
@@ -850,7 +850,7 @@ static int open_bus (int flags)
        if (log_scsi)
                write_log (L"IOCTL: drive mask = %08X\n", dwDriveMask);
        dwDriveMask >>= 2; // Skip A and B drives...
-       for( drive = 'C'; drive <= 'Z'; drive++) {
+       for (drive = 'C'; drive <= 'Z' && total_devices < MAX_TOTAL_DEVICES; drive++) {
                if (dwDriveMask & 1) {
                        int dt;
                        _stprintf (tmp, L"%c:\\", drive);
@@ -918,6 +918,8 @@ void win32_ioctl_media_change (TCHAR driveletter, int insert)
 
 static struct device_scsi_info *ioctl_scsi_info (int unitnum, struct device_scsi_info *dsi)
 {
+       if (!unitcheck (unitnum))
+               return 0;
        dsi->buffer = ciw32[unitnum].tempbuffer;
        dsi->bufsize = IOCTL_DATA_BUFFER;
        return dsi;
index b0fe5913e335ae57fe2998582bc41833d3218e21..7f716796ac8e80c688d8f22d88de39352f9747f3 100644 (file)
@@ -163,7 +163,7 @@ char *ua_fs (const WCHAR *s, int defchar)
        dc = FALSE;
        len = WideCharToMultiByte (fscodepage, DWFLAGS | WC_NO_BEST_FIT_CHARS, s, -1, NULL, 0, &def, &dc);
        if (!len) {
-               err (__FUNCTION__, s, NULL, currprefs.win32_fscodepage);
+               err (__FUNCTION__, s, NULL, fscodepage);
                return strdup ("");
        }
        d = xmalloc (len + 1);
@@ -274,6 +274,7 @@ static void mbtwc (UINT cp, DWORD flags, LPCSTR src, int len, LPWSTR dst, int ma
 
 void unicode_init (void)
 {
+       // iso-8859-15,iso-8859-1,windows-1252,default ansi
        static UINT pages[] = { 28605, 28591, 1252, 0 };
        int i;
 
@@ -294,7 +295,7 @@ void unicode_init (void)
                dst2[1] = 0;
                aufstable[i] = 0;
                mbtwc (CP_ACP, 0, src, 1, dst1, 1);
-               mbtwc (fscodepage, 0, src, 1, dst2, 1);// iso-8859-15
+               mbtwc (fscodepage, 0, src, 1, dst2, 1);
                if (dst2[0] != dst1[0])
                        write_log (L" %02X: %04X (%04X)", i, dst1[0], dst2[0]);
                else
index bd01fe3e039ab932c72f680c9df23d65fee33ba5..7754e1bccbe105c74332de8a5e5569b6e891b4c8 100644 (file)
@@ -1999,7 +1999,7 @@ void logging_init (void)
                SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision,
                SystemInfo.dwNumberOfProcessors);
        write_log (L"\n(c) 1995-2001 Bernd Schmidt   - Core UAE concept and implementation."
-               L"\n(c) 1998-2009 Toni Wilen      - Win32 port, core code updates."
+               L"\n(c) 1998-2010 Toni Wilen      - Win32 port, core code updates."
                L"\n(c) 1996-2001 Brian King      - Win32 port, Picasso96 RTG, and GUI."
                L"\n(c) 1996-1999 Mathias Ortmann - Win32 port and bsdsocket support."
                L"\n(c) 2000-2001 Bernd Meyer     - JIT engine."
index 7da9678e7b609a0433560bac9e417827bfe86245..6e3c1a783b1162b7e8fd1a7c0d11bda6e494ba6c 100644 (file)
@@ -18,8 +18,8 @@
 #define WINUAEPUBLICBETA 1
 #define LANG_DLL 1
 
-#define WINUAEBETA L"Beta 1"
-#define WINUAEDATE MAKEBD(2010, 1, 2)
+#define WINUAEBETA L"Beta 2"
+#define WINUAEDATE MAKEBD(2010, 1, 9)
 #define WINUAEEXTRA L""
 #define WINUAEREV L""
 
index ec179b6938b8d0809fd9c762ce7c5c7f4cd944a2..d1a0e1ec8d6704ef4b11fbc35a79cc96a807cfe5 100644 (file)
@@ -458,7 +458,7 @@ UAEREG *read_disk_history (void)
                if (_tcslen (tmp) == 7) {
                        idx2 = _tstol (tmp + 5) - 1;
                        if (idx2 >= 0)
-                               DISK_history_add (tmp2, idx2, 0);
+                               DISK_history_add (tmp2, idx2, TRUE);
                }
                idx++;
        }
index a37c7b57db63c064a5d3611b8560c4ec35b3d8aa..cb775d68eac8d863670b6ffb0be2bd324b32e15d 100644 (file)
@@ -1,4 +1,22 @@
 
+Beta 2:
+
+- ioctl cd drive detection corrupted memory if more than 8 drives
+  found
+- removed remains of old and wrong OCS Denise "bug" emulation
+- 2.0.1 OCS Denise update diw counting bug fixed (Stardust map selector)
+- eat relative mouse movements while mouse driver mode is active
+- "blitter active while saving state" compatibility updates
+- fixed buffer underflow in sprite code if sprite was really far and
+  hidden in left border, it overwrote part of dual playfield priority
+  tables causing weird effects in dpf modes (Shadow Fighter AGA)
+- removed some code duplication from dpf mode genlinetoscr.c
+- prowizard promizer18a update (Asle)
+- CD32 pad emulation improved, CD32 Roadkill "non-standard" way of
+  reading buttons works now
+- do not scan files in floppy history at startup (=scan and add
+  possible disk images inside archives)
+
 Beta 1:
 
 - prowizard is now in static link library (no functional changes)
index 678ad1672804015afca46af1a33dcc77b3362765..5ad64b78763a42d2edc28af61193936a8e8ef470 100644 (file)
@@ -82,6 +82,9 @@ void Rip_PM18a ( void )
  * update 20 mar 2003 (it's war time again .. brrrr)
  * - removed all open() funcs.
  * - optimized more than quite a bit (src is 5kb shorter !)
+ *
+ * update 07 jan 2010
+ * - bug fix in patternlist generation
 */
 
 #define ON  0
@@ -109,6 +112,8 @@ void Depack_PM18a ( void )
   long Where = PW_Start_Address;
   Uchar *WholePatternData;
   FILE *out;
+  /*FILE *info;*/
+  /*info = fopen ("info.txt","w+b");*/
 
   #include "tuning.h"
   fillPTKtable(poss);
@@ -123,20 +128,27 @@ void Depack_PM18a ( void )
   BZERO ( OldSmpValue , 4 );
   BZERO ( Pats_Address , 128*4 );
 
-  Whatever = (Uchar *) malloc (128);
-  BZERO (Whatever, 128);
+  Whatever = (Uchar *) malloc (1085);
+  BZERO (Whatever, 1085);
   /* title */
-  fwrite ( &Whatever[0] , 20 , 1 , out );
+  /*fwrite ( &Whatever[0] , 20 , 1 , out );*/
 
   /* bypass replaycode routine */
   Where = PW_Start_Address + 4464;
 
   for ( i=0 ; i<31 ; i++ )
   {
-    
     /*sample name*/
-    fwrite ( &Whatever[32] , 22 , 1 , out );
-    fwrite ( &in_data[Where], 8, 1, out );
+    /*fwrite ( &Whatever[32] , 22 , 1 , out );*/
+    Whatever[42+30*i] = in_data[Where];
+    Whatever[43+30*i] = in_data[Where+1];
+    Whatever[44+30*i] = in_data[Where+2];
+    Whatever[45+30*i] = in_data[Where+3];
+    Whatever[46+30*i] = in_data[Where+4];
+    Whatever[47+30*i] = in_data[Where+5];
+    Whatever[48+30*i] = in_data[Where+6];
+    Whatever[49+30*i] = in_data[Where+7];
+    /*fwrite ( &in_data[Where], 8, 1, out );*/
 
     Total_Sample_Size += (((in_data[Where]*256)+in_data[Where+1])*2);
     Smp_Fine_Table[i] = in_data[Where+2];
@@ -145,25 +157,33 @@ void Depack_PM18a ( void )
 
   /* pattern table lenght */
   NOP = ((in_data[Where]*256)+in_data[Where+1])/4;
-  fwrite ( &NOP , 1 , 1 , out );
+  /*fwrite ( &NOP , 1 , 1 , out );*/
+  Whatever[950] = NOP;
   Where += 2;
 
   /*printf ( "Number of patterns : %d\n" , NOP );*/
 
   /* NoiseTracker restart byte */
-  Whatever[0] = 0x7f;
-  fwrite ( &Whatever[0] , 1 , 1 , out );
+  /*Whatever[0] = 0x7f;*/
+  /*fwrite ( &Whatever[0] , 1 , 1 , out );*/
+  Whatever[951] = 0x7f;
 
   for ( i=0 ; i<128 ; i++ )
   {
-    Pats_Address[i] = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3];
+    Pats_Address[i] = (in_data[Where]*256*256*256)+
+                      (in_data[Where+1]*256*256)+
+                      (in_data[Where+2]*256)+
+                      in_data[Where+3];
     Where += 4;
   }
 
 
   /* a little pre-calc code ... no other way to deal with these unknown pattern data sizes ! :( */
   Where = PW_Start_Address + 4460;
-  PatDataSize = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3];
+  PatDataSize = (in_data[Where]*256*256*256)+
+                (in_data[Where+1]*256*256)+
+                (in_data[Where+2]*256)+
+                in_data[Where+3];
   /* go back to pattern data starting address */
   Where = PW_Start_Address + 5226;
   /* now, reading all pattern data to get the max value of note */
@@ -193,11 +213,11 @@ void Depack_PM18a ( void )
   i=0;
   for ( j=0 ; j<PatDataSize ; j+=2 )
   {
-    if ( (i%1024) == 0 )
+    if ( ((i%1024) == 0 ) || (i == 0))
     {
       Read_Pats_Address[c1] = j;
-      c1 += 0x01;
       /*fprintf ( info, " -> new pattern %2d (addy :%ld)\n", c1, j+5226 );*/
+      c1 += 0x01;
     }
 
     m = ((WholePatternData[j]*256)+WholePatternData[j+1])*4;
@@ -237,7 +257,7 @@ void Depack_PM18a ( void )
       /*fprintf ( info, "\n -> bypassing end of pattern" );*/
       FLAG=OFF;
       while ( (i%1024) != 0)
-       i ++;
+           i ++;
       i -= 4;
     }
     k += 1;
@@ -248,24 +268,29 @@ void Depack_PM18a ( void )
   free ( WholePatternData );
 
   /* write pattern table */
-  BZERO ( Whatever, 128 );
+  /*BZERO ( Whatever, 128 );*/
   for ( c2=0; c2<128 ; c2+=0x01 )
-    for ( i=0 ; i<NOP ; i++ )
+    for ( i=0 ; i<c1 ; i++ )
       if ( Pats_Address[c2] == Read_Pats_Address[i])
-       Whatever[c2] = (Uchar) i;
-  while ( i<128 )
-    Whatever[i++] = 0x00;
-  fwrite ( &Whatever[0], 128, 1, out );
+           Whatever[952+c2] = (Uchar) i;
+  while ( NOP<128 )
+  {
+    Whatever[952+NOP] = 0x00;
+    NOP++;
+  }
+  /*fwrite ( &Whatever[0], 128, 1, out );*/
 
   /* write tag */
-  Whatever[0] = 'M';
-  Whatever[1] = '.';
-  Whatever[2] = 'K';
+  Whatever[1080] = 'M';
+  Whatever[1081] = '.';
+  Whatever[1082] = 'K';
+  Whatever[1083] = '.';
 
-  fwrite ( &Whatever[0] , 1 , 1 , out );
+  /*fwrite ( &Whatever[0] , 1 , 1 , out );
   fwrite ( &Whatever[1] , 1 , 1 , out );
   fwrite ( &Whatever[2] , 1 , 1 , out );
-  fwrite ( &Whatever[1] , 1 , 1 , out );
+  fwrite ( &Whatever[1] , 1 , 1 , out );*/
+  fwrite (Whatever, 1, 1084, out);
 
   free ( Whatever );
 
@@ -289,6 +314,7 @@ void Depack_PM18a ( void )
 
   fflush ( out );
   fclose ( out );
+  /*fclose (info);*/
 
   printf ( "done\n" );
   return; /* useless ... but */