--- uae/src/custom.c 2018/04/24 17:02:10 1.1.1.16 +++ uae/src/custom.c 2018/04/24 17:05:47 1.1.1.18 @@ -1452,6 +1452,12 @@ STATIC_INLINE void decide_line (int hpos * but the new color has not been entered into the table yet. */ static void record_color_change (int hpos, int regno, unsigned long value) { + if (regno == -1 && value) { + thisline_decision.ham_seen = 1; + if (hpos < 0x18) + thisline_decision.ham_at_start = 1; + } + /* Early positions don't appear on-screen. */ if (framecnt != 0 || vpos < minfirstline || hpos < 0x18 /*|| currprefs.emul_accuracy == 0*/) @@ -1899,6 +1905,8 @@ static void reset_decisions (void) thisline_decision.plfleft = -1; thisline_decision.plflinelen = -1; + thisline_decision.ham_seen = !! (bplcon0 & 0x800); + thisline_decision.ham_at_start = !! (bplcon0 & 0x800); /* decided_res shouldn't be touched before it's initialized by decide_line(). */ thisline_decision.diwfirstword = -1; @@ -1989,14 +1997,14 @@ static void calcdiw (void) #if 0 /* This happens far too often. */ if (plffirstline < minfirstline) { - fprintf(stderr, "Warning: Playfield begins before line %d!\n", minfirstline); + write_log ("Warning: Playfield begins before line %d!\n", minfirstline); plffirstline = minfirstline; } #endif #if 0 /* Turrican does this */ if (plflastline > 313) { - fprintf (stderr, "Warning: Playfield out of range!\n"); + write_log ("Warning: Playfield out of range!\n"); plflastline = 313; } #endif @@ -2056,13 +2064,22 @@ static uae_u32 mousehack_helper (void) #ifdef PICASSO96 if (picasso_on) { - mousexpos = lastmx - picasso96_state.XOffset; - mouseypos = lastmy - picasso96_state.YOffset; + picasso_clip_mouse (&lastmx, &lastmy); + mousexpos = lastmx; + mouseypos = lastmy; } else #endif { + /* @@@ This isn't completely right, it doesn't deal with virtual + screen sizes larger than physical very well. */ if (lastmy >= gfxvidinfo.height) lastmy = gfxvidinfo.height - 1; + if (lastmy < 0) + lastmy = 0; + if (lastmx < 0) + lastmx = 0; + if (lastmx >= gfxvidinfo.width) + lastmx = gfxvidinfo.width - 1; mouseypos = coord_native_to_amiga_y (lastmy) << 1; mousexpos = coord_native_to_amiga_x (lastmx); } @@ -2331,22 +2348,10 @@ static void DMACON (int hpos, uae_u16 v) if (cdp->dmaen == chan_ena) continue; cdp->dmaen = chan_ena; - if (cdp->dmaen) { - if (cdp->state == 0) { - cdp->state = 1; - cdp->pt = cdp->lc; - cdp->wper = cdp->per; - cdp->wlen = cdp->len; - cdp->data_written = 2; - cdp->evtime = eventtab[ev_hsync].evtime - get_cycles (); - } - } else { - if (cdp->state == 1 || cdp->state == 5) { - cdp->state = 0; - cdp->last_sample = 0; - cdp->current_sample = 0; - } - } + if (cdp->dmaen) + audio_channel_enable_dma (cdp); + else + audio_channel_disable_dma (cdp); } schedule_audio (); } @@ -2358,7 +2363,7 @@ static void DMACON (int hpos, uae_u16 v) STATIC_INLINE void INTENA (uae_u16 v) { /* if (trace_intena) - fprintf (stderr, "INTENA: %04x\n", v);*/ + write_log ("INTENA: %04x\n", v);*/ setclr (&intena,v); /* There's stupid code out there that does [some INTREQ bits at level 3 are set] @@ -2410,7 +2415,8 @@ static void ADKCON (uae_u16 v) static void BEAMCON0 (uae_u16 v) { - new_beamcon0 = v & 0x20; + if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) + new_beamcon0 = v & 0x20; } static void BPLPTH (int hpos, uae_u16 v, int num) @@ -2438,6 +2444,11 @@ static void BPLCON0 (int hpos, uae_u16 v decide_line (hpos); decide_fetch (hpos); + /* HAM change? */ + if ((bplcon0 ^ v) & 0x800) { + record_color_change (hpos, -1, !! (v & 0x800)); + } + bplcon0 = v; curr_diagram = cycle_diagram_table[fetchmode][GET_RES(bplcon0)][GET_PLANES (v)]; @@ -3566,7 +3577,7 @@ static void adjust_array_sizes (void) if (p1) sprite_entries[0] = p1; if (p2) sprite_entries[1] = p2; if (p1 && p2) { - fprintf (stderr, "new max_sprite_entry=%d\n",mcc); + write_log ("new max_sprite_entry=%d\n",mcc); max_sprite_entry = mcc; } } @@ -3579,7 +3590,7 @@ static void adjust_array_sizes (void) if (p1) color_changes[0] = p1; if (p2) color_changes[1] = p2; if (p1 && p2) { - fprintf (stderr, "new max_color_change=%d\n",mcc); + write_log ("new max_color_change=%d\n",mcc); max_color_change = mcc; } } @@ -3663,8 +3674,10 @@ static void vsync_handler (void) if (bplcon0 & 4) lof ^= 0x8000; +#ifdef PICASSO96 if (picasso_on) picasso_handle_vsync (); +#endif vsync_handle_redraw (lof, lof_changed); if (quit_program > 0) @@ -3765,12 +3778,12 @@ static void hsync_handler (void) update_audio (); /* Sound data is fetched at the beginning of each line */ - for (nr = 0; nr < 6; nr++) { + for (nr = 0; nr < 4; nr++) { struct audio_channel_data *cdp = audio_channel + nr; if (cdp->data_written == 2) { cdp->data_written = 0; - cdp->nextdat = chipmem_wget(cdp->pt); + cdp->nextdat = chipmem_wget (cdp->pt); cdp->pt += 2; if (cdp->state == 2 || cdp->state == 3) { if (cdp->wlen == 1) { @@ -4024,7 +4037,7 @@ void customreset (void) v = bplcon0; BPLCON0 (0, 0); BPLCON0 (0, v); - FMODE (v); + FMODE (fmode); if (!(currprefs.chipset_mask & CSMASK_AGA)) { for(i = 0 ; i < 32 ; i++) { vv = current_colors.color_regs_ecs[i]; @@ -4044,6 +4057,8 @@ void customreset (void) current_colors.acolors[i] = CONVERT_RGB(vv); } } + CLXCON (clxcon); + CLXCON2 (clxcon2); calcdiw (); write_log ("State restored\n"); dumpcustom (); @@ -4066,7 +4081,7 @@ void dumpcustom (void) if (total_skipped) write_log ("Skipped frames: %d\n", total_skipped); } - /*for (i=0; i<256; i++) if (blitcount[i]) fprintf (stderr, "minterm %x = %d\n",i,blitcount[i]); blitter debug */ + /*for (i=0; i<256; i++) if (blitcount[i]) write_log ("minterm %x = %d\n",i,blitcount[i]); blitter debug */ } int intlev (void) @@ -4129,11 +4144,11 @@ void custom_init (void) pos = here (); - org (0xF0FF70); + org (RTAREA_BASE+0xFF70); calltrap (deftrap (mousehack_helper)); dw (RTS); - org (0xF0FFA0); + org (RTAREA_BASE+0xFFA0); calltrap (deftrap (timehack_helper)); dw (RTS); @@ -4336,6 +4351,7 @@ void REGPARAM2 custom_wput_1 (int hpos, case 0x108: BPL1MOD (hpos, value); break; case 0x10A: BPL2MOD (hpos, value); break; + case 0x10E: CLXCON2 (value); break; case 0x110: BPL1DAT (hpos, value); break; case 0x112: BPL2DAT (value); break; @@ -4522,7 +4538,7 @@ uae_u8 *restore_custom (uae_u8 *src) bpl1mod = RW; /* 108 BPL1MOD */ bpl2mod = RW; /* 10A BPL2MOD */ bplcon4 = RW; /* 10C BPLCON4 */ - RW; /* 10E CLXCON2* */ + clxcon2 = RW; /* 10E CLXCON2* */ for(i = 0; i < 8; i++) RW; /* BPLXDAT */ for(i = 0; i < 32; i++) @@ -4664,7 +4680,7 @@ uae_u8 *save_custom (int *len) SW (bpl1mod); /* 108 BPL1MOD */ SW (bpl2mod); /* 10A BPL2MOD */ SW (bplcon4); /* 10C BPLCON4 */ - SW (0); /* 10E CLXCON2 */ + SW (clxcon2); /* 10E CLXCON2 */ for (i = 0;i < 8; i++) SW (0); /* 110 BPLxDAT */ for ( i = 0; i < 32; i++)