--- uae/src/custom.c 2018/04/24 17:12:39 1.1.1.22 +++ uae/src/custom.c 2018/04/24 17:16:45 1.1.1.24 @@ -14,7 +14,6 @@ #include #include -#include "config.h" #include "options.h" #include "threaddep/thread.h" #include "uae.h" @@ -28,7 +27,7 @@ #include "disk.h" #include "blitter.h" #include "xwin.h" -#include "joystick.h" +#include "inputdevice.h" #include "audio.h" #include "keybuf.h" #include "serial.h" @@ -38,7 +37,8 @@ #include "picasso96.h" #include "drawing.h" #include "savestate.h" -#include "inputdevice.h" + +#define SPR0_HPOS 0x15 #define SPRITE_COLLISIONS @@ -47,15 +47,7 @@ static uae_u16 last_custom_value; static unsigned int n_consecutive_skipped = 0; static unsigned int total_skipped = 0; -/* Events */ - -unsigned long int currcycle, nextevent, is_lastline; -static int rpt_did_reset; -struct ev eventtab[ev_max]; - -frame_time_t vsynctime, vsyncmintime; - -static int vpos; +int vpos; static uae_u16 lof; static int next_lineno; static enum nln_how nextline_how; @@ -79,7 +71,7 @@ uae_u16 dmacon; uae_u16 adkcon; /* used by audio code */ static uae_u32 cop1lc,cop2lc,copcon; - + int maxhpos = MAXHPOS_PAL; int maxvpos = MAXVPOS_PAL; int minfirstline = MINFIRSTLINE_PAL; @@ -271,7 +263,7 @@ enum fetchstate { STATIC_INLINE int nodraw (void) { - return framecnt != 0; + return framecnt != 0 || !curr_gfx; } uae_u32 get_copper_address (int copno) @@ -311,24 +303,6 @@ int find_copper_record (uaecptr addr, in return 0; } -int rpt_available = 0; - -void reset_frame_rate_hack (void) -{ - if (currprefs.m68k_speed != -1) - return; - - if (! rpt_available) { - currprefs.m68k_speed = 0; - return; - } - - rpt_did_reset = 1; - is_lastline = 0; - vsyncmintime = read_processor_time() + vsynctime; - write_log ("Resetting frame rate hack\n"); -} - STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val) { if (val & 0x8000) @@ -468,7 +442,7 @@ static int get_maxplanes (int res) } /* Disable bitplane DMA if planes > maxplanes. This is needed e.g. by the - Sanity WOC demo (at the "Party Effect"). */ + Sanity WOC demo (at the "Party Effect"). */ STATIC_INLINE int GET_PLANES_LIMIT (uae_u16 v) { if (GET_PLANES(v) > get_maxplanes (GET_RES(v))) @@ -484,7 +458,7 @@ static void add_modulos (void) { int m1, m2; - if ((currprefs.chipset_mask & CSMASK_AGA) && (fmode & 0x4000)) { + if (fmode & 0x4000) { if (((diwstrt >> 8) ^ vpos) & 1) m1 = m2 = bpl2mod; else @@ -495,7 +469,7 @@ static void add_modulos (void) } if (dmaen (DMA_BITPLANE)) - switch (GET_PLANES (bplcon0)) { + switch (GET_PLANES_LIMIT (bplcon0)) { case 8: bplpt[7] += m2; case 7: bplpt[6] += m1; case 6: bplpt[5] += m2; @@ -554,7 +528,7 @@ static int fm_maxplane, fm_maxplane_shif /* The corresponding values, by fetchmode and display resolution. */ static int fetchunits[] = { 8,8,8,0, 16,8,8,0, 32,16,8,0 }; static int fetchstarts[] = { 3,2,1,0, 4,3,2,0, 5,4,3,0 }; -static int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; +static int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; static uae_u8 cycle_diagram_table[3][3][9][32]; static uae_u8 cycle_diagram_free_cycles[3][3][9]; @@ -599,7 +573,7 @@ static void create_cycle_diagram_table(v cycle_sequence = &cycle_sequences[(max_planes - 1) * 8]; max_planes = 1 << max_planes; for (planes = 0; planes <= 8; planes++) { - freecycles = 0; + freecycles = 0; for (cycle = 0; cycle < 32; cycle++) cycle_diagram_table[fm][res][planes][cycle] = -1; if (planes <= max_planes) { @@ -658,10 +632,10 @@ static uae_u32 fetched_aga1[MAX_PLANES]; /* Expansions from bplcon0/bplcon1. */ static int toscr_res, toscr_delay1, toscr_delay2, toscr_nr_planes, fetchwidth; -/* The number of bits left from the last fetched words. +/* The number of bits left from the last fetched words. This is an optimization - conceptually, we have to make sure the result is the same as if toscr is called in each clock cycle. However, to speed this - up, we accumulate display data; this variable keeps track of how much. + up, we accumulate display data; this variable keeps track of how much. Thus, once we do call toscr_nbits (which happens at least every 16 bits), we can do more work at once. */ static int toscr_nbits; @@ -964,7 +938,7 @@ STATIC_INLINE void beginning_of_plane_bl flush_display (fm); if (fm == 0) - for (i = 0; i < MAX_PLANES; i++) + for (i = 0; i < MAX_PLANES; i++) todisplay[i][0] |= fetched[i]; else for (i = 0; i < MAX_PLANES; i++) { @@ -984,7 +958,7 @@ STATIC_INLINE void beginning_of_plane_bl STATIC_INLINE void long_fetch_ecs (int plane, int nwords, int weird_number_of_bits, int dma) { uae_u16 *real_pt = (uae_u16 *)pfield_xlateptr (bplpt[plane] + bpl_off[plane], nwords * 2); - int delay = ((plane & 1) ? toscr_delay2 : toscr_delay1); + int delay = (plane & 1) ? toscr_delay2 : toscr_delay1; int tmp_nbits = out_nbits; uae_u32 shiftbuffer = todisplay[plane][0]; uae_u32 outval = outword[plane]; @@ -1039,7 +1013,7 @@ STATIC_INLINE void long_fetch_ecs (int p STATIC_INLINE void long_fetch_aga (int plane, int nwords, int weird_number_of_bits, int fm, int dma) { uae_u32 *real_pt = (uae_u32 *)pfield_xlateptr (bplpt[plane] + bpl_off[plane], nwords * 2); - int delay = ((plane & 1) ? toscr_delay2 : toscr_delay1); + int delay = (plane & 1) ? toscr_delay2 : toscr_delay1; int tmp_nbits = out_nbits; uae_u32 *shiftbuffer = todisplay[plane]; uae_u32 outval = outword[plane]; @@ -1123,7 +1097,6 @@ static void long_fetch_aga_2_1 (int hpos static void do_long_fetch (int hpos, int nwords, int dma, int fm) { - int added; int i; flush_display (fm); @@ -1172,13 +1145,14 @@ static void finish_final_fetch (int i, i { passed_plfstop = 3; - if (thisline_decision.plfleft != -1) { - i += flush_plane_data (fm); - thisline_decision.plfright = i; - thisline_decision.plflinelen = out_offs; - thisline_decision.bplres = toscr_res; - finish_playfield_line (); - } + if (thisline_decision.plfleft == -1) + return; + + i += flush_plane_data (fm); + thisline_decision.plfright = i; + thisline_decision.plflinelen = out_offs; + thisline_decision.bplres = toscr_res; + finish_playfield_line (); } STATIC_INLINE int one_fetch_cycle_0 (int i, int ddfstop_to_test, int dma, int fm) @@ -1249,7 +1223,7 @@ STATIC_INLINE int one_fetch_cycle (int i case 0: return one_fetch_cycle_fm0 (i, ddfstop_to_test, dma); case 1: return one_fetch_cycle_fm1 (i, ddfstop_to_test, dma); case 2: return one_fetch_cycle_fm2 (i, ddfstop_to_test, dma); - default: abort (); + default: uae_abort ("fm corrupt"); } } @@ -1435,12 +1409,12 @@ static void record_color_change (int hpo { if (regno == -1 && value) { thisline_decision.ham_seen = 1; - if (hpos < 0x18) + if (hpos < HARD_DDF_START) thisline_decision.ham_at_start = 1; } /* Early positions don't appear on-screen. */ - if (nodraw () || vpos < minfirstline || hpos < 0x18 + if (nodraw () || vpos < minfirstline || hpos < HARD_DDF_START /*|| currprefs.emul_accuracy == 0*/) return; @@ -1472,7 +1446,7 @@ static void do_playfield_collisions (voi clxdat |= 1; return; } - + for (i = thisline_decision.plfleft; i < thisline_decision.plfright; i += 2) { int j; uae_u32 total = 0xFFFFFFFF; @@ -1487,7 +1461,7 @@ static void do_playfield_collisions (voi total &= t; } if (total) - clxdat |= 1; + clxdat |= 1; } } @@ -1628,7 +1602,7 @@ static void record_sprite (int line, int uae_u16 *buf; uae_u32 collision_mask; int width = sprite_width; - int dbl = 0; + int dbl = 0, half = 0; unsigned int mask = 0; if (sprres != RES_LORES) @@ -1637,6 +1611,10 @@ static void record_sprite (int line, int if (currprefs.chipset_mask & CSMASK_AGA) { width = (width << 1) >> sprres; dbl = sprite_buffer_res - sprres; + if (dbl < 0) { + half = -dbl; + dbl = 0; + } mask = sprres == RES_SUPERHIRES ? 1 : 0; } @@ -1650,7 +1628,7 @@ static void record_sprite (int line, int } if (sprxp < e->pos) - abort (); + uae_abort ("sprxp < e->pos"); e->max = sprxp + width; e[1].first_pixel = e->first_pixel + ((e->max - e->pos + 3) & ~3); @@ -1665,7 +1643,7 @@ static void record_sprite (int line, int uae_u32 datab = ((sprtaba[da & 0xFF] << 16) | sprtaba[da >> 8] | (sprtabb[db & 0xFF] << 16) | sprtabb[db >> 8]); - buf = spixels + word_offs + (i << dbl); + buf = spixels + word_offs + ((i << dbl) >> half); if (currprefs.collision_level > 0 && collision_mask) record_sprite_1 (buf, datab, num, dbl, mask, 1, collision_mask); else @@ -1680,7 +1658,7 @@ static void record_sprite (int line, int if (ctl & (num << 7) & 0x80) { uae_u32 state = 0x01010101 << (num - 1); uae_u32 *stbuf = spixstate.words + (word_offs >> 2); - uae_u8 *stb1 = spixstate.bytes + word_offs; + uae_u8 *stb1 = spixstate.bytes + word_offs; for (i = 0; i < width; i += 8) { stb1[0] |= state; stb1[1] |= state; @@ -1760,7 +1738,7 @@ STATIC_INLINE int sprites_differ (struct if (dip->nr_sprites != dip_old->nr_sprites) return 1; - + if (dip->nr_sprites == 0) return 0; @@ -1783,7 +1761,7 @@ STATIC_INLINE int color_changes_differ ( { if (dip->nr_color_changes != dip_old->nr_color_changes) return 1; - + if (dip->nr_color_changes == 0) return 0; if (memcmp (curr_color_changes + dip->first_color_change, @@ -1915,14 +1893,6 @@ static void reset_decisions (void) last_fetch_hpos = -1; } -void compute_vsynctime (void) -{ - vsynctime = syncbase / vblank_hz; - if (currprefs.produce_sound > 1) { - vsynctime = vsynctime * 9 / 10; - } -} - /* set PAL or NTSC timing variables */ static void init_hz (void) @@ -2038,7 +2008,7 @@ STATIC_INLINE uae_u16 INTENAR (void) } uae_u16 INTREQR (void) { - return intreq /* | (currprefs.use_serial ? 0x0001 : 0) */; + return intreq; } STATIC_INLINE uae_u16 ADKCONR (void) { @@ -2072,9 +2042,10 @@ STATIC_INLINE void COP1LCL (uae_u16 v) { STATIC_INLINE void COP2LCH (uae_u16 v) { cop2lc = (cop2lc & 0xffff) | ((uae_u32)v << 16); } STATIC_INLINE void COP2LCL (uae_u16 v) { cop2lc = (cop2lc & ~0xffff) | (v & 0xfffe); } -static void start_copper (void) +static void COPJMP (int num) { int was_active = eventtab[ev_copper].active; + cop_state.ip = num == 1 ? cop1lc : cop2lc; eventtab[ev_copper].active = 0; if (was_active) events_schedule (); @@ -2090,24 +2061,12 @@ static void start_copper (void) } } -static void COPJMP1 (uae_u16 a) -{ - cop_state.ip = cop1lc; - start_copper (); -} - -static void COPJMP2 (uae_u16 a) -{ - cop_state.ip = cop2lc; - start_copper (); -} - STATIC_INLINE void COPCON (uae_u16 a) { copcon = a; } -static void DMACON (int hpos, uae_u16 v) +static void DMACON (unsigned int hpos, uae_u16 v) { int i; @@ -2150,25 +2109,33 @@ static void DMACON (int hpos, uae_u16 v) if ((dmacon & (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) != (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) unset_special (SPCFLAG_BLTNASTY); - if (currprefs.produce_sound > 0) { - update_audio (); + if (currprefs.produce_sound > 0) + update_audio_dmacon (); - for (i = 0; i < 4; i++) { - struct audio_channel_data *cdp = audio_channel + i; - int chan_ena = (dmacon & 0x200) && (dmacon & (1<dmaen == chan_ena) - continue; - cdp->dmaen = chan_ena; - if (cdp->dmaen) - audio_channel_enable_dma (cdp); - else - audio_channel_disable_dma (cdp); - } - schedule_audio (); - } events_schedule(); } +/* + * Get level of interrupt request presented to CPU. + * + * If no IRQs are active and enabled, returns -1. + * If none of the active IRQs have yet reached the CPU, returns 0. + * Otherwise, returns the priority level of the highest priorty active IRQ. + */ +int intlev (void) +{ + uae_u16 imask = intreq & intena; + if (imask && (intena & 0x4000)){ + if (imask & 0x2000) return 6; + if (imask & 0x1800) return 5; + if (imask & 0x0780) return 4; + if (imask & 0x0070) return 3; + if (imask & 0x0008) return 2; + if (imask & 0x0007) return 1; + } + return -1; +} + /*static int trace_intena = 0;*/ STATIC_INLINE void INTENA (uae_u16 v) @@ -2204,17 +2171,6 @@ void INTREQ (uae_u16 v) rethink_cias (); } -static void update_adkmasks (void) -{ - unsigned long t; - - t = adkcon | (adkcon >> 4); - audio_channel[0].adk_mask = (((t >> 0) & 1) - 1); - audio_channel[1].adk_mask = (((t >> 1) & 1) - 1); - audio_channel[2].adk_mask = (((t >> 2) & 1) - 1); - audio_channel[3].adk_mask = (((t >> 3) & 1) - 1); -} - static void ADKCON (uae_u16 v) { if (currprefs.produce_sound > 0) @@ -2259,7 +2215,7 @@ static void BPLCON0 (int hpos, uae_u16 v 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)]; @@ -2773,7 +2729,7 @@ static void perform_copper_write (int ol record_copper (cop_state.saved_ip - 4, old_hpos, vpos); if (address < (copcon & 2 ? ((currprefs.chipset_mask & CSMASK_AGA) ? 0 : 0x40u) : 0x80u)) { - cop_state.state = COP_stop; + cop_state.state = COP_stop; copper_enabled_thisline = 0; unset_special (SPCFLAG_COPPER); return; @@ -2790,21 +2746,28 @@ static void perform_copper_write (int ol } static int isagnus[]= { - 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0, - 1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* BPLxPT */ - 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* SPRxPT */ + 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 32 0x00 - 0x3e */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 27 0x40 - 0x74 */ + + 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0, /* 21 */ + 1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0, /* 32 0xa0 - 0xde */ + /* BPLxPTH/BPLxPTL */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */ + /* BPLCON0-3,BPLMOD1-2 */ + 0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, /* 16 */ + /* SPRxPTH/SPRxPTL */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */ + /* SPRxPOS/SPRxCTL/SPRxDATA/SPRxDATB */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* colors */ + /* COLORxx */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + /* RESERVED */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; static void update_copper (int until_hpos) { - int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); int c_hpos = cop_state.hpos; if (eventtab[ev_copper].active) @@ -3101,9 +3064,6 @@ STATIC_INLINE void do_sprites_1 (int num } } else if (s->state == SPR_waiting_stop) { uae_u16 data = sprite_fetch (s, dma); - /* Hack for X mouse auto-calibration */ - if (num == 0 && cycle == 0) - mousehack_handle (sprctl[0], sprpos[0]); if (cycle == 0) SPRxDATA_1 (dma ? data : sprdata[num][0], num); @@ -3130,7 +3090,7 @@ STATIC_INLINE void do_sprites_1 (int num } break; case 32: - { + { uae_u32 data32 = sprite_fetch (s, dma); if (dma) { if (cycle == 0) @@ -3144,7 +3104,6 @@ STATIC_INLINE void do_sprites_1 (int num } } -#define SPR0_HPOS 0x15 static void do_sprites (int hpos) { int maxspr, minspr; @@ -3294,32 +3253,10 @@ static void vsync_handler (void) n_frames++; - if (currprefs.m68k_speed == -1) { - frame_time_t curr_time = read_processor_time (); - vsyncmintime += vsynctime; - /* @@@ Mathias? How do you think we should do this? */ - /* If we are too far behind, or we just did a reset, adjust the - * needed time. */ - if ((long int)(curr_time - vsyncmintime) > 0 || rpt_did_reset) - vsyncmintime = curr_time + vsynctime; - rpt_did_reset = 0; - } else { -#ifdef RPT_WORKS_OK - if (RPT_WORKS_OK) { - frame_time_t curr_time; - do - curr_time = read_processor_time (); - while ((long int)(read_processor_time () - vsyncmintime) < 0); - vsyncmintime = curr_time + vsynctime; - } -#endif - } + time_vsync (); handle_events (); - getjoystate (0, &joy0dir, &joy0button); - getjoystate (1, &joy1dir, &joy1button); - INTREQ (0x8020); if (bplcon0 & 4) lof ^= 0x8000; @@ -3383,10 +3320,9 @@ static void vsync_handler (void) bogusframe = 0; } #endif - if (ievent_alive > 0) - ievent_alive--; if (timehack_alive > 0) timehack_alive--; + inputdevice_vsync (); CIA_vsync_handler (); } @@ -3407,30 +3343,8 @@ static void hsync_handler (void) eventtab[ev_hsync].oldcycles = get_cycles (); CIA_hsync_handler (); - if (currprefs.produce_sound > 0) { - int nr; - - update_audio (); - - /* Sound data is fetched at the beginning of each line */ - 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->pt += 2; - if (cdp->state == 2 || cdp->state == 3) { - if (cdp->wlen == 1) { - cdp->pt = cdp->lc; - cdp->wlen = cdp->len; - cdp->intreq2 = 1; - } else - cdp->wlen = (cdp->wlen - 1) & 0xFFFF; - } - } - } - } + if (currprefs.produce_sound > 0) + audio_hsync (1); hardware_line_completed (next_lineno); @@ -3446,17 +3360,19 @@ static void hsync_handler (void) DISK_update (); - is_lastline = vpos + 1 == maxvpos + (lof == 0 ? 0 : 1) && currprefs.m68k_speed == -1 && ! rpt_did_reset; + is_lastline = (vpos + 1 == maxvpos + (lof == 0 ? 0 : 1) + && currprefs.m68k_speed == -1 + && vsyncmintime_valid); - if ((bplcon0 & 4) && currprefs.gfx_linedbl) + if ((bplcon0 & 4) && curr_gfx && curr_gfx->linedbl) notice_interlace_seen (); if (!nodraw ()) { int lineno = vpos; nextline_how = nln_normal; - if (currprefs.gfx_linedbl) { + if (curr_gfx->linedbl) { lineno *= 2; - nextline_how = currprefs.gfx_linedbl == 1 ? nln_doubled : nln_nblack; + nextline_how = curr_gfx->linedbl == 1 ? nln_doubled : nln_nblack; if (bplcon0 & 4) { if (!lof) { lineno++; @@ -3476,6 +3392,7 @@ static void hsync_handler (void) /* See if there's a chance of a copper wait ending this line. */ cop_state.hpos = 0; compute_spcflag_copper (); + inputdevice_hsync (); } void init_eventtab (void) @@ -3557,16 +3474,7 @@ void customreset (void) vpos = 0; - if (needmousehack ()) { -#if 0 - mousehack_setfollow(); -#else - mousehack_setdontcare(); -#endif - } else { - mousestate = normal_mouse; - } - ievent_alive = 0; + inputdevice_reset (); timehack_alive = 0; curr_sprite_entries = 0; @@ -3588,12 +3496,24 @@ void customreset (void) init_hz (); audio_reset (); + if (savestate_state != STATE_RESTORE) { + /* must be called after audio_reset */ + adkcon = 0; + update_adkmasks (); + } init_sprites (); init_hardware_frame (); reset_drawing (); +#ifdef PICASSO96 + InitPicasso96 (); + picasso_on = 0; + picasso_requested_on = 0; + gfx_set_picasso_state (0); +#endif + reset_decisions (); #ifdef HAVE_GETTIMEOFDAY @@ -3613,9 +3533,9 @@ void customreset (void) #if 0 DMACON (0, 0); #endif - COPJMP1 (0); if (diwhigh) diwhigh_written = 1; + COPJMP (1); v = bplcon0; BPLCON0 (0, 0); BPLCON0 (0, v); @@ -3646,6 +3566,10 @@ void customreset (void) dumpcustom (); for (i = 0; i < 8; i++) nr_armed += spr[i].armed != 0; + if (! currprefs.produce_sound) { + eventtab[ev_audio].active = 0; + events_schedule (); + } } expand_sprres (); } @@ -3667,20 +3591,6 @@ void dumpcustom (void) /*for (i=0; i<256; i++) if (blitcount[i]) write_log ("minterm %x = %d\n",i,blitcount[i]); blitter debug */ } -int intlev (void) -{ - uae_u16 imask = intreq & intena; - if (imask && (intena & 0x4000)){ - if (imask & 0x2000) return 6; - if (imask & 0x1800) return 5; - if (imask & 0x0780) return 4; - if (imask & 0x0070) return 3; - if (imask & 0x0008) return 2; - if (imask & 0x0007) return 1; - } - return -1; -} - static void gen_custom_tables (void) { int i; @@ -3741,11 +3651,6 @@ void custom_init (void) drawing_init (); - mousestate = unknown_mouse; - - if (needmousehack ()) - mousehack_setfollow (); - create_cycle_diagram_table (); } @@ -3873,8 +3778,8 @@ void REGPARAM2 custom_wput_1 (int hpos, case 0x084: COP2LCH (value); break; case 0x086: COP2LCL (value); break; - case 0x088: COPJMP1 (value); break; - case 0x08A: COPJMP2 (value); break; + case 0x088: COPJMP (1); break; + case 0x08A: COPJMP (2); break; case 0x08E: DIWSTRT (hpos, value); break; case 0x090: DIWSTOP (hpos, value); break; @@ -4035,7 +3940,7 @@ void custom_prepare_savestate (void) #define RW restore_u16 () #define RL restore_u32 () -uae_u8 *restore_custom (uae_u8 *src) +const uae_u8 *restore_custom (const uae_u8 *src) { uae_u16 dsklen, dskbytr, dskdatr; int dskpt; @@ -4043,7 +3948,7 @@ uae_u8 *restore_custom (uae_u8 *src) audio_reset (); - currprefs.chipset_mask = RL; + changed_prefs.chipset_mask = currprefs.chipset_mask = RL; RW; /* 000 ? */ RW; /* 002 DMACONR */ RW; /* 004 VPOSR */ @@ -4315,7 +4220,7 @@ uae_u8 *save_custom (int *len, uae_u8 *d return dstbak; } -uae_u8 *restore_custom_agacolors (uae_u8 *src) +const uae_u8 *restore_custom_agacolors (const uae_u8 *src) { int i; @@ -4324,19 +4229,22 @@ uae_u8 *restore_custom_agacolors (uae_u8 return src; } -uae_u8 *save_custom_agacolors (int *len) +uae_u8 *save_custom_agacolors (int *len, uae_u8 *dstptr) { uae_u8 *dstbak, *dst; int i; - dstbak = dst = malloc (256*4); + if (dstptr) + dstbak = dst = dstptr; + else + dstbak = dst = malloc (256*4); for (i = 0; i < 256; i++) SL (current_colors.color_regs_aga[i]); *len = dst - dstbak; return dstbak; } -uae_u8 *restore_custom_sprite (uae_u8 *src, int num) +const uae_u8 *restore_custom_sprite (int num, const uae_u8 *src) { spr[num].pt = RL; /* 120-13E SPRxPT */ sprpos[num] = RW; /* 1x0 SPRxPOS */ @@ -4353,7 +4261,7 @@ uae_u8 *restore_custom_sprite (uae_u8 *s return src; } -uae_u8 *save_custom_sprite(int *len, int num) +uae_u8 *save_custom_sprite(int num, int *len) { uae_u8 *dstbak, *dst; @@ -4377,14 +4285,14 @@ uae_u8 *save_custom_sprite(int *len, int void check_prefs_changed_custom (void) { currprefs.gfx_framerate = changed_prefs.gfx_framerate; - /* Not really the right place... */ - if (currprefs.jport0 != changed_prefs.jport0 - || currprefs.jport1 != changed_prefs.jport1) { - currprefs.jport0 = changed_prefs.jport0; - currprefs.jport1 = changed_prefs.jport1; - joystick_setting_changed (); + if (inputdevice_config_change_test ()) { + inputdevice_copyconfig (&changed_prefs, &currprefs); + inputdevice_updateconfig (&currprefs); } currprefs.immediate_blits = changed_prefs.immediate_blits; currprefs.blits_32bit_enabled = changed_prefs.blits_32bit_enabled; currprefs.collision_level = changed_prefs.collision_level; + if (currprefs.leds_on_screen && !changed_prefs.leds_on_screen) + notice_screen_contents_lost (); + currprefs.leds_on_screen = changed_prefs.leds_on_screen; }